Loading core/java/com/android/internal/app/ActionBarImpl.java +90 −14 Original line number Original line Diff line number Diff line Loading @@ -23,9 +23,9 @@ import com.android.internal.widget.ActionBarContextView; import com.android.internal.widget.ActionBarView; import com.android.internal.widget.ActionBarView; import android.animation.Animator; import android.animation.Animator; import android.animation.ObjectAnimator; import android.animation.Animator.AnimatorListener; import android.animation.Animator.AnimatorListener; import android.animation.AnimatorSet; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.ActionBar; import android.app.ActionBar; import android.app.Activity; import android.app.Activity; import android.app.Dialog; import android.app.Dialog; Loading @@ -40,10 +40,10 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuInflater; import android.view.MenuItem; import android.view.MenuItem; import android.view.View; import android.view.View; import android.view.Window; import android.widget.FrameLayout; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.LinearLayout; import android.widget.SpinnerAdapter; import android.widget.SpinnerAdapter; import android.widget.ViewAnimator; import java.lang.ref.WeakReference; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.ArrayList; Loading @@ -67,6 +67,7 @@ public class ActionBarImpl extends ActionBar { private ActionBarView mActionView; private ActionBarView mActionView; private ActionBarContextView mUpperContextView; private ActionBarContextView mUpperContextView; private LinearLayout mLowerContextView; private LinearLayout mLowerContextView; private View mContentView; private ArrayList<TabImpl> mTabs = new ArrayList<TabImpl>(); private ArrayList<TabImpl> mTabs = new ArrayList<TabImpl>(); Loading @@ -88,7 +89,7 @@ public class ActionBarImpl extends ActionBar { final Handler mHandler = new Handler(); final Handler mHandler = new Handler(); private Animator mCurrentAnimation; private Animator mCurrentAnim; final AnimatorListener[] mAfterAnimation = new AnimatorListener[] { final AnimatorListener[] mAfterAnimation = new AnimatorListener[] { new AnimatorListener() { // NORMAL_VIEW new AnimatorListener() { // NORMAL_VIEW Loading @@ -101,7 +102,7 @@ public class ActionBarImpl extends ActionBar { if (mLowerContextView != null) { if (mLowerContextView != null) { mLowerContextView.removeAllViews(); mLowerContextView.removeAllViews(); } } mCurrentAnimation = null; mCurrentAnim = null; hideAllExcept(NORMAL_VIEW); hideAllExcept(NORMAL_VIEW); } } Loading @@ -120,7 +121,7 @@ public class ActionBarImpl extends ActionBar { @Override @Override public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) { mCurrentAnimation = null; mCurrentAnim = null; hideAllExcept(CONTEXT_VIEW); hideAllExcept(CONTEXT_VIEW); } } Loading @@ -134,9 +135,56 @@ public class ActionBarImpl extends ActionBar { } } }; }; final AnimatorListener mHideListener = new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (mContentView != null) { mContentView.setTranslationY(0); } mContainerView.setVisibility(View.GONE); mCurrentAnim = null; } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }; final AnimatorListener mShowListener = new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mCurrentAnim = null; } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }; public ActionBarImpl(Activity activity) { public ActionBarImpl(Activity activity) { mActivity = activity; mActivity = activity; init(activity.getWindow().getDecorView()); Window window = activity.getWindow(); View decor = window.getDecorView(); init(decor); if (!mActivity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) { mContentView = decor.findViewById(android.R.id.content); } } } public ActionBarImpl(Dialog dialog) { public ActionBarImpl(Dialog dialog) { Loading Loading @@ -444,14 +492,45 @@ public class ActionBarImpl extends ActionBar { @Override @Override public void show() { public void show() { // TODO animate! if (mCurrentAnim != null) { mCurrentAnim.end(); } if (mContainerView.getVisibility() == View.VISIBLE) { return; } mContainerView.setVisibility(View.VISIBLE); mContainerView.setVisibility(View.VISIBLE); mContainerView.setAlpha(0); mContainerView.setTranslationY(-mContainerView.getHeight()); AnimatorSet anim = new AnimatorSet(); AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "translationY", 0)) .with(ObjectAnimator.ofFloat(mContainerView, "alpha", 1)); if (mContentView != null) { b.with(ObjectAnimator.ofFloat(mContentView, "translationY", -mContainerView.getHeight(), 0)); } anim.addListener(mShowListener); mCurrentAnim = anim; anim.start(); } } @Override @Override public void hide() { public void hide() { // TODO animate! if (mCurrentAnim != null) { mContainerView.setVisibility(View.GONE); mCurrentAnim.end(); } if (mContainerView.getVisibility() == View.GONE) { return; } mContainerView.setAlpha(1); AnimatorSet anim = new AnimatorSet(); AnimatorSet.Builder b = anim.play( ObjectAnimator.ofFloat(mContainerView, "translationY", -mContainerView.getHeight())) .with(ObjectAnimator.ofFloat(mContainerView, "alpha", 0)); if (mContentView != null) { b.with(ObjectAnimator.ofFloat(mContentView, "translationY", 0, -mContainerView.getHeight())); } anim.addListener(mHideListener); mCurrentAnim = anim; anim.start(); } } public boolean isShowing() { public boolean isShowing() { Loading @@ -459,10 +538,7 @@ public class ActionBarImpl extends ActionBar { } } private long animateTo(int viewIndex) { private long animateTo(int viewIndex) { // Don't wait for the current animation to finish. show(); if (mCurrentAnimation != null) { mCurrentAnimation.end(); } AnimatorSet set = new AnimatorSet(); AnimatorSet set = new AnimatorSet(); Loading Loading @@ -492,7 +568,7 @@ public class ActionBarImpl extends ActionBar { set.addListener(mAfterAnimation[viewIndex]); set.addListener(mAfterAnimation[viewIndex]); mCurrentAnimation = set; mCurrentAnim = set; set.start(); set.start(); return set.getDuration(); return set.getDuration(); } } Loading Loading
core/java/com/android/internal/app/ActionBarImpl.java +90 −14 Original line number Original line Diff line number Diff line Loading @@ -23,9 +23,9 @@ import com.android.internal.widget.ActionBarContextView; import com.android.internal.widget.ActionBarView; import com.android.internal.widget.ActionBarView; import android.animation.Animator; import android.animation.Animator; import android.animation.ObjectAnimator; import android.animation.Animator.AnimatorListener; import android.animation.Animator.AnimatorListener; import android.animation.AnimatorSet; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.ActionBar; import android.app.ActionBar; import android.app.Activity; import android.app.Activity; import android.app.Dialog; import android.app.Dialog; Loading @@ -40,10 +40,10 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuInflater; import android.view.MenuItem; import android.view.MenuItem; import android.view.View; import android.view.View; import android.view.Window; import android.widget.FrameLayout; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.LinearLayout; import android.widget.SpinnerAdapter; import android.widget.SpinnerAdapter; import android.widget.ViewAnimator; import java.lang.ref.WeakReference; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.ArrayList; Loading @@ -67,6 +67,7 @@ public class ActionBarImpl extends ActionBar { private ActionBarView mActionView; private ActionBarView mActionView; private ActionBarContextView mUpperContextView; private ActionBarContextView mUpperContextView; private LinearLayout mLowerContextView; private LinearLayout mLowerContextView; private View mContentView; private ArrayList<TabImpl> mTabs = new ArrayList<TabImpl>(); private ArrayList<TabImpl> mTabs = new ArrayList<TabImpl>(); Loading @@ -88,7 +89,7 @@ public class ActionBarImpl extends ActionBar { final Handler mHandler = new Handler(); final Handler mHandler = new Handler(); private Animator mCurrentAnimation; private Animator mCurrentAnim; final AnimatorListener[] mAfterAnimation = new AnimatorListener[] { final AnimatorListener[] mAfterAnimation = new AnimatorListener[] { new AnimatorListener() { // NORMAL_VIEW new AnimatorListener() { // NORMAL_VIEW Loading @@ -101,7 +102,7 @@ public class ActionBarImpl extends ActionBar { if (mLowerContextView != null) { if (mLowerContextView != null) { mLowerContextView.removeAllViews(); mLowerContextView.removeAllViews(); } } mCurrentAnimation = null; mCurrentAnim = null; hideAllExcept(NORMAL_VIEW); hideAllExcept(NORMAL_VIEW); } } Loading @@ -120,7 +121,7 @@ public class ActionBarImpl extends ActionBar { @Override @Override public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) { mCurrentAnimation = null; mCurrentAnim = null; hideAllExcept(CONTEXT_VIEW); hideAllExcept(CONTEXT_VIEW); } } Loading @@ -134,9 +135,56 @@ public class ActionBarImpl extends ActionBar { } } }; }; final AnimatorListener mHideListener = new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (mContentView != null) { mContentView.setTranslationY(0); } mContainerView.setVisibility(View.GONE); mCurrentAnim = null; } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }; final AnimatorListener mShowListener = new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mCurrentAnim = null; } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }; public ActionBarImpl(Activity activity) { public ActionBarImpl(Activity activity) { mActivity = activity; mActivity = activity; init(activity.getWindow().getDecorView()); Window window = activity.getWindow(); View decor = window.getDecorView(); init(decor); if (!mActivity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) { mContentView = decor.findViewById(android.R.id.content); } } } public ActionBarImpl(Dialog dialog) { public ActionBarImpl(Dialog dialog) { Loading Loading @@ -444,14 +492,45 @@ public class ActionBarImpl extends ActionBar { @Override @Override public void show() { public void show() { // TODO animate! if (mCurrentAnim != null) { mCurrentAnim.end(); } if (mContainerView.getVisibility() == View.VISIBLE) { return; } mContainerView.setVisibility(View.VISIBLE); mContainerView.setVisibility(View.VISIBLE); mContainerView.setAlpha(0); mContainerView.setTranslationY(-mContainerView.getHeight()); AnimatorSet anim = new AnimatorSet(); AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "translationY", 0)) .with(ObjectAnimator.ofFloat(mContainerView, "alpha", 1)); if (mContentView != null) { b.with(ObjectAnimator.ofFloat(mContentView, "translationY", -mContainerView.getHeight(), 0)); } anim.addListener(mShowListener); mCurrentAnim = anim; anim.start(); } } @Override @Override public void hide() { public void hide() { // TODO animate! if (mCurrentAnim != null) { mContainerView.setVisibility(View.GONE); mCurrentAnim.end(); } if (mContainerView.getVisibility() == View.GONE) { return; } mContainerView.setAlpha(1); AnimatorSet anim = new AnimatorSet(); AnimatorSet.Builder b = anim.play( ObjectAnimator.ofFloat(mContainerView, "translationY", -mContainerView.getHeight())) .with(ObjectAnimator.ofFloat(mContainerView, "alpha", 0)); if (mContentView != null) { b.with(ObjectAnimator.ofFloat(mContentView, "translationY", 0, -mContainerView.getHeight())); } anim.addListener(mHideListener); mCurrentAnim = anim; anim.start(); } } public boolean isShowing() { public boolean isShowing() { Loading @@ -459,10 +538,7 @@ public class ActionBarImpl extends ActionBar { } } private long animateTo(int viewIndex) { private long animateTo(int viewIndex) { // Don't wait for the current animation to finish. show(); if (mCurrentAnimation != null) { mCurrentAnimation.end(); } AnimatorSet set = new AnimatorSet(); AnimatorSet set = new AnimatorSet(); Loading Loading @@ -492,7 +568,7 @@ public class ActionBarImpl extends ActionBar { set.addListener(mAfterAnimation[viewIndex]); set.addListener(mAfterAnimation[viewIndex]); mCurrentAnimation = set; mCurrentAnim = set; set.start(); set.start(); return set.getDuration(); return set.getDuration(); } } Loading