Search in sources :

Example 1 with DialogCell

use of org.telegram.ui.Cells.DialogCell 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 2 with DialogCell

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

the class DialogsItemAnimator method endAnimation.

@Override
public void endAnimation(ViewHolder item) {
    final View view = item.itemView;
    // this will trigger end callback which should set properties to their target values.
    view.animate().cancel();
    // TODO if some other animations are chained to end, how do we cancel them as well?
    for (int i = mPendingMoves.size() - 1; i >= 0; i--) {
        MoveInfo moveInfo = mPendingMoves.get(i);
        if (moveInfo.holder == item) {
            view.setTranslationY(0);
            view.setTranslationX(0);
            dispatchMoveFinished(item);
            mPendingMoves.remove(i);
        }
    }
    endChangeAnimation(mPendingChanges, item);
    if (mPendingRemovals.remove(item)) {
        if (view instanceof DialogCell) {
            ((DialogCell) view).setClipProgress(0.0f);
        } else {
            view.setAlpha(1);
        }
        dispatchRemoveFinished(item);
    }
    if (mPendingAdditions.remove(item)) {
        if (view instanceof DialogCell) {
            ((DialogCell) view).setClipProgress(0.0f);
        } else {
            view.setAlpha(1);
        }
        dispatchAddFinished(item);
    }
    for (int i = mChangesList.size() - 1; i >= 0; i--) {
        ArrayList<ChangeInfo> changes = mChangesList.get(i);
        endChangeAnimation(changes, item);
        if (changes.isEmpty()) {
            mChangesList.remove(i);
        }
    }
    for (int i = mMovesList.size() - 1; i >= 0; i--) {
        ArrayList<MoveInfo> moves = mMovesList.get(i);
        for (int j = moves.size() - 1; j >= 0; j--) {
            MoveInfo moveInfo = moves.get(j);
            if (moveInfo.holder == item) {
                view.setTranslationY(0);
                view.setTranslationX(0);
                dispatchMoveFinished(item);
                moves.remove(j);
                if (moves.isEmpty()) {
                    mMovesList.remove(i);
                }
                break;
            }
        }
    }
    for (int i = mAdditionsList.size() - 1; i >= 0; i--) {
        ArrayList<ViewHolder> additions = mAdditionsList.get(i);
        if (additions.remove(item)) {
            if (view instanceof DialogCell) {
                ((DialogCell) view).setClipProgress(1.0f);
            } else {
                view.setAlpha(1);
            }
            dispatchAddFinished(item);
            if (additions.isEmpty()) {
                mAdditionsList.remove(i);
            }
        }
    }
    if (mRemoveAnimations.remove(item) && DEBUG) {
        throw new IllegalStateException("after animation is cancelled, item should not be in " + "mRemoveAnimations list");
    }
    if (mAddAnimations.remove(item) && DEBUG) {
        throw new IllegalStateException("after animation is cancelled, item should not be in " + "mAddAnimations list");
    }
    if (mChangeAnimations.remove(item) && DEBUG) {
        throw new IllegalStateException("after animation is cancelled, item should not be in " + "mChangeAnimations list");
    }
    if (mMoveAnimations.remove(item) && DEBUG) {
        throw new IllegalStateException("after animation is cancelled, item should not be in " + "mMoveAnimations list");
    }
    dispatchFinishedWhenDone();
}
Also used : DialogCell(org.telegram.ui.Cells.DialogCell) ViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder) View(android.view.View)

Example 3 with DialogCell

use of org.telegram.ui.Cells.DialogCell 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)

Example 4 with DialogCell

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

the class DialogsItemAnimator method animateRemove.

