WebView underneath Andengine - layout

I'm trying to put a joypad made with AndEngine on a WebView that will be the view of an ipCamera. How can I do? I've searched a lot about that, but still haven't found the solution. Thank you all very much

You didn't mention what version of AndEngine you are using.
If you are using GLES2 (same technique may work for the GLES1 branch but I have not verified that), look at the AndEngine TextBreakExample.
That example shows how to use the org.andengine.opengl.view.RenderSurfaceView in combination with another layout like a LinearLayout. The "other layout" can contain anything - this example uses an EditText, but you should be able to use a WebView using the same technique.
Be sure and check the res/layout/textbreakexample.xml file. Also note these extra methods in the TextBreakExample.java file
#Override
protected int getLayoutID() {
return R.layout.textbreakexample;
}
#Override
protected int getRenderSurfaceViewID() {
return R.id.textbreakexample_rendersurfaceview;
}
https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/src/org/andengine/examples/TextBreakExample.java
https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/res/layout/textbreakexample.xml
Also might check out this layout file
https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/res/layout/xmllayoutexample.xml

Related

Native UI Components - Refresh when Android views update

We're trying to implement a Native UI Component that wraps an Android components that fetches data and displays it using our existing rendering framework (using an AdapterView). We don't know what the data will be in advance, so the height and contents of this component are completely arbitrary. This mostly works fine, except for the case where the rendered components request something else asynchronously (e.g. images). In that case, the image is retrieved, the ImageView is "displayed", but the UI ends up showing nothing (literally seems to be a transparent view of the appropriate size).
We know that these views work just fine in normal Android, but we seem to be missing something that tells RN/Yoga that it should re-render when images are loaded from the server so that they are properly displayed.
Here's more or less what this looks like:
public class ReactServerListComponent extends SimpleViewManager<LinearLayoutExtension> {
private static final String REACT_CLASS = "TAReactServerListComponent";
#Override
public String getName() {
return REACT_CLASS;
}
...
#ReactProp(name = "link")
public void setLink(final LinearLayoutExtension view, String theNewLink){
//async loader logic invokes this on success
view.loadRetrievedEntries(newEntries);
}
...
}
In this case LinearLayoutExtension contains all the views produced by the Adapter, which in turn will contain the asynchronously loading image views.
We've tried a few things, like returning a ShadowNode with a measure function, or keeping a reference of the ShadowNode and calling dirty(), etc on it.
What is the correct way to do this? Unfortunately, we have not found documentation or examples that deal with really complex components outside of "check the repo"...
You could try view.invalidate() on the group.
You could also remove the placeholder imageview and add a newer view with the correct image.
However if it is only refreshing the image view, you could also use something like volley, Picasso, Glide etc... to take care of the imageview itself.

Xamarin.Forms.DatePicker Text color

For Xamarin.Forms.DatePicker It is not obvious that the date field is "tapable" I want to change the text color of it to blue so the user will think it is clickable?
I see a background color property but not forecolor/text color?
Let me know how I can do that.
I did it just creating a class like that on my Android Project and making no changes on my Forms Pages:
using Xamarin.Forms;
using xxxx.Droid;
[assembly: ExportRenderer(typeof(Xamarin.Forms.DatePicker), typeof(MyDatePickerRederer))]
namespace xxxx.Droid
{
public class MyDatePickerRederer : Xamarin.Forms.Platform.Android.DatePickerRenderer
{
protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.DatePicker> e)
{
base.OnElementChanged(e);
this.Control.SetTextColor(Android.Graphics.Color.Black);
}
}
}
I don't think that the forecolor/text color is accessible at this time and I'm not sure if it will be in the future or not. Typically what you would do in this scenario is create a Custom Renderer to get down into the native implementation of the UIDatePicker control for iOS and change it's properties there. The problem with that in this case is that if you look through the iOS SDK documentation as well, I don't believe there is a way to customize the text on the UIDatePicker picker control. This is why you can't do it in Xamarin.Forms either.
At this point you will probably have to create your own custom control/renderer to make such a small change. Frustrating, I know, but unfortunately that this point I don't think you can actually accomplish the simple thing you are looking to do. :-(

MonoTouch.Dialog: How to make a RadioElement multiline?

