Sunday, February 27, 2011

Re: [android-developers] Re: How To Determine Which Dialog Was Dismissed

Ok, if that helps your sleep - insomnia can be a terrible thing :)

Unfortunately, there is no dismiss callback in Activity for managed
dialogs, but small stub listeners should work fine.

-- Kostya

27.02.2011 15:39, hoyski пишет:
> Thank you, Ian and Kostya, for your replies.
>
> As far as the brittleness, it may just be my own personal bias. I work
> mainly on large multi-threaded, multi-server apps where objects are
> constantly being serialized and de-serialized. Seeing an == comparison
> of two references is always a red flag in a code review. I'm still
> learning the Android application life-cycle and I wasn't sure if an
> onPause/onResume pair of events may cause the == to fail.
>
> I like the idea of using small specialized OnDismissListeners for each
> dialog rather than having my activity implement OnDismissListener. I'm
> going to switch over to that approach. I'll sleep better, even if my
> fears are unfounded. :-)
>
> Thanks again,
> Dave
>
>
> On Feb 24, 9:07 am, Kostya Vasilyev<kmans...@gmail.com> wrote:
>> 24.02.2011 16:19, hoyski ?????:
>>
>>> For the moment, I'm testing if the dialog interface equals either of
>>> my dialog instances held by the activity, e.g. if (d == mOptionsDlg).
>>> That works but it feels brittle to me.
>> Sounds fine - Dialog impelments DialogInterface, and since you know
>> you're not creating other classes that implement DialogInterface, there
>> shouldn't be any unexpected values here.
>>
>>> Anyone know a better way? Or should I just stick with the instance
>>> comparison?
>> You could implement little "stubs" for onDismiss listener for the dialogs:
>>
>> *dialog_1*.setOnDismissListener(new OnDismissListener() {
>> @Override
>> public void onDismiss(DialogInterface dialog) {
>> myActivity.myDialogDismissed(*DIALOG_1*);
>> }
>> });
>>
>> *dialog_2*.setOnDismissListener(new OnDismissListener() {
>> @Override
>> public void onDismiss(DialogInterface dialog) {
>> myActivity.myDialogDismissed(*DIALOG_2*);
>> }
>> });
>>
>> -- Kostya
>>
>> --
>> Kostya Vasilyev --http://kmansoft.wordpress.com


--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
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

No comments:

Post a Comment