Java Code Examples for android.support.v4.view.ViewPropertyAnimatorCompat

The following are top voted examples for showing how to use android.support.v4.view.ViewPropertyAnimatorCompat. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: BadgeItem.java   Source Code and License 6 votes vote down vote up
/**
 * @param animate whether to animate the change
 * @return this, to allow builder pattern
 */
public T show(boolean animate) {
    mIsHidden = false;
    if (isWeakReferenceValid()) {
        TextView textView = mTextViewRef.get();
        if (animate) {
            textView.setScaleX(0);
            textView.setScaleY(0);
            textView.setVisibility(View.VISIBLE);
            ViewPropertyAnimatorCompat animatorCompat = ViewCompat.animate(textView);
            animatorCompat.cancel();
            animatorCompat.setDuration(mAnimationDuration);
            animatorCompat.scaleX(1).scaleY(1);
            animatorCompat.setListener(null);
            animatorCompat.start();
        } else {
            textView.setScaleX(1);
            textView.setScaleY(1);
            textView.setVisibility(View.VISIBLE);
        }
    }
    return getSubInstance();
}
 
Example 2
Project: GitHub   File: PendingItemAnimator.java   Source Code and License 6 votes vote down vote up
/**
 * Preform your animation. You do not need to override this in most cases cause the default is pretty good.
 * Listeners will be overridden
 **/
protected ViewPropertyAnimatorCompat animateMoveImpl(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
	final View view = holder.itemView;
	final int deltaX = toX - fromX;
	final int deltaY = toY - fromY;
	ViewCompat.animate(view).cancel();
	if (deltaX != 0) {
		ViewCompat.animate(view).translationX(0);
	}
	if (deltaY != 0) {
		ViewCompat.animate(view).translationY(0);
	}
	// TODO: make EndActions end listeners instead, since end actions aren't called when
	// vpas are canceled (and can't end them. why?)
	// need listener functionality in VPACompat for this. Ick.
	return ViewCompat.animate(view).setInterpolator(null).setDuration(getMoveDuration());
}
 
Example 3
Project: Rx2Animations   File: AnimateCompletable.java   Source Code and License 6 votes vote down vote up
@Override
protected void subscribeActual(final CompletableObserver completableObserver) {
    verifyMainThread();
    final View view = viewWeakRef.get();
    if (view == null) {
        completableObserver.onComplete();
        return;
    }

    final ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);

    completableObserver.onSubscribe(createAnimationDisposable(animator, onAnimationCancelAction));

    if (preTransformActions != null) {
        applyActions(preTransformActions, animator);
        animator.setDuration(NONE).setStartDelay(NONE)
                .withEndAction(() -> runAnimation(completableObserver, animator))
                .start();
    } else {
        runAnimation(completableObserver, animator);
    }
}
 
Example 4
Project: boohee_v5.6   File: ViewPropertyAnimatorCompatSet.java   Source Code and License 6 votes vote down vote up
public void start() {
    if (!this.mIsStarted) {
        Iterator i$ = this.mAnimators.iterator();
        while (i$.hasNext()) {
            ViewPropertyAnimatorCompat animator = (ViewPropertyAnimatorCompat) i$.next();
            if (this.mDuration >= 0) {
                animator.setDuration(this.mDuration);
            }
            if (this.mInterpolator != null) {
                animator.setInterpolator(this.mInterpolator);
            }
            if (this.mListener != null) {
                animator.setListener(this.mProxyListener);
            }
            animator.start();
        }
        this.mIsStarted = true;
    }
}
 
Example 5
Project: boohee_v5.6   File: WindowDecorActionBar.java   Source Code and License 6 votes vote down vote up
public void animateToMode(boolean toActionMode) {
    ViewPropertyAnimatorCompat fadeOut;
    ViewPropertyAnimatorCompat fadeIn;
    if (toActionMode) {
        showForActionMode();
    } else {
        hideForActionMode();
    }
    if (toActionMode) {
        fadeOut = this.mDecorToolbar.setupAnimatorToVisibility(4, FADE_OUT_DURATION_MS);
        fadeIn = this.mContextView.setupAnimatorToVisibility(0, FADE_IN_DURATION_MS);
    } else {
        fadeIn = this.mDecorToolbar.setupAnimatorToVisibility(0, FADE_IN_DURATION_MS);
        fadeOut = this.mContextView.setupAnimatorToVisibility(8, FADE_OUT_DURATION_MS);
    }
    ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet();
    set.playSequentially(fadeOut, fadeIn);
    set.start();
}
 
Example 6
Project: boohee_v5.6   File: ScrollingTabContainerView.java   Source Code and License 6 votes vote down vote up
public void animateToVisibility(int visibility) {
    if (this.mVisibilityAnim != null) {
        this.mVisibilityAnim.cancel();
    }
    if (visibility == 0) {
        if (getVisibility() != 0) {
            ViewCompat.setAlpha(this, 0.0f);
        }
        ViewPropertyAnimatorCompat anim = ViewCompat.animate(this).alpha(1.0f);
        anim.setDuration(200);
        anim.setInterpolator(sAlphaInterpolator);
        anim.setListener(this.mVisAnimListener.withFinalVisibility(anim, visibility));
        anim.start();
        return;
    }
    anim = ViewCompat.animate(this).alpha(0.0f);
    anim.setDuration(200);
    anim.setInterpolator(sAlphaInterpolator);
    anim.setListener(this.mVisAnimListener.withFinalVisibility(anim, visibility));
    anim.start();
}
 
