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

Commit 51635f9c authored by Steve McKay's avatar Steve McKay
Browse files

Load correct thumbnail size when switching to grid from list (and visa versa).

This is a quickie change where we clear the cache, but I think there could be
a better behavior where we don't clear the cache, show low res (instantly)
then load higher resolution ontop of the low res.

Bug: 26763078
Change-Id: If9883d507984b555e790a06692390d4fa3334c28
parent f43ec7e5
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.documentsui.dirlist;
import static com.android.documentsui.Shared.DEBUG;
import static com.android.documentsui.State.MODE_GRID;
import static com.android.documentsui.State.MODE_LIST;
import static com.android.documentsui.State.MODE_UNKNOWN;

import android.content.ContentProviderClient;
import android.content.ContentResolver;
@@ -53,7 +52,9 @@ import com.android.documentsui.ThumbnailCache;
public class IconHelper {
    private static String TAG = "IconHelper";

    private Context mContext;
    private final Context mContext;

    // Updated when icon size is set.
    private ThumbnailCache mCache;
    private Point mThumbSize;
    // The display mode (MODE_GRID, MODE_LIST, etc).
@@ -85,8 +86,13 @@ public class IconHelper {
     * @param mode See {@link State.MODE_LIST} and {@link State.MODE_GRID}.
     */
    public void setViewMode(@ViewMode int mode) {
        // TODO: Instead of exposing setMode, make the mode final, and make separate instances for
        // grid/list.
        mMode = mode;
        int thumbSize = getThumbSize(mode);
        mThumbSize = new Point(thumbSize, thumbSize);
        mCache = DocumentsApplication.getThumbnailsCache(mContext, mThumbSize);
    }

    private int getThumbSize(int mode) {
        int thumbSize;
        switch (mode) {
            case MODE_GRID:
@@ -99,8 +105,7 @@ public class IconHelper {
            default:
                throw new IllegalArgumentException("Unsupported layout mode: " + mode);
        }
        mMode = mode;
        mThumbSize = new Point(thumbSize, thumbSize);
        return thumbSize;
    }

    /**