Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d894c8cd authored by Michael Jurka's avatar Michael Jurka
Browse files

Fix bug where icon animation is sometimes skipped

Bug: 7406230
Bug: 7406304

Change-Id: I9058acffa6587a5f8e757f1031750a8ba578c635
parent 2656abe0
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -336,19 +336,6 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
        });
    }

    @Override
    protected void onVisibilityChanged(View changedView, int visibility) {
        super.onVisibilityChanged(changedView, visibility);
        // scroll to bottom after reloading
        if (visibility == View.VISIBLE && changedView == this) {
            post(new Runnable() {
                public void run() {
                    update();
                }
            });
        }
    }

    public void setAdapter(TaskDescriptionAdapter adapter) {
        mAdapter = adapter;
        mAdapter.registerDataSetObserver(new DataSetObserver() {
+27 −13
Original line number Diff line number Diff line
@@ -77,9 +77,10 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener

    private boolean mShowing;
    private boolean mWaitingToShow;
    private int mNumItemsWaitingForThumbnailsAndIcons;
    private ViewHolder mItemToAnimateInWhenWindowAnimationIsFinished;
    private boolean mAnimateIconOfFirstTask;
    private boolean mWaitingForWindowAnimation;
    private long mWindowAnimationStartTime;

    private RecentTasksLoader mRecentTasksLoader;
    private ArrayList<TaskDescription> mRecentTaskDescriptions;
@@ -174,10 +175,9 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
            if (td.isLoaded()) {
                updateThumbnail(holder, td.getThumbnail(), true, false);
                updateIcon(holder, td.getIcon(), true, false);
                mNumItemsWaitingForThumbnailsAndIcons--;
            }
            if (index == 0) {
                if (mWaitingForWindowAnimation) {
                if (mAnimateIconOfFirstTask) {
                    if (mItemToAnimateInWhenWindowAnimationIsFinished != null) {
                        holder.iconView.setAlpha(1f);
                        holder.iconView.setTranslationX(0f);
@@ -206,6 +206,9 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
                        holder.iconView.setAlpha(0f);
                        holder.iconView.setTranslationY(translation);
                    }
                    if (!mWaitingForWindowAnimation) {
                        animateInIconOfFirstTask();
                    }
                }
            }

@@ -220,7 +223,9 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
            updateThumbnail(holder, mRecentTasksLoader.getDefaultThumbnail(), false, false);
            holder.iconView.setImageBitmap(mRecentTasksLoader.getDefaultIcon());
            holder.iconView.setVisibility(INVISIBLE);
            holder.iconView.animate().cancel();
            holder.labelView.setText(null);
            holder.labelView.animate().cancel();
            holder.thumbnailView.setContentDescription(null);
            holder.thumbnailView.setTag(null);
            holder.thumbnailView.setOnLongClickListener(null);
@@ -235,6 +240,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
                holder.calloutLine.setAlpha(1f);
                holder.calloutLine.setTranslationX(0f);
                holder.calloutLine.setTranslationY(0f);
                holder.calloutLine.animate().cancel();
            }
            holder.taskDescription = null;
            holder.loadedThumbnailAndIcon = false;
@@ -291,8 +297,9 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
    }

    public void show(boolean show, ArrayList<TaskDescription> recentTaskDescriptions,
            boolean firstScreenful, boolean waitingForWindowAnimation) {
        mWaitingForWindowAnimation = waitingForWindowAnimation;
            boolean firstScreenful, boolean animateIconOfFirstTask) {
        mAnimateIconOfFirstTask = animateIconOfFirstTask;
        mWaitingForWindowAnimation = animateIconOfFirstTask;
        if (show) {
            mWaitingToShow = true;
            refreshRecentTasksList(recentTaskDescriptions, firstScreenful);
@@ -527,7 +534,6 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
                            updateIcon(h, td.getIcon(), true, animateShow);
                            updateThumbnail(h, td.getThumbnail(), true, animateShow);
                            h.loadedThumbnailAndIcon = true;
                            mNumItemsWaitingForThumbnailsAndIcons--;
                        }
                    }
                }
@@ -536,9 +542,14 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
        showIfReady();
    }

    public void onWindowAnimationStart() {
        if (mItemToAnimateInWhenWindowAnimationIsFinished != null) {
            final int startDelay = 150;
    private void animateInIconOfFirstTask() {
        if (mItemToAnimateInWhenWindowAnimationIsFinished != null &&
                !mRecentTasksLoader.isFirstScreenful()) {
            int timeSinceWindowAnimation =
                    (int) (System.currentTimeMillis() - mWindowAnimationStartTime);
            final int minStartDelay = 150;
            final int startDelay = Math.max(0, Math.min(
                    minStartDelay - timeSinceWindowAnimation, minStartDelay));
            final int duration = 250;
            final ViewHolder holder = mItemToAnimateInWhenWindowAnimationIsFinished;
            final TimeInterpolator cubic = new DecelerateInterpolator(1.5f);
@@ -550,10 +561,16 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
                }
            }
            mItemToAnimateInWhenWindowAnimationIsFinished = null;
            mWaitingForWindowAnimation = false;
            mAnimateIconOfFirstTask = false;
        }
    }

    public void onWindowAnimationStart() {
        mWaitingForWindowAnimation = false;
        mWindowAnimationStartTime = System.currentTimeMillis();
        animateInIconOfFirstTask();
    }

    public void clearRecentTasksList() {
        // Clear memory used by screenshots
        if (mRecentTaskDescriptions != null) {
@@ -590,9 +607,6 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
    }

    public void onTasksLoaded(ArrayList<TaskDescription> tasks, boolean firstScreenful) {
        mNumItemsWaitingForThumbnailsAndIcons = firstScreenful
                ? tasks.size() : mRecentTaskDescriptions == null
                        ? 0 : mRecentTaskDescriptions.size();
        if (mRecentTaskDescriptions == null) {
            mRecentTaskDescriptions = new ArrayList<TaskDescription>(tasks);
        } else {
+0 −13
Original line number Diff line number Diff line
@@ -345,19 +345,6 @@ public class RecentsVerticalScrollView extends ScrollView
        });
    }

    @Override
    protected void onVisibilityChanged(View changedView, int visibility) {
        super.onVisibilityChanged(changedView, visibility);
        // scroll to bottom after reloading
        if (visibility == View.VISIBLE && changedView == this) {
            post(new Runnable() {
                public void run() {
                    update();
                }
            });
        }
    }

    public void setAdapter(TaskDescriptionAdapter adapter) {
        mAdapter = adapter;
        mAdapter.registerDataSetObserver(new DataSetObserver() {