Example 7
Project: boohee_v5.6   File: AbsActionBarView.java   Source Code and License 6 votes vote down vote up
public ViewPropertyAnimatorCompat setupAnimatorToVisibility(int visibility, long duration) {
    if (this.mVisibilityAnim != null) {
        this.mVisibilityAnim.cancel();
    }
    if (visibility == 0) {
        if (getVisibility() != 0) {
            ViewCompat.setAlpha(this, 0.0f);
        }
        ViewPropertyAnimatorCompat anim = ViewCompat.animate(this).alpha(1.0f);
        anim.setDuration(duration);
        anim.setListener(this.mVisAnimListener.withFinalVisibility(anim, visibility));
        return anim;
    }
    anim = ViewCompat.animate(this).alpha(0.0f);
    anim.setDuration(duration);
    anim.setListener(this.mVisAnimListener.withFinalVisibility(anim, visibility));
    return anim;
}
 
Example 8
Project: MenuSet   File: PerseiLayout.java   Source Code and License 6 votes vote down vote up
public void createAnimatorToHeadView(final View v, final float angle)
{
    ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(v);
    viewPropertyAnimatorCompat.setDuration(200);
    viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator());
    viewPropertyAnimatorCompat.rotationX(90);
    viewPropertyAnimatorCompat.start();
    viewPropertyAnimatorCompat.setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(View view) {
            float height = ViewCompat.getTranslationY(mChildView);
            mHeadLayout.setPivotX(mHeadLayout.getWidth() / 2);
            mHeadLayout.setPivotY(height);
        }
    });
}
 
Example 9
Project: SprintNBA   File: MaterialRefreshLayout.java   Source Code and License 6 votes vote down vote up
public void finishRefreshing() {
    if (mChildView != null) {
        ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(mChildView);
        viewPropertyAnimatorCompat.setDuration(200);
        viewPropertyAnimatorCompat.y(ViewCompat.getTranslationY(mChildView));
        viewPropertyAnimatorCompat.translationY(0);
        viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator());
        viewPropertyAnimatorCompat.start();

        if (mMaterialHeaderView != null) {
            mMaterialHeaderView.onComplete(MaterialRefreshLayout.this);
        } else if (mSunLayout != null) {
            mSunLayout.onComplete(MaterialRefreshLayout.this);
        }

        if (refreshListener != null) {
            refreshListener.onfinish();
        }
    }
    isRefreshing = false;
    progressValue = 0;
}
 
Example 10
Project: expandable-recyclerview-with-gridlayout   File: SwipeDismissItemAnimator.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreateAnimation(MoveAnimationInfo info) {
    final View view = info.holder.itemView;
    final int deltaX = info.toX - info.fromX;
    final int deltaY = info.toY - info.fromY;

    if (deltaX != 0) {
        ViewCompat.animate(view).translationX(0);
    }
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }

    final ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);

    animator.setDuration(getDuration());
    animator.setInterpolator(MOVE_INTERPOLATOR);

    startActiveItemAnimation(info, info.holder, animator);
}
 
Example 11
Project: expandable-recyclerview-with-gridlayout   File: RefactoredDefaultItemAnimator.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreateAnimation(MoveAnimationInfo info) {
    final View view = info.holder.itemView;
    final int deltaX = info.toX - info.fromX;
    final int deltaY = info.toY - info.fromY;

    if (deltaX != 0) {
        ViewCompat.animate(view).translationX(0);
    }
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }

    final ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);

    animator.setDuration(getDuration());

    startActiveItemAnimation(info, info.holder, animator);
}
 
Example 12
Project: MousePaintYzz   File: MaterialRefreshLayout.java   Source Code and License 6 votes vote down vote up
public void finishRefreshing() {
    if (mChildView != null) {
        ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(mChildView);
        viewPropertyAnimatorCompat.setDuration(200);
        viewPropertyAnimatorCompat.y(ViewCompat.getTranslationY(mChildView));
        viewPropertyAnimatorCompat.translationY(0);
        viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator());
        viewPropertyAnimatorCompat.start();

        if (materialHeadView != null) {
            materialHeadView.onComlete(MaterialRefreshLayout.this);
        }

        if (refreshListener != null) {
            refreshListener.onfinish();
        }
    }
    isRefreshing = false;
    progressValue = 0;
    setProgressValue(0);
}
 
Example 13
Project: RxAnimations   File: AnimateOnSubscribe.java   Source Code and License 6 votes vote down vote up
@Override
public void call(final CompletableSubscriber completableSubscriber) {
    final View view = viewWeakRef.get();
    if (view == null) {
        completableSubscriber.onCompleted();
        return;
    }

    final ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);
    completableSubscriber.onSubscribe(createClearSubscription(animator));

    if (preTransformActions != null) {
        applyActions(preTransformActions, animator);
        animator.setDuration(NONE).setStartDelay(NONE)
                .withEndAction(() -> runAnimation(completableSubscriber, animator))
                .start();
    } else {
        runAnimation(completableSubscriber, animator);
    }
}
 
Example 14
Project: BitkyShop   File: MaterialRefreshLayout.java   Source Code and License 6 votes vote down vote up
public void finishRefreshing() {
    if (mChildView != null) {
        ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(mChildView);
        viewPropertyAnimatorCompat.setDuration(200);
        viewPropertyAnimatorCompat.y(ViewCompat.getTranslationY(mChildView));
        viewPropertyAnimatorCompat.translationY(0);
        viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator());
        viewPropertyAnimatorCompat.start();

        if (mMaterialHeaderView != null) {
            mMaterialHeaderView.onComlete(MaterialRefreshLayout.this);
        } else if (mSunLayout != null) {
            mSunLayout.onComlete(MaterialRefreshLayout.this);
        }

        if (refreshListener != null) {
            refreshListener.onfinish();
        }
    }
    isRefreshing = false;
    progressValue = 0;
}
 
