List of usage examples for android.view ViewPropertyAnimator translationY
public ViewPropertyAnimator translationY(float value)
translationY
property to be animated to the specified value. From source file:me.lizheng.deckview.helpers.DeckChildViewTransform.java
/** * Applies this transform to a view./*from ww w. j av a 2s .c o m*/ */ public void applyToTaskView(View v, int duration, Interpolator interp, /*boolean allowLayers,*/ boolean allowShadows/*, ValueAnimator.AnimatorUpdateListener updateCallback*/) { // Check to see if any properties have changed, and update the task view if (duration > 0) { ViewPropertyAnimator anim = v.animate(); // boolean requiresLayers = false; // Animate to the final state if (hasTranslationYChangedFrom(v.getTranslationY())) { anim.translationY(translationY); } // if (allowShadows && hasTranslationZChangedFrom(v.getTranslationZ())) { // anim.translationZ(translationZ); // } if (hasScaleChangedFrom(v.getScaleX())) { anim.scaleX(scale).scaleY(scale); // requiresLayers = true; } if (hasAlphaChangedFrom(v.getAlpha())) { // Use layers if we animate alpha anim.alpha(alpha); // requiresLayers = true; } // if (requiresLayers && allowLayers) { // anim.withLayer(); // } // if (updateCallback != null) { // anim.setUpdateListener(updateCallback); // } else { // anim.setUpdateListener(null); // } anim.setStartDelay(startDelay).setDuration(duration).setInterpolator(interp).start(); } else { // Set the changed properties if (hasTranslationYChangedFrom(v.getTranslationY())) { v.setTranslationY(translationY); } if (allowShadows && hasTranslationZChangedFrom(ViewCompat.getTranslationZ(v))) { ViewCompat.setTranslationZ(v, translationZ); } if (hasScaleChangedFrom(v.getScaleX())) { v.setScaleX(scale); v.setScaleY(scale); } if (hasAlphaChangedFrom(v.getAlpha())) { v.setAlpha(alpha); } } }
From source file:edward.com.recyclerview.BaseItemAnimator.java
private void animateChangeImpl(final ChangeInfo changeInfo) { final ViewHolder holder = changeInfo.oldHolder; final View view = holder == null ? null : holder.itemView; final ViewHolder newHolder = changeInfo.newHolder; final View newView = newHolder != null ? newHolder.itemView : null; if (view != null) { mChangeAnimations.add(changeInfo.oldHolder); final ViewPropertyAnimator oldViewAnim = view.animate().setDuration(getChangeDuration()); oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX); oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY); oldViewAnim.alpha(0).setListener(new VpaListenerAdapter() { @Override/*from w ww . j a v a 2 s . c om*/ public void onAnimationStart(Animator animation) { dispatchChangeStarting(changeInfo.oldHolder, true); } @Override public void onAnimationEnd(Animator animation) { View mView = view; if (animation instanceof ObjectAnimator) { mView = (View) ((ObjectAnimator) animation).getTarget(); } oldViewAnim.setListener(null); mView.setAlpha(1); mView.setTranslationX(0); mView.setTranslationY(0); dispatchChangeFinished(changeInfo.oldHolder, true); mChangeAnimations.remove(changeInfo.oldHolder); dispatchFinishedWhenDone(); } }).start(); } if (newView != null) { mChangeAnimations.add(changeInfo.newHolder); final ViewPropertyAnimator newViewAnimation = newView.animate(); newViewAnimation.translationX(0).translationY(0).setDuration(getChangeDuration()).alpha(1) .setListener(new VpaListenerAdapter() { @Override public void onAnimationStart(Animator view) { dispatchChangeStarting(changeInfo.newHolder, false); } @Override public void onAnimationEnd(Animator animation) { newViewAnimation.setListener(null); newView.setAlpha(1); newView.setTranslationX(0); newView.setTranslationY(0); dispatchChangeFinished(changeInfo.newHolder, false); mChangeAnimations.remove(changeInfo.newHolder); dispatchFinishedWhenDone(); } }).start(); } }
From source file:com.android.gallery3d.filtershow.FilterShowActivity.java
public void loadEditorPanel(FilterRepresentation representation, final Editor currentEditor) { if (representation.getEditorId() == ImageOnlyEditor.ID) { currentEditor.reflectCurrentFilter(); return;//from w w w. jav a 2 s . c o m } final int currentId = currentEditor.getID(); Runnable showEditor = new Runnable() { @Override public void run() { EditorPanel panel = new EditorPanel(); panel.setEditor(currentId); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG)); transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG); transaction.commit(); } }; Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); boolean doAnimation = false; if (mShowingImageStatePanel && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { doAnimation = true; } if (doAnimation && main != null && main instanceof MainPanel) { MainPanel mainPanel = (MainPanel) main; View container = mainPanel.getView().findViewById(R.id.category_panel_container); View bottom = mainPanel.getView().findViewById(R.id.bottom_panel); int panelHeight = container.getHeight() + bottom.getHeight(); ViewPropertyAnimator anim = mainPanel.getView().animate(); anim.translationY(panelHeight).start(); final Handler handler = new Handler(); handler.postDelayed(showEditor, anim.getDuration()); } else { showEditor.run(); } }
From source file:com.android.gallery3d.v5.filtershow.FilterShowActivity.java
public void loadEditorPanel(FilterRepresentation representation, final Editor currentEditor) { if (representation.getEditorId() == ImageOnlyEditor.ID) { currentEditor.reflectCurrentFilter(); return;/*from ww w .jav a 2 s . co m*/ } final int currentId = currentEditor.getID(); Runnable showEditor = new Runnable() { @Override public void run() { Log.i("Test", "showEditor"); EditorPanel panel = new EditorPanel(); panel.setEditor(currentId); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG)); transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG); transaction.commit(); } }; Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); boolean doAnimation = false; if (mShowingImageStatePanel && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { doAnimation = true; } if (doAnimation && main != null && main instanceof MainPanel) { MainPanel mainPanel = (MainPanel) main; View container = mainPanel.getView().findViewById(R.id.category_panel_container); View bottom = mainPanel.getView().findViewById(R.id.bottom_panel); int panelHeight = container.getHeight() + bottom.getHeight(); ViewPropertyAnimator anim = mainPanel.getView().animate(); anim.translationY(panelHeight).start(); final Handler handler = new Handler(); handler.postDelayed(showEditor, anim.getDuration()); } else { showEditor.run(); } }
From source file:com.android.incallui.CallCardFragment.java
/** * Sets the visibility of the primary call card. * Ensures that when the primary call card is hidden, the video surface slides over to fill the * entire screen./*from w w w. j a v a 2 s . c o m*/ * * @param visible {@code True} if the primary call card should be visible. */ @Override public void setCallCardVisible(final boolean visible) { Log.v(this, "setCallCardVisible : isVisible = " + visible); // When animating the hide/show of the views in a landscape layout, we need to take into // account whether we are in a left-to-right locale or a right-to-left locale and adjust // the animations accordingly. final boolean isLayoutRtl = InCallPresenter.isRtl(); // Retrieve here since at fragment creation time the incoming video view is not inflated. final View videoView = getView().findViewById(R.id.incomingVideo); if (videoView == null) { return; } // Determine how much space there is below or to the side of the call card. final float spaceBesideCallCard = getSpaceBesideCallCard(); // We need to translate the video surface, but we need to know its position after the layout // has occurred so use a {@code ViewTreeObserver}. final ViewTreeObserver observer = getView().getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { // We don't want to continue getting called. getView().getViewTreeObserver().removeOnPreDrawListener(this); float videoViewTranslation = 0f; // Translate the call card to its pre-animation state. if (!mIsLandscape) { mPrimaryCallCardContainer.setTranslationY(visible ? -mPrimaryCallCardContainer.getHeight() : 0); ViewGroup.LayoutParams p = videoView.getLayoutParams(); videoViewTranslation = p.height / 2 - spaceBesideCallCard / 2; } // Perform animation of video view. ViewPropertyAnimator videoViewAnimator = videoView.animate() .setInterpolator(AnimUtils.EASE_OUT_EASE_IN).setDuration(mVideoAnimationDuration); if (mIsLandscape) { videoViewAnimator.translationX(visible ? videoViewTranslation : 0); } else { videoViewAnimator.translationY(visible ? videoViewTranslation : 0); } videoViewAnimator.start(); // Animate the call card sliding. ViewPropertyAnimator callCardAnimator = mPrimaryCallCardContainer.animate() .setInterpolator(AnimUtils.EASE_OUT_EASE_IN).setDuration(mVideoAnimationDuration) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (!visible) { mPrimaryCallCardContainer.setVisibility(View.GONE); } } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); if (visible) { mPrimaryCallCardContainer.setVisibility(View.VISIBLE); } } }); if (mIsLandscape) { float translationX = mPrimaryCallCardContainer.getWidth(); translationX *= isLayoutRtl ? 1 : -1; callCardAnimator.translationX(visible ? 0 : translationX).start(); } else { callCardAnimator.translationY(visible ? 0 : -mPrimaryCallCardContainer.getHeight()).start(); } return true; } }); }