Shortcut show/hideSearchBar with new conditions.

This is effectively a revert of:
https://googleplex-android-review.googlesource.com/374556

With the new rules, we won't shortcut if:
 - the search bar is in an opposite visibility OR
 - a non-animated change has been requested AND there
   is an ongoing animation.

This makes sure that showSearchBar(false) called after
showSearchBar(true) is not ignored.

Bug: 11105305
Bug: 11237729
Change-Id: I92668dfac072e62506b2872e8bfbe9f707c9cc69
This commit is contained in:
Mac Duy Hai
2013-10-16 13:46:04 +01:00
parent b6d33df909
commit 8246a1434c
@@ -138,6 +138,8 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
* Shows and hides the search bar.
*/
public void showSearchBar(boolean animated) {
boolean needToCancelOngoingAnimation = mQSBSearchBarAnim.isRunning() && !animated;
if (!mIsSearchBarHidden && !needToCancelOngoingAnimation) return;
if (animated) {
prepareStartAnimation(mQSBSearchBar);
mQSBSearchBarAnim.reverse();
@@ -152,6 +154,8 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
mIsSearchBarHidden = false;
}
public void hideSearchBar(boolean animated) {
boolean needToCancelOngoingAnimation = mQSBSearchBarAnim.isRunning() && !animated;
if (mIsSearchBarHidden && !needToCancelOngoingAnimation) return;
if (animated) {
prepareStartAnimation(mQSBSearchBar);
mQSBSearchBarAnim.start();