Example 15
Project: FMTech   File: ViewPropertyAnimatorCompatSet.java   Source Code and License 6 votes vote down vote up
public final void start()
{
  if (this.mIsStarted) {
    return;
  }
  Iterator localIterator = this.mAnimators.iterator();
  while (localIterator.hasNext())
  {
    ViewPropertyAnimatorCompat localViewPropertyAnimatorCompat = (ViewPropertyAnimatorCompat)localIterator.next();
    if (this.mDuration >= 0L) {
      localViewPropertyAnimatorCompat.setDuration(this.mDuration);
    }
    if (this.mInterpolator != null) {
      localViewPropertyAnimatorCompat.setInterpolator(this.mInterpolator);
    }
    if (this.mListener != null) {
      localViewPropertyAnimatorCompat.setListener(this.mProxyListener);
    }
    localViewPropertyAnimatorCompat.start();
  }
  this.mIsStarted = true;
}
 
Example 16
Project: FMTech   File: AbsActionBarView.java   Source Code and License 6 votes vote down vote up
public ViewPropertyAnimatorCompat setupAnimatorToVisibility(int paramInt, long paramLong)
{
  if (this.mVisibilityAnim != null) {
    this.mVisibilityAnim.cancel();
  }
  if (paramInt == 0)
  {
    if (getVisibility() != 0) {
      ViewCompat.setAlpha(this, 0.0F);
    }
    ViewPropertyAnimatorCompat localViewPropertyAnimatorCompat2 = ViewCompat.animate(this).alpha(1.0F);
    localViewPropertyAnimatorCompat2.setDuration(paramLong);
    localViewPropertyAnimatorCompat2.setListener(this.mVisAnimListener.withFinalVisibility(localViewPropertyAnimatorCompat2, paramInt));
    return localViewPropertyAnimatorCompat2;
  }
  ViewPropertyAnimatorCompat localViewPropertyAnimatorCompat1 = ViewCompat.animate(this).alpha(0.0F);
  localViewPropertyAnimatorCompat1.setDuration(paramLong);
  localViewPropertyAnimatorCompat1.setListener(this.mVisAnimListener.withFinalVisibility(localViewPropertyAnimatorCompat1, paramInt));
  return localViewPropertyAnimatorCompat1;
}
 
Example 17
Project: OpenCVTour   File: SwipeDismissItemAnimator.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreateAnimation(MoveAnimationInfo info) {
    final View view = info.holder.itemView;
    final int deltaX = info.toX - info.fromX;
    final int deltaY = info.toY - info.fromY;

    if (deltaX != 0) {
        ViewCompat.animate(view).translationX(0);
    }
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }

    final ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);

    animator.setDuration(getDuration());
    animator.setInterpolator(MOVE_INTERPOLATOR);

    startActiveItemAnimation(info, info.holder, animator);
}
 
Example 18
Project: OpenCVTour   File: RefactoredDefaultItemAnimator.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreateAnimation(MoveAnimationInfo info) {
    final View view = info.holder.itemView;
    final int deltaX = info.toX - info.fromX;
    final int deltaY = info.toY - info.fromY;

    if (deltaX != 0) {
        ViewCompat.animate(view).translationX(0);
    }
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }

    final ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);

    animator.setDuration(getDuration());

    startActiveItemAnimation(info, info.holder, animator);
}
 
Example 19
Project: MousePaint   File: MaterialRefreshLayout.java   Source Code and License 6 votes vote down vote up
public void finishRefreshing() {
    if (mChildView != null) {
        ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(mChildView);
        viewPropertyAnimatorCompat.setDuration(200);
        viewPropertyAnimatorCompat.y(ViewCompat.getTranslationY(mChildView));
        viewPropertyAnimatorCompat.translationY(0);
        viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator());
        viewPropertyAnimatorCompat.start();

        if (materialHeadView != null) {
            materialHeadView.onComlete(MaterialRefreshLayout.this);
        }

        if (refreshListener != null) {
            refreshListener.onfinish();
        }
    }
    isRefreshing = false;
    progressValue = 0;
    setProgressValue(0);
}
 
Example 20
Project: PulltoRefreshLayout   File: PulltoRefreshLayout.java   Source Code and License 6 votes vote down vote up
public void finishRefreshing() {
    if (mChildView != null) {
        ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(mChildView);
        viewPropertyAnimatorCompat.setDuration(200);
        viewPropertyAnimatorCompat.y(ViewCompat.getTranslationY(mChildView));
        viewPropertyAnimatorCompat.translationY(0);
        viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator());
        viewPropertyAnimatorCompat.start();

        if (materialHeadView != null) {
            materialHeadView.onComlete(PulltoRefreshLayout.this);
        }

        if (refreshListener != null) {
            refreshListener.onfinish();
        }
    }
    isRefreshing = false;
    progressValue = 0;
    setProgressValue(0);
}
 
Example 21
Project: FlexibleAdapter   File: PendingItemAnimator.java   Source Code and License 6 votes vote down vote up
/**
 * Preform your animation. You do not need to override this in most cases cause the default is pretty good.
 * Listeners will be overridden
 **/
protected ViewPropertyAnimatorCompat animateMoveImpl(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
    final View view = holder.itemView;
    final int deltaX = toX - fromX;
    final int deltaY = toY - fromY;
    ViewCompat.animate(view).cancel();
    if (deltaX != 0) {
        ViewCompat.animate(view).translationX(0);
    }
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }
    // TODO: make EndActions end listeners instead, since end actions aren't called when
    // vpas are canceled (and can't end them. why?)
    // need listener functionality in VPACompat for this. Ick.
    return ViewCompat.animate(view).setInterpolator(null).setDuration(getMoveDuration());
}
 
