Java Code Examples for android.animation.ObjectAnimator#cancel()

The following examples show how to use android.animation.ObjectAnimator#cancel() . 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: MainKeyboardView.java    From simple-keyboard with Apache License 2.0 6 votes vote down vote up
public void startDisplayLanguageOnSpacebar(final boolean subtypeChanged,
        final int languageOnSpacebarFormatType) {
    if (subtypeChanged) {
        KeyPreviewView.clearTextCache();
    }
    mLanguageOnSpacebarFormatType = languageOnSpacebarFormatType;
    final ObjectAnimator animator = mLanguageOnSpacebarFadeoutAnimator;
    if (animator == null) {
        mLanguageOnSpacebarFormatType = LanguageOnSpacebarUtils.FORMAT_TYPE_NONE;
    } else {
        if (subtypeChanged
                && languageOnSpacebarFormatType != LanguageOnSpacebarUtils.FORMAT_TYPE_NONE) {
            setLanguageOnSpacebarAnimAlpha(Constants.Color.ALPHA_OPAQUE);
            if (animator.isStarted()) {
                animator.cancel();
            }
            animator.start();
        } else {
            if (!animator.isStarted()) {
                mLanguageOnSpacebarAnimAlpha = mLanguageOnSpacebarFinalAlpha;
            }
        }
    }
    invalidateKey(mSpaceKey);
}
 
Example 2
Source File: DeleteView.java    From budget-envelopes with GNU General Public License v3.0 6 votes vote down vote up
private void cancelSwipe() {
    if (getParent() instanceof ViewGroup) {
        ViewGroup p = (ViewGroup)getParent();
        p.requestDisallowInterceptTouchEvent(false);
    }
    mSwipeState = STATE_READY;
    if (mVelocityTracker != null) {
        mVelocityTracker.recycle();
        mVelocityTracker = null;
    }
    if (mAnim != null) {
        ObjectAnimator anim = mAnim;
        mAnim = null;
        anim.cancel();
    }
    setClickable(true);
    setInnerViewPosition(0);
    setBackgroundResource(0);
    setInnerViewHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
}
 
Example 3
Source File: SampleTests.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
/**
 * Test if all Interpolators can be used to start an animation.
 */
@UiThreadTest
public void testStartInterpolators() {

    // Start an animation for each interpolator
    final Interpolator[] interpolators = mTestFragment.getInterpolators();

    for (final Interpolator i : interpolators) {
        // Start the animation
        ObjectAnimator animator = mTestFragment.startAnimation(i, 1000L, mTestFragment.getPathIn());
        // Check that the correct interpolator is used for the animation
        assertEquals(i, animator.getInterpolator());
        // Verify the animation has started
        assertTrue(animator.isStarted());
        // Cancel before starting the next animation
        animator.cancel();
    }
}
 
Example 4
Source File: MainKeyboardView.java    From LokiBoard-Android-Keylogger with Apache License 2.0 6 votes vote down vote up
public void startDisplayLanguageOnSpacebar(final boolean subtypeChanged,
        final int languageOnSpacebarFormatType) {
    if (subtypeChanged) {
        KeyPreviewView.clearTextCache();
    }
    mLanguageOnSpacebarFormatType = languageOnSpacebarFormatType;
    final ObjectAnimator animator = mLanguageOnSpacebarFadeoutAnimator;
    if (animator == null) {
        mLanguageOnSpacebarFormatType = LanguageOnSpacebarUtils.FORMAT_TYPE_NONE;
    } else {
        if (subtypeChanged
                && languageOnSpacebarFormatType != LanguageOnSpacebarUtils.FORMAT_TYPE_NONE) {
            setLanguageOnSpacebarAnimAlpha(Constants.Color.ALPHA_OPAQUE);
            if (animator.isStarted()) {
                animator.cancel();
            }
            animator.start();
        } else {
            if (!animator.isStarted()) {
                mLanguageOnSpacebarAnimAlpha = mLanguageOnSpacebarFinalAlpha;
            }
        }
    }
    invalidateKey(mSpaceKey);
}
 
Example 5
Source File: MainKeyboardView.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
public void startDisplayLanguageOnSpacebar(final boolean subtypeChanged,
        final int languageOnSpacebarFormatType,
        final boolean hasMultipleEnabledIMEsOrSubtypes) {
    if (subtypeChanged) {
        KeyPreviewView.clearTextCache();
    }
    mLanguageOnSpacebarFormatType = languageOnSpacebarFormatType;
    mHasMultipleEnabledIMEsOrSubtypes = hasMultipleEnabledIMEsOrSubtypes;
    final ObjectAnimator animator = mLanguageOnSpacebarFadeoutAnimator;
    if (animator == null) {
        mLanguageOnSpacebarFormatType = LanguageOnSpacebarUtils.FORMAT_TYPE_NONE;
    } else {
        if (subtypeChanged
                && languageOnSpacebarFormatType != LanguageOnSpacebarUtils.FORMAT_TYPE_NONE) {
            setLanguageOnSpacebarAnimAlpha(Constants.Color.ALPHA_OPAQUE);
            if (animator.isStarted()) {
                animator.cancel();
            }
            animator.start();
        } else {
            if (!animator.isStarted()) {
                mLanguageOnSpacebarAnimAlpha = mLanguageOnSpacebarFinalAlpha;
            }
        }
    }
    invalidateKey(mSpaceKey);
}
 
