Search in sources :

Example 96 with ViewPropertyAnimator

use of android.view.ViewPropertyAnimator in project Hentoid by avluis.

the class ZoomableRecyclerView method zoomFling.

boolean zoomFling(int velocityX, int velocityY) {
    if (scale <= DEFAULT_SCALE)
        return false;
    float distanceTimeFactor = 0.4f;
    Float newX = null;
    Float newY = null;
    if (velocityX != 0 && canMoveHorizontally()) {
        float dx = (distanceTimeFactor * velocityX / 2);
        newX = getPositionX(getX() + dx);
    }
    if (velocityY != 0 && canMoveVertically()) {
        float dy = (distanceTimeFactor * velocityY / 2);
        newY = getPositionY(getY() + dy);
    }
    ViewPropertyAnimator animation = animate();
    if (newX != null)
        animation.x(newX);
    if (newY != null)
        animation.y(newY);
    animation.setInterpolator(new DecelerateInterpolator()).setDuration(400).start();
    return true;
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ViewPropertyAnimator(android.view.ViewPropertyAnimator)

Example 97 with ViewPropertyAnimator

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

the class LocationActivityAdapter method onCreateViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view;
    switch(viewType) {
        case 0:
            // view = emptyCell = new EmptyCell(mContext) {
            // @Override
            // public ViewPropertyAnimator animate() {
            // ViewPropertyAnimator animator = super.animate();
            // if (Build.VERSION.SDK_INT >= 19) {
            // animator.setUpdateListener(animation -> {
            // if (updateRunnable != null) {
            // updateRunnable.run();
            // }
            // });
            // }
            // return animator;
            // }
            // };
            view = emptyCell = new FrameLayout(mContext);
            emptyCell.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, overScrollHeight));
            break;
        case 1:
            view = new SendLocationCell(mContext, false, resourcesProvider);
            break;
        case 2:
            view = new HeaderCell(mContext, resourcesProvider);
            break;
        case 3:
            LocationCell locationCell = new LocationCell(mContext, false, resourcesProvider);
            view = locationCell;
            break;
        case 4:
            view = new LocationLoadingCell(mContext, resourcesProvider);
            break;
        case 5:
            view = new LocationPoweredCell(mContext, resourcesProvider);
            break;
        case 6:
            {
                SendLocationCell cell = new SendLocationCell(mContext, true, resourcesProvider);
                cell.setDialogId(dialogId);
                view = cell;
                break;
            }
        case 7:
            view = new SharingLiveLocationCell(mContext, true, locationType == LocationActivity.LOCATION_TYPE_GROUP || locationType == LocationActivity.LOCATION_TYPE_GROUP_VIEW ? 16 : 54, resourcesProvider);
            break;
        case 8:
            {
                LocationDirectionCell cell = new LocationDirectionCell(mContext, resourcesProvider);
                cell.setOnButtonClick(v -> onDirectionClick());
                view = cell;
                break;
            }
        case 9:
            {
                view = new ShadowSectionCell(mContext);
                Drawable drawable = Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow);
                CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(getThemedColor(Theme.key_windowBackgroundGray)), drawable);
                combinedDrawable.setFullsize(true);
                view.setBackgroundDrawable(combinedDrawable);
                break;
            }
        case 10:
        default:
            {
                view = new View(mContext);
                break;
            }
    }
    return new RecyclerListView.Holder(view);
}
Also used : Context(android.content.Context) LocationActivity(org.telegram.ui.LocationActivity) Theme(org.telegram.ui.ActionBar.Theme) FrameLayout(android.widget.FrameLayout) AndroidUtilities(org.telegram.messenger.AndroidUtilities) ColorDrawable(android.graphics.drawable.ColorDrawable) LocaleController(org.telegram.messenger.LocaleController) LocationController(org.telegram.messenger.LocationController) HeaderCell(org.telegram.ui.Cells.HeaderCell) Drawable(android.graphics.drawable.Drawable) ArrayList(java.util.ArrayList) LocationDirectionCell(org.telegram.ui.Cells.LocationDirectionCell) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) SendLocationCell(org.telegram.ui.Cells.SendLocationCell) TLRPC(org.telegram.tgnet.TLRPC) Locale(java.util.Locale) View(android.view.View) MessageObject(org.telegram.messenger.MessageObject) RecyclerView(androidx.recyclerview.widget.RecyclerView) Build(android.os.Build) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) LocationLoadingCell(org.telegram.ui.Cells.LocationLoadingCell) LocationPoweredCell(org.telegram.ui.Cells.LocationPoweredCell) R(org.telegram.messenger.R) TextUtils(android.text.TextUtils) SharingLiveLocationCell(org.telegram.ui.Cells.SharingLiveLocationCell) ViewGroup(android.view.ViewGroup) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) UserConfig(org.telegram.messenger.UserConfig) LocationCell(org.telegram.ui.Cells.LocationCell) ViewPropertyAnimator(android.view.ViewPropertyAnimator) Location(android.location.Location) EmptyCell(org.telegram.ui.Cells.EmptyCell) RecyclerListView(org.telegram.ui.Components.RecyclerListView) SharingLiveLocationCell(org.telegram.ui.Cells.SharingLiveLocationCell) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) HeaderCell(org.telegram.ui.Cells.HeaderCell) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) LocationLoadingCell(org.telegram.ui.Cells.LocationLoadingCell) LocationDirectionCell(org.telegram.ui.Cells.LocationDirectionCell) ColorDrawable(android.graphics.drawable.ColorDrawable) FrameLayout(android.widget.FrameLayout) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) RecyclerView(androidx.recyclerview.widget.RecyclerView) LocationPoweredCell(org.telegram.ui.Cells.LocationPoweredCell) SendLocationCell(org.telegram.ui.Cells.SendLocationCell) SharingLiveLocationCell(org.telegram.ui.Cells.SharingLiveLocationCell) LocationCell(org.telegram.ui.Cells.LocationCell) SendLocationCell(org.telegram.ui.Cells.SendLocationCell)