Example 22
Project: android-advancedrecyclerview-master   File: SwipeDismissItemAnimator.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreateAnimation(MoveAnimationInfo info) {
    final View view = info.holder.itemView;
    final int deltaX = info.toX - info.fromX;
    final int deltaY = info.toY - info.fromY;

    if (deltaX != 0) {
        ViewCompat.animate(view).translationX(0);
    }
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }

    final ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);

    animator.setDuration(getDuration());
    animator.setInterpolator(MOVE_INTERPOLATOR);

    startActiveItemAnimation(info, info.holder, animator);
}
 
Example 23
Project: android-advancedrecyclerview-master   File: RefactoredDefaultItemAnimator.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreateAnimation(MoveAnimationInfo info) {
    final View view = info.holder.itemView;
    final int deltaX = info.toX - info.fromX;
    final int deltaY = info.toY - info.fromY;

    if (deltaX != 0) {
        ViewCompat.animate(view).translationX(0);
    }
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }

    final ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);

    animator.setDuration(getDuration());

    startActiveItemAnimation(info, info.holder, animator);
}
 
Example 24
Project: MyCTFWriteUps   File: WindowDecorActionBar.java   Source Code and License 6 votes vote down vote up
public void animateToMode(boolean flag)
{
    ViewPropertyAnimatorCompat viewpropertyanimatorcompat;
    ViewPropertyAnimatorCompat viewpropertyanimatorcompat1;
    ViewPropertyAnimatorCompatSet viewpropertyanimatorcompatset;
    if (flag)
    {
        showForActionMode();
    } else
    {
        hideForActionMode();
    }
    if (flag)
    {
        viewpropertyanimatorcompat1 = mDecorToolbar.setupAnimatorToVisibility(8, 100L);
        viewpropertyanimatorcompat = mContextView.setupAnimatorToVisibility(0, 200L);
    } else
    {
        viewpropertyanimatorcompat = mDecorToolbar.setupAnimatorToVisibility(0, 200L);
        viewpropertyanimatorcompat1 = mContextView.setupAnimatorToVisibility(8, 100L);
    }
    viewpropertyanimatorcompatset = new ViewPropertyAnimatorCompatSet();
    viewpropertyanimatorcompatset.playSequentially(viewpropertyanimatorcompat1, viewpropertyanimatorcompat);
    viewpropertyanimatorcompatset.start();
}
 
Example 25
Project: MyCTFWriteUps   File: AbsActionBarView.java   Source Code and License 6 votes vote down vote up
public ViewPropertyAnimatorCompat setupAnimatorToVisibility(int i, long l)
{
    if (mVisibilityAnim != null)
    {
        mVisibilityAnim.cancel();
    }
    if (i == 0)
    {
        if (getVisibility() != 0)
        {
            ViewCompat.setAlpha(this, 0.0F);
        }
        ViewPropertyAnimatorCompat viewpropertyanimatorcompat = ViewCompat.animate(this).alpha(1.0F);
        viewpropertyanimatorcompat.setDuration(l);
        viewpropertyanimatorcompat.setListener(mVisAnimListener.withFinalVisibility(viewpropertyanimatorcompat, i));
        return viewpropertyanimatorcompat;
    } else
    {
        ViewPropertyAnimatorCompat viewpropertyanimatorcompat1 = ViewCompat.animate(this).alpha(0.0F);
        viewpropertyanimatorcompat1.setDuration(l);
        viewpropertyanimatorcompat1.setListener(mVisAnimListener.withFinalVisibility(viewpropertyanimatorcompat1, i));
        return viewpropertyanimatorcompat1;
    }
}
 
Example 26
Project: SimpleItemAnimator   File: ChangeAnimationExecutor.java   Source Code and License 6 votes vote down vote up
Observable<ViewPropertyAnimatorCompat> executeForNewHolder(AnimationTask.AnimationEvent animationEvent) {
    final Option<RecyclerView.ViewHolder> newHolder = animationEvent.getEvent().getSecondaryHolder();
    if (newHolder.bind(h -> Option.fromNull(h.itemView)).isNone() || animationEvent.getPreStateOption().isNone()) {
        return Observable.empty();
    }

    final RecyclerView.ViewHolder holder = newHolder.some();
    final SimpleItemAnimator.Event event = animationEvent.getEvent();

    final F<Unit, P1<Unit>> startDispatcher = startDispatcherSelectorForNewHolder(holder);
    final F<Unit, P1<Unit>> finishDispatcher = finishDispatcherSelectorForNewHolder(holder);
    final F<View, Unit> defaultStateSetter = (animationEvent.getPreStateOption().some()::restoreState);
    final ViewPropertyAnimatorCompat animator =
            createAnimatorForNewHolder(holder.itemView, event.getParam()).setDuration(duration(event.getParam().getEventType()));

    return create(
            true,
            startDispatcher,
            finishDispatcher,
            defaultStateSetter,
            animator);
}
 