@Override
public boolean animateRemove(final ViewHolder holder, ItemHolderInfo info) {
    resetAnimation(holder);
    mPendingRemovals.add(holder);
    int top = Integer.MIN_VALUE;
    DialogCell bottomView = null;
    for (int i = 0; i < listView.getChildCount(); i++) {
        View view = listView.getChildAt(i);
        if (view.getTop() > top && view instanceof DialogCell) {
            bottomView = (DialogCell) view;
        }
    }
    if (holder.itemView == bottomView) {
        removingDialog = bottomView;
    }
    return true;
}
Also used : DialogCell(org.telegram.ui.Cells.DialogCell) View(android.view.View)

Example 5 with DialogCell

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

the class DialogsItemAnimator method animateMoveImpl.

void animateMoveImpl(final ViewHolder holder, ItemHolderInfo info, int fromX, int fromY, int toX, int toY) {
    final View view = holder.itemView;
    final int deltaX = toX - fromX;
    final int deltaY = toY - fromY;
    if (deltaX != 0) {
        view.animate().translationX(0);
    }
    if (deltaY != 0) {
        view.animate().translationY(0);
    }
    if (fromY > toY) {
        bottomClip = fromY - toY;
    } else {
        topClip = toY - fromY;
    }
    if (removingDialog != null) {
        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);
        }
    }
    // TODO: make EndActions end listeners instead, since end actions aren't called when
    // vpas are canceled (and can't end them. why?)
    // need listener functionality in VPACompat for this. Ick.
    final ViewPropertyAnimator animation = view.animate();
    mMoveAnimations.add(holder);
    animation.setDuration(deleteDuration).setListener(new AnimatorListenerAdapter() {

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

        @Override
        public void onAnimationCancel(Animator animator) {
            if (deltaX != 0) {
                view.setTranslationX(0);
            }
            if (deltaY != 0) {
                view.setTranslationY(0);
            }
            if (holder.itemView instanceof DialogCell) {
                ((DialogCell) holder.itemView).setMoving(false);
            } else if (holder.itemView instanceof DialogsAdapter.LastEmptyView) {
                ((DialogsAdapter.LastEmptyView) holder.itemView).moving = false;
            }
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            animation.setListener(null);
            dispatchMoveFinished(holder);
            mMoveAnimations.remove(holder);
            dispatchFinishedWhenDone();
            if (holder.itemView instanceof DialogCell) {
                ((DialogCell) holder.itemView).setMoving(false);
            } else if (holder.itemView instanceof DialogsAdapter.LastEmptyView) {
                ((DialogsAdapter.LastEmptyView) holder.itemView).moving = false;
            }
            view.setTranslationX(0);
            view.setTranslationY(0);
        }
    }).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) DialogsAdapter(org.telegram.ui.Adapters.DialogsAdapter) View(android.view.View) ViewPropertyAnimator(android.view.ViewPropertyAnimator)

Aggregations

DialogCell (org.telegram.ui.Cells.DialogCell)22 View (android.view.View)19 RecyclerView (androidx.recyclerview.widget.RecyclerView)12 RecyclerListView (org.telegram.ui.Components.RecyclerListView)11 TextView (android.widget.TextView)8 FlickerLoadingView (org.telegram.ui.Components.FlickerLoadingView)8 ImageView (android.widget.ImageView)7 ArrayList (java.util.ArrayList)7 TLRPC (org.telegram.tgnet.TLRPC)7 HintDialogCell (org.telegram.ui.Cells.HintDialogCell)7 SuppressLint (android.annotation.SuppressLint)6 Paint (android.graphics.Paint)6 TextPaint (android.text.TextPaint)6 FiltersView (org.telegram.ui.Adapters.FiltersView)6 ProfileSearchCell (org.telegram.ui.Cells.ProfileSearchCell)6 Theme (org.telegram.ui.ActionBar.Theme)5 BackupImageView (org.telegram.ui.Components.BackupImageView)5 ChatActivityEnterView (org.telegram.ui.Components.ChatActivityEnterView)5 FragmentContextView (org.telegram.ui.Components.FragmentContextView)5 NumberTextView (org.telegram.ui.Components.NumberTextView)5