diff options
author | Yorke Lee <yorkelee@google.com> | 2014-04-17 18:57:24 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-04-17 18:57:24 +0000 |
commit | 3e4413473f2580e1a081fd858b0f21e4ce183c95 (patch) | |
tree | 314fff68b3ea31166386404af6c422b310b500da | |
parent | 1375a1a62d9962bc6bc89edb983ecca72c5b1279 (diff) | |
parent | 23553a71152409708841f957283f8f84d90023fe (diff) |
Merge "Reattach listener when fragment is destroyed and recreated"
-rw-r--r-- | src/com/android/dialer/list/AllContactsFragment.java | 15 | ||||
-rw-r--r-- | src/com/android/dialer/list/ListsFragment.java | 16 |
2 files changed, 10 insertions, 21 deletions
diff --git a/src/com/android/dialer/list/AllContactsFragment.java b/src/com/android/dialer/list/AllContactsFragment.java index 40d5c14b7..47476e686 100644 --- a/src/com/android/dialer/list/AllContactsFragment.java +++ b/src/com/android/dialer/list/AllContactsFragment.java @@ -24,6 +24,7 @@ import android.view.View; import android.view.ViewGroup; import com.android.contacts.common.list.ContactListItemView; +import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; import com.android.contacts.common.list.PhoneNumberPickerFragment; import com.android.dialer.R; @@ -33,11 +34,6 @@ import com.android.dialer.R; public class AllContactsFragment extends PhoneNumberPickerFragment{ @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - - @Override public void onAttach(Activity activity) { super.onAttach(activity); @@ -46,6 +42,15 @@ public class AllContactsFragment extends PhoneNumberPickerFragment{ setDarkTheme(false); setPhotoPosition(ContactListItemView.getDefaultPhotoPosition(true /* opposite */)); setUseCallableUri(true); + + try { + OnPhoneNumberPickerActionListener mNumberPickerListener = + (OnPhoneNumberPickerActionListener) activity; + setOnPhoneNumberPickerActionListener(mNumberPickerListener); + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + + " must implement OnPhoneNumberPickerActionListener"); + } } @Override diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index 768d3601e..f1d421c46 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -28,8 +28,6 @@ public class ListsFragment extends Fragment { private PhoneFavoriteFragment mSpeedDialFragment; private AllContactsFragment mAllContactsFragment; - private OnPhoneNumberPickerActionListener mNumberPickerListener; - private static final int TAB_INDEX_SPEED_DIAL = 0; private static final int TAB_INDEX_ALL_CONTACTS = 1; @@ -50,8 +48,6 @@ public class ListsFragment extends Fragment { return mSpeedDialFragment; case TAB_INDEX_ALL_CONTACTS: mAllContactsFragment = new AllContactsFragment(); - mAllContactsFragment.setOnPhoneNumberPickerActionListener( - mNumberPickerListener); return mAllContactsFragment; } throw new IllegalStateException("No fragment at position " + position); @@ -85,16 +81,4 @@ public class ListsFragment extends Fragment { tabs.setViewPager(mViewPager); return parentView; } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - - try { - mNumberPickerListener = (OnPhoneNumberPickerActionListener) activity; - } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() - + " must implement OnPhoneNumberPickerActionListener"); - } - } } |