Example 27
Project: SimpleItemAnimator   File: SimpleItemAnimator.java   Source Code and License 6 votes vote down vote up
private SimpleItemAnimator(
        final F<ViewPropertyAnimatorCompat, ViewPropertyAnimatorCompat> addEventAnimation,
        final F<ViewPropertyAnimatorCompat, ViewPropertyAnimatorCompat> removeEventAnimation,
        final F2<ViewPropertyAnimatorCompat, EventParam, ViewPropertyAnimatorCompat> moveEventAnimation,
        final Option<F2<ViewPropertyAnimatorCompat, EventParam, ViewPropertyAnimatorCompat>> changeEventAnimationForOldView,
        final Option<F2<ViewPropertyAnimatorCompat, EventParam, ViewPropertyAnimatorCompat>> changeEventAnimationForNewView,
        final boolean isChangeEventMix,
        final F<View, Unit> prepareAddEventView,
        final F<View, Unit> prepareRemoveEventView,
        final F2<View, EventParam, Unit> prepareMoveEventView,
        final F3<View, Option<View>, EventParam, Unit> prepareChangeEventView) {

    this.addEventAnimation = addEventAnimation;
    this.removeEventAnimation = removeEventAnimation;
    this.moveEventAnimation = moveEventAnimation;
    this.changeEventAnimationForOldView = changeEventAnimationForOldView.toNull();
    this.changeEventAnimationForNewView = changeEventAnimationForNewView.toNull();
    final Boolean supportChange = changeEventAnimationForOldView.bind(cfo ->
            changeEventAnimationForNewView.map(cfn -> true)).orSome(false);
    setSupportsChangeAnimations(supportChange);
    this.changeEventMix = isChangeEventMix;
    this.prepareAddEventView = prepareAddEventView;
    this.prepareRemoveEventView = prepareRemoveEventView;
    this.prepareMoveEventView = prepareMoveEventView;
    this.prepareChangeEventView = prepareChangeEventView;
}
 
Example 28
Project: SimpleItemAnimator   File: AbstAnimationExecutor.java   Source Code and License 6 votes vote down vote up
/**
 * アニメーション実行命令を出して返す
 *
 * @return cancelを可能とするために {@link android.support.v4.view.ViewPropertyAnimatorCompat} を返す
 */
protected Observable<ViewPropertyAnimatorCompat> defaultExecute(
        @Nonnull final AnimationTask.AnimationEvent animationEvent) {

    final SimpleItemAnimator.Event event = animationEvent.getEvent();
    final F<Unit, P1<Unit>> startDispatcher = startDispatcherSelector(event);
    final F<Unit, P1<Unit>> finishDispatcher = finishDispatcherSelector(event);
    final F<View, Unit> defaultStateSetter = (animationEvent.getPreState()::restoreState);
    final SimpleItemAnimator.EventType eventType = event.getParam().getEventType();
    final ViewPropertyAnimatorCompat animator =
            createAnimator(event).setDuration(duration(eventType));

    return create(
            eventType == SimpleItemAnimator.EventType.ADD || eventType == SimpleItemAnimator.EventType.MOVE,
            startDispatcher,
            finishDispatcher,
            defaultStateSetter,
            animator);
}
 
Example 29
Project: RecyclerViewLib   File: PendingItemAnimator.java   Source Code and License 6 votes vote down vote up
/** Preform your animation. You do not need to override this in most cases cause the default is pretty good.
 * Listeners will be overridden **/
protected ViewPropertyAnimatorCompat animateMoveImpl(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
    final View view = holder.itemView;
    final int deltaX = toX - fromX;
    final int deltaY = toY - fromY;
    ViewCompat.animate(view).cancel();
    if (deltaX != 0) {
        ViewCompat.animate(view).translationX(0);
    }
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }
    // TODO: make EndActions end listeners instead, since end actions aren't called when
    // vpas are canceled (and can't end them. why?)
    // need listener functionality in VPACompat for this. Ick.
    return ViewCompat.animate(view).setInterpolator(null).setDuration(getMoveDuration());
}
 
Example 30
Project: SinaWeibo_Android   File: MaterialRefreshLayout.java   Source Code and License 6 votes vote down vote up
public void finishRefreshing() {
    if (mChildView != null) {
        ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(mChildView);
        viewPropertyAnimatorCompat.setDuration(200);
        viewPropertyAnimatorCompat.y(ViewCompat.getTranslationY(mChildView));
        viewPropertyAnimatorCompat.translationY(0);
        viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator());
        viewPropertyAnimatorCompat.start();

        if (mMaterialHeaderView != null) {
            mMaterialHeaderView.onComlete(MaterialRefreshLayout.this);
        } else if (mSunLayout != null) {
            mSunLayout.onComlete(MaterialRefreshLayout.this);
        }

        if (refreshListener != null) {
            refreshListener.onfinish();
        }
    }
    isRefreshing = false;
    progressValue = 0;
}
 
Example 31
Project: Unofficial-Ups   File: LoginActivity.java   Source Code and License 5 votes vote down vote up
private ViewPropertyAnimatorCompat displayWarning(boolean visible){
    setVisibility(View.GONE,llaForm);
    setVisibility(visible ? View.VISIBLE : View.INVISIBLE,tviWarning,btnUnderstood);
    return ViewCompat.animate(btnUnderstood)
            .scaleX(visible ? 1.0f : 0.0f)
            .setStartDelay(500);
}
 
Example 32
Project: GitHub   File: FlipDownItemAnimator.java   Source Code and License 5 votes vote down vote up
@Override
protected ViewPropertyAnimatorCompat animateRemoveImpl(ViewHolder holder) {
	return ViewCompat.animate(holder.itemView)
			.rotationY(90)
			.translationX(-(holder.itemView.getMeasuredWidth() / 4))
			.scaleX(0.5F)
			.scaleY(0.5F)
			.setInterpolator(new AccelerateInterpolator());
}
 
Example 33
Project: GitHub   File: FlipDownItemAnimator.java   Source Code and License 5 votes vote down vote up
@Override
protected ViewPropertyAnimatorCompat animateAddImpl(ViewHolder holder) {
	return ViewCompat.animate(holder.itemView)
			.rotationY(0)
			.translationX(0)
			.setInterpolator(new BounceInterpolator());
}
 
Example 34
Project: GitHub   File: FromTopItemAnimator.java   Source Code and License 5 votes vote down vote up
@Override
protected ViewPropertyAnimatorCompat animateRemoveImpl(ViewHolder holder) {
	Point screen = Utils.getScreenDimensions(holder.itemView.getContext());
	int top = holder.itemView.getTop();
	return ViewCompat.animate(holder.itemView)
			.rotation(80)
			.translationY(screen.y - top)
			.setInterpolator(new AccelerateInterpolator());
}
 