I am trying to develop an app with MonoTouch. For some screens I create the UI in code. I have a dynamically created RadioGroup with normally two to four RadioElements (choices). Sometimes the text (dynamic too) is too long for the RadioElement so that on an iPhone the text gets shorted by ... at the end.
I have googled and found no suggestion on how to create multiline RadioElements. I know you can create a MultilineElement if you want text over several lines, but how would I go about combining the two? I assume I have to inherit from RadioElement and override some events, but which? Is it the MonoTouch.UIKit.UITableViewCell GetCell (MonoTouch.UIKit.UITableView tv) event?
Alternatively, how would you go about creating a MultilineElement that get a check mark on it when it got pressed/selected?
Or should I be thinking completely different? Are there some other components that could solve this in a simpler way?
This is a sort-of solution (at least it solves my problem):
public class MultilineRadioElement : RadioElement
{
public MultilineRadioElement (string caption, string group)
: base(caption, group) { }
public override MonoTouch.UIKit.UITableViewCell GetCell
(MonoTouch.UIKit.UITableView tv)
{
var cell = base.GetCell (tv);
cell.TextLabel.Lines = 2;
return cell;
}
}
When I now use a MultilineRadioElement instead of a RadioElement the text shows on two lines. For me two lines are enough. If the text is even longer and you still want to fit it inside the RadioElement at its current size you will probably have to calculate the size of the text and for example set the font in cell.TextLabel.Font to a more appropriate font.
I don't know how to make the RadioElement itself get bigger, so this is my best suggestion.
By the way, you should probably also add
protected override MonoTouch.Foundation.NSString CellKey
{
get { return base.CellKey; }
}
to the MultilineRadioElement as the intellisense in my Xamarin Studio suggests that this should be done when overriding GetCell, although it seems to work without it as well.
I am very happy if someone has an even better suggestion!! (yes, two exclamation marks :) )

How do I add zone based alternates for ContainerWidgets in Orchard?

I'd like to be able to customize how lists are rendered by ContainerWidgets. Shape tracing only gives me the following options:
Parts.ContainerWidget.cshtml
Parts.ContainerWidget-url-homepage.cshtml
I'd like to be able to supply an alternate for a specific zone. I think that IShapeTableProvider is the way to go, but I'm just not sure. I've also thought of using a Widget alternate (Widget-MyZone.cshtml) but I can't understand how to get to the underlying list items to render them myself. Also, overriding Widget seems like overkill. Ideally, I'd like to be able to add a Part alternate like Parts.ContainerWidget-MyZone.cshtml.
There seem to be quite a few posts around the web that discuss this problem, but nothing I could find really points to a concrete working example.
Is this the right approach? Something else I should try? Any examples around?
It turns out that Orchard 1.4 has built-in support for zone based container widget alternates. The recommended solution, therefore, is to just upgrade to 1.4.
IShapeTable provider should work. What happens when you try it? Here's a rough example (not tested):
public class Shapes : IShapeTableProvider {
public void Discover(ShapeTableBuilder builder) {
builder.Describe("Content").OnDisplaying(displaying => {
if (displaying.ShapeMetadata.DisplayType == "Detail"
&& (displaying.Shape.ContentItem as ContentItem).ContentType.Equals("MyWidgetType", System.StringComparison.OrdinalIgnoreCase)) {
var metadata = displaying.ShapeMetadata;
ContentItem contentItem = displaying.Shape.ContentItem;
metadata.Alternates.Add("MyWidgetType_MyCUstomAlternate");
}
});
}

How to use UITableViewDelegate.AccessoryButtonTapped (with Monotouch)

I'm creating an IPad application using C#, Mono develop and Monotouch.
I've been using Monotouch.Dialog to create functionality similar to the wifi-settings on an iPhone. I'm using StyledStringElement with an accessory and am now trying to differentiate between tapping the row and tapping the DetailDisclosureButton.
I've been found out that I should override the UITableViewDelegate.AccessoryButtonTapped on the UITableView. I've tried to created a derived class from UITableViewDelegate and hook this into the Monotouch.Dialog. But this is where I got stuck. I didn't manage to replace the existing UITableViewDelegate with my extended version.
So my questions are:
Is this the preferred way of handling this event (to be able to differentiate between a tap on the element and a tap on the DetailDisclosureButton) ?
If not, any pointer on how to accomplish this ?
I have been searching the web for a (similar) example but have not found any yet. Any examples that you know of that could get me started ?
Thanks,
boris
event EventHandler accessoryPushed;
public override void AccessoryButtonTapped (UITableView tableView, NSIndexPath indexPath)
{
if(!accessoryPushed)
{
accessoryPushed(this,EventArgs.Empty);
}
}
You will need to add this to the DailogViewController code that you are using (this will override the tapping action). Instead of a simple function, you may want an event to be triggered, so just handle the event in your main code. That is probably your best bet.
Once you change this line, you will have to implement new functions like AccessorySelected (just mimic the path the code follows when a row is selected except with accessory).
On the other hand, you could try a different navigation method, often disclosure buttons are annoying and you don't want to click on them except to get simple information about the button (like a help feature).
I haven't found any other examples, sorry!

Resources