mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-24 08:38:51 -05:00
Don't attempt to configure a dismissed dialog during Android activity
reloading As part of automatic activity reloading following a configuration change, Android invokes Activity#onPrepareDialog() even for dismissed dialogs. Consequently, one can't make the assumption that this method is only invoked by explicit calls to Activity#showDialog() from our code. The actual problem here was the mActiveMessages member being null at such times.
This commit is contained in:
parent
153c665084
commit
fc4dd077e4
@ -1293,6 +1293,14 @@ public class MessageList
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* Android happens to invoke this method even if the given dialog is not
|
||||
* shown (eg. a dismissed dialog) as part of the automatic activity
|
||||
* reloading following a configuration change (orientation, keyboard,
|
||||
* locale, etc.).
|
||||
*/
|
||||
@Override
|
||||
public void onPrepareDialog(final int id, final Dialog dialog) {
|
||||
switch (id) {
|
||||
@ -1304,10 +1312,16 @@ public class MessageList
|
||||
break;
|
||||
}
|
||||
case R.id.dialog_confirm_spam: {
|
||||
final int selectionSize = mActiveMessages.size();
|
||||
final String message;
|
||||
message = getResources().getQuantityString(R.plurals.dialog_confirm_spam_message, selectionSize, Integer.valueOf(selectionSize));
|
||||
((AlertDialog) dialog).setMessage(message);
|
||||
// mActiveMessages can be null if Android restarts the activity
|
||||
// while this dialog is not actually shown (but was displayed at
|
||||
// least once)
|
||||
if (mActiveMessages != null) {
|
||||
final int selectionSize = mActiveMessages.size();
|
||||
final String message;
|
||||
message = getResources().getQuantityString(R.plurals.dialog_confirm_spam_message, selectionSize,
|
||||
Integer.valueOf(selectionSize));
|
||||
((AlertDialog) dialog).setMessage(message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
Loading…
Reference in New Issue
Block a user