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

Commit 8c972f2c authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Some fixes to the new loader management."

parents 6bd08c56 f73c75ca
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -147,7 +147,10 @@ public abstract class LoaderManager {
            LoaderManager.LoaderCallbacks<D> callback);

    /**
     * Stops and removes the loader with the given ID.
     * Stops and removes the loader with the given ID.  If this loader
     * had previously reported data to the client through
     * {@link LoaderCallbacks#onLoadFinished(Loader, Object)}, a call
     * will be made to {@link LoaderCallbacks#onLoaderReset(Loader)}.
     */
    public abstract void destroyLoader(int id);

@@ -397,7 +400,8 @@ class LoaderManagerImpl extends LoaderManager {
            writer.print(prefix); writer.print("mData="); writer.println(mData);
            writer.print(prefix); writer.print("mStarted="); writer.print(mStarted);
                    writer.print(" mRetaining="); writer.print(mRetaining);
                    writer.print(" mDestroyed="); writer.print(mDestroyed);
                    writer.print(" mDestroyed="); writer.println(mDestroyed);
            writer.print(prefix); writer.print("mNeedReset="); writer.print(mNeedReset);
                    writer.print(" mListenerRegistered="); writer.println(mListenerRegistered);
        }
    }
@@ -491,6 +495,12 @@ class LoaderManagerImpl extends LoaderManager {
            mLoaders.removeAt(idx);
            info.destroy();
        }
        idx = mInactiveLoaders.indexOfKey(id);
        if (idx >= 0) {
            LoaderInfo info = mInactiveLoaders.valueAt(idx);
            mInactiveLoaders.removeAt(idx);
            info.destroy();
        }
    }

    @SuppressWarnings("unchecked")
+16 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> {
    Cursor mCursor;
    ForceLoadContentObserver mObserver;
    boolean mStopped;
    boolean mContentChanged;
    boolean mReset;
    Uri mUri;
    String[] mProjection;
@@ -102,7 +103,9 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> {

        if (mCursor != null) {
            deliverResult(mCursor);
        } else {
        }
        if (mCursor == null || mContentChanged) {
            mContentChanged = false;
            forceLoad();
        }
    }
@@ -119,6 +122,18 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> {
        mStopped = true;
    }

    @Override
    public void onContentChanged() {
        if (mStopped) {
            // This loader has been stopped, so we don't want to load
            // new data right now...  but keep track of it changing to
            // refresh later if we start again.
            mContentChanged = true;
            return;
        }
        super.onContentChanged();
    }
    
    @Override
    public void onCancelled(Cursor cursor) {
        if (cursor != null && !cursor.isClosed()) {