Example usage for android.view View getAnimation

List of usage examples for android.view View getAnimation

Introduction

In this page you can find the example usage for android.view View getAnimation.

Prototype

public Animation getAnimation() 

Source Link

Document

Get the animation currently associated with this view.

Usage

From source file:Main.java

/**
 * Cancel any previous animation./*from  w w  w .j  ava2s .c o m*/
 * @param view the view.
 */
public static void cancelAnimation(View view) {
    Animation animation = view.getAnimation();
    if (animation != null) {
        animation.reset();
        animation.cancel();
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        view.animate().cancel();
    }
    view.clearAnimation();
}

From source file:Main.java

public static void clearAnimation(View v) {
    if (null == v) {
        return;/*from  w  ww.ja  v a  2  s. com*/
    }

    if (null != v.getAnimation()) {
        v.getAnimation().cancel();
        v.clearAnimation();
    }
}

From source file:Main.java

public static void clearViewAnim(View view) {
    if (view == null) {
        return;//from  w ww  .  j a  v a  2s .c o m
    }
    Animation anim = view.getAnimation();
    if (anim != null) {
        anim.cancel();
        view.setAnimation(null);
    }
    anim = null;
}

From source file:com.kayo.mdviews.AnimatorUtil.java

public static void scaleHide(View view, ViewPropertyAnimatorListener viewPropertyAnimatorListener) {
    if (view.getAnimation() != null) {
        view.getAnimation().cancel();//from  ww w .j  a va  2  s  .  co  m
    }
    ViewCompat.animate(view).scaleX(0.0f).scaleY(0.0f).alpha(0.0f).setDuration(200)
            .setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR).setListener(viewPropertyAnimatorListener).start();
}

From source file:com.kayo.mdviews.AnimatorUtil.java

public static void scaleShow(View view, ViewPropertyAnimatorListener viewPropertyAnimatorListener) {
    view.setVisibility(View.VISIBLE);
    if (view.getAnimation() != null) {
        view.getAnimation().cancel();//w w w.  jav a 2 s . co  m
    }
    ViewCompat.animate(view).scaleX(1.0f).scaleY(1.0f).alpha(1.0f).setDuration(200)
            .setListener(viewPropertyAnimatorListener).setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR).start();
}

From source file:Main.java

public static void addAnimation(View view, Animation animation, boolean first) {
    Animation previousAnimation = view.getAnimation();
    if (previousAnimation == null || previousAnimation.getClass() == animation.getClass()) {
        if (animation.getStartTime() == Animation.START_ON_FIRST_FRAME)
            view.startAnimation(animation);
        else/*from www .j a  va2  s  .  c om*/
            view.setAnimation(animation);
        return;
    }

    if (!(previousAnimation instanceof AnimationSet)) {
        AnimationSet newSet = new AnimationSet(false);
        newSet.addAnimation(previousAnimation);
        previousAnimation = newSet;
    }

    // Remove old of same type
    //
    AnimationSet set = (AnimationSet) previousAnimation;
    for (int i = 0; i < set.getAnimations().size(); i++) {
        Animation anim = set.getAnimations().get(i);
        if (anim.getClass() == animation.getClass()) {
            set.getAnimations().remove(i);
            break;
        }
    }

    // Add this (first if it is a scale animation ,else at end)
    if (animation instanceof ScaleAnimation || first) {
        set.getAnimations().add(0, animation);
    } else {
        set.getAnimations().add(animation);
    }

    animation.startNow();
    view.setAnimation(set);
}

From source file:Main.java

static void addAnimation(View view, Animation animation, boolean first) {
    Animation previousAnimation = view.getAnimation();
    if (previousAnimation == null || previousAnimation.getClass() == animation.getClass()) {
        if (animation.getStartTime() == Animation.START_ON_FIRST_FRAME)
            view.startAnimation(animation);
        else//from  w w w  .  j  a v a 2 s .co  m
            view.setAnimation(animation);
        return;
    }

    if (!(previousAnimation instanceof AnimationSet)) {
        AnimationSet newSet = new AnimationSet(false);
        newSet.addAnimation(previousAnimation);
        previousAnimation = newSet;
    }

    // Remove old of same type
    //
    AnimationSet set = (AnimationSet) previousAnimation;
    for (int i = 0; i < set.getAnimations().size(); i++) {
        Animation anim = set.getAnimations().get(i);
        if (anim.getClass() == animation.getClass()) {
            set.getAnimations().remove(i);
            break;
        }
    }

    // Add this (first if it is a scale animation ,else at end)
    if (animation instanceof ScaleAnimation || first) {
        set.getAnimations().add(0, animation);
    } else {
        set.getAnimations().add(animation);
    }

    animation.startNow();
    view.setAnimation(set);
}

From source file:Main.java

private static void scaleUpAni(View v) {
    /*if(scaleUpAni == null){
       scaleUpAni = new ScaleAnimation(SCALE_DOWN_VALUE, 1.0f, SCALE_DOWN_VALUE, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
       scaleUpAni.setDuration(SCALE_ANI_DURATION);
       scaleUpAni.setFillAfter(true);/*from  www  . j a v  a 2s .c o m*/
    }
                
    //v.startAnimation(scaleUpAni);
    v.setAnimation(scaleUpAni);
    scaleUpAni.startNow();*/

    //v.getAnimation().cancel();
    //v.getAnimation().reset();
    /*v.clearAnimation();
    v.clearFocus();*/

    /*v.clearAnimation();
    v.setAnimation(null);*/
    if (v.getAnimation() != null) {
        v.getAnimation().cancel();
        v.getAnimation().reset();
    }

    v.clearAnimation();
    v.setAnimation(null);

    /*v.animate().scaleX(1.0f);
    v.animate().scaleY(1.0f);
    v.animate().setDuration(SCALE_ANI_DURATION);
    v.animate().start();*/

    //v.setScaleX(1.0f);
    //v.setScaleY(1.0f);
}

From source file:com.vaguehope.onosendai.widget.SidebarLayout.java

protected void animateSidebar(final boolean gotoOpen) {
    final View host = getHostView();
    if (host.getAnimation() != null)
        return;//from ww  w  .j av  a2  s.  c  o m

    final float deltaX;
    final Animation animation;
    if (gotoOpen) {
        deltaX = host.getTranslationX() > 0 ? -host.getTranslationX() : -this.sidebarWidth;
        animation = new TranslateAnimation(0, deltaX, 0, 0);
        animation.setAnimationListener(this.openListener);
    } else {
        deltaX = this.sidebarWidth - host.getTranslationX();
        animation = new TranslateAnimation(0, deltaX, 0, 0);
        animation.setAnimationListener(this.closeListener);
    }
    animation.setDuration((long) (SLIDE_DURATION * (Math.abs(deltaX) / this.sidebarWidth)));
    animation.setFillAfter(true);
    animation.setFillEnabled(true);
    host.startAnimation(animation);
}

From source file:com.carver.paul.truesight.Ui.MainActivity.java

/**
 * stopHeroRecognitionLoadingAnimations shows makes the the camera do one final pulse, and
 * then fades it away/*from   w ww  .java2  s  .co m*/
 */
protected void stopHeroRecognitionLoadingAnimations() {
    View processingText = findViewById(R.id.text_processing_image);
    processingText.animate().alpha(0).setDuration(150);

    View cameraImage = findViewById(R.id.image_pulsing_camera);
    Animation animation = cameraImage.getAnimation();
    if (animation != null) {
        animation.setRepeatCount(0);
    }

    cameraImage.animate().alpha(0).setDuration(150);
}