Search in sources :

Example 36 with ViewPropertyAnimator

use of android.view.ViewPropertyAnimator in project mTHMMY by ThmmyNoLife.

the class EditorView method showMarkdown.

/**
 * Animates the showing of the markdown options.
 */
public void showMarkdown() {
    if (formatButtonsRecyclerview.getVisibility() == VISIBLE)
        return;
    ViewPropertyAnimator animator = formatButtonsRecyclerview.animate().translationY(0).setInterpolator(new FastOutSlowInInterpolator()).setDuration(ANIMATION_DURATION);
    animator.setListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
            formatButtonsRecyclerview.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animator) {
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    animator.start();
}
Also used : Animator(android.animation.Animator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) ViewPropertyAnimator(android.view.ViewPropertyAnimator)

Example 37 with ViewPropertyAnimator

use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.

the class ActionBar method setTitleOverlayText.

public void setTitleOverlayText(String title, int titleId, Runnable action) {
    if (!allowOverlayTitle || parentFragment.parentLayout == null) {
        return;
    }
    overlayTitleToSet[0] = title;
    overlayTitleToSet[1] = titleId;
    overlayTitleToSet[2] = action;
    if (overlayTitleAnimationInProgress) {
        return;
    }
    if (lastOverlayTitle == null && title == null || (lastOverlayTitle != null && lastOverlayTitle.equals(title))) {
        return;
    }
    lastOverlayTitle = title;
    CharSequence textToSet = title != null ? LocaleController.getString(title, titleId) : lastTitle;
    boolean ellipsize = false;
    if (title != null) {
        int index = TextUtils.indexOf(textToSet, "...");
        if (index >= 0) {
            SpannableString spannableString = SpannableString.valueOf(textToSet);
            ellipsizeSpanAnimator.wrap(spannableString, index);
            textToSet = spannableString;
            ellipsize = true;
        }
    }
    titleOverlayShown = title != null;
    if ((textToSet != null && titleTextView[0] == null) || getMeasuredWidth() == 0 || (titleTextView[0] != null && titleTextView[0].getVisibility() != View.VISIBLE)) {
        createTitleTextView(0);
        if (supportsHolidayImage) {
            titleTextView[0].invalidate();
            invalidate();
        }
        titleTextView[0].setText(textToSet);
        if (ellipsize) {
            ellipsizeSpanAnimator.addView(titleTextView[0]);
        } else {
            ellipsizeSpanAnimator.removeView(titleTextView[0]);
        }
    } else if (titleTextView[0] != null) {
        titleTextView[0].animate().cancel();
        if (titleTextView[1] != null) {
            titleTextView[1].animate().cancel();
        }
        if (titleTextView[1] == null) {
            createTitleTextView(1);
        }
        titleTextView[1].setText(textToSet);
        if (ellipsize) {
            ellipsizeSpanAnimator.addView(titleTextView[1]);
        }
        overlayTitleAnimationInProgress = true;
        SimpleTextView tmp = titleTextView[1];
        titleTextView[1] = titleTextView[0];
        titleTextView[0] = tmp;
        titleTextView[0].setAlpha(0);
        titleTextView[0].setTranslationY(-AndroidUtilities.dp(20));
        titleTextView[0].animate().alpha(1f).translationY(0).setDuration(220).start();
        ViewPropertyAnimator animator = titleTextView[1].animate().alpha(0);
        if (subtitleTextView == null) {
            animator.translationY(AndroidUtilities.dp(20));
        } else {
            animator.scaleY(0.7f).scaleX(0.7f);
        }
        requestLayout();
        centerScale = true;
        animator.setDuration(220).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                if (titleTextView[1] != null && titleTextView[1].getParent() != null) {
                    ViewGroup viewGroup = (ViewGroup) titleTextView[1].getParent();
                    viewGroup.removeView(titleTextView[1]);
                }
                ellipsizeSpanAnimator.removeView(titleTextView[1]);
                titleTextView[1] = null;
                overlayTitleAnimationInProgress = false;
                setTitleOverlayText((String) overlayTitleToSet[0], (int) overlayTitleToSet[1], (Runnable) overlayTitleToSet[2]);
            }
        }).start();
    }
    titleActionRunnable = action != null ? action : lastRunnable;
}
Also used : SpannableString(android.text.SpannableString) Animator(android.animation.Animator) EllipsizeSpanAnimator(org.telegram.ui.Components.EllipsizeSpanAnimator) ObjectAnimator(android.animation.ObjectAnimator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ViewGroup(android.view.ViewGroup) SpannableString(android.text.SpannableString) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) ViewPropertyAnimator(android.view.ViewPropertyAnimator)

