am c11a94e9: am 3a84d401: Merge "Fix NPE caused by status update outside activity lifecycle" into lmp-mr1-dev
* commit 'c11a94e98a911756e645216d36dbf0a438a3fb3e':
Fix NPE caused by status update outside activity lifecycle
diff --git a/src/com/android/settings/accounts/AccountSyncSettings.java b/src/com/android/settings/accounts/AccountSyncSettings.java
index 12a63e6..fe45299 100644
--- a/src/com/android/settings/accounts/AccountSyncSettings.java
+++ b/src/com/android/settings/accounts/AccountSyncSettings.java
@@ -24,6 +24,7 @@
import android.accounts.AccountManagerFuture;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ContentResolver;
@@ -313,12 +314,18 @@
private void startSyncForEnabledProviders() {
requestOrCancelSyncForEnabledProviders(true /* start them */);
- getActivity().invalidateOptionsMenu();
+ final Activity activity = getActivity();
+ if (activity != null) {
+ activity.invalidateOptionsMenu();
+ }
}
private void cancelSyncForEnabledProviders() {
requestOrCancelSyncForEnabledProviders(false /* cancel them */);
- getActivity().invalidateOptionsMenu();
+ final Activity activity = getActivity();
+ if (activity != null) {
+ activity.invalidateOptionsMenu();
+ }
}
private void requestOrCancelSyncForEnabledProviders(boolean startSync) {
@@ -367,7 +374,10 @@
protected void onSyncStateUpdated() {
if (!isResumed()) return;
setFeedsState();
- getActivity().invalidateOptionsMenu();
+ final Activity activity = getActivity();
+ if (activity != null) {
+ activity.invalidateOptionsMenu();
+ }
}
private void setFeedsState() {
@@ -440,7 +450,6 @@
syncPref.setChecked(oneTimeSyncMode || syncEnabled);
}
mErrorInfoView.setVisibility(syncIsFailing ? View.VISIBLE : View.GONE);
- getActivity().invalidateOptionsMenu();
}
@Override
diff --git a/src/com/android/settings/accounts/ManageAccountsSettings.java b/src/com/android/settings/accounts/ManageAccountsSettings.java
index ef3e40b..85ecd90 100644
--- a/src/com/android/settings/accounts/ManageAccountsSettings.java
+++ b/src/com/android/settings/accounts/ManageAccountsSettings.java
@@ -231,7 +231,11 @@
@Override
protected void onSyncStateUpdated() {
showSyncState();
- getActivity().invalidateOptionsMenu();
+ // Catch any delayed delivery of update messages
+ final Activity activity = getActivity();
+ if (activity != null) {
+ activity.invalidateOptionsMenu();
+ }
}
/**