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

Commit ba2be0a9 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Gallery:Fix page skipping error after the editing"

parents 0bcd9062 7ed375d6
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -1308,6 +1308,7 @@ public class PhotoDataAdapter implements PhotoPage.Model {
                    }
                }
                mDirty = false;

                version = mSource.reload();
                if (mIsFromTimelineScreen) {
                    mSource.setClusterKind(GalleryActivity.CLUSTER_ALBUMSET_NO_TITLE);
@@ -1316,6 +1317,12 @@ public class PhotoDataAdapter implements PhotoPage.Model {
                if (version == MediaObject.INVALID_DATA_VERSION) {
                    continue;
                }
                if (mSource.isLoading()) {
                    mDirty = true;
                    continue;
                } else {
                    mSourceVersion = version;
                }
                UpdateInfo info = executeAndWait(new GetUpdateInfo());
                updateLoading(true);

@@ -1331,9 +1338,9 @@ public class PhotoDataAdapter implements PhotoPage.Model {

                if (info.version != version) {
                    info.reloadContent = true;
                    info.size = mSource.getMediaItemCount();
                }
                if (!info.reloadContent) continue;
                info.size = mSource.getMediaItemCount();

                // Check it is from camera or not
                boolean isCameraFlag = false;
@@ -1436,7 +1443,10 @@ public class PhotoDataAdapter implements PhotoPage.Model {

                // Don't change index if mSize == 0
                if (mSize > 0) {
                    if (index >= mSize) index = mSize - 1;
                    // Due to the set identification and new photo, photos
                    // in the last two positions disappear in the temp info.items.
                    // Don't change index in such a situation.
                    if (index >= mSize + 2) index = mSize - 1;
                }

                info.indexHint = index;
+5 −0
Original line number Diff line number Diff line
@@ -178,6 +178,11 @@ public class ClusterAlbum extends MediaSet implements ContentListener {
        return super.getMediaType();
    }

    @Override
    public boolean isLoading() {
        return mClusterAlbumSet.isLoading();
    }

    @Override
    public long reload() {
        long version = mClusterAlbumSet.reload();
+9 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ public class ClusterAlbumSet extends MediaSet implements ContentListener {
    private MediaSet mBaseSet;
    private int mKind;
    private ArrayList<ClusterAlbum> mAlbums = new ArrayList<ClusterAlbum>();
    private boolean mIsLoading;

    private int mTotalMediaItemCount;
    /** mTotalSelectableMediaItemCount is the count of items
@@ -63,12 +64,19 @@ public class ClusterAlbumSet extends MediaSet implements ContentListener {
        return mBaseSet.getName();
    }

    @Override
    public synchronized boolean isLoading() {
        return mIsLoading;
    }

    @Override
    public long reload() {
        synchronized (this) {
            long version = mBaseSet.reload();
            if (version > mDataVersion && !mBaseSet.isLoading()) {
            mIsLoading = mBaseSet.isLoading();
            if (version > mDataVersion && !mIsLoading) {
                updateClusters();
                mIsLoading = false;
                mDataVersion = nextVersionNumber();
            }
            if (mKind == ClusterSource.CLUSTER_ALBUMSET_TIME) {
+14 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ public class FilterDeleteSet extends MediaSet implements ContentListener {
    private static final int REQUEST_REMOVE = 2;
    private static final int REQUEST_CLEAR = 3;

    private boolean mIsLoading;

    private static class Request {
        int type;  // one of the REQUEST_* constants
        Path path;
@@ -141,12 +143,21 @@ public class FilterDeleteSet extends MediaSet implements ContentListener {
        return base;
    }

    @Override
    public boolean isLoading() {
        return mIsLoading;
    }

    // We apply the pending requests in the mRequests to construct mCurrent in reload().
    @Override
    public long reload() {
        mIsLoading = true;
        boolean newData = mBaseSet.reload() > mDataVersion;
        synchronized (mRequests) {
            if (!newData && mRequests.isEmpty()) {
                if (!mBaseSet.isLoading()) {
                    mIsLoading = false;
                }
                return mDataVersion;
            }
            for (int i = 0; i < mRequests.size(); i++) {
@@ -220,6 +231,9 @@ public class FilterDeleteSet extends MediaSet implements ContentListener {
        }

        mDataVersion = nextVersionNumber();
        if (!mBaseSet.isLoading()) {
            mIsLoading = false;
        }
        return mDataVersion;
    }