Example 35
Project: GitHub   File: SlideItemAnimator.java   Source Code and License 5 votes vote down vote up
protected ViewPropertyAnimatorCompat animateRemoveImpl(ViewHolder holder) {
	final View view = holder.itemView;
	ViewCompat.animate(view).cancel();
	return ViewCompat.animate(view)
			.translationX(Utils.getScreenDimensions(holder.itemView.getContext()).x)
			.setInterpolator(new AnticipateOvershootInterpolator());
}
 
Example 36
Project: GitHub   File: SlideItemAnimator.java   Source Code and License 5 votes vote down vote up
protected ViewPropertyAnimatorCompat animateAddImpl(ViewHolder holder) {
	final View view = holder.itemView;
	ViewCompat.animate(view).cancel();
	int width = getWidth(holder);
	return ViewCompat.animate(view)
			.translationXBy(-width)
			.setInterpolator(new BounceInterpolator());
}
 
Example 37
Project: Rx2Animations   File: AnimateCompletable.java   Source Code and License 5 votes vote down vote up
private AnimateCompletable(final WeakReference<View> viewWeakRef,
                           @Nullable final List<Consumer<ViewPropertyAnimatorCompat>> preTransformActions,
                           final List<Consumer<ViewPropertyAnimatorCompat>> animationActions,
                           final Consumer<View> onAnimationCancelAction) {
    this.viewWeakRef = viewWeakRef;
    this.preTransformActions = preTransformActions;
    this.animationActions = animationActions;
    this.onAnimationCancelAction = onAnimationCancelAction;
}
 
Example 38
Project: Rx2Animations   File: AnimateCompletable.java   Source Code and License 5 votes vote down vote up
private void applyActions(final List<Consumer<ViewPropertyAnimatorCompat>> actions, final ViewPropertyAnimatorCompat animator) {
    for (final Consumer<ViewPropertyAnimatorCompat> action : actions) {
        try {
            action.accept(animator);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
Example 39
Project: JD-Test   File: BadgeItem.java   Source Code and License 5 votes vote down vote up
/**
 * @param animate whether to animate the change
 * @return this, to allow builder pattern
 */
public BadgeItem show(boolean animate) {
    mIsHidden = false;
    if (isWeakReferenceValid()) {
        TextView textView = mTextViewRef.get();
        if (animate) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                textView.setScaleX(0);
                textView.setScaleY(0);
            }
            textView.setVisibility(View.VISIBLE);
            ViewPropertyAnimatorCompat animatorCompat = ViewCompat.animate(textView);
            animatorCompat.cancel();
            animatorCompat.setDuration(mAnimationDuration);
            animatorCompat.scaleX(1).scaleY(1);
            animatorCompat.setListener(null);
            animatorCompat.start();
        } else {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                textView.setScaleX(1);
                textView.setScaleY(1);
            }
            textView.setVisibility(View.VISIBLE);
        }
    }
    return this;
}
 
Example 40
Project: android-radiobutton-extended   File: SecondAdapter.java   Source Code and License 5 votes vote down vote up
@Override
public void onBindRadioGroupedViewHolder(SecondViewHolder holder, int position, List<Object> payloads) {
    {
        setDefaults(holder, position);
    }
    {
        MyPayload payload = null;

        for (Object itrPayload : payloads) {
            if (itrPayload != null && itrPayload instanceof MyPayload) {
                payload = (MyPayload) itrPayload;
                break;
            }
        }

        if (payload != null) {
            ViewPropertyAnimatorCompat animator = ViewCompat
                    .animate(holder.getIcon())
                    .setInterpolator(new LinearOutSlowInInterpolator())
                    .setDuration(500);

            int diff = payload.calcDiffY();

            if (diff == 0) {
                ViewCompat.setTranslationX(holder.getIcon(), holder.getIcon().getMeasuredWidth() * -1);
                animator = animator
                        .translationX(0);
            } else {
                ViewCompat.setTranslationY(holder.getIcon(), diff);
                animator = animator
                        .translationY(0);
            }

            animator.start();
        }
    }
}
 
Example 41
Project: QiangHongBao   File: BottomBarTab.java   Source Code and License 5 votes vote down vote up
private void animateTitle(float finalScale, float finalAlpha) {
    if (type == Type.TABLET) {
        return;
    }

    ViewPropertyAnimatorCompat titleAnimator = ViewCompat.animate(titleView)
            .setDuration(ANIMATION_DURATION)
            .scaleX(finalScale)
            .scaleY(finalScale);
    titleAnimator.alpha(finalAlpha);
    titleAnimator.start();
}
 
Example 42
Project: boohee_v5.6   File: ViewPropertyAnimatorCompatSet.java   Source Code and License 5 votes vote down vote up
public void cancel() {
    if (this.mIsStarted) {
        Iterator i$ = this.mAnimators.iterator();
        while (i$.hasNext()) {
            ((ViewPropertyAnimatorCompat) i$.next()).cancel();
        }
        this.mIsStarted = false;
    }
}
 
