Java Code Examples for android.animation.Animator#end()

The following examples show how to use android.animation.Animator#end() . 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: PointIndicator.java    From IndicatorBox with MIT License 6 votes vote down vote up
/**
 * 添加单个指示器
 * @param backgroundResId
 * @param animator
 */
private void addIndicator(@DrawableRes int backgroundResId, Animator animator){
    if (animator.isRunning()){
        animator.end();
        animator.cancel();
    }
    View indicator = new View(getContext());
    indicator.setBackgroundResource(backgroundResId);
    addView(indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) indicator.getLayoutParams();
    if (mOrientation == LinearLayout.HORIZONTAL){
        lp.leftMargin = mIndicatorMargin;
        lp.rightMargin = mIndicatorMargin;
    }else if (mOrientation == LinearLayout.VERTICAL){
        lp.topMargin = mIndicatorMargin;
        lp.bottomMargin = mIndicatorMargin;
    }
    indicator.setLayoutParams(lp);
    animator.setTarget(indicator);
    animator.start();
}
 
Example 2
Source File: ItemAnimator.java    From FancyAccordionView with Apache License 2.0 6 votes vote down vote up
@Override
public void endAnimation(ViewHolder holder) {
    final Animator animator = mAnimators.get(holder);

    mAnimators.remove(holder);
    mAddAnimatorsList.remove(animator);
    mRemoveAnimatorsList.remove(animator);
    mChangeAnimatorsList.remove(animator);
    mMoveAnimatorsList.remove(animator);

    if (animator != null) {
        animator.end();
    }

    dispatchFinishedWhenDone();
}
 
Example 3
Source File: CircleIndicator.java    From MNImageBrowser with GNU General Public License v3.0 6 votes vote down vote up
private void addIndicator(int orientation, @DrawableRes int backgroundDrawableId,
                          Animator animator) {
    if (animator.isRunning()) {
        animator.end();
        animator.cancel();
    }

    View Indicator = new View(getContext());
    Indicator.setBackgroundResource(backgroundDrawableId);
    addView(Indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) Indicator.getLayoutParams();

    if (orientation == HORIZONTAL) {
        lp.leftMargin = mIndicatorMargin;
        lp.rightMargin = mIndicatorMargin;
    } else {
        lp.topMargin = mIndicatorMargin;
        lp.bottomMargin = mIndicatorMargin;
    }

    Indicator.setLayoutParams(lp);

    animator.setTarget(Indicator);
    animator.start();
}
 
Example 4
Source File: AnimatedVectorDrawable.java    From ElasticProgressBar with Apache License 2.0 5 votes vote down vote up
@Override
public void stop() {
    final ArrayList<Animator> animators = mAnimatedVectorState.mAnimators;
    final int size = animators.size();
    for (int i = 0; i < size; i++) {
        final Animator animator = animators.get(i);
        animator.end();
    }
}
 
Example 5
Source File: SupportAnimatorLollipop.java    From material-sheet-fab with MIT License 5 votes vote down vote up
@Override
public void end() {
    Animator a = mAnimator.get();
    if(a != null){
        a.end();
    }
}
 
Example 6
Source File: MapController.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
/**
 * Stops a running animation.
 *
 * @param jumpToTarget
 */
@Override
public void stopAnimation(final boolean jumpToTarget) {

    if (!mMapView.getScroller().isFinished()) {
        if (jumpToTarget) {
            mMapView.mIsFlinging = false;
            mMapView.getScroller().abortAnimation();
        } else
            stopPanning();
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        final Animator currentAnimator = this.mCurrentAnimator;
        if (mMapView.mIsAnimating.get()) {
            if (jumpToTarget) {
                currentAnimator.end();
            }
            else {
                currentAnimator.cancel();
            }
        }
    } else {
        if (mMapView.mIsAnimating.get()) {
            mMapView.clearAnimation();
        }
    }
}
 
Example 7
Source File: AnimatorAdapter.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
/**
 * Cancels any existing animations for given View. Useful when fling.
 */
private void cancelExistingAnimation(final int hashCode) {
    Animator animator = mAnimators.get(hashCode);
    if (animator != null) {
        animator.end();
    }
}
 
Example 8
Source File: ProgressIndicatorView.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * make animation to start or end when target
 * view was be Visible or Gone or Invisible.
 * make animation to cancel when target view
 * be onDetachedFromWindow.
 *
 * @param animStatus
 */
public void setAnimationStatus(AnimStatus animStatus) {
    if (mAnimators == null) {
        return;
    }
    int count = mAnimators.size();
    for (int i = 0; i < count; i++) {
        Animator animator = mAnimators.get(i);
        boolean isRunning = animator.isRunning();
        switch (animStatus) {
            case START:
                if (!isRunning) {
                    animator.start();
                }
                break;
            case END:
                if (isRunning) {
                    animator.end();
                }
                break;
            case CANCEL:
                if (isRunning) {
                    animator.cancel();
                }
                break;
        }
    }
}
 
Example 9
Source File: AnimatorEvents.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void onAnimationStart(Animator animation) {
    if (animation instanceof AnimatorSet) {
        startText.setAlpha(1f);
    } else {
        startTextAnimator.setAlpha(1f);
    }
    if (endImmediately) {
        animation.end();
    }
}
 
Example 10
Source File: Transition.java    From Transitions-Everywhere with Apache License 2.0 5 votes vote down vote up
/**
 * Force the transition to move to its end state, ending all the animators.
 */
