Java Code Examples for android.support.v4.view.ViewCompat#animate()

The following examples show how to use android.support.v4.view.ViewCompat#animate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaterialRefreshLayout.java    From styT with Apache License 2.0 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 2
Source File: MaterialRefreshLayout.java    From MousePaint with MIT 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 3
Source File: MaterialRefreshLayout.java    From BitkyShop with MIT 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 4
Source File: AnimateOnSubscribe.java    From RxAnimations with Apache License 2.0 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 5
Source File: MaterialRefreshLayout.java    From SprintNBA with Apache License 2.0 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 6
Source File: BottomNavigationBar.java    From JD-Test with Apache License 2.0 5 votes vote down vote up
/**
 * Internal Method
 * <p>
 * used to set animation and
 * takes care of cancelling current animation
 * and sets duration and interpolator for animation
 *
 * @param offset translation offset that needs to set with animation
 */
private void animateOffset(final int offset) {
    if (mTranslationAnimator == null) {
        mTranslationAnimator = ViewCompat.animate(this);
        mTranslationAnimator.setDuration(mRippleAnimationDuration);
        mTranslationAnimator.setInterpolator(INTERPOLATOR);
    } else {
        mTranslationAnimator.cancel();
    }
    mTranslationAnimator.translationY(offset).start();
}
 
Example 7
Source File: BottomSheetBehavior.java    From Nimbus with GNU General Public License v3.0 5 votes vote down vote up
private void ensureOrCancelAnimator(V child) {
    if (mOffsetValueAnimator == null) {
        mOffsetValueAnimator = ViewCompat.animate(child);
        mOffsetValueAnimator.setDuration(100);
        mOffsetValueAnimator.setInterpolator(INTERPOLATOR);
    } else {
        mOffsetValueAnimator.cancel();
    }
}
 
Example 8
Source File: BottomNavigationBehavior.java    From NanoIconPack with Apache License 2.0 5 votes vote down vote up
private void ensureOrCancelAnimator(@NonNull  V child) {
    if (mOffsetValueAnimator == null) {
        mOffsetValueAnimator = ViewCompat.animate(child);
        mOffsetValueAnimator.setDuration(100);
        mOffsetValueAnimator.setInterpolator(INTERPOLATOR);
    } else {
        mOffsetValueAnimator.cancel();
    }
}
 
Example 9
Source File: BottomNavigationBehavior.java    From BottomBar with Apache License 2.0 5 votes vote down vote up
private void ensureOrCancelAnimator(V child) {
    if (mTranslationAnimator == null) {
        mTranslationAnimator = ViewCompat.animate(child);
        mTranslationAnimator.setDuration(300);
        mTranslationAnimator.setInterpolator(INTERPOLATOR);
    } else {
        mTranslationAnimator.cancel();
    }
}
 
Example 10
Source File: MaterialRefreshLayout.java    From styT with Apache License 2.0 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 11
Source File: MaterialRefreshLayout.java    From SprintNBA with Apache License 2.0 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 12
Source File: BadgeItem.java    From JD-Test with Apache License 2.0 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 13
Source File: BottomNavBarFabBehaviour.java    From JD-Test with Apache License 2.0 5 votes vote down vote up
private void ensureOrCancelAnimator(FloatingActionButton fab) {
    if (mFabTranslationYAnimator == null) {
        mFabTranslationYAnimator = ViewCompat.animate(fab);
        mFabTranslationYAnimator.setDuration(400);
        mFabTranslationYAnimator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
    } else {
        mFabTranslationYAnimator.cancel();
    }
}
 
Example 14
Source File: MaterialRefreshLayout.java    From BitkyShop with MIT 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 15
Source File: BottomSheetBehavior.java    From Hillffair17 with GNU General Public License v3.0 5 votes vote down vote up
private void ensureOrCancelAnimator(V child) {
    if (mOffsetValueAnimator == null) {
        mOffsetValueAnimator = ViewCompat.animate(child);
        mOffsetValueAnimator.setDuration(100);
        mOffsetValueAnimator.setInterpolator(INTERPOLATOR);
    } else {
        mOffsetValueAnimator.cancel();
    }
}
 
Example 16
Source File: MaterialRefreshLayout.java    From MousePaint with MIT 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 17
Source File: BadgeView.java    From android-common-utils with Apache License 2.0 4 votes vote down vote up
public ViewPropertyAnimatorCompat animate(){
	return ViewCompat.animate(view);
}
 
Example 18
Source File: BaseItemAnimator.java    From onboarding-examples-android with Apache License 2.0 4 votes vote down vote up
protected ViewPropertyAnimatorCompat onAnimatedAdd(final ViewHolder holder) {
    return ViewCompat.animate(holder.itemView);
}