diff options
author | twyen <twyen@google.com> | 2017-09-26 17:37:59 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-09-26 17:37:59 +0000 |
commit | 386d3ab387c211c88989bafe36474b9bf0fd929e (patch) | |
tree | 89de265181c776f28cba3c34b1efc02fe10dacaa | |
parent | 62fd9483ed6004ac1a702198249ad0caf87521bb (diff) | |
parent | 418dc0004c59b3380e2dc6408fb87800c4460479 (diff) |
Merge "Fix onVisible/onNotVisible called on CallLogFragment without being attahced after rotation"
am: 418dc0004c
Change-Id: Id4ef0d67366e2a615a9d9e71c644e9de1241d972
-rw-r--r-- | java/com/android/dialer/app/calllog/CallLogFragment.java | 9 | ||||
-rw-r--r-- | java/com/android/dialer/app/list/ListsFragment.java | 12 |
2 files changed, 11 insertions, 10 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java index 8ed924d76..a82afa5fe 100644 --- a/java/com/android/dialer/app/calllog/CallLogFragment.java +++ b/java/com/android/dialer/app/calllog/CallLogFragment.java @@ -411,11 +411,18 @@ public class CallLogFragment extends Fragment mAdapter.onResume(); rescheduleDisplayUpdate(); + // onResume() may also be called as a "side" page on the ViewPager, which is not visible. + if (getUserVisibleHint()) { + onVisible(); + } } @Override public void onPause() { LogUtil.enterBlock("CallLogFragment.onPause"); + if (getUserVisibleHint()) { + onNotVisible(); + } cancelDisplayUpdate(); mAdapter.onPause(); super.onPause(); @@ -594,7 +601,7 @@ public class CallLogFragment extends Fragment @CallSuper public void onVisible() { LogUtil.enterBlock("CallLogFragment.onPageSelected"); - if (getActivity() != null) { + if (getActivity() != null && getActivity() instanceof HostInterface) { ((HostInterface) getActivity()) .enableFloatingButton(mModalAlertManager == null || mModalAlertManager.isEmpty()); } diff --git a/java/com/android/dialer/app/list/ListsFragment.java b/java/com/android/dialer/app/list/ListsFragment.java index 8dbe18cee..a94f9c137 100644 --- a/java/com/android/dialer/app/list/ListsFragment.java +++ b/java/com/android/dialer/app/list/ListsFragment.java @@ -107,7 +107,7 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis @Override public void onResume() { - LogUtil.d("ListsFragment.onResume", null); + LogUtil.enterBlock("ListsFragment.onResume"); Trace.beginSection(TAG + " onResume"); super.onResume(); @@ -124,17 +124,11 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis mCallLogQueryHandler.fetchMissedCallsUnreadCount(); Trace.endSection(); mCurrentPage = mAdapter.getItem(mViewPager.getCurrentItem()); - if (mCurrentPage instanceof CallLogFragment) { - ((CallLogFragment) mCurrentPage).onVisible(); - } } @Override public void onPause() { - LogUtil.d("ListsFragment.onPause", null); - if (mCurrentPage instanceof CallLogFragment) { - ((CallLogFragment) mCurrentPage).onNotVisible(); - } + LogUtil.enterBlock("ListsFragment.onPause"); super.onPause(); mPaused = true; @@ -149,7 +143,7 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - LogUtil.d("ListsFragment.onCreateView", null); + LogUtil.enterBlock("ListsFragment.onCreateView"); Trace.beginSection(TAG + " onCreateView"); Trace.beginSection(TAG + " inflate view"); final View parentView = inflater.inflate(R.layout.lists_fragment, container, false); |