diff options
author | calderwoodra <calderwoodra@google.com> | 2018-03-13 17:27:09 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-13 17:29:25 -0700 |
commit | 5e16adb54c4e442510d31c7d93fb862dc4154b15 (patch) | |
tree | 66b910a9dad376c360194be509f1f7e711f7693e | |
parent | f6c6f3befd928800dd5382eab106f6f2bab5cb08 (diff) |
Fixed overlapping fragments issue.
Fast consercutive calls to #showFragment can have undesirable effects because
fragment manager doesn't handle transactions sychronously. This CL resolves one
of the scanrios where voicemail fetch status was calling #showFragment nearly
simulataniously to the #onHandleIntent call.
This issue may show itself again and I'm looking into more long term solutions
but we should be fine in the short term since the all of our fragment logic
is implemented.
Bug: 74051208,74621909
Test: manual
PiperOrigin-RevId: 188956984
Change-Id: I0796e31b03e0b749ae7e81f82859ea6f814a5fb5
-rw-r--r-- | java/com/android/dialer/main/impl/OldMainActivityPeer.java | 6 | ||||
-rw-r--r-- | java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index 2ea36ea20..03afef4b4 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -1186,8 +1186,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen * * <p>Executes all fragment shows/hides in one transaction with no conflicting transactions * (like showing and hiding the same fragment in the same transaction). See a bug. + * + * <p>Special care should be taken to avoid calling this method several times in a short window + * as it can lead to fragments overlapping. */ private void showFragment(@NonNull Fragment fragment, String tag) { + LogUtil.enterBlock("MainBottomNavBarBottomNavTabListener.showFragment"); Fragment speedDial = fragmentManager.findFragmentByTag(SPEED_DIAL_TAG); Fragment callLog = fragmentManager.findFragmentByTag(CALL_LOG_TAG); Fragment contacts = fragmentManager.findFragmentByTag(CONTACTS_TAG); @@ -1200,6 +1204,8 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen fragmentShown |= showIfEqualElseHide(transaction, fragment, voicemail); if (!fragmentShown) { + LogUtil.i( + "MainBottomNavBarBottomNavTabListener.showFragment", "Not added yet: " + fragment); transaction.add(R.id.fragment_container, fragment, tag); } transaction.commit(); diff --git a/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java b/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java index 903f51fd2..80aa38b3e 100644 --- a/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java +++ b/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java @@ -155,7 +155,8 @@ public final class BottomNavBar extends LinearLayout { int voicemailcurrentVisibility = voicemail.getVisibility(); if (voicemailpreviousVisibility != voicemailcurrentVisibility - && voicemailpreviousVisibility == View.VISIBLE) { + && voicemailpreviousVisibility == View.VISIBLE + && getSelectedTab() == TabIndex.VOICEMAIL) { LogUtil.i("OldMainActivityPeer.showVoicemail", "hid VM tab and moved to speed dial tab"); selectTab(TabIndex.SPEED_DIAL); } |