summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-04-17 11:46:59 -0700
committerYorke Lee <yorkelee@google.com>2014-04-17 11:52:51 -0700
commit23553a71152409708841f957283f8f84d90023fe (patch)
treebcd3597e0efec002f14964b00592c8ab97437844 /src
parentf653040adb93cafdd8f9cd4fdfa5f69ed0b1f77d (diff)
Reattach listener when fragment is destroyed and recreated
Bug: 14136602 Change-Id: I49796b7a545c6c650680cb0ee6152a93381b2736
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/list/AllContactsFragment.java15
-rw-r--r--src/com/android/dialer/list/ListsFragment.java16
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");
- }
- }
}