Example 43
Project: boohee_v5.6   File: WindowDecorActionBar.java   Source Code and License 5 votes vote down vote up
public void doShow(boolean fromSystem) {
    if (this.mCurrentShowAnim != null) {
        this.mCurrentShowAnim.cancel();
    }
    this.mContainerView.setVisibility(0);
    if (this.mCurWindowVisibility == 0 && ALLOW_SHOW_HIDE_ANIMATIONS && (this.mShowHideAnimationEnabled || fromSystem)) {
        ViewCompat.setTranslationY(this.mContainerView, 0.0f);
        float startingY = (float) (-this.mContainerView.getHeight());
        if (fromSystem) {
            int[] topLeft = new int[]{0, 0};
            this.mContainerView.getLocationInWindow(topLeft);
            startingY -= (float) topLeft[1];
        }
        ViewCompat.setTranslationY(this.mContainerView, startingY);
        ViewPropertyAnimatorCompatSet anim = new ViewPropertyAnimatorCompatSet();
        ViewPropertyAnimatorCompat a = ViewCompat.animate(this.mContainerView).translationY(0.0f);
        a.setUpdateListener(this.mUpdateListener);
        anim.play(a);
        if (this.mContentAnimations && this.mContentView != null) {
            ViewCompat.setTranslationY(this.mContentView, startingY);
            anim.play(ViewCompat.animate(this.mContentView).translationY(0.0f));
        }
        anim.setInterpolator(sShowInterpolator);
        anim.setDuration(250);
        anim.setListener(this.mShowListener);
        this.mCurrentShowAnim = anim;
        anim.start();
    } else {
        ViewCompat.setAlpha(this.mContainerView, 1.0f);
        ViewCompat.setTranslationY(this.mContainerView, 0.0f);
        if (this.mContentAnimations && this.mContentView != null) {
            ViewCompat.setTranslationY(this.mContentView, 0.0f);
        }
        this.mShowListener.onAnimationEnd(null);
    }
    if (this.mOverlayLayout != null) {
        ViewCompat.requestApplyInsets(this.mOverlayLayout);
    }
}
 
Example 44
Project: boohee_v5.6   File: WindowDecorActionBar.java   Source Code and License 5 votes vote down vote up
public void doHide(boolean fromSystem) {
    if (this.mCurrentShowAnim != null) {
        this.mCurrentShowAnim.cancel();
    }
    if (this.mCurWindowVisibility == 0 && ALLOW_SHOW_HIDE_ANIMATIONS && (this.mShowHideAnimationEnabled || fromSystem)) {
        ViewCompat.setAlpha(this.mContainerView, 1.0f);
        this.mContainerView.setTransitioning(true);
        ViewPropertyAnimatorCompatSet anim = new ViewPropertyAnimatorCompatSet();
        float endingY = (float) (-this.mContainerView.getHeight());
        if (fromSystem) {
            int[] topLeft = new int[]{0, 0};
            this.mContainerView.getLocationInWindow(topLeft);
            endingY -= (float) topLeft[1];
        }
        ViewPropertyAnimatorCompat a = ViewCompat.animate(this.mContainerView).translationY(endingY);
        a.setUpdateListener(this.mUpdateListener);
        anim.play(a);
        if (this.mContentAnimations && this.mContentView != null) {
            anim.play(ViewCompat.animate(this.mContentView).translationY(endingY));
        }
        anim.setInterpolator(sHideInterpolator);
        anim.setDuration(250);
        anim.setListener(this.mHideListener);
        this.mCurrentShowAnim = anim;
        anim.start();
        return;
    }
    this.mHideListener.onAnimationEnd(null);
}
 
Example 45
Project: MenuSet   File: PerseiLayout.java   Source Code and License 5 votes vote down vote up
public void createAnimatorTranslationY(final View v, final float h, final FrameLayout fl) {
    ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(v);
    viewPropertyAnimatorCompat.setDuration(200);
    viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator());
    viewPropertyAnimatorCompat.translationY(h);
    viewPropertyAnimatorCompat.start();
    viewPropertyAnimatorCompat.setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(View view) {
            float height = ViewCompat.getTranslationY(v);
            fl.getLayoutParams().height = (int) height;
            fl.requestLayout();
        }
    });
}
 
Example 46
Project: MenuSet   File: PerseiLayout.java   Source Code and License 5 votes vote down vote up
private void closeMenuing() {
    if (mChildView != null) {
        ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(mChildView);
        viewPropertyAnimatorCompat.setDuration(200);
        viewPropertyAnimatorCompat.y(ViewCompat.getTranslationY(mChildView));
        viewPropertyAnimatorCompat.translationY(0);
        viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator());
        viewPropertyAnimatorCompat.start();
    }
    isOpenMenu = false;
}
 
Example 47
Project: ElephantReader   File: MyBaseItemAnimtor.java   Source Code and License 5 votes vote down vote up
protected void onAnimateRemoveImpl(RecyclerView.ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);
    animation.setDuration(getRemoveDuration())
            .alpha(0).setListener(getDefaultVpaListener(holder)).start();
}
 
Example 48
Project: ElephantReader   File: SlideInUpDelayAnimator.java   Source Code and License 5 votes vote down vote up
@Override
protected ViewPropertyAnimatorCompat onAnimateAdd(RecyclerView.ViewHolder holder) {
    return ViewCompat.animate(holder.itemView)
            .translationY(0)
            .alpha(1)
            .scaleX(1.0f)
            .scaleY(1.0f)
            .setInterpolator(mInterpolator)
            .setDuration(getAddDuration())
            .setStartDelay(getAddDelay(holder));

}
 
Example 49
Project: BottomBar   File: BottomBarTab.java   Source Code and License 5 votes vote down vote up
private void animateTitle(int padding, float scale, float alpha) {
    if (type == Type.TABLET && isTitleless) {
        return;
    }

    setTopPaddingAnimated(iconView.getPaddingTop(), padding);

    ViewPropertyAnimatorCompat titleAnimator = ViewCompat.animate(titleView)
            .setDuration(ANIMATION_DURATION)
            .scaleX(scale)
            .scaleY(scale);
    titleAnimator.alpha(alpha);
    titleAnimator.start();
}
 
