mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 09:08:49 -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);
|
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
|
@Override
|
||||||
public void onPrepareDialog(final int id, final Dialog dialog) {
|
public void onPrepareDialog(final int id, final Dialog dialog) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
@ -1304,10 +1312,16 @@ public class MessageList
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R.id.dialog_confirm_spam: {
|
case R.id.dialog_confirm_spam: {
|
||||||
|
// 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 int selectionSize = mActiveMessages.size();
|
||||||
final String message;
|
final String message;
|
||||||
message = getResources().getQuantityString(R.plurals.dialog_confirm_spam_message, selectionSize, Integer.valueOf(selectionSize));
|
message = getResources().getQuantityString(R.plurals.dialog_confirm_spam_message, selectionSize,
|
||||||
|
Integer.valueOf(selectionSize));
|
||||||
((AlertDialog) dialog).setMessage(message);
|
((AlertDialog) dialog).setMessage(message);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
Loading…
Reference in New Issue
Block a user