Merge "Update xml attributes for the expand button."
diff --git a/app-toolkit/core-testing/api/1.1.0.txt b/app-toolkit/core-testing/api/1.1.0.txt
new file mode 100644
index 0000000..f1d206c
--- /dev/null
+++ b/app-toolkit/core-testing/api/1.1.0.txt
@@ -0,0 +1,15 @@
+package android.arch.core.executor.testing {
+
+ public class CountingTaskExecutorRule extends org.junit.rules.TestWatcher {
+ ctor public CountingTaskExecutorRule();
+ method public void drainTasks(int, java.util.concurrent.TimeUnit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException;
+ method public boolean isIdle();
+ method protected void onIdle();
+ }
+
+ public class InstantTaskExecutorRule extends org.junit.rules.TestWatcher {
+ ctor public InstantTaskExecutorRule();
+ }
+
+}
+
diff --git a/app-toolkit/runtime/api/1.1.0.txt b/app-toolkit/runtime/api/1.1.0.txt
new file mode 100644
index 0000000..af5b253
--- /dev/null
+++ b/app-toolkit/runtime/api/1.1.0.txt
@@ -0,0 +1,8 @@
+package android.arch.core.util {
+
+ public abstract interface Function<I, O> {
+ method public abstract O apply(I);
+ }
+
+}
+
diff --git a/buildSrc/src/main/java/android/support/LibraryVersions.java b/buildSrc/src/main/java/android/support/LibraryVersions.java
index 0378a65..813d9a8 100644
--- a/buildSrc/src/main/java/android/support/LibraryVersions.java
+++ b/buildSrc/src/main/java/android/support/LibraryVersions.java
@@ -26,19 +26,14 @@
public static final Version SUPPORT_LIBRARY = new Version("28.0.0-SNAPSHOT");
/**
- * Version code for flatfoot 1.0 projects (room, lifecycles)
- */
- private static final Version FLATFOOT_1_0_BATCH = new Version("1.1.0-SNAPSHOT");
-
- /**
* Version code for Room
*/
- public static final Version ROOM = FLATFOOT_1_0_BATCH;
+ public static final Version ROOM = new Version("1.1.0-alpha1");
/**
* Version code for Lifecycle extensions (ProcessLifecycleOwner, Fragment support)
*/
- public static final Version LIFECYCLES_EXT = new Version("1.1.0-SNAPSHOT");
+ public static final Version LIFECYCLES_EXT = new Version("1.1.0");
/**
* Version code for Lifecycle LiveData
@@ -53,9 +48,9 @@
/**
* Version code for RecyclerView & Room paging
*/
- public static final Version PAGING = new Version("1.0.0-alpha4-1");
+ public static final Version PAGING = new Version("1.0.0-alpha5");
- private static final Version LIFECYCLES = new Version("1.0.3");
+ private static final Version LIFECYCLES = new Version("1.1.0");
/**
* Version code for Lifecycle libs that are required by the support library
@@ -70,15 +65,15 @@
/**
* Version code for shared code of flatfoot
*/
- public static final Version ARCH_CORE = new Version("1.0.0");
+ public static final Version ARCH_CORE = new Version("1.1.0");
/**
* Version code for shared code of flatfoot runtime
*/
- public static final Version ARCH_RUNTIME = FLATFOOT_1_0_BATCH;
+ public static final Version ARCH_RUNTIME = ARCH_CORE;
/**
* Version code for shared testing code of flatfoot
*/
- public static final Version ARCH_CORE_TESTING = FLATFOOT_1_0_BATCH;
+ public static final Version ARCH_CORE_TESTING = ARCH_CORE;
}
diff --git a/buildSrc/src/main/kotlin/android/support/DiffAndDocs.kt b/buildSrc/src/main/kotlin/android/support/DiffAndDocs.kt
index b96260c..b0eadcd 100644
--- a/buildSrc/src/main/kotlin/android/support/DiffAndDocs.kt
+++ b/buildSrc/src/main/kotlin/android/support/DiffAndDocs.kt
@@ -128,7 +128,7 @@
private fun getApiFile(rootDir: File, refVersion: Version, forceRelease: Boolean = false): File {
val apiDir = File(rootDir, "api")
- if (!refVersion.isSnapshot() || forceRelease) {
+ if (refVersion.isFinalApi() || forceRelease) {
// Release API file is always X.Y.0.txt.
return File(apiDir, "${refVersion.major}.${refVersion.minor}.0.txt")
}
@@ -148,11 +148,11 @@
if (version.isPatch()) {
throw GradleException("Public APIs may not be modified in patch releases.")
- } else if (version.isSnapshot() && getApiFile(rootFolder,
+ } else if (!version.isFinalApi() && getApiFile(rootFolder,
version,
true).exists()) {
throw GradleException("Inconsistent version. Public API file already exists.")
- } else if (!version.isSnapshot() && getApiFile(rootFolder, version).exists()
+ } else if (version.isFinalApi() && getApiFile(rootFolder, version).exists()
&& !project.hasProperty("force")) {
throw GradleException("Public APIs may not be modified in finalized releases.")
}
diff --git a/buildSrc/src/main/kotlin/android/support/Version.kt b/buildSrc/src/main/kotlin/android/support/Version.kt
index 0a9d945..6348b0c 100644
--- a/buildSrc/src/main/kotlin/android/support/Version.kt
+++ b/buildSrc/src/main/kotlin/android/support/Version.kt
@@ -41,6 +41,10 @@
fun isSnapshot(): Boolean = "-SNAPSHOT" == extra
+ fun isAlpha(): Boolean = extra?.toLowerCase()?.startsWith("-alpha") ?: false
+
+ fun isFinalApi(): Boolean = !isSnapshot() && !isAlpha()
+
override fun compareTo(other: Version) = compareValuesBy(this, other,
{ it.major },
{ it.minor },
diff --git a/core-utils/java/android/support/v4/content/Loader.java b/core-utils/java/android/support/v4/content/Loader.java
index 2ac10d7..431964d 100644
--- a/core-utils/java/android/support/v4/content/Loader.java
+++ b/core-utils/java/android/support/v4/content/Loader.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.database.ContentObserver;
import android.os.Handler;
+import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.DebugUtils;
@@ -123,6 +124,7 @@
*
* @param data the result of the load
*/
+ @MainThread
public void deliverResult(@Nullable D data) {
if (mListener != null) {
mListener.onLoadComplete(this, data);
@@ -135,6 +137,7 @@
*
* Must be called from the process's main thread.
*/
+ @MainThread
public void deliverCancellation() {
if (mOnLoadCanceledListener != null) {
mOnLoadCanceledListener.onLoadCanceled(this);
@@ -163,6 +166,7 @@
*
* <p>Must be called from the process's main thread.
*/
+ @MainThread
public void registerListener(int id, @NonNull OnLoadCompleteListener<D> listener) {
if (mListener != null) {
throw new IllegalStateException("There is already a listener registered");
@@ -176,6 +180,7 @@
*
* Must be called from the process's main thread.
*/
+ @MainThread
public void unregisterListener(@NonNull OnLoadCompleteListener<D> listener) {
if (mListener == null) {
throw new IllegalStateException("No listener register");
@@ -195,6 +200,7 @@
*
* @param listener The listener to register.
*/
+ @MainThread
public void registerOnLoadCanceledListener(@NonNull OnLoadCanceledListener<D> listener) {
if (mOnLoadCanceledListener != null) {
throw new IllegalStateException("There is already a listener registered");
@@ -210,6 +216,7 @@
*
* @param listener The listener to unregister.
*/
+ @MainThread
public void unregisterOnLoadCanceledListener(@NonNull OnLoadCanceledListener<D> listener) {
if (mOnLoadCanceledListener == null) {
throw new IllegalStateException("No listener register");
@@ -268,6 +275,7 @@
*
* <p>Must be called from the process's main thread.
*/
+ @MainThread
public final void startLoading() {
mStarted = true;
mReset = false;
@@ -279,7 +287,9 @@
* Subclasses must implement this to take care of loading their data,
* as per {@link #startLoading()}. This is not called by clients directly,
* but as a result of a call to {@link #startLoading()}.
+ * This will always be called from the process's main thread.
*/
+ @MainThread
protected void onStartLoading() {
}
@@ -301,6 +311,7 @@
* is still running and the {@link OnLoadCanceledListener} will be called
* when the task completes.
*/
+ @MainThread
public boolean cancelLoad() {
return onCancelLoad();
}
@@ -316,6 +327,7 @@
* is still running and the {@link OnLoadCanceledListener} will be called
* when the task completes.
*/
+ @MainThread
protected boolean onCancelLoad() {
return false;
}
@@ -328,6 +340,7 @@
*
* <p>Must be called from the process's main thread.
*/
+ @MainThread
public void forceLoad() {
onForceLoad();
}
@@ -336,6 +349,7 @@
* Subclasses must implement this to take care of requests to {@link #forceLoad()}.
* This will always be called from the process's main thread.
*/
+ @MainThread
protected void onForceLoad() {
}
@@ -359,6 +373,7 @@
*
* <p>Must be called from the process's main thread.
*/
+ @MainThread
public void stopLoading() {
mStarted = false;
onStopLoading();
@@ -370,6 +385,7 @@
* but as a result of a call to {@link #stopLoading()}.
* This will always be called from the process's main thread.
*/
+ @MainThread
protected void onStopLoading() {
}
@@ -383,12 +399,15 @@
* Tell the Loader that it is being abandoned. This is called prior
* to {@link #reset} to have it retain its current data but not report
* any new data.
+ *
+ * <p>Must be called from the process's main thread.
*/
+ @MainThread
public void abandon() {
mAbandoned = true;
onAbandon();
}
-
+
/**
* Subclasses implement this to take care of being abandoned. This is
* an optional intermediate state prior to {@link #onReset()} -- it means that
@@ -397,10 +416,12 @@
* loader <em>must</em> keep its last reported data valid until the final
* {@link #onReset()} happens. You can retrieve the current abandoned
* state with {@link #isAbandoned}.
+ * This will always be called from the process's main thread.
*/
+ @MainThread
protected void onAbandon() {
}
-
+
/**
* This function will normally be called for you automatically by
* {@link android.support.v4.app.LoaderManager} when destroying a Loader. When using
@@ -419,6 +440,7 @@
*
* <p>Must be called from the process's main thread.
*/
+ @MainThread
public void reset() {
onReset();
mReset = true;
@@ -434,6 +456,7 @@
* but as a result of a call to {@link #reset()}.
* This will always be called from the process's main thread.
*/
+ @MainThread
protected void onReset() {
}
@@ -481,6 +504,7 @@
*
* <p>Must be called from the process's main thread.
*/
+ @MainThread
public void onContentChanged() {
if (mStarted) {
forceLoad();
diff --git a/fragment/src/main/java/android/support/v4/app/LoaderManager.java b/fragment/src/main/java/android/support/v4/app/LoaderManager.java
index 521b218..32e211a 100644
--- a/fragment/src/main/java/android/support/v4/app/LoaderManager.java
+++ b/fragment/src/main/java/android/support/v4/app/LoaderManager.java
@@ -16,8 +16,11 @@
package android.support.v4.app;
-import android.app.Activity;
import android.os.Bundle;
+import android.os.Looper;
+import android.support.annotation.MainThread;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.support.v4.content.Loader;
import android.support.v4.util.DebugUtils;
import android.support.v4.util.SparseArrayCompat;
@@ -44,11 +47,15 @@
/**
* Instantiate and return a new Loader for the given ID.
*
+ * <p>This will always be called from the process's main thread.
+ *
* @param id The ID whose loader is to be created.
* @param args Any arguments supplied by the caller.
* @return Return a new Loader instance that is ready to start loading.
*/
- public Loader<D> onCreateLoader(int id, Bundle args);
+ @MainThread
+ @NonNull
+ Loader<D> onCreateLoader(int id, @Nullable Bundle args);
/**
* Called when a previously created loader has finished its load. Note
@@ -86,19 +93,25 @@
* method so that the old Cursor is not closed.
* </ul>
*
+ * <p>This will always be called from the process's main thread.
+ *
* @param loader The Loader that has finished.
* @param data The data generated by the Loader.
*/
- public void onLoadFinished(Loader<D> loader, D data);
+ @MainThread
+ void onLoadFinished(@NonNull Loader<D> loader, D data);
/**
* Called when a previously created loader is being reset, and thus
* making its data unavailable. The application should at this point
* remove any references it has to the Loader's data.
*
+ * <p>This will always be called from the process's main thread.
+ *
* @param loader The Loader that is being reset.
*/
- public void onLoaderReset(Loader<D> loader);
+ @MainThread
+ void onLoaderReset(@NonNull Loader<D> loader);
}
/**
@@ -115,6 +128,8 @@
* be called immediately (inside of this function), so you must be prepared
* for this to happen.
*
+ * <p>Must be called from the process's main thread.
+ *
* @param id A unique identifier for this loader. Can be whatever you want.
* Identifiers are scoped to a particular LoaderManager instance.
* @param args Optional arguments to supply to the loader at construction.
@@ -123,8 +138,10 @@
* @param callback Interface the LoaderManager will call to report about
* changes in the state of the loader. Required.
*/
- public abstract <D> Loader<D> initLoader(int id, Bundle args,
- LoaderManager.LoaderCallbacks<D> callback);
+ @MainThread
+ @NonNull
+ public abstract <D> Loader<D> initLoader(int id, @Nullable Bundle args,
+ @NonNull LoaderManager.LoaderCallbacks<D> callback);
/**
* Starts a new or restarts an existing {@link android.content.Loader} in
@@ -135,27 +152,35 @@
* its work. The callback will be delivered before the old loader
* is destroyed.
*
+ * <p>Must be called from the process's main thread.
+ *
* @param id A unique identifier for this loader. Can be whatever you want.
* Identifiers are scoped to a particular LoaderManager instance.
* @param args Optional arguments to supply to the loader at construction.
* @param callback Interface the LoaderManager will call to report about
* changes in the state of the loader. Required.
*/
- public abstract <D> Loader<D> restartLoader(int id, Bundle args,
- LoaderManager.LoaderCallbacks<D> callback);
+ @MainThread
+ @NonNull
+ public abstract <D> Loader<D> restartLoader(int id, @Nullable Bundle args,
+ @NonNull LoaderManager.LoaderCallbacks<D> callback);
/**
* 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)}.
+ *
+ * <p>Must be called from the process's main thread.
*/
+ @MainThread
public abstract void destroyLoader(int id);
/**
* Return the Loader with the given id or null if no matching Loader
* is found.
*/
+ @Nullable
public abstract <D> Loader<D> getLoader(int id);
/**
@@ -378,7 +403,7 @@
}
@Override
- public void onLoadCanceled(Loader<Object> loader) {
+ public void onLoadCanceled(@NonNull Loader<Object> loader) {
if (DEBUG) Log.v(TAG, "onLoadCanceled: " + this);
if (mDestroyed) {
@@ -407,7 +432,7 @@
}
@Override
- public void onLoadComplete(Loader<Object> loader, Object data) {
+ public void onLoadComplete(@NonNull Loader<Object> loader, Object data) {
if (DEBUG) Log.v(TAG, "onLoadComplete: " + this);
if (mDestroyed) {
@@ -563,36 +588,18 @@
}
}
- /**
- * Call to initialize a particular ID with a Loader. If this ID already
- * has a Loader associated with it, it is left unchanged and any previous
- * callbacks replaced with the newly provided ones. If there is not currently
- * a Loader for the ID, a new one is created and started.
- *
- * <p>This function should generally be used when a component is initializing,
- * to ensure that a Loader it relies on is created. This allows it to re-use
- * an existing Loader's data if there already is one, so that for example
- * when an {@link Activity} is re-created after a configuration change it
- * does not need to re-create its loaders.
- *
- * <p>Note that in the case where an existing Loader is re-used, the
- * <var>args</var> given here <em>will be ignored</em> because you will
- * continue using the previous Loader.
- *
- * @param id A unique (to this LoaderManager instance) identifier under
- * which to manage the new Loader.
- * @param args Optional arguments that will be propagated to
- * {@link android.support.v4.app.LoaderManager.LoaderCallbacks#onCreateLoader(int, Bundle) LoaderCallbacks.onCreateLoader()}.
- * @param callback Interface implementing management of this Loader. Required.
- * Its onCreateLoader() method will be called while inside of the function to
- * instantiate the Loader object.
- */
+ @MainThread
+ @NonNull
@Override
@SuppressWarnings("unchecked")
- public <D> Loader<D> initLoader(int id, Bundle args, LoaderManager.LoaderCallbacks<D> callback) {
+ public <D> Loader<D> initLoader(int id, @Nullable Bundle args,
+ @NonNull LoaderManager.LoaderCallbacks<D> callback) {
if (mCreatingLoader) {
throw new IllegalStateException("Called while creating a loader");
}
+ if (Looper.getMainLooper() != Looper.myLooper()) {
+ throw new IllegalStateException("initLoader must be called on the main thread");
+ }
LoaderInfo info = mLoaders.get(id);
@@ -615,35 +622,18 @@
return (Loader<D>)info.mLoader;
}
- /**
- * Call to re-create the Loader associated with a particular ID. If there
- * is currently a Loader associated with this ID, it will be
- * canceled/stopped/destroyed as appropriate. A new Loader with the given
- * arguments will be created and its data delivered to you once available.
- *
- * <p>This function does some throttling of Loaders. If too many Loaders
- * have been created for the given ID but not yet generated their data,
- * new calls to this function will create and return a new Loader but not
- * actually start it until some previous loaders have completed.
- *
- * <p>After calling this function, any previous Loaders associated with
- * this ID will be considered invalid, and you will receive no further
- * data updates from them.
- *
- * @param id A unique (to this LoaderManager instance) identifier under
- * which to manage the new Loader.
- * @param args Optional arguments that will be propagated to
- * {@link android.support.v4.app.LoaderManager.LoaderCallbacks#onCreateLoader(int, Bundle) LoaderCallbacks.onCreateLoader()}.
- * @param callback Interface implementing management of this Loader. Required.
- * Its onCreateLoader() method will be called while inside of the function to
- * instantiate the Loader object.
- */
+ @MainThread
+ @NonNull
@Override
@SuppressWarnings("unchecked")
- public <D> Loader<D> restartLoader(int id, Bundle args, LoaderManager.LoaderCallbacks<D> callback) {
+ public <D> Loader<D> restartLoader(int id, @Nullable Bundle args,
+ @NonNull LoaderManager.LoaderCallbacks<D> callback) {
if (mCreatingLoader) {
throw new IllegalStateException("Called while creating a loader");
}
+ if (Looper.getMainLooper() != Looper.myLooper()) {
+ throw new IllegalStateException("restartLoader must be called on the main thread");
+ }
LoaderInfo info = mLoaders.get(id);
if (DEBUG) Log.v(TAG, "restartLoader in " + this + ": args=" + args);
@@ -701,18 +691,15 @@
return (Loader<D>)info.mLoader;
}
- /**
- * Rip down, tear apart, shred to pieces a current Loader ID. After returning
- * from this function, any Loader objects associated with this ID are
- * destroyed. Any data associated with them is destroyed. You better not
- * be using it when you do this.
- * @param id Identifier of the Loader to be destroyed.
- */
+ @MainThread
@Override
public void destroyLoader(int id) {
if (mCreatingLoader) {
throw new IllegalStateException("Called while creating a loader");
}
+ if (Looper.getMainLooper() != Looper.myLooper()) {
+ throw new IllegalStateException("destroyLoader must be called on the main thread");
+ }
if (DEBUG) Log.v(TAG, "destroyLoader in " + this + " of " + id);
int idx = mLoaders.indexOfKey(id);
@@ -732,10 +719,7 @@
}
}
- /**
- * Return the most recent Loader object associated with the
- * given ID.
- */
+ @Nullable
@Override
@SuppressWarnings("unchecked")
public <D> Loader<D> getLoader(int id) {
diff --git a/fragment/tests/java/android/support/v4/app/LoaderTest.java b/fragment/tests/java/android/support/v4/app/LoaderTest.java
index a3067bb..d3bfe44 100644
--- a/fragment/tests/java/android/support/v4/app/LoaderTest.java
+++ b/fragment/tests/java/android/support/v4/app/LoaderTest.java
@@ -24,12 +24,14 @@
import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;
+import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.support.testutils.FragmentActivityUtils;
+import android.support.testutils.RecreatedActivity;
import android.support.v4.app.test.LoaderActivity;
import android.support.v4.content.AsyncTaskLoader;
import android.support.v4.content.Loader;
@@ -49,7 +51,7 @@
@Rule
public ActivityTestRule<LoaderActivity> mActivityRule =
- new ActivityTestRule(LoaderActivity.class);
+ new ActivityTestRule<>(LoaderActivity.class);
/**
* Test to ensure that there is no Activity leak due to Loader
@@ -78,7 +80,8 @@
FragmentTestUtil.executePendingTransactions(mActivityRule, fm);
fm = null; // clear it so that it can be released
- WeakReference<LoaderActivity> weakActivity = new WeakReference(LoaderActivity.sActivity);
+ WeakReference<RecreatedActivity> weakActivity =
+ new WeakReference<>(LoaderActivity.sActivity);
activity = FragmentActivityUtils.recreateActivity(mActivityRule, activity);
@@ -109,6 +112,26 @@
assertEquals("Loaded!", activity.textView.getText().toString());
}
+ @Test(expected = IllegalStateException.class)
+ public void enforceOnMainThread_initLoader() {
+ LoaderActivity activity = mActivityRule.getActivity();
+ activity.getSupportLoaderManager().initLoader(-1, null,
+ new DummyLoaderCallbacks(activity));
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void enforceOnMainThread_restartLoader() {
+ LoaderActivity activity = mActivityRule.getActivity();
+ activity.getSupportLoaderManager().restartLoader(-1, null,
+ new DummyLoaderCallbacks(activity));
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void enforceOnMainThread_destroyLoader() {
+ LoaderActivity activity = mActivityRule.getActivity();
+ activity.getSupportLoaderManager().destroyLoader(-1);
+ }
+
/**
* When a change is interrupted with stop, the data in the LoaderManager remains stale.
*/
@@ -125,6 +148,7 @@
final Loader<String> loader =
activity.getSupportLoaderManager().initLoader(DELAY_LOADER, null,
new LoaderManager.LoaderCallbacks<String>() {
+ @NonNull
@Override
public Loader<String> onCreateLoader(int id, Bundle args) {
return new AsyncTaskLoader<String>(activity) {
@@ -150,13 +174,14 @@
}
@Override
- public void onLoadFinished(Loader<String> loader, String data) {
+ public void onLoadFinished(@NonNull Loader<String> loader,
+ String data) {
activity.textViewB.setText(data);
loadedLatch[0].countDown();
}
@Override
- public void onLoaderReset(Loader<String> loader) {
+ public void onLoaderReset(@NonNull Loader<String> loader) {
}
});
loader.forceLoad();
@@ -195,29 +220,35 @@
public static class LoaderFragment extends Fragment {
private static final int LOADER_ID = 1;
- private final LoaderManager.LoaderCallbacks<Boolean> mLoaderCallbacks =
- new LoaderManager.LoaderCallbacks<Boolean>() {
- @Override
- public Loader<Boolean> onCreateLoader(int id, Bundle args) {
- return new DummyLoader(getContext());
- }
-
- @Override
- public void onLoadFinished(Loader<Boolean> loader, Boolean data) {
-
- }
-
- @Override
- public void onLoaderReset(Loader<Boolean> loader) {
-
- }
- };
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- getLoaderManager().initLoader(LOADER_ID, null, mLoaderCallbacks);
+ getLoaderManager().initLoader(LOADER_ID, null,
+ new DummyLoaderCallbacks(getContext()));
+ }
+ }
+
+ static class DummyLoaderCallbacks implements LoaderManager.LoaderCallbacks<Boolean> {
+ private final Context mContext;
+
+ DummyLoaderCallbacks(Context context) {
+ mContext = context;
+ }
+
+ @NonNull
+ @Override
+ public Loader<Boolean> onCreateLoader(int id, Bundle args) {
+ return new DummyLoader(mContext);
+ }
+
+ @Override
+ public void onLoadFinished(@NonNull Loader<Boolean> loader, Boolean data) {
+ }
+
+ @Override
+ public void onLoaderReset(@NonNull Loader<Boolean> loader) {
}
}
diff --git a/fragment/tests/java/android/support/v4/app/test/LoaderActivity.java b/fragment/tests/java/android/support/v4/app/test/LoaderActivity.java
index 2990f0a..812cc97 100644
--- a/fragment/tests/java/android/support/v4/app/test/LoaderActivity.java
+++ b/fragment/tests/java/android/support/v4/app/test/LoaderActivity.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.os.Bundle;
+import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.fragment.test.R;
import android.support.testutils.RecreatedActivity;
@@ -50,18 +51,19 @@
}
class TextLoaderCallback implements LoaderManager.LoaderCallbacks<String> {
+ @NonNull
@Override
public Loader<String> onCreateLoader(int id, Bundle args) {
return new TextLoader(LoaderActivity.this);
}
@Override
- public void onLoadFinished(Loader<String> loader, String data) {
+ public void onLoadFinished(@NonNull Loader<String> loader, String data) {
textView.setText(data);
}
@Override
- public void onLoaderReset(Loader<String> loader) {
+ public void onLoaderReset(@NonNull Loader<String> loader) {
}
}
diff --git a/lifecycle/extensions/api/1.1.0.txt b/lifecycle/extensions/api/1.1.0.txt
new file mode 100644
index 0000000..8bd7d59
--- /dev/null
+++ b/lifecycle/extensions/api/1.1.0.txt
@@ -0,0 +1,42 @@
+package android.arch.lifecycle {
+
+ public class LifecycleService extends android.app.Service implements android.arch.lifecycle.LifecycleOwner {
+ ctor public LifecycleService();
+ method public android.arch.lifecycle.Lifecycle getLifecycle();
+ method public android.os.IBinder onBind(android.content.Intent);
+ method public void onStart(android.content.Intent, int);
+ }
+
+ public class ProcessLifecycleOwner implements android.arch.lifecycle.LifecycleOwner {
+ method public static android.arch.lifecycle.LifecycleOwner get();
+ method public android.arch.lifecycle.Lifecycle getLifecycle();
+ }
+
+ public class ServiceLifecycleDispatcher {
+ ctor public ServiceLifecycleDispatcher(android.arch.lifecycle.LifecycleOwner);
+ method public android.arch.lifecycle.Lifecycle getLifecycle();
+ method public void onServicePreSuperOnBind();
+ method public void onServicePreSuperOnCreate();
+ method public void onServicePreSuperOnDestroy();
+ method public void onServicePreSuperOnStart();
+ }
+
+ public class ViewModelProviders {
+ ctor public deprecated ViewModelProviders();
+ method public static android.arch.lifecycle.ViewModelProvider of(android.support.v4.app.Fragment);
+ method public static android.arch.lifecycle.ViewModelProvider of(android.support.v4.app.FragmentActivity);
+ method public static android.arch.lifecycle.ViewModelProvider of(android.support.v4.app.Fragment, android.arch.lifecycle.ViewModelProvider.Factory);
+ method public static android.arch.lifecycle.ViewModelProvider of(android.support.v4.app.FragmentActivity, android.arch.lifecycle.ViewModelProvider.Factory);
+ }
+
+ public static deprecated class ViewModelProviders.DefaultFactory extends android.arch.lifecycle.ViewModelProvider.AndroidViewModelFactory {
+ ctor public deprecated ViewModelProviders.DefaultFactory(android.app.Application);
+ }
+
+ public class ViewModelStores {
+ method public static android.arch.lifecycle.ViewModelStore of(android.support.v4.app.FragmentActivity);
+ method public static android.arch.lifecycle.ViewModelStore of(android.support.v4.app.Fragment);
+ }
+
+}
+
diff --git a/lifecycle/livedata-core/api/1.1.0.txt b/lifecycle/livedata-core/api/1.1.0.txt
new file mode 100644
index 0000000..0c855c4
--- /dev/null
+++ b/lifecycle/livedata-core/api/1.1.0.txt
@@ -0,0 +1,29 @@
+package android.arch.lifecycle {
+
+ public abstract class LiveData<T> {
+ ctor public LiveData();
+ method public T getValue();
+ method public boolean hasActiveObservers();
+ method public boolean hasObservers();
+ method public void observe(android.arch.lifecycle.LifecycleOwner, android.arch.lifecycle.Observer<T>);
+ method public void observeForever(android.arch.lifecycle.Observer<T>);
+ method protected void onActive();
+ method protected void onInactive();
+ method protected void postValue(T);
+ method public void removeObserver(android.arch.lifecycle.Observer<T>);
+ method public void removeObservers(android.arch.lifecycle.LifecycleOwner);
+ method protected void setValue(T);
+ }
+
+ public class MutableLiveData<T> extends android.arch.lifecycle.LiveData {
+ ctor public MutableLiveData();
+ method public void postValue(T);
+ method public void setValue(T);
+ }
+
+ public abstract interface Observer<T> {
+ method public abstract void onChanged(T);
+ }
+
+}
+
diff --git a/lifecycle/livedata/api/1.1.0.txt b/lifecycle/livedata/api/1.1.0.txt
new file mode 100644
index 0000000..f9783ec
--- /dev/null
+++ b/lifecycle/livedata/api/1.1.0.txt
@@ -0,0 +1,15 @@
+package android.arch.lifecycle {
+
+ public class MediatorLiveData<T> extends android.arch.lifecycle.MutableLiveData {
+ ctor public MediatorLiveData();
+ method public <S> void addSource(android.arch.lifecycle.LiveData<S>, android.arch.lifecycle.Observer<S>);
+ method public <S> void removeSource(android.arch.lifecycle.LiveData<S>);
+ }
+
+ public class Transformations {
+ method public static <X, Y> android.arch.lifecycle.LiveData<Y> map(android.arch.lifecycle.LiveData<X>, android.arch.core.util.Function<X, Y>);
+ method public static <X, Y> android.arch.lifecycle.LiveData<Y> switchMap(android.arch.lifecycle.LiveData<X>, android.arch.core.util.Function<X, android.arch.lifecycle.LiveData<Y>>);
+ }
+
+}
+
diff --git a/lifecycle/reactivestreams/api/1.1.0.txt b/lifecycle/reactivestreams/api/1.1.0.txt
new file mode 100644
index 0000000..4a509e9
--- /dev/null
+++ b/lifecycle/reactivestreams/api/1.1.0.txt
@@ -0,0 +1,9 @@
+package android.arch.lifecycle {
+
+ public final class LiveDataReactiveStreams {
+ method public static <T> android.arch.lifecycle.LiveData<T> fromPublisher(org.reactivestreams.Publisher<T>);
+ method public static <T> org.reactivestreams.Publisher<T> toPublisher(android.arch.lifecycle.LifecycleOwner, android.arch.lifecycle.LiveData<T>);
+ }
+
+}
+
diff --git a/lifecycle/runtime/api/1.1.0.txt b/lifecycle/runtime/api/1.1.0.txt
new file mode 100644
index 0000000..2b900b0
--- /dev/null
+++ b/lifecycle/runtime/api/1.1.0.txt
@@ -0,0 +1,18 @@
+package android.arch.lifecycle {
+
+ public class LifecycleRegistry extends android.arch.lifecycle.Lifecycle {
+ ctor public LifecycleRegistry(android.arch.lifecycle.LifecycleOwner);
+ method public void addObserver(android.arch.lifecycle.LifecycleObserver);
+ method public android.arch.lifecycle.Lifecycle.State getCurrentState();
+ method public int getObserverCount();
+ method public void handleLifecycleEvent(android.arch.lifecycle.Lifecycle.Event);
+ method public void markState(android.arch.lifecycle.Lifecycle.State);
+ method public void removeObserver(android.arch.lifecycle.LifecycleObserver);
+ }
+
+ public abstract deprecated interface LifecycleRegistryOwner implements android.arch.lifecycle.LifecycleOwner {
+ method public abstract android.arch.lifecycle.LifecycleRegistry getLifecycle();
+ }
+
+}
+
diff --git a/lifecycle/viewmodel/api/1.1.0.txt b/lifecycle/viewmodel/api/1.1.0.txt
new file mode 100644
index 0000000..6a82d4c
--- /dev/null
+++ b/lifecycle/viewmodel/api/1.1.0.txt
@@ -0,0 +1,44 @@
+package android.arch.lifecycle {
+
+ public class AndroidViewModel extends android.arch.lifecycle.ViewModel {
+ ctor public AndroidViewModel(android.app.Application);
+ method public <T extends android.app.Application> T getApplication();
+ }
+
+ public abstract class ViewModel {
+ ctor public ViewModel();
+ method protected void onCleared();
+ }
+
+ public class ViewModelProvider {
+ ctor public ViewModelProvider(android.arch.lifecycle.ViewModelStoreOwner, android.arch.lifecycle.ViewModelProvider.Factory);
+ ctor public ViewModelProvider(android.arch.lifecycle.ViewModelStore, android.arch.lifecycle.ViewModelProvider.Factory);
+ method public <T extends android.arch.lifecycle.ViewModel> T get(java.lang.Class<T>);
+ method public <T extends android.arch.lifecycle.ViewModel> T get(java.lang.String, java.lang.Class<T>);
+ }
+
+ public static class ViewModelProvider.AndroidViewModelFactory extends android.arch.lifecycle.ViewModelProvider.NewInstanceFactory {
+ ctor public ViewModelProvider.AndroidViewModelFactory(android.app.Application);
+ method public static android.arch.lifecycle.ViewModelProvider.AndroidViewModelFactory getInstance(android.app.Application);
+ }
+
+ public static abstract interface ViewModelProvider.Factory {
+ method public abstract <T extends android.arch.lifecycle.ViewModel> T create(java.lang.Class<T>);
+ }
+
+ public static class ViewModelProvider.NewInstanceFactory implements android.arch.lifecycle.ViewModelProvider.Factory {
+ ctor public ViewModelProvider.NewInstanceFactory();
+ method public <T extends android.arch.lifecycle.ViewModel> T create(java.lang.Class<T>);
+ }
+
+ public class ViewModelStore {
+ ctor public ViewModelStore();
+ method public final void clear();
+ }
+
+ public abstract interface ViewModelStoreOwner {
+ method public abstract android.arch.lifecycle.ViewModelStore getViewModelStore();
+ }
+
+}
+
diff --git a/paging/common/src/main/java/android/arch/paging/TiledDataSource.java b/paging/common/src/main/java/android/arch/paging/TiledDataSource.java
index 77695e5..7285aa4 100644
--- a/paging/common/src/main/java/android/arch/paging/TiledDataSource.java
+++ b/paging/common/src/main/java/android/arch/paging/TiledDataSource.java
@@ -23,6 +23,8 @@
import java.util.Collections;
import java.util.List;
+// NOTE: Room 1.0 depends on this class, so it should not be removed until
+// we can require a version of Room that uses PositionalDataSource directly
/**
* @param <T> Type loaded by the TiledDataSource.
*
@@ -60,9 +62,11 @@
// convert from legacy behavior
List<T> list = loadRange(firstLoadPosition, firstLoadSize);
- if (list != null) {
+ if (list != null && list.size() == firstLoadSize) {
callback.onResult(list, firstLoadPosition, totalCount);
} else {
+ // null list, or size doesn't match request
+ // The size check is a WAR for Room 1.0, subsequent versions do the check in Room
invalidate();
}
}
diff --git a/paging/runtime/src/main/java/android/arch/paging/LivePagedListProvider.java b/paging/runtime/src/main/java/android/arch/paging/LivePagedListProvider.java
index 44b71a8..74334ee 100644
--- a/paging/runtime/src/main/java/android/arch/paging/LivePagedListProvider.java
+++ b/paging/runtime/src/main/java/android/arch/paging/LivePagedListProvider.java
@@ -22,8 +22,8 @@
import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
-// NOTE: Room 1.0 depends on this class, so it should not be removed
-// until Room switches to using DataSource.Factory directly
+// NOTE: Room 1.0 depends on this class, so it should not be removed until
+// we can require a version of Room that uses DataSource.Factory directly
/**
* Provides a {@code LiveData<PagedList>}, given a means to construct a DataSource.
* <p>
diff --git a/room/compiler/src/main/kotlin/android/arch/persistence/room/ext/javapoet_ext.kt b/room/compiler/src/main/kotlin/android/arch/persistence/room/ext/javapoet_ext.kt
index 5893e8f..3880df7 100644
--- a/room/compiler/src/main/kotlin/android/arch/persistence/room/ext/javapoet_ext.kt
+++ b/room/compiler/src/main/kotlin/android/arch/persistence/room/ext/javapoet_ext.kt
@@ -94,10 +94,10 @@
object PagingTypeNames {
val DATA_SOURCE: ClassName =
ClassName.get("android.arch.paging", "DataSource")
- val TILED_DATA_SOURCE: ClassName =
- ClassName.get("android.arch.paging", "TiledDataSource")
- val LIVE_PAGED_LIST_PROVIDER: ClassName =
- ClassName.get("android.arch.paging", "LivePagedListProvider")
+ val POSITIONAL_DATA_SOURCE: ClassName =
+ ClassName.get("android.arch.paging", "PositionalDataSource")
+ val DATA_SOURCE_FACTORY: ClassName =
+ ClassName.get("android.arch.paging", "DataSource.Factory")
}
object LifecyclesTypeNames {
diff --git a/room/compiler/src/main/kotlin/android/arch/persistence/room/processor/ProcessorErrors.kt b/room/compiler/src/main/kotlin/android/arch/persistence/room/processor/ProcessorErrors.kt
index 88961e7..7087059 100644
--- a/room/compiler/src/main/kotlin/android/arch/persistence/room/processor/ProcessorErrors.kt
+++ b/room/compiler/src/main/kotlin/android/arch/persistence/room/processor/ProcessorErrors.kt
@@ -481,7 +481,7 @@
fetched after the object is constructed.
""".trim()
- val PAGING_SPECIFY_DATA_SOURCE_TYPE = "For now, Room only supports TiledDataSource class."
+ val PAGING_SPECIFY_DATA_SOURCE_TYPE = "For now, Room only supports PositionalDataSource class."
fun primaryKeyNull(field: String): String {
return "You must annotate primary keys with @NonNull. \"$field\" is nullable. SQLite " +
diff --git a/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/TypeAdapterStore.kt b/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/TypeAdapterStore.kt
index c465d4a..7abad86 100644
--- a/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/TypeAdapterStore.kt
+++ b/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/TypeAdapterStore.kt
@@ -29,7 +29,7 @@
import android.arch.persistence.room.solver.binderprovider.FlowableQueryResultBinderProvider
import android.arch.persistence.room.solver.binderprovider.InstantQueryResultBinderProvider
import android.arch.persistence.room.solver.binderprovider.LiveDataQueryResultBinderProvider
-import android.arch.persistence.room.solver.binderprovider.LivePagedListQueryResultBinderProvider
+import android.arch.persistence.room.solver.binderprovider.DataSourceFactoryQueryResultBinderProvider
import android.arch.persistence.room.solver.binderprovider.RxMaybeQueryResultBinderProvider
import android.arch.persistence.room.solver.binderprovider.RxSingleQueryResultBinderProvider
import android.arch.persistence.room.solver.query.parameter.ArrayQueryParameterAdapter
@@ -135,7 +135,7 @@
RxMaybeQueryResultBinderProvider(context),
RxSingleQueryResultBinderProvider(context),
DataSourceQueryResultBinderProvider(context),
- LivePagedListQueryResultBinderProvider(context),
+ DataSourceFactoryQueryResultBinderProvider(context),
InstantQueryResultBinderProvider(context)
)
diff --git a/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/binderprovider/LivePagedListQueryResultBinderProvider.kt b/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/binderprovider/DataSourceFactoryQueryResultBinderProvider.kt
similarity index 78%
rename from room/compiler/src/main/kotlin/android/arch/persistence/room/solver/binderprovider/LivePagedListQueryResultBinderProvider.kt
rename to room/compiler/src/main/kotlin/android/arch/persistence/room/solver/binderprovider/DataSourceFactoryQueryResultBinderProvider.kt
index bbf1cea..4d0a280 100644
--- a/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/binderprovider/LivePagedListQueryResultBinderProvider.kt
+++ b/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/binderprovider/DataSourceFactoryQueryResultBinderProvider.kt
@@ -20,17 +20,17 @@
import android.arch.persistence.room.parser.ParsedQuery
import android.arch.persistence.room.processor.Context
import android.arch.persistence.room.solver.QueryResultBinderProvider
-import android.arch.persistence.room.solver.query.result.TiledDataSourceQueryResultBinder
+import android.arch.persistence.room.solver.query.result.PositionalDataSourceQueryResultBinder
import android.arch.persistence.room.solver.query.result.ListQueryResultAdapter
import android.arch.persistence.room.solver.query.result.LivePagedListQueryResultBinder
import android.arch.persistence.room.solver.query.result.QueryResultBinder
import javax.lang.model.type.DeclaredType
import javax.lang.model.type.TypeMirror
-class LivePagedListQueryResultBinderProvider(val context: Context) : QueryResultBinderProvider {
- private val livePagedListTypeMirror: TypeMirror? by lazy {
+class DataSourceFactoryQueryResultBinderProvider(val context: Context) : QueryResultBinderProvider {
+ private val dataSourceFactoryTypeMirror: TypeMirror? by lazy {
context.processingEnv.elementUtils
- .getTypeElement(PagingTypeNames.LIVE_PAGED_LIST_PROVIDER.toString())?.asType()
+ .getTypeElement(PagingTypeNames.DATA_SOURCE_FACTORY.toString())?.asType()
}
override fun provide(declared: DeclaredType, query: ParsedQuery): QueryResultBinder {
@@ -38,7 +38,7 @@
val listAdapter = context.typeAdapterStore.findRowAdapter(typeArg, query)?.let {
ListQueryResultAdapter(it)
}
- val countedBinder = TiledDataSourceQueryResultBinder(listAdapter,
+ val countedBinder = PositionalDataSourceQueryResultBinder(listAdapter,
query.tables.map { it.name })
return LivePagedListQueryResultBinder(countedBinder)
}
@@ -47,11 +47,11 @@
declared.typeArguments.size == 2 && isLivePagedList(declared)
private fun isLivePagedList(declared: DeclaredType): Boolean {
- if (livePagedListTypeMirror == null) {
+ if (dataSourceFactoryTypeMirror == null) {
return false
}
val erasure = context.processingEnv.typeUtils.erasure(declared)
// we don't want to return paged list unless explicitly requested
- return context.processingEnv.typeUtils.isAssignable(livePagedListTypeMirror, erasure)
+ return context.processingEnv.typeUtils.isAssignable(dataSourceFactoryTypeMirror, erasure)
}
-}
\ No newline at end of file
+}
diff --git a/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/binderprovider/DataSourceQueryResultBinderProvider.kt b/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/binderprovider/DataSourceQueryResultBinderProvider.kt
index 71570f2..c13354e 100644
--- a/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/binderprovider/DataSourceQueryResultBinderProvider.kt
+++ b/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/binderprovider/DataSourceQueryResultBinderProvider.kt
@@ -21,7 +21,7 @@
import android.arch.persistence.room.processor.Context
import android.arch.persistence.room.processor.ProcessorErrors
import android.arch.persistence.room.solver.QueryResultBinderProvider
-import android.arch.persistence.room.solver.query.result.TiledDataSourceQueryResultBinder
+import android.arch.persistence.room.solver.query.result.PositionalDataSourceQueryResultBinder
import android.arch.persistence.room.solver.query.result.ListQueryResultAdapter
import android.arch.persistence.room.solver.query.result.QueryResultBinder
import javax.lang.model.type.DeclaredType
@@ -33,9 +33,9 @@
.getTypeElement(PagingTypeNames.DATA_SOURCE.toString())?.asType()
}
- private val tiledDataSourceTypeMirror: TypeMirror? by lazy {
+ private val positionalDataSourceTypeMirror: TypeMirror? by lazy {
context.processingEnv.elementUtils
- .getTypeElement(PagingTypeNames.TILED_DATA_SOURCE.toString())?.asType()
+ .getTypeElement(PagingTypeNames.POSITIONAL_DATA_SOURCE.toString())?.asType()
}
override fun provide(declared: DeclaredType, query: ParsedQuery): QueryResultBinder {
@@ -43,11 +43,11 @@
val listAdapter = context.typeAdapterStore.findRowAdapter(typeArg, query)?.let {
ListQueryResultAdapter(it)
}
- return TiledDataSourceQueryResultBinder(listAdapter, query.tables.map { it.name })
+ return PositionalDataSourceQueryResultBinder(listAdapter, query.tables.map { it.name })
}
override fun matches(declared: DeclaredType): Boolean {
- if (dataSourceTypeMirror == null || tiledDataSourceTypeMirror == null) {
+ if (dataSourceTypeMirror == null || positionalDataSourceTypeMirror == null) {
return false
}
if (declared.typeArguments.isEmpty()) {
@@ -59,11 +59,11 @@
if (!isDataSource) {
return false
}
- val isTiled = context.processingEnv.typeUtils
- .isAssignable(erasure, tiledDataSourceTypeMirror)
- if (!isTiled) {
+ val isPositional = context.processingEnv.typeUtils
+ .isAssignable(erasure, positionalDataSourceTypeMirror)
+ if (!isPositional) {
context.logger.e(ProcessorErrors.PAGING_SPECIFY_DATA_SOURCE_TYPE)
}
return true
}
-}
\ No newline at end of file
+}
diff --git a/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/query/result/LivePagedListQueryResultBinder.kt b/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/query/result/LivePagedListQueryResultBinder.kt
index 25d8416..5daf7d4 100644
--- a/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/query/result/LivePagedListQueryResultBinder.kt
+++ b/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/query/result/LivePagedListQueryResultBinder.kt
@@ -27,10 +27,10 @@
import javax.lang.model.element.Modifier
class LivePagedListQueryResultBinder(
- val tiledDataSourceQueryResultBinder: TiledDataSourceQueryResultBinder)
- : QueryResultBinder(tiledDataSourceQueryResultBinder.listAdapter) {
+ val positionalDataSourceQueryResultBinder: PositionalDataSourceQueryResultBinder)
+ : QueryResultBinder(positionalDataSourceQueryResultBinder.listAdapter) {
@Suppress("HasPlatformType")
- val typeName = tiledDataSourceQueryResultBinder.itemTypeName
+ val typeName = positionalDataSourceQueryResultBinder.itemTypeName
override fun convertAndReturn(
roomSQLiteQueryVar: String,
canReleaseQuery: Boolean,
@@ -41,9 +41,9 @@
scope.builder().apply {
val pagedListProvider = TypeSpec
.anonymousClassBuilder("").apply {
- superclass(ParameterizedTypeName.get(PagingTypeNames.LIVE_PAGED_LIST_PROVIDER,
+ superclass(ParameterizedTypeName.get(PagingTypeNames.DATA_SOURCE_FACTORY,
Integer::class.typeName(), typeName))
- addMethod(createCreateDataSourceMethod(
+ addMethod(createCreateMethod(
roomSQLiteQueryVar = roomSQLiteQueryVar,
dbField = dbField,
inTransaction = inTransaction,
@@ -53,17 +53,17 @@
}
}
- private fun createCreateDataSourceMethod(
+ private fun createCreateMethod(
roomSQLiteQueryVar: String,
dbField: FieldSpec,
inTransaction: Boolean,
scope: CodeGenScope
- ): MethodSpec = MethodSpec.methodBuilder("createDataSource").apply {
+ ): MethodSpec = MethodSpec.methodBuilder("create").apply {
addAnnotation(Override::class.java)
- addModifiers(Modifier.PROTECTED)
- returns(tiledDataSourceQueryResultBinder.typeName)
+ addModifiers(Modifier.PUBLIC)
+ returns(positionalDataSourceQueryResultBinder.typeName)
val countedBinderScope = scope.fork()
- tiledDataSourceQueryResultBinder.convertAndReturn(
+ positionalDataSourceQueryResultBinder.convertAndReturn(
roomSQLiteQueryVar = roomSQLiteQueryVar,
canReleaseQuery = true,
dbField = dbField,
diff --git a/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/query/result/TiledDataSourceQueryResultBinder.kt b/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/query/result/PositionalDataSourceQueryResultBinder.kt
similarity index 91%
rename from room/compiler/src/main/kotlin/android/arch/persistence/room/solver/query/result/TiledDataSourceQueryResultBinder.kt
rename to room/compiler/src/main/kotlin/android/arch/persistence/room/solver/query/result/PositionalDataSourceQueryResultBinder.kt
index 19917ff..ac5a256 100644
--- a/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/query/result/TiledDataSourceQueryResultBinder.kt
+++ b/room/compiler/src/main/kotlin/android/arch/persistence/room/solver/query/result/PositionalDataSourceQueryResultBinder.kt
@@ -31,9 +31,9 @@
import com.squareup.javapoet.TypeSpec
import javax.lang.model.element.Modifier
-class TiledDataSourceQueryResultBinder(val listAdapter: ListQueryResultAdapter?,
- val tableNames: List<String>)
- : QueryResultBinder(listAdapter) {
+class PositionalDataSourceQueryResultBinder(
+ val listAdapter: ListQueryResultAdapter?,
+ val tableNames: List<String>) : QueryResultBinder(listAdapter) {
val itemTypeName: TypeName = listAdapter?.rowAdapter?.out?.typeName() ?: TypeName.OBJECT
val typeName: ParameterizedTypeName = ParameterizedTypeName.get(
RoomTypeNames.LIMIT_OFFSET_DATA_SOURCE, itemTypeName)
@@ -53,7 +53,7 @@
}
}
- fun createConvertRowsMethod(scope: CodeGenScope): MethodSpec =
+ private fun createConvertRowsMethod(scope: CodeGenScope): MethodSpec =
MethodSpec.methodBuilder("convertRows").apply {
addAnnotation(Override::class.java)
addModifiers(Modifier.PROTECTED)
@@ -67,4 +67,4 @@
addCode(rowsScope.builder().build())
addStatement("return $L", resultVar)
}.build()
-}
\ No newline at end of file
+}
diff --git a/room/compiler/src/test/data/common/input/LivePagedListProvider.java b/room/compiler/src/test/data/common/input/DataSource.java
similarity index 80%
rename from room/compiler/src/test/data/common/input/LivePagedListProvider.java
rename to room/compiler/src/test/data/common/input/DataSource.java
index b7c68dd..9f51539 100644
--- a/room/compiler/src/test/data/common/input/LivePagedListProvider.java
+++ b/room/compiler/src/test/data/common/input/DataSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,5 +16,7 @@
package android.arch.paging;
-abstract public class LivePagedListProvider<K, T> {
-}
\ No newline at end of file
+abstract public class DataSource<K, T> {
+ public interface Factory<Key, Value> {
+ }
+}
diff --git a/room/compiler/src/test/kotlin/android/arch/persistence/room/solver/TypeAdapterStoreTest.kt b/room/compiler/src/test/kotlin/android/arch/persistence/room/solver/TypeAdapterStoreTest.kt
index 0148d2a..43c0aa4 100644
--- a/room/compiler/src/test/kotlin/android/arch/persistence/room/solver/TypeAdapterStoreTest.kt
+++ b/room/compiler/src/test/kotlin/android/arch/persistence/room/solver/TypeAdapterStoreTest.kt
@@ -17,6 +17,8 @@
package android.arch.persistence.room.solver
import COMMON
+import android.arch.paging.DataSource
+import android.arch.paging.PositionalDataSource
import android.arch.persistence.room.Entity
import android.arch.persistence.room.ext.L
import android.arch.persistence.room.ext.LifecyclesTypeNames
@@ -31,13 +33,11 @@
import android.arch.persistence.room.solver.binderprovider.DataSourceQueryResultBinderProvider
import android.arch.persistence.room.solver.binderprovider.FlowableQueryResultBinderProvider
import android.arch.persistence.room.solver.binderprovider.LiveDataQueryResultBinderProvider
-import android.arch.persistence.room.solver.binderprovider.LivePagedListQueryResultBinderProvider
+import android.arch.persistence.room.solver.binderprovider.DataSourceFactoryQueryResultBinderProvider
import android.arch.persistence.room.solver.types.CompositeAdapter
import android.arch.persistence.room.solver.types.TypeConverter
import android.arch.persistence.room.testing.TestInvocation
import android.arch.persistence.room.testing.TestProcessor
-import android.arch.paging.DataSource
-import android.arch.paging.TiledDataSource
import com.google.auto.common.MoreTypes
import com.google.common.truth.Truth
import com.google.testing.compile.CompileTester
@@ -263,11 +263,11 @@
}
@Test
- fun findTiledDataSource() {
+ fun findPositionalDataSource() {
simpleRun {
invocation ->
val dataSource = invocation.processingEnv.elementUtils
- .getTypeElement(TiledDataSource::class.java.canonicalName)
+ .getTypeElement(PositionalDataSource::class.java.canonicalName)
assertThat(dataSource, notNullValue())
assertThat(DataSourceQueryResultBinderProvider(invocation.context).matches(
MoreTypes.asDeclared(dataSource.asType())), `is`(true))
@@ -275,13 +275,13 @@
}
@Test
- fun findPagedListProvider() {
- simpleRun(jfos = COMMON.LIVE_PAGED_LIST_PROVIDER) {
+ fun findDataSourceFactory() {
+ simpleRun(jfos = COMMON.DATA_SOURCE_FACTORY) {
invocation ->
val pagedListProvider = invocation.processingEnv.elementUtils
- .getTypeElement(PagingTypeNames.LIVE_PAGED_LIST_PROVIDER.toString())
+ .getTypeElement(PagingTypeNames.DATA_SOURCE_FACTORY.toString())
assertThat(pagedListProvider, notNullValue())
- assertThat(LivePagedListQueryResultBinderProvider(invocation.context).matches(
+ assertThat(DataSourceFactoryQueryResultBinderProvider(invocation.context).matches(
MoreTypes.asDeclared(pagedListProvider.asType())), `is`(true))
}.compilesWithoutError()
}
diff --git a/room/compiler/src/test/kotlin/android/arch/persistence/room/testing/test_util.kt b/room/compiler/src/test/kotlin/android/arch/persistence/room/testing/test_util.kt
index 4d100b3..b657643 100644
--- a/room/compiler/src/test/kotlin/android/arch/persistence/room/testing/test_util.kt
+++ b/room/compiler/src/test/kotlin/android/arch/persistence/room/testing/test_util.kt
@@ -21,7 +21,6 @@
import android.arch.persistence.room.Query
import android.arch.persistence.room.Relation
import android.arch.persistence.room.ext.LifecyclesTypeNames
-import android.arch.persistence.room.ext.PagingTypeNames
import android.arch.persistence.room.ext.ReactiveStreamsTypeNames
import android.arch.persistence.room.ext.RoomRxJava2TypeNames
import android.arch.persistence.room.ext.RxJava2TypeNames
@@ -86,9 +85,8 @@
loadJavaCode("common/input/Rx2Room.java", RoomRxJava2TypeNames.RX_ROOM.toString())
}
- val LIVE_PAGED_LIST_PROVIDER by lazy {
- loadJavaCode("common/input/LivePagedListProvider.java",
- PagingTypeNames.LIVE_PAGED_LIST_PROVIDER.toString())
+ val DATA_SOURCE_FACTORY by lazy {
+ loadJavaCode("common/input/DataSource.java", "android.arch.paging.DataSource")
}
}
fun testCodeGenScope(): CodeGenScope {
diff --git a/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/dao/UserDao.java b/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/dao/UserDao.java
index 1a2a468..82a3583 100644
--- a/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/dao/UserDao.java
+++ b/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/dao/UserDao.java
@@ -18,8 +18,6 @@
import android.arch.lifecycle.LiveData;
import android.arch.paging.DataSource;
-import android.arch.paging.LivePagedListProvider;
-import android.arch.paging.TiledDataSource;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
@@ -190,16 +188,10 @@
@Query("SELECT * FROM user where mAge > :age")
public abstract DataSource.Factory<Integer, User> loadPagedByAge(int age);
- @Query("SELECT * FROM user where mAge > :age")
- public abstract LivePagedListProvider<Integer, User> loadPagedByAge_legacy(int age);
-
// TODO: switch to PositionalDataSource once Room supports it
@Query("SELECT * FROM user ORDER BY mAge DESC")
public abstract DataSource.Factory<Integer, User> loadUsersByAgeDesc();
- @Query("SELECT * FROM user ORDER BY mAge DESC")
- public abstract TiledDataSource<User> loadUsersByAgeDesc_legacy();
-
@Query("DELETE FROM User WHERE mId IN (:ids) AND mAge == :age")
public abstract int deleteByAgeAndIds(int age, List<Integer> ids);
diff --git a/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/paging/DataSourceFactoryTest.java b/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/paging/DataSourceFactoryTest.java
index b54abe8..0f68656 100644
--- a/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/paging/DataSourceFactoryTest.java
+++ b/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/paging/DataSourceFactoryTest.java
@@ -60,37 +60,13 @@
@Test
public void getUsersAsPagedList()
throws InterruptedException, ExecutionException, TimeoutException {
- validateUsersAsPagedList(new LivePagedListFactory() {
- @Override
- public LiveData<PagedList<User>> create() {
- return new LivePagedListBuilder<>(
- mUserDao.loadPagedByAge(3),
- new PagedList.Config.Builder()
- .setPageSize(10)
- .setPrefetchDistance(1)
- .setInitialLoadSizeHint(10).build())
- .build();
- }
- });
- }
-
-
- // TODO: delete this and factory abstraction when LivePagedListProvider is removed
- @Test
- public void getUsersAsPagedList_legacyLivePagedListProvider()
- throws InterruptedException, ExecutionException, TimeoutException {
- validateUsersAsPagedList(new LivePagedListFactory() {
- @Override
- public LiveData<PagedList<User>> create() {
- return mUserDao.loadPagedByAge_legacy(3).create(
- 0,
- new PagedList.Config.Builder()
- .setPageSize(10)
- .setPrefetchDistance(1)
- .setInitialLoadSizeHint(10)
- .build());
- }
- });
+ validateUsersAsPagedList(() -> new LivePagedListBuilder<>(
+ mUserDao.loadPagedByAge(3),
+ new PagedList.Config.Builder()
+ .setPageSize(10)
+ .setPrefetchDistance(1)
+ .setInitialLoadSizeHint(10).build())
+ .build());
}
private void validateUsersAsPagedList(LivePagedListFactory factory)
diff --git a/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/paging/LimitOffsetDataSourceTest.java b/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/paging/LimitOffsetDataSourceTest.java
index 7a2faf0..89359be 100644
--- a/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/paging/LimitOffsetDataSourceTest.java
+++ b/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/paging/LimitOffsetDataSourceTest.java
@@ -45,15 +45,6 @@
mUserDao.deleteEverything();
}
- // TODO: delete this and factory abstraction when LivePagedListProvider is removed
- @Test
- public void limitOffsetDataSource_legacyTiledDataSource() {
- // Simple verification that loading a TiledDataSource still works.
- LimitOffsetDataSource<User> dataSource =
- (LimitOffsetDataSource<User>) mUserDao.loadUsersByAgeDesc_legacy();
- assertThat(dataSource.countItems(), is(0));
- }
-
private LimitOffsetDataSource<User> loadUsersByAgeDesc() {
return (LimitOffsetDataSource<User>) mUserDao.loadUsersByAgeDesc().create();
}
diff --git a/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/test/QueryTransactionTest.java b/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/test/QueryTransactionTest.java
index f076cf1..292e588 100644
--- a/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/test/QueryTransactionTest.java
+++ b/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/test/QueryTransactionTest.java
@@ -28,7 +28,7 @@
import android.arch.paging.DataSource;
import android.arch.paging.LivePagedListBuilder;
import android.arch.paging.PagedList;
-import android.arch.paging.TiledDataSource;
+import android.arch.paging.PositionalDataSource;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Database;
import android.arch.persistence.room.Entity;
@@ -41,6 +41,7 @@
import android.arch.persistence.room.RoomDatabase;
import android.arch.persistence.room.RoomWarnings;
import android.arch.persistence.room.Transaction;
+import android.arch.persistence.room.paging.LimitOffsetDataSource;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.test.InstrumentationRegistry;
@@ -227,7 +228,8 @@
drain();
resetTransactionCount();
@SuppressWarnings("deprecation")
- TiledDataSource<Entity1> dataSource = mDao.dataSource();
+ LimitOffsetDataSource<Entity1> dataSource =
+ (LimitOffsetDataSource<Entity1>) mDao.dataSource();
dataSource.loadRange(0, 10);
assertThat(sStartedTransactionCount.get(), is(mUseTransactionDao ? 1 : 0));
}
@@ -371,7 +373,7 @@
DataSource.Factory<Integer, Entity1> pagedList();
- TiledDataSource<Entity1> dataSource();
+ PositionalDataSource<Entity1> dataSource();
@Insert
void insert(Entity1 entity1);
@@ -413,7 +415,7 @@
@Override
@Query(SELECT_ALL)
- TiledDataSource<Entity1> dataSource();
+ PositionalDataSource<Entity1> dataSource();
}
@Dao
@@ -456,7 +458,7 @@
@Override
@Transaction
@Query(SELECT_ALL)
- TiledDataSource<Entity1> dataSource();
+ PositionalDataSource<Entity1> dataSource();
}
@Database(version = 1, entities = {Entity1.class, Child.class}, exportSchema = false)
diff --git a/room/runtime/src/main/java/android/arch/persistence/room/paging/LimitOffsetDataSource.java b/room/runtime/src/main/java/android/arch/persistence/room/paging/LimitOffsetDataSource.java
index 2f9a888..baa5b43 100644
--- a/room/runtime/src/main/java/android/arch/persistence/room/paging/LimitOffsetDataSource.java
+++ b/room/runtime/src/main/java/android/arch/persistence/room/paging/LimitOffsetDataSource.java
@@ -16,7 +16,7 @@
package android.arch.persistence.room.paging;
-import android.arch.paging.TiledDataSource;
+import android.arch.paging.PositionalDataSource;
import android.arch.persistence.room.InvalidationTracker;
import android.arch.persistence.room.RoomDatabase;
import android.arch.persistence.room.RoomSQLiteQuery;
@@ -25,6 +25,7 @@
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -42,7 +43,7 @@
* @hide
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
-public abstract class LimitOffsetDataSource<T> extends TiledDataSource<T> {
+public abstract class LimitOffsetDataSource<T> extends PositionalDataSource<T> {
private final RoomSQLiteQuery mSourceQuery;
private final String mCountQuery;
private final String mLimitOffsetQuery;
@@ -67,7 +68,10 @@
db.getInvalidationTracker().addWeakObserver(mObserver);
}
- @Override
+ /**
+ * Count number of rows query can return
+ */
+ @SuppressWarnings("WeakerAccess")
public int countItems() {
final RoomSQLiteQuery sqLiteQuery = RoomSQLiteQuery.acquire(mCountQuery,
mSourceQuery.getArgCount());
@@ -93,8 +97,43 @@
@SuppressWarnings("WeakerAccess")
protected abstract List<T> convertRows(Cursor cursor);
- @Nullable
@Override
+ public void loadInitial(@NonNull LoadInitialParams params,
+ @NonNull LoadInitialCallback<T> callback) {
+ int totalCount = countItems();
+ if (totalCount == 0) {
+ callback.onResult(Collections.<T>emptyList(), 0, 0);
+ return;
+ }
+
+ // bound the size requested, based on known count
+ final int firstLoadPosition = computeInitialLoadPosition(params, totalCount);
+ final int firstLoadSize = computeInitialLoadSize(params, firstLoadPosition, totalCount);
+
+ List<T> list = loadRange(firstLoadPosition, firstLoadSize);
+ if (list != null && list.size() == firstLoadSize) {
+ callback.onResult(list, firstLoadPosition, totalCount);
+ } else {
+ // null list, or size doesn't match request - DB modified between count and load
+ invalidate();
+ }
+ }
+
+ @Override
+ public void loadRange(@NonNull LoadRangeParams params,
+ @NonNull LoadRangeCallback<T> callback) {
+ List<T> list = loadRange(params.startPosition, params.loadSize);
+ if (list != null) {
+ callback.onResult(list);
+ } else {
+ invalidate();
+ }
+ }
+
+ /**
+ * Return the rows from startPos to startPos + loadCount
+ */
+ @Nullable
public List<T> loadRange(int startPosition, int loadCount) {
final RoomSQLiteQuery sqLiteQuery = RoomSQLiteQuery.acquire(mLimitOffsetQuery,
mSourceQuery.getArgCount() + 2);
diff --git a/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderCursorSupport.java b/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderCursorSupport.java
index 868f244..5c3a70e 100644
--- a/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderCursorSupport.java
+++ b/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderCursorSupport.java
@@ -20,6 +20,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.provider.Contacts.People;
+import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.ListFragment;
@@ -146,6 +147,7 @@
People.DISPLAY_NAME,
};
+ @NonNull
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
// This is called when a new Loader needs to be created. This
// sample only has one Loader, so we don't care about the ID.
@@ -167,7 +169,7 @@
People.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
}
- public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+ public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor data) {
// Swap the new cursor in. (The framework will take care of closing the
// old cursor once we return.)
mAdapter.swapCursor(data);
@@ -180,7 +182,7 @@
}
}
- public void onLoaderReset(Loader<Cursor> loader) {
+ public void onLoaderReset(@NonNull Loader<Cursor> loader) {
// This is called when the last Cursor provided to onLoadFinished()
// above is about to be closed. We need to make sure we are no
// longer using it.
diff --git a/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderCustomSupport.java b/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderCustomSupport.java
index 4da1e74..53c769c 100644
--- a/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderCustomSupport.java
+++ b/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderCustomSupport.java
@@ -27,6 +27,7 @@
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.ListFragment;
@@ -471,13 +472,15 @@
Log.i("LoaderCustom", "Item clicked: " + id);
}
+ @NonNull
@Override public Loader<List<AppEntry>> onCreateLoader(int id, Bundle args) {
// This is called when a new Loader needs to be created. This
// sample only has one Loader with no arguments, so it is simple.
return new AppListLoader(getActivity());
}
- @Override public void onLoadFinished(Loader<List<AppEntry>> loader, List<AppEntry> data) {
+ @Override public void onLoadFinished(@NonNull Loader<List<AppEntry>> loader,
+ List<AppEntry> data) {
// Set the new data in the adapter.
mAdapter.setData(data);
@@ -489,7 +492,7 @@
}
}
- @Override public void onLoaderReset(Loader<List<AppEntry>> loader) {
+ @Override public void onLoaderReset(@NonNull Loader<List<AppEntry>> loader) {
// Clear the data in the adapter.
mAdapter.setData(null);
}
diff --git a/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderRetainedSupport.java b/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderRetainedSupport.java
index a6dd264..247beca 100644
--- a/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderRetainedSupport.java
+++ b/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderRetainedSupport.java
@@ -20,6 +20,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.provider.Contacts.People;
+import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.ListFragment;
@@ -140,6 +141,7 @@
People.DISPLAY_NAME,
};
+ @NonNull
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
// This is called when a new Loader needs to be created. This
// sample only has one Loader, so we don't care about the ID.
@@ -161,7 +163,7 @@
People.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
}
- public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+ public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor data) {
// Swap the new cursor in. (The framework will take care of closing the
// old cursor once we return.)
mAdapter.swapCursor(data);
@@ -174,7 +176,7 @@
}
}
- public void onLoaderReset(Loader<Cursor> loader) {
+ public void onLoaderReset(@NonNull Loader<Cursor> loader) {
// This is called when the last Cursor provided to onLoadFinished()
// above is about to be closed. We need to make sure we are no
// longer using it.
diff --git a/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderThrottleSupport.java b/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderThrottleSupport.java
index a03a690..da35457 100644
--- a/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderThrottleSupport.java
+++ b/samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderThrottleSupport.java
@@ -33,6 +33,7 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.BaseColumns;
+import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.ListFragment;
@@ -486,6 +487,7 @@
MainTable.COLUMN_NAME_DATA,
};
+ @NonNull
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
CursorLoader cl = new CursorLoader(getActivity(), MainTable.CONTENT_URI,
@@ -495,7 +497,7 @@
}
@Override
- public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+ public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor data) {
mAdapter.swapCursor(data);
// The list should now be shown.
@@ -507,7 +509,7 @@
}
@Override
- public void onLoaderReset(Loader<Cursor> loader) {
+ public void onLoaderReset(@NonNull Loader<Cursor> loader) {
mAdapter.swapCursor(null);
}
}
diff --git a/samples/Support7Demos/src/main/java/com/example/android/supportv7/graphics/PaletteActivity.java b/samples/Support7Demos/src/main/java/com/example/android/supportv7/graphics/PaletteActivity.java
index 0a99787..57d326d 100644
--- a/samples/Support7Demos/src/main/java/com/example/android/supportv7/graphics/PaletteActivity.java
+++ b/samples/Support7Demos/src/main/java/com/example/android/supportv7/graphics/PaletteActivity.java
@@ -23,6 +23,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
+import android.support.annotation.NonNull;
import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
@@ -146,6 +147,7 @@
startActivity(intent);
}
+ @NonNull
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle bundle) {
return new CursorLoader(
@@ -158,12 +160,12 @@
}
@Override
- public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
+ public void onLoadFinished(@NonNull Loader<Cursor> cursorLoader, Cursor cursor) {
mAdapter.swapCursor(cursor);
}
@Override
- public void onLoaderReset(Loader<Cursor> cursorLoader) {
+ public void onLoaderReset(@NonNull Loader<Cursor> cursorLoader) {
mAdapter.swapCursor(null);
}
diff --git a/v7/appcompat/res/values-ne/strings.xml b/v7/appcompat/res/values-ne/strings.xml
index 0d23bd7..96b1042 100644
--- a/v7/appcompat/res/values-ne/strings.xml
+++ b/v7/appcompat/res/values-ne/strings.xml
@@ -29,7 +29,7 @@
<string name="abc_searchview_description_voice" msgid="893419373245838918">"भ्वाइस खोजी"</string>
<string name="abc_activitychooserview_choose_application" msgid="2031811694353399454">"एउटा अनुप्रयोग छान्नुहोस्"</string>
<string name="abc_activity_chooser_view_see_all" msgid="7468859129482906941">"सबै हेर्नुहोस्"</string>
- <string name="abc_shareactionprovider_share_with_application" msgid="3300176832234831527">"<xliff:g id="APPLICATION_NAME">%s</xliff:g> सँग आदान-प्रदान गर्नुहोस्"</string>
+ <string name="abc_shareactionprovider_share_with_application" msgid="3300176832234831527">"<xliff:g id="APPLICATION_NAME">%s</xliff:g> सँग आदान प्रदान गर्नुहोस्"</string>
<string name="abc_shareactionprovider_share_with" msgid="3421042268587513524">"साझेदारी गर्नुहोस्..."</string>
<string name="abc_capital_on" msgid="3405795526292276155">"सक्रिय गर्नुहोस्"</string>
<string name="abc_capital_off" msgid="121134116657445385">"निष्क्रिय पार्नुहोस्"</string>
diff --git a/v7/mediarouter/res/values-ar/strings.xml b/v7/mediarouter/res/values-ar/strings.xml
index 2cfe9e4..864fb91 100644
--- a/v7/mediarouter/res/values-ar/strings.xml
+++ b/v7/mediarouter/res/values-ar/strings.xml
@@ -34,7 +34,7 @@
<string name="mr_controller_collapse_group" msgid="7924809056904240926">"تصغير"</string>
<string name="mr_controller_album_art" msgid="6422801843540543585">"صورة الألبوم"</string>
<string name="mr_controller_volume_slider" msgid="2361785992211841709">"شريط تمرير مستوى الصوت"</string>
- <string name="mr_controller_no_media_selected" msgid="6547130360349182381">"لم يتم اختيار أية وسائط"</string>
- <string name="mr_controller_no_info_available" msgid="5585418471741142924">"لا تتوفر أية معلومات"</string>
+ <string name="mr_controller_no_media_selected" msgid="6547130360349182381">"لم يتم اختيار أي وسائط"</string>
+ <string name="mr_controller_no_info_available" msgid="5585418471741142924">"لا تتوفر أي معلومات"</string>
<string name="mr_controller_casting_screen" msgid="4868457957151124867">"جارٍ إرسال الشاشة"</string>
</resources>