Example 50
Project: onboarding-examples-android   File: OnboardingWithCenterAnimationActivity.java   Source Code and License 5 votes vote down vote up
private void animate() {
    ImageView logoImageView = (ImageView) findViewById(R.id.img_logo);
    ViewGroup container = (ViewGroup) findViewById(R.id.container);

    ViewCompat.animate(logoImageView)
        .translationY(-250)
        .setStartDelay(STARTUP_DELAY)
        .setDuration(ANIM_ITEM_DURATION).setInterpolator(
            new DecelerateInterpolator(1.2f)).start();

    for (int i = 0; i < container.getChildCount(); i++) {
        View v = container.getChildAt(i);
        ViewPropertyAnimatorCompat viewAnimator;

        if (!(v instanceof Button)) {
            viewAnimator = ViewCompat.animate(v)
                    .translationY(50).alpha(1)
                    .setStartDelay((ITEM_DELAY * i) + 500)
                    .setDuration(1000);
        } else {
            viewAnimator = ViewCompat.animate(v)
                    .scaleY(1).scaleX(1)
                    .setStartDelay((ITEM_DELAY * i) + 500)
                    .setDuration(500);
        }

        viewAnimator.setInterpolator(new DecelerateInterpolator()).start();
    }
}
 
Example 51
Project: onboarding-examples-android   File: SlideInUpDelayedAnimator.java   Source Code and License 5 votes vote down vote up
@Override
protected ViewPropertyAnimatorCompat onAnimatedAdd(RecyclerView.ViewHolder holder) {
    return ViewCompat.animate(holder.itemView)
            .translationY(0)
            .setInterpolator(mInterpolator)
            .setStartDelay(offsetDelay*holder.getLayoutPosition());
}
 
Example 52
Project: FloatingSearchView   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected ViewPropertyAnimatorCompat onAnimateAdd(RecyclerView.ViewHolder holder) {
    if(!mSearchView.isActivated()) return null;
    return ViewCompat.animate(holder.itemView)
            .translationY(0)
            .alpha(1)
            .setStartDelay((getAddDuration() / 2) * holder.getLayoutPosition())
            .setInterpolator(INTERPOLATOR_ADD);
}
 
Example 53
Project: FloatingSearchView   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected ViewPropertyAnimatorCompat onAnimateRemove(RecyclerView.ViewHolder holder) {
    return ViewCompat.animate(holder.itemView)
            .alpha(0)
            .setStartDelay(0)
            .setInterpolator(INTERPOLATOR_REMOVE);
}
 
Example 54
Project: SprintNBA   File: MaterialRefreshLayout.java   Source Code and License 5 votes vote down vote up
public void createAnimatorTranslationY(final View v, final float h, final FrameLayout fl) {
    ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(v);
    viewPropertyAnimatorCompat.setDuration(250);
    viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator());
    viewPropertyAnimatorCompat.translationY(h);
    viewPropertyAnimatorCompat.start();
    viewPropertyAnimatorCompat.setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(View view) {
            float height = ViewCompat.getTranslationY(v);
            fl.getLayoutParams().height = (int) height;
            fl.requestLayout();
        }
    });
}
 
Example 55
Project: RxAnimationBinding   File: RxViewPropertyAnimatorCompat.java   Source Code and License 5 votes vote down vote up
@CheckResult
@NonNull
public static Observable<View> starts(ViewPropertyAnimatorCompat animator) {
    checkNotNull(animator, "animator == null");
    return Observable.create(
            new ViewPropertyAnimatorListenerOnSubscribe(animator, AnimationEvent.START));
}
 
Example 56
Project: RxAnimationBinding   File: RxViewPropertyAnimatorCompat.java   Source Code and License 5 votes vote down vote up
@CheckResult
@NonNull
public static Observable<View> ends(ViewPropertyAnimatorCompat animator) {
    checkNotNull(animator, "animator == null");
    return Observable.create(
            new ViewPropertyAnimatorListenerOnSubscribe(animator, AnimationEvent.END));
}
 
Example 57
Project: RxAnimationBinding   File: RxViewPropertyAnimatorCompat.java   Source Code and License 5 votes vote down vote up
@CheckResult
@NonNull
public static Observable<View> cancels(ViewPropertyAnimatorCompat animator) {
    checkNotNull(animator, "animator == null");
    return Observable.create(
            new ViewPropertyAnimatorListenerOnSubscribe(animator, AnimationEvent.CANCEL));
}
 
Example 58
Project: RxAnimationBinding   File: RxViewPropertyAnimatorCompat.java   Source Code and License 5 votes vote down vote up
@CheckResult
@NonNull
public static Observable<View> updates(ViewPropertyAnimatorCompat animator) {
    checkNotNull(animator, "animator == null");
    return Observable.create(
            new ViewPropertyAnimatorUpdateListenerOnSubscribe(animator));
}
 
Example 59
Project: expandable-recyclerview-with-gridlayout   File: SwipeDismissItemAnimator.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreateAnimation(AddAnimationInfo info) {
    final ViewPropertyAnimatorCompat animator = ViewCompat.animate(info.holder.itemView);

    animator.alpha(1);
    animator.setDuration(getDuration());

    startActiveItemAnimation(info, info.holder, animator);
}
 
Example 60
Project: expandable-recyclerview-with-gridlayout   File: SwipeDismissItemAnimator.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreateChangeAnimationForOldItem(ChangeAnimationInfo info) {
    final ViewPropertyAnimatorCompat animator = ViewCompat.animate(info.oldHolder.itemView);

    animator.setDuration(getDuration());
    animator.translationX(info.toX - info.fromX);
    animator.translationY(info.toY - info.fromY);
    animator.alpha(0);

    startActiveItemAnimation(info, info.oldHolder, animator);
}