Example 38 with ViewPropertyAnimator

use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.

the class ActionBar method setTitleAnimated.

public void setTitleAnimated(CharSequence title, boolean fromBottom, long duration) {
    if (titleTextView[0] == null || title == null) {
        setTitle(title);
        return;
    }
    boolean crossfade = overlayTitleAnimation && !TextUtils.isEmpty(subtitle);
    if (crossfade) {
        if (subtitleTextView.getVisibility() != View.VISIBLE) {
            subtitleTextView.setVisibility(View.VISIBLE);
            subtitleTextView.setAlpha(0);
        }
        subtitleTextView.animate().alpha(fromBottom ? 0 : 1f).setDuration(220).start();
    }
    if (titleTextView[1] != null) {
        if (titleTextView[1].getParent() != null) {
            ViewGroup viewGroup = (ViewGroup) titleTextView[1].getParent();
            viewGroup.removeView(titleTextView[1]);
        }
        titleTextView[1] = null;
    }
    titleTextView[1] = titleTextView[0];
    titleTextView[0] = null;
    setTitle(title);
    this.fromBottom = fromBottom;
    titleTextView[0].setAlpha(0);
    if (!crossfade) {
        titleTextView[0].setTranslationY(fromBottom ? AndroidUtilities.dp(20) : -AndroidUtilities.dp(20));
    }
    titleTextView[0].animate().alpha(1f).translationY(0).setDuration(duration).start();
    titleAnimationRunning = true;
    ViewPropertyAnimator a = titleTextView[1].animate().alpha(0);
    if (!crossfade) {
        a.translationY(fromBottom ? -AndroidUtilities.dp(20) : AndroidUtilities.dp(20));
    }
    a.setDuration(duration).setListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (titleTextView[1] != null && titleTextView[1].getParent() != null) {
                ViewGroup viewGroup = (ViewGroup) titleTextView[1].getParent();
                viewGroup.removeView(titleTextView[1]);
            }
            titleTextView[1] = null;
            titleAnimationRunning = false;
            if (crossfade && fromBottom) {
                subtitleTextView.setVisibility(View.GONE);
            }
            requestLayout();
        }
    }).start();
    requestLayout();
}
Also used : Animator(android.animation.Animator) EllipsizeSpanAnimator(org.telegram.ui.Components.EllipsizeSpanAnimator) ObjectAnimator(android.animation.ObjectAnimator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) ViewGroup(android.view.ViewGroup) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ViewPropertyAnimator(android.view.ViewPropertyAnimator)

Example 39 with ViewPropertyAnimator

use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.

the class DialogsItemAnimator method animateAddImpl.

void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    mAddAnimations.add(holder);
    final ViewPropertyAnimator animation = view.animate();
    animation.alpha(1).setDuration(deleteDuration).setListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animator) {
            dispatchAddStarting(holder);
        }

        @Override
        public void onAnimationCancel(Animator animator) {
            view.setAlpha(1);
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            animation.setListener(null);
            dispatchAddFinished(holder);
            mAddAnimations.remove(holder);
            dispatchFinishedWhenDone();
            if (holder.itemView instanceof DialogCell) {
                ((DialogCell) holder.itemView).setMoving(false);
            }
        }
    }).start();
}
Also used : DialogCell(org.telegram.ui.Cells.DialogCell) ObjectAnimator(android.animation.ObjectAnimator) SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) Animator(android.animation.Animator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) View(android.view.View) ViewPropertyAnimator(android.view.ViewPropertyAnimator)

Example 40 with ViewPropertyAnimator

use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.