void forceToEnd(@Nullable ViewGroup sceneRoot) {
    ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
    int numOldAnims = runningAnimators.size();
    if (sceneRoot != null) {
        Object windowId = ViewUtils.getWindowId(sceneRoot);
        for (int i = numOldAnims - 1; i >= 0; i--) {
            AnimationInfo info = runningAnimators.valueAt(i);
            if (info.view != null && windowId != null && windowId.equals(info.windowId)) {
                Animator anim = runningAnimators.keyAt(i);
                anim.end();
            }
        }
    }
}
 
Example 11
Source File: CircleIndicator.java    From Android-Application-ZJB with Apache License 2.0 5 votes vote down vote up
private void addIndicator(@DrawableRes int backgroundDrawableId, Animator animator) {
    if (animator.isRunning()) animator.end();

    View Indicator = new View(getContext());
    Indicator.setBackgroundResource(backgroundDrawableId);
    addView(Indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) Indicator.getLayoutParams();
    lp.leftMargin = mIndicatorMargin;
    lp.rightMargin = mIndicatorMargin;
    Indicator.setLayoutParams(lp);

    animator.setTarget(Indicator);
    animator.start();
}
 
Example 12
Source File: BaseIndicatorController.java    From LRecyclerView with Apache License 2.0 5 votes vote down vote up
/**
 * make animation to start or end when target
 * view was be Visible or Gone or Invisible.
 * make animation to cancel when target view
 * be onDetachedFromWindow.
 * @param animStatus
 */
public void setAnimationStatus(AnimStatus animStatus){
    if (mAnimators==null){
        return;
    }
    int count=mAnimators.size();
    for (int i = 0; i < count; i++) {
        Animator animator=mAnimators.get(i);
        boolean isRunning=animator.isRunning();
        switch (animStatus){
            case START:
                if (!isRunning){
                    animator.start();
                }
                break;
            case END:
                if (isRunning){
                    animator.end();
                }
                break;
            case CANCEL:
                if (isRunning){
                    animator.cancel();
                }
                break;
        }
    }
}
 
Example 13
Source File: SupportAnimatorLollipop.java    From PersistentSearchView with Apache License 2.0 5 votes vote down vote up
@Override
public void end() {
    Animator a = mAnimator.get();
    if(a != null){
        a.end();
    }
}
 
Example 14
Source File: SupportAnimatorForLollipop.java    From Nibo with MIT License 5 votes vote down vote up
@Override
public void end() {
    Animator a = mAnimator.get();
    if(a != null){
        a.end();
    }
}
 
Example 15
Source File: BaseIndeterminateProgressDrawable.java    From MaterialProgressBar with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void stop() {
    for (Animator animator : mAnimators) {
        animator.end();
    }
}
 
Example 16
Source File: CircleIndicator.java    From XERUNG with Apache License 2.0 5 votes vote down vote up
private void addIndicator(@DrawableRes int backgroundDrawableId, Animator animator) {
    if (animator.isRunning()) animator.end();

    View Indicator = new View(getContext());
    Indicator.setBackgroundResource(backgroundDrawableId);
    addView(Indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) Indicator.getLayoutParams();
    lp.leftMargin = mIndicatorMargin;
    lp.rightMargin = mIndicatorMargin;
    Indicator.setLayoutParams(lp);

    animator.setTarget(Indicator);
    animator.start();
}
 
Example 17
Source File: CircleIndicator.java    From XERUNG with Apache License 2.0 5 votes vote down vote up
private void addIndicator(@DrawableRes int backgroundDrawableId, Animator animator) {
    if (animator.isRunning()) animator.end();

    View Indicator = new View(getContext());
    Indicator.setBackgroundResource(backgroundDrawableId);
    addView(Indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) Indicator.getLayoutParams();
    lp.leftMargin = mIndicatorMargin;
    lp.rightMargin = mIndicatorMargin;
    Indicator.setLayoutParams(lp);

    animator.setTarget(Indicator);
    animator.start();
}
 
Example 18
Source File: AnimatorUtil.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
/**
 * call function and end
 *
 * @param animator
 * @return
 */
public static boolean end(Animator animator) {
    if (animator != null && animator.isStarted()) {
        animator.end();
        return true;
    }
    return false;
}
 
Example 19
Source File: ProgressIndicatorView.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * make animation to start or end when target
 * view was be Visible or Gone or Invisible.
 * make animation to cancel when target view
 * be onDetachedFromWindow.
 *
 * @param animStatus
 */
public void setAnimationStatus(AnimStatus animStatus) {
    if (mAnimators == null) {
        return;
    }
    int count = mAnimators.size();
    for (int i = 0; i < count; i++) {
        Animator animator = mAnimators.get(i);
        boolean isRunning = animator.isRunning();
        switch (animStatus) {
            case START:
                if (!isRunning) {
                    animator.start();
                }
                break;
            case END:
                if (isRunning) {
                    animator.end();
                }
                break;
            case CANCEL:
                if (isRunning) {
                    animator.cancel();
                }
                break;
        }
    }
}
 
Example 20
Source File: AnimationUtils.java    From RxTools-master with Apache License 2.0 4 votes vote down vote up
public static void stop(Animator animator) {
    if (animator != null && !animator.isRunning()) {
        animator.end();
    }
}