summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Shrauner <shrauner@google.com>2014-03-21 15:35:16 -0700
committerJay Shrauner <shrauner@google.com>2014-03-21 15:35:16 -0700
commit3fb7218a3fe75460d675bf979fb6269088e5eb16 (patch)
tree773029820a3214f42fc934fbc7be24ca31aaa589
parente3b3b4a864d8c417217e3cff847f63f165cb4141 (diff)
Fix NPE in dismissShortcut
Use the view's context, which is non-null, instead of getActivity(), which may be null when it's detached. Bug:13588513 Change-Id: I2121a56cc686c0f4000747bac39b238928ee7af4
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteFragment.java5
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java
index 5f5e55cd1..9af0cb237 100644
--- a/src/com/android/dialer/list/PhoneFavoriteFragment.java
+++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java
@@ -650,10 +650,11 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
saveOffsets(0);
}
- public void dismissShortcut(int height) {
+ public void dismissShortcut(View view) {
+ final int height = ((View) view.getParent()).getHeight();
saveOffsets(height);
mLastCallShortcutDate = mCurrentCallShortcutDate;
- final SharedPreferences prefs = getActivity().getSharedPreferences(
+ final SharedPreferences prefs = view.getContext().getSharedPreferences(
DialtactsActivity.SHARED_PREFS_NAME, Context.MODE_PRIVATE);
prefs.edit().putLong(KEY_LAST_DISMISSED_CALL_SHORTCUT_DATE, mLastCallShortcutDate)
.apply();
diff --git a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
index e966f101d..81d682b8b 100644
--- a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
@@ -74,7 +74,7 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
mCallLogQueryHandler.markNewVoicemailsAsOld();
CallLogNotificationsHelper.removeMissedCallNotifications();
CallLogNotificationsHelper.updateVoicemailNotifications(mContext);
- mFragment.dismissShortcut(((View) view.getParent()).getHeight());
+ mFragment.dismissShortcut(view);
}
@Override