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

Commit 8e781d94 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Part 3: Fade in app icons"

parents 84844597 6d5b8b8e
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -77,6 +77,10 @@ public class RecentsHistoryAdapter extends RecyclerView.Adapter<RecentsHistoryAd
            // This callback is only made for TaskRow view holders
            ImageView iv = (ImageView) content.findViewById(R.id.icon);
            iv.setImageDrawable(task.icon);
            iv.animate()
                    .alpha(1f)
                    .setDuration(100)
                    .start();
        }

        @Override
@@ -84,6 +88,7 @@ public class RecentsHistoryAdapter extends RecyclerView.Adapter<RecentsHistoryAd
            // This callback is only made for TaskRow view holders
            ImageView iv = (ImageView) content.findViewById(R.id.icon);
            iv.setImageBitmap(null);
            iv.animate().cancel();
        }

        @Override
@@ -265,8 +270,10 @@ public class RecentsHistoryAdapter extends RecyclerView.Adapter<RecentsHistoryAd
                taskRow.task.addCallback(holder);
                TextView tv = (TextView) holder.content.findViewById(R.id.description);
                tv.setText(taskRow.task.title);
                ImageView iv = (ImageView) holder.content.findViewById(R.id.icon);
                iv.setAlpha(0f);
                holder.content.setOnClickListener(taskRow);
                loader.loadTaskData(taskRow.task);
                loader.loadTaskData(taskRow.task, false /* fetchAndInvalidateThumbnails */);
                break;
            }
        }
@@ -275,19 +282,25 @@ public class RecentsHistoryAdapter extends RecyclerView.Adapter<RecentsHistoryAd
    @Override
    public void onViewRecycled(ViewHolder holder) {
        RecentsTaskLoader loader = Recents.getTaskLoader();

        int position = holder.getAdapterPosition();
        if (position != RecyclerView.NO_POSITION) {
            Row row = mRows.get(position);
            int viewType = row.getViewType();
            if (viewType == TASK_ROW_VIEW_TYPE) {
                TaskRow taskRow = (TaskRow) row;
                taskRow.task.removeCallback(holder);
                loader.unloadTaskData(taskRow.task);
                taskRow.task.removeCallback(holder);
            }
        }
    }

    @Override
    public boolean onFailedToRecycleView(ViewHolder holder) {
        // Always recycle views, even if it is animating
        onViewRecycled(holder);
        return true;
    }

    public void onTaskRemoved(Task task, int position) {
        // Since this is removed from the history, we need to update the stack as well to ensure
        // that the model is correct. Since the stack is hidden, we can update it immediately.
+14 −3
Original line number Diff line number Diff line
@@ -334,10 +334,19 @@ public class RecentsTaskLoader {
        }
    }

    /** Acquires the task resource data directly from the pool. */
    public void loadTaskData(Task t) {
    /**
     * Acquires the task resource data directly from the cache, loading if necessary.
     *
     * @param fetchAndInvalidateThumbnails If set, will try loading thumbnails, invalidating them
     *                                     in the cache and loading if necessary. Otherwise, do not
     *                                     load the thumbnail unless the icon also has to be loaded.
     */
    public void loadTaskData(Task t, boolean fetchAndInvalidateThumbnails) {
        Drawable icon = mIconCache.getAndInvalidateIfModified(t.key);
        Bitmap thumbnail = mThumbnailCache.getAndInvalidateIfModified(t.key);
        Bitmap thumbnail = mDefaultThumbnail;
        if (fetchAndInvalidateThumbnails) {
            thumbnail = mThumbnailCache.getAndInvalidateIfModified(t.key);
        }

        // Grab the thumbnail/icon from the cache, if either don't exist, then trigger a reload and
        // use the default assets in their place until they load
@@ -360,6 +369,8 @@ public class RecentsTaskLoader {
        mLoadQueue.removeTask(t);
        mThumbnailCache.remove(t.key);
        mIconCache.remove(t.key);
        mActivityLabelCache.remove(t.key);
        mContentDescriptionCache.remove(t.key);
        mActivityInfoCache.remove(t.key.getComponent());
        if (notifyTaskDataUnloaded) {
            t.notifyTaskDataUnloaded(null, mDefaultIcon);
+1 −1
Original line number Diff line number Diff line
@@ -1417,7 +1417,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        tv.onTaskBound(task);

        // Load the task data
        Recents.getTaskLoader().loadTaskData(task);
        Recents.getTaskLoader().loadTaskData(task, true /* fetchAndInvalidateThumbnails */);

        // If the doze trigger has already fired, then update the state for this task view
        tv.setNoUserInteractionState();