Example 6
Source File: MainKeyboardView.java    From LokiBoard-Android-Keylogger with Apache License 2.0 5 votes vote down vote up
private static void cancelAndStartAnimators(final ObjectAnimator animatorToCancel,
        final ObjectAnimator animatorToStart) {
    if (animatorToCancel == null || animatorToStart == null) {
        // TODO: Stop using null as a no-operation animator.
        return;
    }
    float startFraction = 0.0f;
    if (animatorToCancel.isStarted()) {
        animatorToCancel.cancel();
        startFraction = 1.0f - animatorToCancel.getAnimatedFraction();
    }
    final long startTime = (long)(animatorToStart.getDuration() * startFraction);
    animatorToStart.start();
    animatorToStart.setCurrentPlayTime(startTime);
}
 
Example 7
Source File: MainKeyboardView.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
private static void cancelAndStartAnimators(final ObjectAnimator animatorToCancel,
        final ObjectAnimator animatorToStart) {
    if (animatorToCancel == null || animatorToStart == null) {
        // TODO: Stop using null as a no-operation animator.
        return;
    }
    float startFraction = 0.0f;
    if (animatorToCancel.isStarted()) {
        animatorToCancel.cancel();
        startFraction = 1.0f - animatorToCancel.getAnimatedFraction();
    }
    final long startTime = (long)(animatorToStart.getDuration() * startFraction);
    animatorToStart.start();
    animatorToStart.setCurrentPlayTime(startTime);
}
 
Example 8
Source File: StoryStatusView.java    From StatusStories with Apache License 2.0 5 votes vote down vote up
/**
 * Need to call when Activity or Fragment destroy
 */
public void destroy() {
    for (ObjectAnimator a : animators) {
        a.removeAllListeners();
        a.cancel();
    }
}
 
Example 9
Source File: MainKeyboardView.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
private static void cancelAndStartAnimators(final ObjectAnimator animatorToCancel,
        final ObjectAnimator animatorToStart) {
    if (animatorToCancel == null || animatorToStart == null) {
        // TODO: Stop using null as a no-operation animator.
        return;
    }
    float startFraction = 0.0f;
    if (animatorToCancel.isStarted()) {
        animatorToCancel.cancel();
        startFraction = 1.0f - animatorToCancel.getAnimatedFraction();
    }
    final long startTime = (long)(animatorToStart.getDuration() * startFraction);
    animatorToStart.start();
    animatorToStart.setCurrentPlayTime(startTime);
}
 
Example 10
Source File: StackView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean cancelSliderAnimator() {
    if (sliderAnimator != null) {
        ObjectAnimator oa = sliderAnimator.get();
        if (oa != null) {
            oa.cancel();
            return true;
        }
    }
    return false;
}
 
Example 11
Source File: MainKeyboardView.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
private static void cancelAndStartAnimators(final ObjectAnimator animatorToCancel,
        final ObjectAnimator animatorToStart) {
    if (animatorToCancel == null || animatorToStart == null) {
        // TODO: Stop using null as a no-operation animator.
        return;
    }
    float startFraction = 0.0f;
    if (animatorToCancel.isStarted()) {
        animatorToCancel.cancel();
        startFraction = 1.0f - animatorToCancel.getAnimatedFraction();
    }
    final long startTime = (long)(animatorToStart.getDuration() * startFraction);
    animatorToStart.start();
    animatorToStart.setCurrentPlayTime(startTime);
}
 
