Loading api/current.xml +14 −3 Original line number Diff line number Diff line Loading @@ -54754,7 +54754,7 @@ native="false" synchronized="false" static="false" final="false" final="true" deprecated="not deprecated" visibility="public" > Loading Loading @@ -54879,7 +54879,7 @@ native="false" synchronized="false" static="false" final="false" final="true" deprecated="not deprecated" visibility="public" > Loading @@ -54890,7 +54890,7 @@ native="false" synchronized="false" static="false" final="false" final="true" deprecated="not deprecated" visibility="public" > Loading @@ -54901,6 +54901,17 @@ native="false" synchronized="false" static="false" final="true" deprecated="not deprecated" visibility="public" > </method> <method name="takeContentChanged" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" core/java/android/app/LoaderManager.java +20 −14 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.util.SparseArray; import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.reflect.Modifier; /** * Interface associated with an {@link Activity} or {@link Fragment} for managing Loading Loading @@ -217,8 +218,8 @@ class LoaderManagerImpl extends LoaderManager { LoaderManager.LoaderCallbacks<Object> mCallbacks; Loader<Object> mLoader; Object mData; Object mDeliveredData; boolean mStarted; boolean mNeedReset; boolean mRetaining; boolean mRetainingStarted; boolean mDestroyed; Loading @@ -244,14 +245,17 @@ class LoaderManagerImpl extends LoaderManager { return; } mStarted = true; if (DEBUG) Log.v(TAG, " Starting: " + this); if (mLoader == null && mCallbacks != null) { mLoader = mCallbacks.onCreateLoader(mId, mArgs); } if (mLoader != null) { if (mLoader.getClass().isMemberClass()) { if (mLoader.getClass().isMemberClass() && !Modifier.isStatic(mLoader.getClass().getModifiers())) { throw new IllegalArgumentException( "Object returned from onCreateLoader must not be a member class: " "Object returned from onCreateLoader must not be a non-static inner member class: " + mLoader); } if (!mListenerRegistered) { Loading @@ -259,7 +263,6 @@ class LoaderManagerImpl extends LoaderManager { mListenerRegistered = true; } mLoader.startLoading(); mStarted = true; } } Loading Loading @@ -312,8 +315,8 @@ class LoaderManagerImpl extends LoaderManager { void destroy() { if (DEBUG) Log.v(TAG, " Destroying: " + this); mDestroyed = true; boolean needReset = mNeedReset; mNeedReset = false; boolean needReset = mDeliveredData != null; mDeliveredData = null; if (mCallbacks != null && mLoader != null && mData != null && needReset) { if (DEBUG) Log.v(TAG, " Reseting: " + this); String lastBecause = null; Loading Loading @@ -350,10 +353,12 @@ class LoaderManagerImpl extends LoaderManager { // Notify of the new data so the app can switch out the old data before // we try to destroy it. if (mData != data) { mData = data; if (mStarted) { callOnLoadFinished(loader, data); } } //if (DEBUG) Log.v(TAG, " onLoadFinished returned: " + this); Loading @@ -363,7 +368,7 @@ class LoaderManagerImpl extends LoaderManager { // clean it up. LoaderInfo info = mInactiveLoaders.get(mId); if (info != null && info != this) { info.mNeedReset = false; info.mDeliveredData = null; info.destroy(); mInactiveLoaders.remove(mId); } Loading @@ -385,7 +390,7 @@ class LoaderManagerImpl extends LoaderManager { mActivity.mFragments.mNoTransactionsBecause = lastBecause; } } mNeedReset = true; mDeliveredData = data; } } Loading @@ -411,11 +416,12 @@ class LoaderManagerImpl extends LoaderManager { mLoader.dump(prefix + " ", fd, writer, args); } writer.print(prefix); writer.print("mData="); writer.println(mData); writer.print(prefix); writer.print("mDeliveredData="); writer.println(mDeliveredData); writer.print(prefix); writer.print("mStarted="); writer.print(mStarted); writer.print(" mRetaining="); writer.print(mRetaining); writer.print(" mDestroyed="); writer.println(mDestroyed); writer.print(prefix); writer.print("mNeedReset="); writer.print(mNeedReset); writer.print(" mListenerRegistered="); writer.println(mListenerRegistered); writer.print(prefix); writer.print("mListenerRegistered="); writer.println(mListenerRegistered); } } Loading Loading @@ -479,7 +485,7 @@ class LoaderManagerImpl extends LoaderManager { // yet destroyed the last inactive loader. So just do // that now. if (DEBUG) Log.v(TAG, " Removing last inactive loader: " + info); inactive.mNeedReset = false; inactive.mDeliveredData = null; inactive.destroy(); mInactiveLoaders.put(id, info); } else { Loading core/java/android/content/AsyncTaskLoader.java +9 −4 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ public abstract class AsyncTaskLoader<D> extends Loader<D> { /* Runs on the UI thread */ @Override protected void onPostExecute(D data) { AsyncTaskLoader.this.dispatchOnLoadComplete(data); AsyncTaskLoader.this.dispatchOnLoadComplete(this, data); } @Override Loading @@ -55,6 +55,7 @@ public abstract class AsyncTaskLoader<D> extends Loader<D> { @Override protected void onForceLoad() { super.onForceLoad(); cancelLoad(); mTask = new LoadTask(); mTask.execute((Void[]) null); Loading Loading @@ -85,10 +86,14 @@ public abstract class AsyncTaskLoader<D> extends Loader<D> { public void onCancelled(D data) { } void dispatchOnLoadComplete(D data) { void dispatchOnLoadComplete(LoadTask task, D data) { if (mTask != task) { onCancelled(data); } else { mTask = null; deliverResult(data); } } /** * Called on a worker thread to perform the actual load. Implementations should not deliver the Loading core/java/android/content/CursorLoader.java +5 −19 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> { String mSortOrder; Cursor mCursor; boolean mContentChanged; /* Runs on a worker thread */ @Override Loading @@ -63,7 +62,7 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> { /* Runs on the UI thread */ @Override public void deliverResult(Cursor cursor) { if (mReset) { if (isReset()) { // An async query came in while the loader is stopped if (cursor != null) { cursor.close(); Loading Loading @@ -105,8 +104,7 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> { if (mCursor != null) { deliverResult(mCursor); } if (mCursor == null || mContentChanged) { mContentChanged = false; if (takeContentChanged() || mCursor == null) { forceLoad(); } } Loading @@ -120,18 +118,6 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> { cancelLoad(); } @Override public void onContentChanged() { if (!isStarted()) { // 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()) { Loading @@ -141,10 +127,10 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> { @Override protected void onReset() { mReset = true; super.onReset(); // Ensure the loader is stopped stopLoading(); onStopLoading(); if (mCursor != null && !mCursor.isClosed()) { mCursor.close(); Loading core/java/android/content/Loader.java +38 −9 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ public class Loader<D> { Context mContext; boolean mStarted = false; boolean mReset = true; boolean mContentChanged = false; public final class ForceLoadContentObserver extends ContentObserver { public ForceLoadContentObserver() { Loading Loading @@ -161,7 +162,7 @@ public class Loader<D> { * * <p>Must be called from the UI thread. */ public void startLoading() { public final void startLoading() { mStarted = true; mReset = false; onStartLoading(); Loading @@ -178,11 +179,12 @@ public class Loader<D> { /** * Force an asynchronous load. Unlike {@link #startLoading()} this will ignore a previously * loaded data set and load a new one. This simply calls through to the * implementation's {@link #onForceLoad()}. * implementation's {@link #onForceLoad()}. You generally should only call this * when the loader is started -- that is, {@link #isStarted()} returns true. * * <p>Must be called from the UI thread. */ public void forceLoad() { public final void forceLoad() { onForceLoad(); } Loading @@ -194,6 +196,11 @@ public class Loader<D> { /** * Stops delivery of updates until the next time {@link #startLoading()} is called. * Implementations should <em>not</em> invalidate their data at this point -- * clients are still free to use the last data the loader reported. They will, * however, typically stop reporting new data if the data changes; they can * still monitor for changes, but must not report them to the client until and * if {@link #startLoading()} is later called. * * <p>This updates the Loader's internal state so that * {@link #isStarted()} will return the correct Loading @@ -201,7 +208,7 @@ public class Loader<D> { * * <p>Must be called from the UI thread. */ public void stopLoading() { public final void stopLoading() { mStarted = false; onStopLoading(); } Loading @@ -226,10 +233,11 @@ public class Loader<D> { * * <p>Must be called from the UI thread. */ public void reset() { public final void reset() { onReset(); mReset = true; mStarted = false; mContentChanged = false; } /** Loading @@ -241,13 +249,33 @@ public class Loader<D> { } /** * Called when {@link ForceLoadContentObserver} detects a change. Calls {@link #forceLoad()} * by default. * Take the current flag indicating whether the loader's content had * changed while it was stopped. If it had, true is returned and the * flag is cleared. */ public boolean takeContentChanged() { boolean res = mContentChanged; mContentChanged = false; return res; } /** * Called when {@link ForceLoadContentObserver} detects a change. The * default implementation checks to see if the loader is currently started; * if so, it simply calls {@link #forceLoad()}; otherwise, it sets a flag * so that {@link #takeContentChanged()} returns true. * * <p>Must be called from the UI thread * <p>Must be called from the UI thread. */ public void onContentChanged() { if (mStarted) { forceLoad(); } else { // 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; } } /** Loading Loading @@ -283,6 +311,7 @@ public class Loader<D> { writer.print(prefix); writer.print("mId="); writer.print(mId); writer.print(" mListener="); writer.println(mListener); writer.print(prefix); writer.print("mStarted="); writer.print(mStarted); writer.print(" mContentChanged="); writer.print(mContentChanged); writer.print(" mReset="); writer.println(mReset); } } No newline at end of file Loading
api/current.xml +14 −3 Original line number Diff line number Diff line Loading @@ -54754,7 +54754,7 @@ native="false" synchronized="false" static="false" final="false" final="true" deprecated="not deprecated" visibility="public" > Loading Loading @@ -54879,7 +54879,7 @@ native="false" synchronized="false" static="false" final="false" final="true" deprecated="not deprecated" visibility="public" > Loading @@ -54890,7 +54890,7 @@ native="false" synchronized="false" static="false" final="false" final="true" deprecated="not deprecated" visibility="public" > Loading @@ -54901,6 +54901,17 @@ native="false" synchronized="false" static="false" final="true" deprecated="not deprecated" visibility="public" > </method> <method name="takeContentChanged" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public"
core/java/android/app/LoaderManager.java +20 −14 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.util.SparseArray; import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.reflect.Modifier; /** * Interface associated with an {@link Activity} or {@link Fragment} for managing Loading Loading @@ -217,8 +218,8 @@ class LoaderManagerImpl extends LoaderManager { LoaderManager.LoaderCallbacks<Object> mCallbacks; Loader<Object> mLoader; Object mData; Object mDeliveredData; boolean mStarted; boolean mNeedReset; boolean mRetaining; boolean mRetainingStarted; boolean mDestroyed; Loading @@ -244,14 +245,17 @@ class LoaderManagerImpl extends LoaderManager { return; } mStarted = true; if (DEBUG) Log.v(TAG, " Starting: " + this); if (mLoader == null && mCallbacks != null) { mLoader = mCallbacks.onCreateLoader(mId, mArgs); } if (mLoader != null) { if (mLoader.getClass().isMemberClass()) { if (mLoader.getClass().isMemberClass() && !Modifier.isStatic(mLoader.getClass().getModifiers())) { throw new IllegalArgumentException( "Object returned from onCreateLoader must not be a member class: " "Object returned from onCreateLoader must not be a non-static inner member class: " + mLoader); } if (!mListenerRegistered) { Loading @@ -259,7 +263,6 @@ class LoaderManagerImpl extends LoaderManager { mListenerRegistered = true; } mLoader.startLoading(); mStarted = true; } } Loading Loading @@ -312,8 +315,8 @@ class LoaderManagerImpl extends LoaderManager { void destroy() { if (DEBUG) Log.v(TAG, " Destroying: " + this); mDestroyed = true; boolean needReset = mNeedReset; mNeedReset = false; boolean needReset = mDeliveredData != null; mDeliveredData = null; if (mCallbacks != null && mLoader != null && mData != null && needReset) { if (DEBUG) Log.v(TAG, " Reseting: " + this); String lastBecause = null; Loading Loading @@ -350,10 +353,12 @@ class LoaderManagerImpl extends LoaderManager { // Notify of the new data so the app can switch out the old data before // we try to destroy it. if (mData != data) { mData = data; if (mStarted) { callOnLoadFinished(loader, data); } } //if (DEBUG) Log.v(TAG, " onLoadFinished returned: " + this); Loading @@ -363,7 +368,7 @@ class LoaderManagerImpl extends LoaderManager { // clean it up. LoaderInfo info = mInactiveLoaders.get(mId); if (info != null && info != this) { info.mNeedReset = false; info.mDeliveredData = null; info.destroy(); mInactiveLoaders.remove(mId); } Loading @@ -385,7 +390,7 @@ class LoaderManagerImpl extends LoaderManager { mActivity.mFragments.mNoTransactionsBecause = lastBecause; } } mNeedReset = true; mDeliveredData = data; } } Loading @@ -411,11 +416,12 @@ class LoaderManagerImpl extends LoaderManager { mLoader.dump(prefix + " ", fd, writer, args); } writer.print(prefix); writer.print("mData="); writer.println(mData); writer.print(prefix); writer.print("mDeliveredData="); writer.println(mDeliveredData); writer.print(prefix); writer.print("mStarted="); writer.print(mStarted); writer.print(" mRetaining="); writer.print(mRetaining); writer.print(" mDestroyed="); writer.println(mDestroyed); writer.print(prefix); writer.print("mNeedReset="); writer.print(mNeedReset); writer.print(" mListenerRegistered="); writer.println(mListenerRegistered); writer.print(prefix); writer.print("mListenerRegistered="); writer.println(mListenerRegistered); } } Loading Loading @@ -479,7 +485,7 @@ class LoaderManagerImpl extends LoaderManager { // yet destroyed the last inactive loader. So just do // that now. if (DEBUG) Log.v(TAG, " Removing last inactive loader: " + info); inactive.mNeedReset = false; inactive.mDeliveredData = null; inactive.destroy(); mInactiveLoaders.put(id, info); } else { Loading
core/java/android/content/AsyncTaskLoader.java +9 −4 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ public abstract class AsyncTaskLoader<D> extends Loader<D> { /* Runs on the UI thread */ @Override protected void onPostExecute(D data) { AsyncTaskLoader.this.dispatchOnLoadComplete(data); AsyncTaskLoader.this.dispatchOnLoadComplete(this, data); } @Override Loading @@ -55,6 +55,7 @@ public abstract class AsyncTaskLoader<D> extends Loader<D> { @Override protected void onForceLoad() { super.onForceLoad(); cancelLoad(); mTask = new LoadTask(); mTask.execute((Void[]) null); Loading Loading @@ -85,10 +86,14 @@ public abstract class AsyncTaskLoader<D> extends Loader<D> { public void onCancelled(D data) { } void dispatchOnLoadComplete(D data) { void dispatchOnLoadComplete(LoadTask task, D data) { if (mTask != task) { onCancelled(data); } else { mTask = null; deliverResult(data); } } /** * Called on a worker thread to perform the actual load. Implementations should not deliver the Loading
core/java/android/content/CursorLoader.java +5 −19 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> { String mSortOrder; Cursor mCursor; boolean mContentChanged; /* Runs on a worker thread */ @Override Loading @@ -63,7 +62,7 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> { /* Runs on the UI thread */ @Override public void deliverResult(Cursor cursor) { if (mReset) { if (isReset()) { // An async query came in while the loader is stopped if (cursor != null) { cursor.close(); Loading Loading @@ -105,8 +104,7 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> { if (mCursor != null) { deliverResult(mCursor); } if (mCursor == null || mContentChanged) { mContentChanged = false; if (takeContentChanged() || mCursor == null) { forceLoad(); } } Loading @@ -120,18 +118,6 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> { cancelLoad(); } @Override public void onContentChanged() { if (!isStarted()) { // 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()) { Loading @@ -141,10 +127,10 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> { @Override protected void onReset() { mReset = true; super.onReset(); // Ensure the loader is stopped stopLoading(); onStopLoading(); if (mCursor != null && !mCursor.isClosed()) { mCursor.close(); Loading
core/java/android/content/Loader.java +38 −9 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ public class Loader<D> { Context mContext; boolean mStarted = false; boolean mReset = true; boolean mContentChanged = false; public final class ForceLoadContentObserver extends ContentObserver { public ForceLoadContentObserver() { Loading Loading @@ -161,7 +162,7 @@ public class Loader<D> { * * <p>Must be called from the UI thread. */ public void startLoading() { public final void startLoading() { mStarted = true; mReset = false; onStartLoading(); Loading @@ -178,11 +179,12 @@ public class Loader<D> { /** * Force an asynchronous load. Unlike {@link #startLoading()} this will ignore a previously * loaded data set and load a new one. This simply calls through to the * implementation's {@link #onForceLoad()}. * implementation's {@link #onForceLoad()}. You generally should only call this * when the loader is started -- that is, {@link #isStarted()} returns true. * * <p>Must be called from the UI thread. */ public void forceLoad() { public final void forceLoad() { onForceLoad(); } Loading @@ -194,6 +196,11 @@ public class Loader<D> { /** * Stops delivery of updates until the next time {@link #startLoading()} is called. * Implementations should <em>not</em> invalidate their data at this point -- * clients are still free to use the last data the loader reported. They will, * however, typically stop reporting new data if the data changes; they can * still monitor for changes, but must not report them to the client until and * if {@link #startLoading()} is later called. * * <p>This updates the Loader's internal state so that * {@link #isStarted()} will return the correct Loading @@ -201,7 +208,7 @@ public class Loader<D> { * * <p>Must be called from the UI thread. */ public void stopLoading() { public final void stopLoading() { mStarted = false; onStopLoading(); } Loading @@ -226,10 +233,11 @@ public class Loader<D> { * * <p>Must be called from the UI thread. */ public void reset() { public final void reset() { onReset(); mReset = true; mStarted = false; mContentChanged = false; } /** Loading @@ -241,13 +249,33 @@ public class Loader<D> { } /** * Called when {@link ForceLoadContentObserver} detects a change. Calls {@link #forceLoad()} * by default. * Take the current flag indicating whether the loader's content had * changed while it was stopped. If it had, true is returned and the * flag is cleared. */ public boolean takeContentChanged() { boolean res = mContentChanged; mContentChanged = false; return res; } /** * Called when {@link ForceLoadContentObserver} detects a change. The * default implementation checks to see if the loader is currently started; * if so, it simply calls {@link #forceLoad()}; otherwise, it sets a flag * so that {@link #takeContentChanged()} returns true. * * <p>Must be called from the UI thread * <p>Must be called from the UI thread. */ public void onContentChanged() { if (mStarted) { forceLoad(); } else { // 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; } } /** Loading Loading @@ -283,6 +311,7 @@ public class Loader<D> { writer.print(prefix); writer.print("mId="); writer.print(mId); writer.print(" mListener="); writer.println(mListener); writer.print(prefix); writer.print("mStarted="); writer.print(mStarted); writer.print(" mContentChanged="); writer.print(mContentChanged); writer.print(" mReset="); writer.println(mReset); } } No newline at end of file