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

The following examples show how to use android.animation.Animator#removeAllListeners() . 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: AnimUtils.java    From Android-utils with Apache License 2.0 5 votes vote down vote up
public static void clearValueAnimator(Animator animator) {
    if (animator != null) {
        animator.removeAllListeners();
        if (animator instanceof ValueAnimator) {
            ((ValueAnimator) animator).removeAllUpdateListeners();
        }

        if (Build.VERSION.SDK_INT >= 19) {
            animator.pause();
        }
        animator.cancel();
    }
}
 
Example 2
Source File: PointViewAnimObject.java    From DragPointView with Apache License 2.0 5 votes vote down vote up
private void start(Animator object, final OnPointDragListener removeListener) {
    view.setVisibility(View.VISIBLE);
    Animator copy = object.clone();
    copy.setTarget(view);
    copy.removeAllListeners();
    copy.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            animation.removeListener(this);
            end(removeListener);
        }
    });
    copy.start();
}
 
Example 3
Source File: TextSelectionHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onTextSelected(ChatMessageCell newView, ChatMessageCell oldView) {
    boolean idChanged = oldView == null || (oldView.getMessageObject() != null && oldView.getMessageObject().getId() != newView.getMessageObject().getId());
    selectedCellId = newView.getMessageObject().getId();
    enterProgress = 0;
    isDescription = maybeIsDescription;

    Animator oldAnimator = animatorSparseArray.get(selectedCellId);
    if (oldAnimator != null) {
        oldAnimator.removeAllListeners();
        oldAnimator.cancel();
    }

    ValueAnimator animator = ValueAnimator.ofFloat(0, 1f);
    animator.addUpdateListener(animation -> {
        enterProgress = (float) animation.getAnimatedValue();
        if (textSelectionOverlay != null) {
            textSelectionOverlay.invalidate();
        }
        if (selectedView != null && selectedView.getCurrentMessagesGroup() == null && idChanged) {
            selectedView.setSelectedBackgroundProgress(1f - enterProgress);
        }
    });
    animator.setDuration(250);
    animator.start();

    animatorSparseArray.put(selectedCellId, animator);

    if (!idChanged) {
        newView.setSelectedBackgroundProgress(0f);
    }

    SharedConfig.removeTextSelectionHint();
}
 
Example 4
Source File: TextSelectionHelper.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onTextSelected(ChatMessageCell newView, ChatMessageCell oldView) {
    boolean idChanged = oldView == null || (oldView.getMessageObject() != null && oldView.getMessageObject().getId() != newView.getMessageObject().getId());
    selectedCellId = newView.getMessageObject().getId();
    enterProgress = 0;
    isDescription = maybeIsDescription;

    Animator oldAnimator = animatorSparseArray.get(selectedCellId);
    if (oldAnimator != null) {
        oldAnimator.removeAllListeners();
        oldAnimator.cancel();
    }

    ValueAnimator animator = ValueAnimator.ofFloat(0, 1f);
    animator.addUpdateListener(animation -> {
        enterProgress = (float) animation.getAnimatedValue();
        if (textSelectionOverlay != null) {
            textSelectionOverlay.invalidate();
        }
        if (selectedView != null && selectedView.getCurrentMessagesGroup() == null && idChanged) {
            selectedView.setSelectedBackgroundProgress(1f - enterProgress);
        }
    });
    animator.setDuration(250);
    animator.start();

    animatorSparseArray.put(selectedCellId, animator);

    if (!idChanged) {
        newView.setSelectedBackgroundProgress(0f);
    }

    SharedConfig.removeTextSelectionHint();
}