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

Commit ea4f93bc 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 a34ea9f6
Loading
Loading
Loading
Loading
+11 −6
Original line number Original line 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.Shared.DEBUG;
import static com.android.documentsui.State.MODE_GRID;
import static com.android.documentsui.State.MODE_GRID;
import static com.android.documentsui.State.MODE_LIST;
import static com.android.documentsui.State.MODE_LIST;
import static com.android.documentsui.State.MODE_UNKNOWN;


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


    private Context mContext;
    private final Context mContext;

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

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


    /**
    /**