mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 00:58:50 -05:00
Prevent NPEs in methods called by the handler after activity detached
This commit is contained in:
parent
4eefcb3a31
commit
999dd33169
@ -450,6 +450,20 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
|
||||
@Override
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
// The following messages don't need an attached activity.
|
||||
switch (msg.what) {
|
||||
case ACTION_REMOTE_SEARCH_FINISHED: {
|
||||
MessageListFragment.this.remoteSearchFinished();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Discard messages if the fragment isn't attached to an activity anymore.
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg.what) {
|
||||
case ACTION_FOLDER_LOADING: {
|
||||
String folder = (String) msg.obj;
|
||||
@ -466,10 +480,6 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
MessageListFragment.this.progress(progress);
|
||||
break;
|
||||
}
|
||||
case ACTION_REMOTE_SEARCH_FINISHED: {
|
||||
MessageListFragment.this.remoteSearchFinished();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user