Example 12
Source File: MainKeyboardView.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
public void startDisplayLanguageOnSpacebar(final boolean subtypeChanged,
        final int languageOnSpacebarFormatType,
        final boolean hasMultipleEnabledIMEsOrSubtypes) {
    if (subtypeChanged) {
        KeyPreviewView.clearTextCache();
    }
    mLanguageOnSpacebarFormatType = languageOnSpacebarFormatType;
    mHasMultipleEnabledIMEsOrSubtypes = hasMultipleEnabledIMEsOrSubtypes;
    final ObjectAnimator animator = mLanguageOnSpacebarFadeoutAnimator;
    if (animator == null) {
        mLanguageOnSpacebarFormatType = LanguageOnSpacebarUtils.FORMAT_TYPE_NONE;
    } else {
        if (subtypeChanged
                && languageOnSpacebarFormatType != LanguageOnSpacebarUtils.FORMAT_TYPE_NONE) {
            setLanguageOnSpacebarAnimAlpha(Constants.Color.ALPHA_OPAQUE);
            if (animator.isStarted()) {
                animator.cancel();
            }
            animator.start();
        } else {
            if (!animator.isStarted()) {
                mLanguageOnSpacebarAnimAlpha = mLanguageOnSpacebarFinalAlpha;
            }
        }
    }
    invalidateKey(mSpaceKey);
}
 
Example 13
Source File: DeleteView.java    From budget-envelopes with GNU General Public License v3.0 5 votes vote down vote up
private void cancelAnimation(float newStartPosition) {
    if (mAnim != null) {
        ObjectAnimator anim = mAnim;
        mAnim = null;
        anim.cancel();
    }
    mVelocityTracker.clear();
    mSwipeStart = newStartPosition - mInnerView.getTranslationX();
    mSwipeState = STATE_IN_SWIPE;
}
 
Example 14
Source File: AllAppsBackgroundDrawable.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
private ObjectAnimator cancelAnimator(ObjectAnimator animator) {
    if (animator != null) {
        animator.removeAllListeners();
        animator.cancel();
    }
    return null;
}
 
Example 15
Source File: MainKeyboardView.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
private static void cancelAndStartAnimators(final ObjectAnimator animatorToCancel,
        final ObjectAnimator animatorToStart) {
    if (animatorToCancel == null || animatorToStart == null) {
        // TODO: Stop using null as a no-operation animator.
        return;
    }
    float startFraction = 0.0f;
    if (animatorToCancel.isStarted()) {
        animatorToCancel.cancel();
        startFraction = 1.0f - animatorToCancel.getAnimatedFraction();
    }
    final long startTime = (long)(animatorToStart.getDuration() * startFraction);
    animatorToStart.start();
    animatorToStart.setCurrentPlayTime(startTime);
}
 
Example 16
Source File: MainKeyboardView.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
public void startDisplayLanguageOnSpacebar(final boolean subtypeChanged,
        final int languageOnSpacebarFormatType,
        final boolean hasMultipleEnabledIMEsOrSubtypes) {
    if (subtypeChanged) {
        KeyPreviewView.clearTextCache();
    }
    mLanguageOnSpacebarFormatType = languageOnSpacebarFormatType;
    mHasMultipleEnabledIMEsOrSubtypes = hasMultipleEnabledIMEsOrSubtypes;
    final ObjectAnimator animator = mLanguageOnSpacebarFadeoutAnimator;
    if (animator == null) {
        mLanguageOnSpacebarFormatType = LanguageOnSpacebarUtils.FORMAT_TYPE_NONE;
    } else {
        if (subtypeChanged
                && languageOnSpacebarFormatType != LanguageOnSpacebarUtils.FORMAT_TYPE_NONE) {
            setLanguageOnSpacebarAnimAlpha(Constants.Color.ALPHA_OPAQUE);
            if (animator.isStarted()) {
                animator.cancel();
            }
            animator.start();
        } else {
            if (!animator.isStarted()) {
                mLanguageOnSpacebarAnimAlpha = mLanguageOnSpacebarFinalAlpha;
            }
        }
    }
    invalidateKey(mSpaceKey);
}
 
Example 17
Source File: AnimatorsCompat.java    From RippleDrawable with MIT License 5 votes vote down vote up
public static void startWithAutoCancel(ObjectAnimator animator) {
    for (WeakReference<ObjectAnimator> wa : sRunningAnimators) {
        ObjectAnimator a = wa.get();
        if (a == null) {
            continue;
        }

        if (hasSameTargetAndProperties(animator, a)) {
            a.cancel();
        }
    }

    start(animator);
}
 
Example 18
Source File: StackView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean cancelTransformAnimator() {
    if (transformAnimator != null) {
        ObjectAnimator oa = transformAnimator.get();
        if (oa != null) {
            oa.cancel();
            return true;
        }
    }
    return false;
}
 
Example 19
Source File: AllAppsBackgroundDrawable.java    From LaunchEnr with GNU General Public License v3.0 4 votes vote down vote up
private ObjectAnimator cancelAnimator(ObjectAnimator animator) {
    if (animator != null) {
        animator.cancel();
    }
    return null;
}
 
Example 20
Source File: MenuView.java    From floatingsearchview with Apache License 2.0 4 votes vote down vote up
private void cancelChildAnimListAndClear() {
    for (ObjectAnimator animator : anims) {
        animator.cancel();
    }
    anims.clear();
}