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

Commit 47874fb1 authored by Jet.Z's avatar Jet.Z Committed by Steve Kondik
Browse files

fix bug about view cache in RemoteViews

clear the data in cache before reloading new items,
& the method 'getCount()' returns tmpMetaData.count.

Change-Id: I0d37d7a99408f60b1d63fa5ca0c0a0f265dd0a8a
parent 1d0e262e
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -1082,9 +1082,9 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback
    }

    public int getCount() {
        final RemoteViewsMetaData metaData = mCache.getMetaData();
        synchronized (metaData) {
            return metaData.count;
        final RemoteViewsMetaData tmpMetaData = mCache.getTemporaryMetaData();
        synchronized (tmpMetaData) {
            return tmpMetaData.count;
        }
    }

@@ -1270,6 +1270,11 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback
            return;
        }

        // Clear the data in cache
        final RemoteViewsMetaData metaData = mCache.getMetaData();
        synchronized (metaData) {
            metaData.reset();
        }
        // Flush the cache so that we can reload new items from the service
        synchronized (mCache) {
            mCache.reset();