Java Code Examples for android.view.View.clearAnimation()

The following are Jave code examples for showing how to use clearAnimation() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Hotspot-master-devp   File: SavorAnimUtil.java   Source Code and License Vote up 7 votes
public static void shake(final View view, final Animator.AnimatorListener listener) {
        view.clearAnimation();
        view.post(new Runnable() {
            @Override
            public void run() {
                view.setPivotX(view.getWidth()/2);
                view.setPivotY(view.getHeight());
                ObjectAnimator shakeAnim = ObjectAnimator.ofFloat(view, "rotation", 0f,-15f,0f, 15f, 0f).setDuration(1200);
//        shakeAnim.setInterpolator(new AccelerateInterpolator());
                if(listener!=null) {
                    shakeAnim.addListener(listener);
                }
                shakeAnim.setStartDelay(500);
                shakeAnim.start();
            }
        });

    }
 
Example 2
Project: mvvm-template   File: AnimHelper.java   Source Code and License Vote up 6 votes
@UiThread public static void startBeatsAnimation(@NonNull View view) {
    view.clearAnimation();
    if (view.getAnimation() != null) {
        view.getAnimation().cancel();
    }
    List<ObjectAnimator> animators = getBeats(view);
    for (ObjectAnimator anim : animators) {
        anim.setDuration(300).start();
        anim.setInterpolator(interpolator);
    }
}
 
Example 3
Project: boohee_v5.6   File: StateListAnimator.java   Source Code and License Vote up 6 votes
private void clearTarget() {
    View view = getTarget();
    int size = this.mTuples.size();
    for (int i = 0; i < size; i++) {
        if (view.getAnimation() == ((Tuple) this.mTuples.get(i)).mAnimation) {
            view.clearAnimation();
        }
    }
    this.mViewRef = null;
    this.mLastMatch = null;
    this.mRunningAnimation = null;
}
 
Example 4
Project: AndroidBasicLibs   File: DrawerToast.java   Source Code and License Vote up 6 votes
/**
 * 隐藏指定控件
 *
 * @param v       需要隐藏的控件
 * @param endAnim 结束动画
 */
public final void hide(final View v, Animation endAnim) {
    if (v == null || mView.indexOfChild(v) < 0) return;

    //获得出场动画
    if (endAnim == null) endAnim = getEndAnimation();
    v.clearAnimation();
    //开始出场动画
    v.startAnimation(endAnim);

    //动画结束后移除控件
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            if (v == null || mView.indexOfChild(v) < 0) return;
            //移除指定控件
            mView.removeView(v);
            //隐藏顶层容器控件
            if (mView.getChildCount() == 1) hideToast();
        }
    }, TIME_END_ANIM);
}
 
Example 5
Project: ClouldReader   File: Instrument.java   Source Code and License Vote up 5 votes
public void slidingToY(View view ,float y){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setY(y);
    }else{
        ViewHelper.setY(view, y);
    }
}
 