Example 98 with ViewPropertyAnimator

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

the class SideMenultItemAnimator method animateAddImpl.

void animateAddImpl(final RecyclerView.ViewHolder holder, int num, int addCount, int totalHeight) {
    final View view = holder.itemView;
    final ViewPropertyAnimator animation = view.animate();
    mAddAnimations.add(holder);
    view.setAlpha(1.0f);
    view.setTranslationY(-totalHeight);
    animation.translationY(0.0f).setDuration(220).setInterpolator(CubicBezierInterpolator.EASE_OUT).setListener(new AnimatorListenerAdapter() {

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

        @Override
        public void onAnimationCancel(Animator animator) {
            view.setTranslationY(0.0f);
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            animation.setListener(null);
            dispatchAddFinished(holder);
            mAddAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}
Also used : SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) Animator(android.animation.Animator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ViewPropertyAnimator(android.view.ViewPropertyAnimator)

Example 99 with ViewPropertyAnimator

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

the class SideMenultItemAnimator method animateRemoveImpl.

private void animateRemoveImpl(final RecyclerView.ViewHolder holder, int totalHeight) {
    final View view = holder.itemView;
    final ViewPropertyAnimator animation = view.animate();
    mRemoveAnimations.add(holder);
    animation.setDuration(220).translationY(-totalHeight).setInterpolator(CubicBezierInterpolator.EASE_OUT).setListener(new AnimatorListenerAdapter() {

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

        @Override
        public void onAnimationEnd(Animator animator) {
            animation.setListener(null);
            dispatchRemoveFinished(holder);
            mRemoveAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}
Also used : SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) Animator(android.animation.Animator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ViewPropertyAnimator(android.view.ViewPropertyAnimator)

Example 100 with ViewPropertyAnimator

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

the class ChatListItemAnimator method animateChangeImpl.

void animateChangeImpl(final ChangeInfo changeInfo) {
    if (BuildVars.LOGS_ENABLED) {
        FileLog.d("animate change impl");
    }
    final RecyclerView.ViewHolder holder = changeInfo.oldHolder;
    final View view = holder == null ? null : holder.itemView;
    final RecyclerView.ViewHolder newHolder = changeInfo.newHolder;
    final View newView = newHolder != null ? newHolder.itemView : null;
    if (view != null) {
        final ViewPropertyAnimator oldViewAnim = view.animate().setDuration(getChangeDuration());
        mChangeAnimations.add(changeInfo.oldHolder);
        oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX);
        oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY);
        oldViewAnim.alpha(0).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animator) {
                dispatchChangeStarting(changeInfo.oldHolder, true);
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                oldViewAnim.setListener(null);
                view.setAlpha(1);
                view.setScaleX(1f);
                view.setScaleX(1f);
                if (view instanceof ChatMessageCell) {
                    ((ChatMessageCell) view).setAnimationOffsetX(0);
                } else {
                    view.setTranslationX(0);
                }
                view.setTranslationY(0);
                if (mChangeAnimations.remove(changeInfo.oldHolder)) {
                    dispatchChangeFinished(changeInfo.oldHolder, true);
                    dispatchFinishedWhenDone();
                }
            }
        }).start();
    }
    if (newView != null) {
        final ViewPropertyAnimator newViewAnimation = newView.animate();
        mChangeAnimations.add(changeInfo.newHolder);
        newViewAnimation.translationX(0).translationY(0).setDuration(getChangeDuration()).alpha(1).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animator) {
                dispatchChangeStarting(changeInfo.newHolder, false);
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                newViewAnimation.setListener(null);
                newView.setAlpha(1);
                newView.setScaleX(1f);
                newView.setScaleX(1f);
                if (newView instanceof ChatMessageCell) {
                    ((ChatMessageCell) newView).setAnimationOffsetX(0);
                } else {
                    newView.setTranslationX(0);
                }
                newView.setTranslationY(0);
                if (mChangeAnimations.remove(changeInfo.newHolder)) {
                    dispatchChangeFinished(changeInfo.newHolder, false);
                    dispatchFinishedWhenDone();
                }
            }
        }).start();
    }
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) ValueAnimator(android.animation.ValueAnimator) ChatMessageCell(org.telegram.ui.Cells.ChatMessageCell) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ChatGreetingsView(org.telegram.ui.Components.ChatGreetingsView) View(android.view.View) RecyclerListView(org.telegram.ui.Components.RecyclerListView) 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