From 2a58ab88d23238f252d5ccc6a6798f58b0e9ef56 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 15 May 2014 02:16:04 -0700 Subject: Cleanup dialpad show/hide logic. This is the first step in cleaning up the DialtactsActivity logic to make it easier to transition between different states, and handle the states in between (hopefully). Originally, I thought to also block show/hide actions if there was already a dialpad transition in progress, but in the end I did not do this because it made the UI seem unresponsive. - Delete custom predraw listener in DialpadFragment; it doesn't appear to be used (?) and made the animation logic more confusing. - Replace the fragment custom animations with our own animations, which seem to perform better. - Changed the animation xmls from objectAnimators to translates. - Replaced isDialpadShowing with uses of mIsDialpadShown. - Reorder show/hide logic. Now it is less parallel, but better reflects the ordering/nature of fragment transactions. - Reorder some methods to group them more logically. - Pull out a helper method for updating the search fragment's yTranslation. - Pull out a helper method for updating the floating action bar. - Delete predraw method in DialpadFragment; doesn't appear to be used and caused. Bug: 14900155 Change-Id: I768324b2293622ea43974f7f566eec9b11fb0d4e --- .../android/dialer/dialpad/DialpadFragment.java | 31 ++++------------------ 1 file changed, 5 insertions(+), 26 deletions(-) (limited to 'src/com/android/dialer/dialpad/DialpadFragment.java') diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 4557bd4b1..418d54a20 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -347,29 +347,6 @@ public class DialpadFragment extends Fragment false); fragmentView.buildLayer(); - final ViewTreeObserver vto = fragmentView.getViewTreeObserver(); - // Adjust the translation of the DialpadFragment in a preDrawListener instead of in - // DialtactsActivity, because at the point in time when the DialpadFragment is added, - // its views have not been laid out yet. - final OnPreDrawListener preDrawListener = new OnPreDrawListener() { - - @Override - public boolean onPreDraw() { - - if (isHidden()) return true; - if (mAnimate && fragmentView.getTranslationY() == 0) { - ((DialpadSlidingLinearLayout) fragmentView).setYFraction( - DIALPAD_SLIDE_FRACTION); - } - final ViewTreeObserver vto = fragmentView.getViewTreeObserver(); - vto.removeOnPreDrawListener(this); - return true; - } - - }; - - vto.addOnPreDrawListener(preDrawListener); - Resources r = getResources(); mDialpadView = (DialpadView) fragmentView.findViewById(R.id.dialpad_view); @@ -1593,9 +1570,7 @@ public class DialpadFragment extends Fragment final DialtactsActivity activity = (DialtactsActivity) getActivity(); final DialpadView dialpadView = (DialpadView) getView().findViewById(R.id.dialpad_view); if (activity == null) return; - if (hidden) { - activity.onDialpadHidden(); - } else { + if (!hidden) { if (mAnimate) { dialpadView.animateShow(); } @@ -1608,6 +1583,10 @@ public class DialpadFragment extends Fragment mAnimate = value; } + public boolean getAnimate() { + return mAnimate; + } + public void setYFraction(float yFraction) { ((DialpadSlidingLinearLayout) getView()).setYFraction(yFraction); } -- cgit v1.2.3