Example 6
Project: DodaTheExploda   File: MainActivity.java   Source Code and License Vote up 5 votes
@Override
public void onClick(final View v) {

    if (currentLookForWid.getText().equals(" ")) {
        v.startAnimation(notItAnim);
        return;
    }

    String symv = (String)v.getTag();

    TextView wid2 = activeSyms.get(current);
    if (wid2==null) return;

    String symw = (String)wid2.getTag();

    if (symv.equals(symw)) {

        Log.d("Doda", "Found " + symv.codePointAt(0));
        v.setAlpha(.6f);
        v.startAnimation(wasItAnim);


        final ImageView blow = new ImageView(this);
        blow.setBackgroundResource(R.drawable.explosion);

        Point location = symPoints.get((TextView)v);
        float fac = 1.25f;

        score += Math.max(100, 5000 - (System.currentTimeMillis() - findTime)) * (backgroundImage?1.5:1);

        int msize = spToPx((int)(mMode.getMaxIconSize(bsize)*fac));
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(msize, msize);
        lp.setMargins(location.x - (int)(mMode.getMaxIconSize(bsize)*fac/2), location.y - (int)(mMode.getMaxIconSize(bsize)*fac/2), 0, 0);
        lp.gravity = Gravity.START | Gravity.TOP;


        blow.setLayoutParams(lp);
        mSoundEffects.playPlode();

        v.clearAnimation();

        mMainScreen.removeView(v);
        activeSyms.set(current, null);
        mMainScreen.addView(blow);

        AnimationDrawable ad = ((AnimationDrawable) blow.getBackground());
        int time = ad.getNumberOfFrames() * ad.getDuration(0);
        ad.start();
        showNext(false);

        mMainScreen.postDelayed(new Runnable() {
            @Override
            public void run() {
                mMainScreen.removeView(blow);
            }
        }, time + 20);

    } else {

        v.startAnimation(notItAnim);
        if (mMode.isTimed()) {
            startTime -= 5000;
            showMessage(getString(R.string.miss_penalty));
        }

    }

}
 
Example 7
Project: GitHub   File: ViewTransition.java   Source Code and License Vote up 5 votes
/**
 * Always clears the current animation on the view using
 * {@link android.view.View#clearAnimation()}, then starts the
 * {@link android.view.animation.Animation} given in the constructor using
 * {@link android.view.View#startAnimation(android.view.animation.Animation)} and then returns
 * {@code false} because the animation does not actually put the current resource on the view.
 *
 * @param current {@inheritDoc}
 * @param adapter {@inheritDoc}
 * @return {@inheritDoc}
 */
@Override
public boolean transition(R current, ViewAdapter adapter) {
  View view = adapter.getView();
  if (view != null) {
    view.clearAnimation();
    Animation animation = viewTransitionAnimationFactory.build(view.getContext());
    view.startAnimation(animation);
  }

  return false;
}
 
Example 8
Project: GitHub   File: Instrument.java   Source Code and License Vote up 5 votes
public void slidingByDelta(View view ,float delta){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setTranslationY(delta);
    }else{
        ViewHelper.setTranslationY(view, delta);
    }
}
 
Example 9
Project: UiLib   File: RayMenu.java   Source Code and License Vote up 5 votes
private void itemDidDisappear() {
	final int itemCount = mRayLayout.getChildCount();
	for (int i = 0; i < itemCount; i++) {
		View item = mRayLayout.getChildAt(i);
		item.clearAnimation();
	}

	mRayLayout.switchState(false);
}
 
Example 10
Project: GitHub   File: Instrument.java   Source Code and License Vote up 5 votes
public void reset(View view, long duration){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        android.animation.ObjectAnimator.ofFloat(view, "translationY", 0F).setDuration(duration).start();
    }else{
        com.nineoldandroids.animation.ObjectAnimator.ofFloat(view, "translationY", 0F).setDuration(duration).start();
    }
}
 
Example 11
Project: GitHub   File: Instrument.java   Source Code and License Vote up 5 votes
public void smoothTo(View view ,float y, long duration){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        android.animation.ObjectAnimator.ofFloat(view, "translationY", y).setDuration(duration).start();
    }else{
        com.nineoldandroids.animation.ObjectAnimator.ofFloat(view, "translationY", y).setDuration(duration).start();
    }
}
 
Example 12
Project: GitHub   File: ViewTransition.java   Source Code and License Vote up 5 votes
/**
 * Always clears the current animation on the view using
 * {@link android.view.View#clearAnimation()}, then starts the
 * {@link android.view.animation.Animation} given in the constructor using
 * {@link android.view.View#startAnimation(android.view.animation.Animation)} and then returns
 * {@code false} because the animation does not actually put the current resource on the view.
 *
 * @param current {@inheritDoc}
 * @param adapter {@inheritDoc}
 * @return {@inheritDoc}
 */
