I have a small iOS app (written using monotouch) which I'm wanting to bring over monodroid. The port is causing a couple of issues, some of which are down to the way the two platforms go about doing the UI and creating classes around them.
In the iOS app there is code like this
private void BtnSomething_TouchUpInside (object sender, EventArgs e)
{
string f = this.foo;
LGPM gpm = new LGPM(Constants.a, Constants.b, f);
this.auth = new Auth("cheese", gpm);
(*) this.auth.TokenReceived += (o, e, a, aTS, r) => {
// more stuff here
};
this.PresentModalViewController(this.auth, true);
}
the auth class looks like this
public partial class Auth
{
public Auth(string m, data d)
{
this.d = d;
this.m = m;
}
// create a UIWebView and do things
Upshot - auth creates the webview, does things and returns control back to the (*) line
For monodroid, things are different as you can't really create classes like that. The best I've come up with is this
private void BtnSomething_TouchUpInside (object sender, EventArgs e)
{
string f = this.foo;
LGPM gpm = new LGPM(Constants.a, Constants.b, f);
this.auth = new Auth("cheese", gpm, context);
(*) this.auth.TokenReceived += (o, e, a, aTS, r) => {
// more stuff here
};
this.PresentModalViewController(this.auth, true);
}
then in the Auth class
public class Auth : Application
{
public Auth(string m, data d, Context c)
{
this.d = d;
this.m = m;
Intent t = new Intent(this, typeof(webview));
t.PutExtra("todo", 1);
c.StartActivity(t);
}
}
[Activity]
It's then a "normal" webview activity.
This seems to work, however, control is not return to the (*) line once the webview has completed.
The webview itself is performing an async grab of data from a website (called AuthToken), which causes an event to be thrown once it's done. I'm not sure if it's down to the difference in how classes and activities are written between the two, but in the iOS version, the event is triggered, in the Android version, it's missed.
This leads me to wonder if the way the platforms differ in how they deal with async events. Is there a tutorial somewhere on the difference between how the two platforms deal with async events?
Lots of questions I know, but threading and async events are important.
Thanks