the class DialogsItemAnimator method animateRemoveImpl.

private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    mRemoveAnimations.add(holder);
    if (view instanceof DialogCell) {
        DialogCell dialogCell = (DialogCell) view;
        if (view == removingDialog) {
            if (topClip != Integer.MAX_VALUE) {
                bottomClip = removingDialog.getMeasuredHeight() - topClip;
                removingDialog.setTopClip(topClip);
                removingDialog.setBottomClip(bottomClip);
            } else if (bottomClip != Integer.MAX_VALUE) {
                topClip = removingDialog.getMeasuredHeight() - bottomClip;
                removingDialog.setTopClip(topClip);
                removingDialog.setBottomClip(bottomClip);
            }
            if (Build.VERSION.SDK_INT >= 21) {
                dialogCell.setElevation(-1);
                dialogCell.setOutlineProvider(null);
            }
            final ObjectAnimator animator = ObjectAnimator.ofFloat(dialogCell, AnimationProperties.CLIP_DIALOG_CELL_PROGRESS, 1.0f).setDuration(deleteDuration);
            animator.setInterpolator(sDefaultInterpolator);
            animator.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationStart(Animator animator) {
                    dispatchRemoveStarting(holder);
                }

                @Override
                public void onAnimationEnd(Animator animator) {
                    animator.removeAllListeners();
                    dialogCell.setClipProgress(0.0f);
                    if (Build.VERSION.SDK_INT >= 21) {
                        dialogCell.setElevation(0);
                    }
                    dispatchRemoveFinished(holder);
                    mRemoveAnimations.remove(holder);
                    dispatchFinishedWhenDone();
                }
            });
            animator.start();
        } else {
            final ObjectAnimator animator = ObjectAnimator.ofFloat(dialogCell, View.ALPHA, 1.0f).setDuration(deleteDuration);
            animator.setInterpolator(sDefaultInterpolator);
            animator.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationStart(Animator animator) {
                    dispatchRemoveStarting(holder);
                }

                @Override
                public void onAnimationEnd(Animator animator) {
                    animator.removeAllListeners();
                    dialogCell.setClipProgress(0.0f);
                    if (Build.VERSION.SDK_INT >= 21) {
                        dialogCell.setElevation(0);
                    }
                    dispatchRemoveFinished(holder);
                    mRemoveAnimations.remove(holder);
                    dispatchFinishedWhenDone();
                }
            });
            animator.start();
        }
    } else {
        final ViewPropertyAnimator animation = view.animate();
        animation.setDuration(deleteDuration).alpha(0).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animator) {
                dispatchRemoveStarting(holder);
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                animation.setListener(null);
                view.setAlpha(1);
                dispatchRemoveFinished(holder);
                mRemoveAnimations.remove(holder);
                dispatchFinishedWhenDone();
            }
        }).start();
    }
}
Also used : DialogCell(org.telegram.ui.Cells.DialogCell) ObjectAnimator(android.animation.ObjectAnimator) SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) Animator(android.animation.Animator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) View(android.view.View) ViewPropertyAnimator(android.view.ViewPropertyAnimator)

Aggregations

ViewPropertyAnimator (android.view.ViewPropertyAnimator)104 Animator (android.animation.Animator)59 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)36 View (android.view.View)30 ValueAnimator (android.animation.ValueAnimator)23 ObjectAnimator (android.animation.ObjectAnimator)11 RecyclerView (androidx.recyclerview.widget.RecyclerView)9 AnimatorListener (android.animation.Animator.AnimatorListener)8 SimpleItemAnimator (androidx.recyclerview.widget.SimpleItemAnimator)7 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)4 ViewGroup (android.view.ViewGroup)4 ImageView (android.widget.ImageView)4 FastOutSlowInInterpolator (androidx.interpolator.view.animation.FastOutSlowInInterpolator)4 ProgressCardView (org.wikipedia.feed.progress.ProgressCardView)4 Paint (android.graphics.Paint)3 ViewTreeObserver (android.view.ViewTreeObserver)3 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)3 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)3 DialogCell (org.telegram.ui.Cells.DialogCell)3 Point (android.graphics.Point)2