@Override
public boolean transition(R current, ViewAdapter adapter) {
  View view = adapter.getView();
  if (view != null) {
    view.clearAnimation();
    Animation animation = viewTransitionAnimationFactory.build(view.getContext());
    view.startAnimation(animation);
  }

  return false;
}
 
Example 13
Project: Fatigue-Detection   File: AnimationUtils.java   Source Code and License Vote up 5 votes
public static void displayAnim(View view, Context context, int animId, int targetVisibility){
    view.clearAnimation();
    Animation anim =
            android.view.animation.AnimationUtils.loadAnimation(context, animId);
    view.setVisibility(targetVisibility);
    view.startAnimation(anim);
}
 
Example 14
Project: stynico   File: Instrument.java   Source Code and License Vote up 5 votes
public void slidingByDelta(View view ,float delta){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setTranslationY(delta);
    }else{
       // ViewHelper.setTranslationY(view, delta);
    }
}
 
Example 15
Project: stynico   File: Instrument.java   Source Code and License Vote up 5 votes
public void slidingToY(View view ,float y){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setY(y);
    }else{
        //ViewHelper.setY(view, y);
    }
}
 
Example 16
Project: Cable-Android   File: ViewUtil.java   Source Code and License Vote up 5 votes
public static void animateIn(final @NonNull View view, final @NonNull Animation animation) {
  if (view.getVisibility() == View.VISIBLE) return;

  view.clearAnimation();
  animation.reset();
  animation.setStartTime(0);
  view.setVisibility(View.VISIBLE);
  view.startAnimation(animation);
}
 
Example 17
Project: qmui   File: QMUIAnimationListView.java   Source Code and License Vote up 5 votes
protected Animator getAddAnimator(View view, int top, int position, int addOccurTop, int addOccurPosition) {
    view.setAlpha(0);
    view.clearAnimation();
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(alphaObjectAnimator(view, true, 50, false));
    if (addOccurTop != top) {
        animatorSet.play(getOffsetAnimator(view, addOccurTop, top));
    }
    animatorSet.setStartDelay((long) (view.getHeight() * mOffsetDurationUnit));
    return animatorSet;
}
 
Example 18
Project: UiLib   File: ArcMenu.java   Source Code and License Vote up 5 votes
private void itemDidDisappear() {
    final int itemCount = mArcLayout.getChildCount();
    for (int i = 0; i < itemCount; i++) {
        View item = mArcLayout.getChildAt(i);
        item.clearAnimation();
    }

    mArcLayout.switchState(false);
}
 
Example 19
Project: AndroidBasicLibs   File: DrawerToast.java   Source Code and License Vote up 5 votes
/**
 * 显示一条Toast
 *
 * @param v         显示的内容
 * @param duration  持续时间,单位为毫秒
 * @param startAnim 入场动画
 * @param endAnim   离场动画
 */
public final void show(final View v, Long duration, Animation startAnim, final Animation endAnim) {
    //反射过程异常时则使用源生Toast
    if (hasReflectException) {
        Toast t = new Toast(mContext);
        t.setView(v);
        t.setDuration(Toast.LENGTH_SHORT);
        t.show();
        //重新获取反射对象
        initTN();
        return;
    }

    //显示顶层容器控件
    if (mView.getChildCount() == 1) showToast();

    //获得入场动画
    if (startAnim == null) startAnim = getStartAnimation();
    v.clearAnimation();
    v.startAnimation(startAnim);
    //把传入的toast显示出来
    mView.addView(v, 0);
    //延迟后隐藏传入toast
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            hide(v, endAnim);
        }
    }, duration == null ? TIME_DURATION : duration);

}
 
Example 20
Project: PLDroidShortVideo   File: StickerAdapter.java   Source Code and License Vote up 4 votes
private void stopAnimation(final View viewToAnimate) {
    viewToAnimate.clearAnimation();
}