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

Commit dd46fe62 authored by Owen Lin's avatar Owen Lin
Browse files

Fix a IllegalArgumentException in Gallery 0 not in (0, 0)

fix: 5379253

We add a hack to prevent flush out cached data. But the hack will leave
the content window in an invalid values.

Change-Id: I3ed1527b9ee9023b07ca44cafc27510ef9f08d59
parent b289d441
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -165,9 +165,6 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener {
        mActiveStart = start;
        mActiveEnd = end;

        // If no data is visible, keep the cache content
        if (start == end) return;

        int contentStart = Utils.clamp((start + end) / 2 - data.length / 2,
                0, Math.max(0, mSize - data.length));
        int contentEnd = Math.min(contentStart + data.length, mSize);
+9 −2
Original line number Diff line number Diff line
@@ -206,8 +206,15 @@ public class AlbumSetView extends SlotView {
    private class MyCacheListener implements AlbumSetSlidingWindow.Listener {

        public void onSizeChanged(int size) {
            if (setSlotCount(size)) {
                // If the layout parameters are changed, we need reput all items.
            if (setSlotCount(size)) updateVisibleRange(0, 0);
                // We keep the visible range at the same center but with size 0.
                // So that we can:
                //     1.) flush all visible items
                //     2.) keep the cached data
                int center = (getVisibleStart() + getVisibleEnd()) / 2;
                updateVisibleRange(center, center);
            }
            updateVisibleRange(getVisibleStart(), getVisibleEnd());
            invalidate();
        }
+3 −7
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.gallery3d.ui;

import android.graphics.Bitmap;
import android.os.Message;

import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.common.BitmapUtils;
import com.android.gallery3d.common.LruCache;
@@ -29,10 +32,6 @@ import com.android.gallery3d.util.JobLimiter;
import com.android.gallery3d.util.ThreadPool.Job;
import com.android.gallery3d.util.ThreadPool.JobContext;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Message;

public class AlbumSlidingWindow implements AlbumView.ModelListener {
    @SuppressWarnings("unused")
    private static final String TAG = "AlbumSlidingWindow";
@@ -178,9 +177,6 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener {
        mActiveStart = start;
        mActiveEnd = end;

        // If no data is visible, keep the cache content
        if (start == end) return;

        int contentStart = Utils.clamp((start + end) / 2 - data.length / 2,
                0, Math.max(0, mSize - data.length));
        int contentEnd = Math.min(contentStart + data.length, mSize);
+11 −4
Original line number Diff line number Diff line
@@ -16,12 +16,12 @@

package com.android.gallery3d.ui;

import android.graphics.Rect;

import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.ui.PositionRepository.Position;

import android.graphics.Rect;

public class AlbumView extends SlotView {
    @SuppressWarnings("unused")
    private static final String TAG = "AlbumView";
@@ -163,8 +163,15 @@ public class AlbumView extends SlotView {
        }

        public void onSizeChanged(int size) {
            if (setSlotCount(size)) {
                // If the layout parameters are changed, we need reput all items.
            if (setSlotCount(size)) updateVisibleRange(0, 0);
                // We keep the visible range at the same center but with size 0.
                // So that we can:
                //     1.) flush all visible items
                //     2.) keep the cached data
                int center = (getVisibleStart() + getVisibleEnd()) / 2;
                updateVisibleRange(center, center);
            }
            updateVisibleRange(getVisibleStart(), getVisibleEnd());
            invalidate();
        }