private void acceptConfirmationIn( View v ) { if( !this.opem ) return; this.callback( this.confirmationInCallback ); YoYo.with( Techniques.ZoomOut ) .duration( 400 ) .playOn( this.ivExamConfirmationInReject ); YoYo.with( Techniques.ZoomIn ) .duration( 400 ) .withListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); ivExamConfirmationInAccept.setImageResource( R.drawable.ic_sentiment_satisfied_green_500_18dp ); } }) .playOn( this.ivExamConfirmationInAccept ) ; //Remover o evento this.ivExamConfirmationInReject.setOnClickListener( null ); this.ivExamConfirmationInAccept.setOnClickListener( null ); }
private void acceptConfirmationOut( View v ) { if( !this.opem ) return; this.callback( this.confirmationOutCallback ); YoYo.with( Techniques.ZoomOut ) .duration( 400 ) .playOn( this.ivExamConfirmationOutReject ); YoYo.with( Techniques.ZoomIn ) .duration( 400 ) .withListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); ivExamConfirmationOutAccept.setImageResource( R.drawable.ic_sentiment_very_dissatisfied_red_500_18dp ); } }) .playOn( this.ivExamConfirmationOutAccept ) ; //Remover o evento this.ivExamConfirmationOutReject.setOnClickListener( null ); this.ivExamConfirmationOutAccept.setOnClickListener( null ); }
private void hideBubble() { if (mBubbleAnimator == null) { mBubbleAnimator = ValueAnimator.ofFloat(1.0F, 0.0F); mBubbleAnimator.addUpdateListener(mBubbleAnimatorListener); mBubbleAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mBubbleVisible = false; invalidate(); } }); } else { mBubbleAnimator.cancel(); } mBubbleAnimator.start(); }
private void hideScroller() { if (mScrollerAnimator == null) { mScrollerAnimator = ValueAnimator.ofFloat(1.0F, 0.0F); mScrollerAnimator.addUpdateListener(mHandleAnimatorListener); mScrollerAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mScrollerVisible = false; invalidate(); } }); } else { mScrollerAnimator.cancel(); } mScrollerAnimator.start(); }
void onFingerUp() { if (mCurrentAnimator != null) { mCurrentAnimator.end(); mCurrentAnimator = null; createTouchRipple(END_RIPPLE_TOUCH_RADIUS); } mCurrentAnimator = ObjectAnimator.ofFloat(this, DESTROY_TOUCH_RIPPLE, 0f, 1f); mCurrentAnimator.setDuration(DEFAULT_ANIM_DURATION); mCurrentAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mCurrentAnimator = null; } }); mCurrentAnimator.start(); }
protected void performDismiss(final PendingDismissData data) { // Animate the dismissed list item to zero-height and fire the // dismiss callback when all dismissed list item animations have // completed. final ViewGroup.LayoutParams lp = data.view.getLayoutParams(); final int originalHeight = data.view.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); data.view.setLayoutParams(lp); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animation) { finalizeDismiss(); } }); animator.start(); }
public void hideUndoBar(boolean immediate) { // mHideHandler.removeCallbacks(mHideRunnable); if (immediate) { mBarView.setVisibility(View.GONE); AlphaManager.setAlpha(mBarView, 0); mUndoMessage = null; mUndoToken = null; } else { mBarAnimator.cancel(); mBarAnimator .alpha(0) .setDuration(mBarView.getResources() .getInteger(android.R.integer.config_shortAnimTime)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mBarView.setVisibility(View.GONE); mUndoMessage = null; mUndoToken = null; } }); } isVisible = false; }
private void animateFlip(final View aboveView, final View behindView){ aboveView.setVisibility(View.VISIBLE); behindView.setVisibility(View.GONE); ObjectAnimator flipAboveAnimator = ObjectAnimator.ofFloat(aboveView,"rotationY",0f,90f); final ObjectAnimator flipBehindAnimator = ObjectAnimator.ofFloat(behindView,"rotationY",-90f,0f); flipBehindAnimator.setInterpolator(new DecelerateInterpolator()); flipBehindAnimator.setDuration(500); flipAboveAnimator.setInterpolator(new AccelerateInterpolator()); flipAboveAnimator.setDuration(500); flipAboveAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { aboveView.setVisibility(View.GONE); behindView.setVisibility(View.VISIBLE); flipBehindAnimator.start(); isOpened = !isOpened; } }); flipAboveAnimator.start(); }
public void show( int x, int y, int duration ) { if( x < 0 || x > getWidth() || y < 0 || y > getHeight() ) { throw new RuntimeException( "Center point out of range or call method when View is not initialed yet." ); } mClipCenterX = x; mClipCenterY = y; float maxRadius = getMaxRadius( x, y ); if( mAnimator != null && mAnimator.isRunning() ) { mAnimator.cancel(); } mAnimator = ObjectAnimator.ofFloat( this, "clipRadius", 0f, maxRadius ); mAnimator.setInterpolator( new BakedBezierInterpolator() ); mAnimator.setDuration( duration ); mAnimator.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd( Animator animation ) { super.onAnimationEnd( animation ); mIsContentShown = true; } } ); mAnimator.start(); }
/** * @param direction 方向 */ public void dragCard(int direction) { if (mIndex > baseGragAdapter.getCount()) { return; } if (!animt_finish) return; animt_finish = false; AnimatorSet animatorSet = baseLayoutManager.animForward(direction, mScale, card_margin, mAlpha, getTopView(), viewCollection); animatorSet.start(); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); animt_finish = true; mIndex++; moveToBack(); } }); if (cardListener != null) cardListener.startSwip(mIndex); }
void onFingerUp(){ if(mCurrentAnimator != null) { mCurrentAnimator.end(); mCurrentAnimator = null; createTouchRipple(END_RIPPLE_TOUCH_RADIUS); } mCurrentAnimator = ObjectAnimator.ofFloat(this, DESTROY_TOUCH_RIPPLE, 0f, 1f); mCurrentAnimator.setDuration(DEFAULT_ANIM_DURATION); mCurrentAnimator.addListener(new AnimatorListenerAdapter(){ @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mCurrentAnimator = null; } }); mCurrentAnimator.start(); }
/** * Slide the overlay down off the screen and destroy it. */ private void slideOut() { if (isAnimating) { return; } isAnimating = true; ObjectAnimator animator = ObjectAnimator.ofFloat(containerView, "translationY", containerView.getHeight()); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { finish(); } }); animator.start(); }
public void show(int x, int y, int duration) { if (x < 0 || x > getWidth() || y < 0 || y > getHeight()) { throw new RuntimeException("Center point out of range or call method when View is not initialed yet."); } mClipCenterX = x; mClipCenterY = y; float maxRadius = getMaxRadius(x, y); if (mAnimator != null && mAnimator.isRunning()) { mAnimator.cancel(); } mAnimator = ObjectAnimator.ofFloat(this, "clipRadius", 0f, maxRadius); mAnimator.setInterpolator(new BakedBezierInterpolator()); mAnimator.setDuration(duration); mAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mIsContentShown = true; } }); mAnimator.start(); }
public void animateEnabled(boolean enabled) { if(animator != null) { animator.cancel(); animator = null; } if (enabled) { animator = ObjectAnimator.ofFloat(view, "alpha", 1f); } else animator = ObjectAnimator.ofFloat(view, "alpha", 0.5f); animator.setDuration(300); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); animator = null; } }); animator.start(); }
/** * 落地挤压 */ public void pressView() { ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(this, "scaleY", 1f, 0.7f); ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(this, "scaleX", 0.7f, 1f); scaleYAnimator.setDuration(ANIMATION_DURATION / 2); scaleXAnimator.setDuration(ANIMATION_DURATION / 2); scaleXAnimator.setInterpolator(new DecelerateInterpolator(mFactor)); scaleYAnimator.setInterpolator(new DecelerateInterpolator(mFactor)); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setDuration(ANIMATION_DURATION / 2); animatorSet.playTogether(scaleXAnimator, scaleYAnimator); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { springView(); } }); animatorSet.start(); }
/** * 反弹 */ public void springView() { ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(this, "scaleX", 1f, 0.7f); ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(this, "scaleY", 0.7f, 1f); scaleYAnimator.setDuration(ANIMATION_DURATION / 4); scaleXAnimator.setDuration(ANIMATION_DURATION / 4); scaleXAnimator.setInterpolator(new AccelerateInterpolator(mFactor)); scaleYAnimator.setInterpolator(new AccelerateInterpolator(mFactor)); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setDuration(ANIMATION_DURATION / 4); animatorSet.playTogether(scaleXAnimator, scaleYAnimator); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { upThrow(); } }); animatorSet.start(); }
/** * 上抛 */ public void upThrow() { ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "translationY", mDistance, 0); ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(this, "scaleX", 0.7f, 1f); objectAnimator.setDuration(ANIMATION_DURATION); scaleYAnimator.setDuration(ANIMATION_DURATION); scaleYAnimator.setInterpolator(new DecelerateInterpolator(mFactor)); objectAnimator.setInterpolator(new DecelerateInterpolator(mFactor)); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setDuration(ANIMATION_DURATION); animatorSet.playTogether(objectAnimator, scaleYAnimator); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { freeFall(); } }); animatorSet.start(); }
/** * 下落 */ public void freeFall() { ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "translationY", 0, mDistance); ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(this, "scaleX", 1f, 0.7f); objectAnimator.setDuration(ANIMATION_DURATION); scaleYAnimator.setDuration(ANIMATION_DURATION); scaleYAnimator.setInterpolator(new AccelerateInterpolator(mFactor)); objectAnimator.setInterpolator(new AccelerateInterpolator(mFactor)); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setDuration(ANIMATION_DURATION); animatorSet.playTogether(objectAnimator, scaleYAnimator); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { pressView(); } }); animatorSet.start(); }
private void slideUp(int startDelay){ mReAttached = false; ViewPropertyAnimator.animate(mView).setStartDelay(startDelay).alpha(0f) .translationY(-mView.getHeight() + mTranslationY) .setInterpolator(new AccelerateInterpolator()) .setDuration(300) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if(!mReAttached){ cleanup(); } } }) .start(); mVisible = false; }
@AfterViews void init() { YoYo.with(Techniques.DropOut).duration(DURATION).withListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // startMain(); } }).playOn(logo); RetrofitClient.apiService.getOneSentence("http://api.hitokoto.us/rand?&cat=a") .subscribeOn(Schedulers.from(Constant.executor)) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Action1<OneSentenceInfo>() { @Override public void call(OneSentenceInfo oneSentenceInfo) { oneSentence.setText(oneSentenceInfo.getHitokoto()); } }); startMain(); }
/** * Hide the label using an animation */ private void hideLabel() { ViewHelper.setAlpha(mLabel, 1f); ViewHelper.setTranslationY(mLabel, 0f); ViewPropertyAnimator.animate(mLabel) .alpha(0f) .translationY(mLabel.getHeight()) .setDuration(ANIMATION_DURATION) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLabel.setVisibility(View.GONE); } }).start(); }
/** * Slide out a view to the right or left of the list. After the animation has finished, the * view will be dismissed by calling {@link #performDismiss(android.view.View, android.view.View, int)}. * * @param view The view, that should be slided out. * @param childView The whole view of the list item. * @param position The item position of the item. * @param toRightSide Whether it should slide out to the right side. */ private void slideOutView(final View view, final View childView, final int position, boolean toRightSide) { // Only start new animation, if this view isn't already animated (too fast swiping bug) synchronized(mAnimationLock) { if(mAnimatedViews.contains(view)) { return; } ++mDismissAnimationRefCount; mAnimatedViews.add(view); } ViewPropertyAnimator.animate(view) .translationX(toRightSide ? mViewWidth : -mViewWidth) .alpha(0) .setDuration(mAnimationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { performDismiss(view, childView, position); } }); }
/** * Hide the label using an animation */ private void hideLabel() { ViewHelper.setAlpha(mLabel, 1f); ViewHelper.setTranslationY(mLabel, 0f); ViewPropertyAnimator.animate(mLabel) .alpha(0f) .translationY(mLabel.getHeight()) .setDuration(ANIMATION_DURATION) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLabel.setVisibility(View.GONE); } }) .start(); }
@Override public final void onClick(final View v) { v.setEnabled(false); final float initAplha = ViewHelper.getAlpha(v); ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(v, Utils.ALPHA, initAplha, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, initAplha).setDuration(400); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); onClick(); v.setEnabled(true); } }); objectAnimator.start(); }
@Override public final void onClick(final View v) { v.setEnabled(false); final float initX = ViewHelper.getScaleX(v); final float initY = ViewHelper.getScaleY(v); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(v, "scaleX", initX, 0.5f, initX).setDuration(100), ObjectAnimator.ofFloat(v, "scaleY", initY, 0.5f, initY).setDuration(100)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); onClick(); v.setEnabled(true); } }); animatorSet.start(); }
/** * Slide out a view to the right or left of the list. After the animation has finished, the * view will be dismissed by calling {@link #performDismiss(android.view.View, android.view.View, int)}. * * @param view The view, that should be slided out. * @param childView The whole view of the list item. * @param position The item position of the item. * @param toRightSide Whether it should slide out to the right side. */ private void slideOutView(final View view, final View childView, final int position, boolean toRightSide) { // Only start new animation, if this view isn't already animated (too fast swiping bug) synchronized (mAnimationLock) { if (mAnimatedViews.contains(view)) { return; } ++mDismissAnimationRefCount; mAnimatedViews.add(view); } ViewPropertyAnimator.animate(view) .translationX(toRightSide ? mViewWidth : -mViewWidth) //.alpha(0) .setDuration(mAnimationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { performDismiss(view, childView, position); } }); }
public void hideUndoBar(boolean immediate) { // mHideHandler.removeCallbacks(mHideRunnable); if (immediate) { mBarView.setVisibility(View.GONE); AlphaManager.setAlpha(mBarView, 0); mUndoMessage = null; mUndoToken = null; } else { mBarAnimator.cancel(); mBarAnimator .alpha(0) .setDuration(mBarView.getResources() .getInteger(android.R.integer.config_shortAnimTime)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mBarView.setVisibility(View.GONE); mUndoMessage = null; mUndoToken = null; } }); } }
/** * @param shouldResetTextColor if true make sure you end the previous animation before starting this one. */ public static ObjectAnimator getShakeAnimation(final TextView textView, final boolean shouldResetTextColor) { final int textColor = textView.getCurrentTextColor(); textView.setTextColor(Color.RED); ObjectAnimator shakeAnim = ObjectAnimator.ofFloat(textView, "translationX", -16); shakeAnim.setDuration(SHAKE_DURATION); shakeAnim.setInterpolator(new CycleInterpolator(2.0f)); shakeAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator anim) { if (shouldResetTextColor) { textView.setTextColor(textColor); } } }); return shakeAnim; }
/** * Create choice animation * * @param view affected view * @param position list position */ private void generateChoiceAnimate(final View view, final int position) { animate(view) .translationX(0) .setDuration(animationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { swipeListView.resetScrolling(); resetCell(); } }); }
/** * Create dismiss animation * * @param view affected view * @param swap If will change state. If is "false" returns to the original position * @param swapRight If swap is true, this parameter tells if move is to the right or left * @param position Position of list */ private void generateDismissAnimate(final View view, final boolean swap, final boolean swapRight, final int position) { int moveTo = 0; if (opened.get(position)) { if (!swap) { moveTo = openedRight.get(position) ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset); } } else { if (swap) { moveTo = swapRight ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset); } } int alpha = 1; if (swap) { ++dismissAnimationRefCount; alpha = 0; } animate(view) .translationX(moveTo) .alpha(alpha) .setDuration(animationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (swap) { closeOpenedItems(); performDismiss(view, position, true); } resetCell(); } }); }
/** * Create reveal animation * * @param view affected view * @param swap If will change state. If "false" returns to the original position * @param swapRight If swap is true, this parameter tells if movement is toward right or left * @param position list position */ private void generateRevealAnimate(final View view, final boolean swap, final boolean swapRight, final int position) { int moveTo = 0; if (opened.get(position)) { if (!swap) { moveTo = openedRight.get(position) ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset); } } else { if (swap) { moveTo = swapRight ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset); } } animate(view) .translationX(moveTo) .setDuration(animationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { swipeListView.resetScrolling(); if (swap) { boolean aux = !opened.get(position); opened.set(position, aux); if (aux) { swipeListView.onOpened(position, swapRight); openedRight.set(position, swapRight); } else { swipeListView.onClosed(position, openedRight.get(position)); } } resetCell(); } }); }
/** * Perform dismiss action * * @param dismissView View * @param dismissPosition Position of list */ protected void performDismiss(final View dismissView, final int dismissPosition, boolean doPendingDismiss) { final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(animationTime); if (doPendingDismiss) { animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { --dismissAnimationRefCount; if (dismissAnimationRefCount == 0) { removePendingDismisses(originalHeight); } } }); } animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); dismissView.setLayoutParams(lp); } }); pendingDismisses.add(new PendingDismissData(dismissPosition, dismissView)); animator.start(); }