Search in sources :

Example 1 with VoiceMessageEnterTransition

use of org.telegram.ui.VoiceMessageEnterTransition in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatListItemAnimator method animateAddImpl.

public void animateAddImpl(final RecyclerView.ViewHolder holder, int addedItemsHeight) {
    final View view = holder.itemView;
    final ViewPropertyAnimator animation = view.animate();
    mAddAnimations.add(holder);
    view.setTranslationY(addedItemsHeight);
    holder.itemView.setScaleX(1);
    holder.itemView.setScaleY(1);
    ChatMessageCell chatMessageCell = holder.itemView instanceof ChatMessageCell ? (ChatMessageCell) holder.itemView : null;
    if (!(chatMessageCell != null && chatMessageCell.getTransitionParams().ignoreAlpha)) {
        holder.itemView.setAlpha(1);
    }
    if (chatMessageCell != null && activity.animatingMessageObjects.contains(chatMessageCell.getMessageObject())) {
        activity.animatingMessageObjects.remove(chatMessageCell.getMessageObject());
        if (activity.getChatActivityEnterView().canShowMessageTransition()) {
            if (chatMessageCell.getMessageObject().isVoice()) {
                if (Math.abs(view.getTranslationY()) < view.getMeasuredHeight() * 3f) {
                    VoiceMessageEnterTransition transition = new VoiceMessageEnterTransition(chatMessageCell, activity.getChatActivityEnterView(), recyclerListView, activity.messageEnterTransitionContainer, resourcesProvider);
                    transition.start();
                }
            } else {
                if (SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW && Math.abs(view.getTranslationY()) < recyclerListView.getMeasuredHeight()) {
                    TextMessageEnterTransition transition = new TextMessageEnterTransition(chatMessageCell, activity, recyclerListView, activity.messageEnterTransitionContainer, resourcesProvider);
                    transition.start();
                }
            }
            activity.getChatActivityEnterView().startMessageTransition();
        }
    }
    animation.translationY(0).setDuration(getMoveDuration()).setInterpolator(translationInterpolator).setListener(new AnimatorListenerAdapter() {

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

        @Override
        public void onAnimationCancel(Animator animator) {
            view.setTranslationY(0);
            if (view instanceof ChatMessageCell) {
                ((ChatMessageCell) view).getTransitionParams().messageEntering = false;
            }
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            if (view instanceof ChatMessageCell) {
                ((ChatMessageCell) view).getTransitionParams().messageEntering = false;
            }
            animation.setListener(null);
            if (mAddAnimations.remove(holder)) {
                dispatchAddFinished(holder);
                dispatchFinishedWhenDone();
            }
        }
    }).start();
}
Also used : ChatMessageCell(org.telegram.ui.Cells.ChatMessageCell) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) ValueAnimator(android.animation.ValueAnimator) TextMessageEnterTransition(org.telegram.ui.TextMessageEnterTransition) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ChatGreetingsView(org.telegram.ui.Components.ChatGreetingsView) View(android.view.View) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ViewPropertyAnimator(android.view.ViewPropertyAnimator) VoiceMessageEnterTransition(org.telegram.ui.VoiceMessageEnterTransition)

Aggregations

Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ObjectAnimator (android.animation.ObjectAnimator)1 ValueAnimator (android.animation.ValueAnimator)1 View (android.view.View)1 ViewPropertyAnimator (android.view.ViewPropertyAnimator)1 ChatMessageCell (org.telegram.ui.Cells.ChatMessageCell)1 ChatGreetingsView (org.telegram.ui.Components.ChatGreetingsView)1 RecyclerListView (org.telegram.ui.Components.RecyclerListView)1 TextMessageEnterTransition (org.telegram.ui.TextMessageEnterTransition)1 VoiceMessageEnterTransition (org.telegram.ui.VoiceMessageEnterTransition)1