Friday, July 30, 2010

Re: [android-developers] Re: AlertDialog changes sequence of events

I strongly recommend you try to find some sample code at
developer.android.com that does something similar and follow that
example.

In other UI frameworks, there's a convenience function, such as
MsgBox() that accomplishes "blocking" the UI thread. I don't know
exactly how it's done, but I suspect it uses co-routines.
Unfortunately, I don't know how to do co-routines in Java, if that's
even possible.

I suggest two solutions: 1) completion methods, 2) state machine.

First is like this: start with this code sequence:

code section A // work done up to needing user input
block for user input
if (OK) {
code section B // work done for positive user input
}

refactor that (requires moving local variables to fields) to

methodA() {
code section A
}
methodB() {
code section B
}
methodA();
block for user input
if (OK) {
methodB();
}

then refactor that to: call methodB in the positive callback method of
the alert dialog instead of after the dialog.show().

The state machine approach is more general, and handles more complex
situations and is easier to modify than a rat's nest of completion
methods..

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate