Merge "Fix issue with showing start item in small mode"
diff --git a/app-toolkit/settings.gradle b/app-toolkit/settings.gradle
index ac85d95..62ea628 100644
--- a/app-toolkit/settings.gradle
+++ b/app-toolkit/settings.gradle
@@ -45,6 +45,15 @@
include ':arch:core-testing'
project(':arch:core-testing').projectDir = new File(supportRoot, "app-toolkit/core-testing")
+include ':lifecycle:livedata'
+project(':lifecycle:livedata').projectDir = new File(supportRoot, "lifecycle/livedata")
+
+include ':lifecycle:viewmodel'
+project(':lifecycle:viewmodel').projectDir = new File(supportRoot, "lifecycle/viewmodel")
+
+include ':lifecycle:extensions'
+project(':lifecycle:extensions').projectDir = new File(supportRoot, "lifecycle/extensions")
+
include ':lifecycle:extensions'
project(':lifecycle:extensions').projectDir = new File(supportRoot, "lifecycle/extensions")
diff --git a/buildSrc/src/main/java/android/support/LibraryVersions.java b/buildSrc/src/main/java/android/support/LibraryVersions.java
index b5c74e3..6d8d6bf 100644
--- a/buildSrc/src/main/java/android/support/LibraryVersions.java
+++ b/buildSrc/src/main/java/android/support/LibraryVersions.java
@@ -36,9 +36,19 @@
public static final Version ROOM = FLATFOOT_1_0_BATCH;
/**
- * Version code for Lifecycle extensions (live data, view model etc)
+ * Version code for Lifecycle extensions (ProcessLifecycleOwner, Fragment support)
*/
- public static final Version LIFECYCLES_EXT = FLATFOOT_1_0_BATCH;
+ public static final Version LIFECYCLES_EXT = new Version("1.1.0-SNAPSHOT");
+
+ /**
+ * Version code for Lifecycle LiveData
+ */
+ public static final Version LIFECYCLES_LIVEDATA = LIFECYCLES_EXT;
+
+ /**
+ * Version code for Lifecycle ViewModel
+ */
+ public static final Version LIFECYCLES_VIEWMODEL = LIFECYCLES_EXT;
/**
* Version code for RecyclerView & Room paging
diff --git a/compat/tests/res/drawable/pointer_icon.xml b/compat/tests/res/drawable/pointer_icon.xml
index afb5a1a..f62ef45 100644
--- a/compat/tests/res/drawable/pointer_icon.xml
+++ b/compat/tests/res/drawable/pointer_icon.xml
@@ -16,5 +16,5 @@
<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
android:bitmap="@drawable/test_drawable"
- android:hotSpotX="16dp"
- android:hotSpotY="16dp" />
+ android:hotSpotX="1dp"
+ android:hotSpotY="1dp" />
diff --git a/lifecycle/extensions/api/1.0.0.ignore b/lifecycle/extensions/api/1.0.0.ignore
new file mode 100644
index 0000000..8d6e57b
--- /dev/null
+++ b/lifecycle/extensions/api/1.0.0.ignore
@@ -0,0 +1,11 @@
+f6e2d00
+3c52930
+0544727
+6518b05
+5d02244
+78d0e3a
+c690bb6
+e8aa0bd
+5900545
+aadc61e
+f39f879
\ No newline at end of file
diff --git a/lifecycle/extensions/api/current.txt b/lifecycle/extensions/api/current.txt
new file mode 100644
index 0000000..bf093a9
--- /dev/null
+++ b/lifecycle/extensions/api/current.txt
@@ -0,0 +1,55 @@
+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 deprecated class LifecycleActivity extends android.support.v4.app.FragmentActivity {
+ ctor public LifecycleActivity();
+ }
+
+ public deprecated class LifecycleFragment extends android.support.v4.app.Fragment {
+ ctor public LifecycleFragment();
+ }
+
+ 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 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 class ViewModelProviders.DefaultFactory extends android.arch.lifecycle.ViewModelProvider.NewInstanceFactory {
+ ctor public 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/extensions/build.gradle b/lifecycle/extensions/build.gradle
index 070394d..e8ab2f6 100644
--- a/lifecycle/extensions/build.gradle
+++ b/lifecycle/extensions/build.gradle
@@ -35,6 +35,8 @@
api(project(":arch:runtime"))
api(SUPPORT_FRAGMENTS, libs.support_exclude_config)
api(project(":lifecycle:common"))
+ api(project(":lifecycle:livedata"))
+ api(project(":lifecycle:viewmodel"))
testImplementation(project(":arch:core-testing"))
testImplementation(JUNIT)
diff --git a/lifecycle/extensions/proguard-rules.pro b/lifecycle/extensions/proguard-rules.pro
index a24a5d3..68db05a 100644
--- a/lifecycle/extensions/proguard-rules.pro
+++ b/lifecycle/extensions/proguard-rules.pro
@@ -1,7 +1,3 @@
--keep class * extends android.arch.lifecycle.ViewModel {
- <init>();
-}
-
-keep class * extends android.arch.lifecycle.AndroidViewModel {
<init>(android.app.Application);
}
\ No newline at end of file
diff --git a/lifecycle/extensions/src/test/java/android/arch/lifecycle/ViewModelProvidersTest.java b/lifecycle/extensions/src/test/java/android/arch/lifecycle/ViewModelProvidersTest.java
new file mode 100644
index 0000000..f37c9a2
--- /dev/null
+++ b/lifecycle/extensions/src/test/java/android/arch/lifecycle/ViewModelProvidersTest.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.arch.lifecycle;
+
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class ViewModelProvidersTest {
+
+ @Test(expected = IllegalStateException.class)
+ public void testNotAttachedActivity() {
+ // This is similar to call ViewModelProviders.of in Activity's constructor
+ ViewModelProviders.of(new FragmentActivity());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testNotAttachedFragment() {
+ // This is similar to call ViewModelProviders.of in Activity's constructor
+ ViewModelProviders.of(new Fragment());
+ }
+}
diff --git a/lifecycle/livedata/api/current.txt b/lifecycle/livedata/api/current.txt
new file mode 100644
index 0000000..64f199f
--- /dev/null
+++ b/lifecycle/livedata/api/current.txt
@@ -0,0 +1,40 @@
+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 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 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);
+ }
+
+ 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/livedata/build.gradle b/lifecycle/livedata/build.gradle
new file mode 100644
index 0000000..9906c0e
--- /dev/null
+++ b/lifecycle/livedata/build.gradle
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import static android.support.dependencies.DependenciesKt.*
+import android.support.LibraryGroups
+import android.support.LibraryVersions
+import android.support.SupportLibraryExtension
+
+plugins {
+ id("SupportAndroidLibraryPlugin")
+}
+
+dependencies {
+ api(project(":arch:common"))
+ api(project(":arch:runtime"))
+ api(project(":lifecycle:common"))
+ api(project(":lifecycle:runtime"))
+
+ testImplementation(project(":arch:core-testing"))
+ testImplementation(JUNIT)
+ testImplementation(MOCKITO_CORE)
+}
+
+supportLibrary {
+ name = "Android Lifecycle LiveData"
+ publish = true
+ mavenVersion = LibraryVersions.LIFECYCLES_LIVEDATA
+ mavenGroup = LibraryGroups.LIFECYCLE
+ inceptionYear = "2017"
+ description = "Android Lifecycle LiveData"
+ url = SupportLibraryExtension.ARCHITECTURE_URL
+}
\ No newline at end of file
diff --git a/lifecycle/livedata/src/main/AndroidManifest.xml b/lifecycle/livedata/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..9f738ee
--- /dev/null
+++ b/lifecycle/livedata/src/main/AndroidManifest.xml
@@ -0,0 +1,19 @@
+<!--
+ ~ Copyright 2017 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.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.arch.lifecycle.livedata">
+</manifest>
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/ComputableLiveData.java b/lifecycle/livedata/src/main/java/android/arch/lifecycle/ComputableLiveData.java
similarity index 100%
rename from lifecycle/extensions/src/main/java/android/arch/lifecycle/ComputableLiveData.java
rename to lifecycle/livedata/src/main/java/android/arch/lifecycle/ComputableLiveData.java
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/LiveData.java b/lifecycle/livedata/src/main/java/android/arch/lifecycle/LiveData.java
similarity index 100%
rename from lifecycle/extensions/src/main/java/android/arch/lifecycle/LiveData.java
rename to lifecycle/livedata/src/main/java/android/arch/lifecycle/LiveData.java
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/MediatorLiveData.java b/lifecycle/livedata/src/main/java/android/arch/lifecycle/MediatorLiveData.java
similarity index 100%
rename from lifecycle/extensions/src/main/java/android/arch/lifecycle/MediatorLiveData.java
rename to lifecycle/livedata/src/main/java/android/arch/lifecycle/MediatorLiveData.java
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/MutableLiveData.java b/lifecycle/livedata/src/main/java/android/arch/lifecycle/MutableLiveData.java
similarity index 100%
rename from lifecycle/extensions/src/main/java/android/arch/lifecycle/MutableLiveData.java
rename to lifecycle/livedata/src/main/java/android/arch/lifecycle/MutableLiveData.java
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/Observer.java b/lifecycle/livedata/src/main/java/android/arch/lifecycle/Observer.java
similarity index 100%
rename from lifecycle/extensions/src/main/java/android/arch/lifecycle/Observer.java
rename to lifecycle/livedata/src/main/java/android/arch/lifecycle/Observer.java
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/Transformations.java b/lifecycle/livedata/src/main/java/android/arch/lifecycle/Transformations.java
similarity index 100%
rename from lifecycle/extensions/src/main/java/android/arch/lifecycle/Transformations.java
rename to lifecycle/livedata/src/main/java/android/arch/lifecycle/Transformations.java
diff --git a/lifecycle/extensions/src/test/java/android/arch/lifecycle/ComputableLiveDataTest.java b/lifecycle/livedata/src/test/java/android/arch/lifecycle/ComputableLiveDataTest.java
similarity index 100%
rename from lifecycle/extensions/src/test/java/android/arch/lifecycle/ComputableLiveDataTest.java
rename to lifecycle/livedata/src/test/java/android/arch/lifecycle/ComputableLiveDataTest.java
diff --git a/lifecycle/extensions/src/test/java/android/arch/lifecycle/LiveDataTest.java b/lifecycle/livedata/src/test/java/android/arch/lifecycle/LiveDataTest.java
similarity index 100%
rename from lifecycle/extensions/src/test/java/android/arch/lifecycle/LiveDataTest.java
rename to lifecycle/livedata/src/test/java/android/arch/lifecycle/LiveDataTest.java
diff --git a/lifecycle/extensions/src/test/java/android/arch/lifecycle/MediatorLiveDataTest.java b/lifecycle/livedata/src/test/java/android/arch/lifecycle/MediatorLiveDataTest.java
similarity index 100%
rename from lifecycle/extensions/src/test/java/android/arch/lifecycle/MediatorLiveDataTest.java
rename to lifecycle/livedata/src/test/java/android/arch/lifecycle/MediatorLiveDataTest.java
diff --git a/lifecycle/extensions/src/test/java/android/arch/lifecycle/ThreadedLiveDataTest.java b/lifecycle/livedata/src/test/java/android/arch/lifecycle/ThreadedLiveDataTest.java
similarity index 100%
rename from lifecycle/extensions/src/test/java/android/arch/lifecycle/ThreadedLiveDataTest.java
rename to lifecycle/livedata/src/test/java/android/arch/lifecycle/ThreadedLiveDataTest.java
diff --git a/lifecycle/extensions/src/test/java/android/arch/lifecycle/TransformationsTest.java b/lifecycle/livedata/src/test/java/android/arch/lifecycle/TransformationsTest.java
similarity index 100%
rename from lifecycle/extensions/src/test/java/android/arch/lifecycle/TransformationsTest.java
rename to lifecycle/livedata/src/test/java/android/arch/lifecycle/TransformationsTest.java
diff --git a/lifecycle/extensions/src/test/java/android/arch/lifecycle/util/InstantTaskExecutor.java b/lifecycle/livedata/src/test/java/android/arch/lifecycle/util/InstantTaskExecutor.java
similarity index 100%
rename from lifecycle/extensions/src/test/java/android/arch/lifecycle/util/InstantTaskExecutor.java
rename to lifecycle/livedata/src/test/java/android/arch/lifecycle/util/InstantTaskExecutor.java
diff --git a/lifecycle/reactivestreams/api/current.txt b/lifecycle/reactivestreams/api/current.txt
new file mode 100644
index 0000000..4a509e9
--- /dev/null
+++ b/lifecycle/reactivestreams/api/current.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/reactivestreams/build.gradle b/lifecycle/reactivestreams/build.gradle
index fbbc82f..985ee29 100644
--- a/lifecycle/reactivestreams/build.gradle
+++ b/lifecycle/reactivestreams/build.gradle
@@ -26,7 +26,7 @@
dependencies {
api(project(":arch:common"))
api(project(":lifecycle:common"))
- api(project(":lifecycle:extensions"))
+ api(project(":lifecycle:livedata"))
api(project(":lifecycle:runtime"))
api(SUPPORT_ANNOTATIONS)
api(REACTIVE_STREAMS)
diff --git a/lifecycle/viewmodel/api/current.txt b/lifecycle/viewmodel/api/current.txt
new file mode 100644
index 0000000..56de7fe
--- /dev/null
+++ b/lifecycle/viewmodel/api/current.txt
@@ -0,0 +1,34 @@
+package android.arch.lifecycle {
+
+ 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 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/lifecycle/viewmodel/build.gradle b/lifecycle/viewmodel/build.gradle
new file mode 100644
index 0000000..914d9ce
--- /dev/null
+++ b/lifecycle/viewmodel/build.gradle
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import static android.support.dependencies.DependenciesKt.*
+import android.support.LibraryGroups
+import android.support.LibraryVersions
+import android.support.SupportLibraryExtension
+
+plugins {
+ id("SupportAndroidLibraryPlugin")
+}
+
+android {
+ buildTypes.all {
+ consumerProguardFiles 'proguard-rules.pro'
+ }
+}
+
+dependencies {
+ api(SUPPORT_ANNOTATIONS)
+
+ testImplementation(JUNIT)
+ testImplementation(MOCKITO_CORE)
+}
+
+supportLibrary {
+ name = "Android Lifecycle ViewModel"
+ publish = true
+ mavenVersion = LibraryVersions.LIFECYCLES_VIEWMODEL
+ mavenGroup = LibraryGroups.LIFECYCLE
+ inceptionYear = "2017"
+ description = "Android Lifecycle ViewModel"
+ url = SupportLibraryExtension.ARCHITECTURE_URL
+}
\ No newline at end of file
diff --git a/lifecycle/viewmodel/proguard-rules.pro b/lifecycle/viewmodel/proguard-rules.pro
new file mode 100644
index 0000000..daac94e
--- /dev/null
+++ b/lifecycle/viewmodel/proguard-rules.pro
@@ -0,0 +1,3 @@
+-keep class * extends android.arch.lifecycle.ViewModel {
+ <init>();
+}
\ No newline at end of file
diff --git a/lifecycle/viewmodel/src/main/AndroidManifest.xml b/lifecycle/viewmodel/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..c5d9c0d
--- /dev/null
+++ b/lifecycle/viewmodel/src/main/AndroidManifest.xml
@@ -0,0 +1,19 @@
+<!--
+ ~ Copyright 2017 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.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.arch.lifecycle.viewmodel">
+</manifest>
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModel.java b/lifecycle/viewmodel/src/main/java/android/arch/lifecycle/ViewModel.java
similarity index 100%
rename from lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModel.java
rename to lifecycle/viewmodel/src/main/java/android/arch/lifecycle/ViewModel.java
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelProvider.java b/lifecycle/viewmodel/src/main/java/android/arch/lifecycle/ViewModelProvider.java
similarity index 100%
rename from lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelProvider.java
rename to lifecycle/viewmodel/src/main/java/android/arch/lifecycle/ViewModelProvider.java
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelStore.java b/lifecycle/viewmodel/src/main/java/android/arch/lifecycle/ViewModelStore.java
similarity index 100%
rename from lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelStore.java
rename to lifecycle/viewmodel/src/main/java/android/arch/lifecycle/ViewModelStore.java
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelStoreOwner.java b/lifecycle/viewmodel/src/main/java/android/arch/lifecycle/ViewModelStoreOwner.java
similarity index 100%
rename from lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelStoreOwner.java
rename to lifecycle/viewmodel/src/main/java/android/arch/lifecycle/ViewModelStoreOwner.java
diff --git a/lifecycle/extensions/src/test/java/android/arch/lifecycle/ViewModelProviderTest.java b/lifecycle/viewmodel/src/test/java/android/arch/lifecycle/ViewModelProviderTest.java
similarity index 82%
rename from lifecycle/extensions/src/test/java/android/arch/lifecycle/ViewModelProviderTest.java
rename to lifecycle/viewmodel/src/test/java/android/arch/lifecycle/ViewModelProviderTest.java
index 8877357..37d2020 100644
--- a/lifecycle/extensions/src/test/java/android/arch/lifecycle/ViewModelProviderTest.java
+++ b/lifecycle/viewmodel/src/test/java/android/arch/lifecycle/ViewModelProviderTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright 2017 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.
@@ -21,8 +21,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
import android.arch.lifecycle.ViewModelProvider.NewInstanceFactory;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
import org.junit.Assert;
import org.junit.Before;
@@ -84,18 +82,6 @@
assertThat(viewModel, is(provider.get(ViewModel1.class)));
}
- @Test(expected = IllegalStateException.class)
- public void testNotAttachedActivity() {
- // This is similar to call ViewModelProviders.of in Activity's constructor
- ViewModelProviders.of(new FragmentActivity());
- }
-
- @Test(expected = IllegalStateException.class)
- public void testNotAttachedFragment() {
- // This is similar to call ViewModelProviders.of in Activity's constructor
- ViewModelProviders.of(new Fragment());
- }
-
public static class ViewModel1 extends ViewModel {
boolean mCleared;
diff --git a/lifecycle/extensions/src/test/java/android/arch/lifecycle/ViewModelStoreTest.java b/lifecycle/viewmodel/src/test/java/android/arch/lifecycle/ViewModelStoreTest.java
similarity index 100%
rename from lifecycle/extensions/src/test/java/android/arch/lifecycle/ViewModelStoreTest.java
rename to lifecycle/viewmodel/src/test/java/android/arch/lifecycle/ViewModelStoreTest.java
diff --git a/slices/view/src/androidTest/java/androidx/app/slice/SliceXmlTest.java b/slices/view/src/androidTest/java/androidx/app/slice/SliceXmlTest.java
index c191db9..5e4444d 100644
--- a/slices/view/src/androidTest/java/androidx/app/slice/SliceXmlTest.java
+++ b/slices/view/src/androidTest/java/androidx/app/slice/SliceXmlTest.java
@@ -30,8 +30,8 @@
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.SmallTest;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/v7/recyclerview/src/test/java/android/support/v7/widget/AdapterHelperTest.java b/v7/recyclerview/src/test/java/android/support/v7/widget/AdapterHelperTest.java
index e0dbde5..bcaa252 100644
--- a/v7/recyclerview/src/test/java/android/support/v7/widget/AdapterHelperTest.java
+++ b/v7/recyclerview/src/test/java/android/support/v7/widget/AdapterHelperTest.java
@@ -18,19 +18,22 @@
import static android.support.v7.widget.RecyclerView.ViewHolder;
-import android.support.test.filters.SmallTest;
-import android.test.AndroidTestCase;
-import android.util.Log;
-import android.view.View;
-import android.widget.TextView;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
-import junit.framework.AssertionFailedError;
-import junit.framework.TestResult;
+import android.support.test.filters.SmallTest;
+import android.view.View;
+
+import junit.framework.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+import org.mockito.Mockito;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -41,7 +44,7 @@
@RunWith(JUnit4.class)
@SmallTest
-public class AdapterHelperTest extends AndroidTestCase {
+public class AdapterHelperTest {
private static final boolean DEBUG = false;
@@ -49,35 +52,40 @@
private static final String TAG = "AHT";
- List<MockViewHolder> mViewHolders;
+ private List<MockViewHolder> mViewHolders;
- AdapterHelper mAdapterHelper;
+ private AdapterHelper mAdapterHelper;
- List<AdapterHelper.UpdateOp> mFirstPassUpdates, mSecondPassUpdates;
+ private List<AdapterHelper.UpdateOp> mFirstPassUpdates, mSecondPassUpdates;
TestAdapter mTestAdapter;
- TestAdapter mPreProcessClone; // we clone adapter pre-process to run operations to see result
+ private TestAdapter mPreProcessClone;
+ // we clone adapter pre-process to run operations to see result
private List<TestAdapter.Item> mPreLayoutItems;
private StringBuilder mLog = new StringBuilder();
- @Override
- public void run(TestResult result) {
- super.run(result);
- if (!result.wasSuccessful()) {
- result.addFailure(this, new AssertionFailedError(mLog.toString()));
+ @Rule
+ public TestWatcher reportErrorLog = new TestWatcher() {
+ @Override
+ protected void failed(Throwable e, Description description) {
+ System.out.println(mLog.toString());
}
- }
+
+ @Override
+ protected void succeeded(Description description) {
+ }
+ };
@Before
public void cleanState() {
mLog.setLength(0);
- mPreLayoutItems = new ArrayList<TestAdapter.Item>();
- mViewHolders = new ArrayList<MockViewHolder>();
- mFirstPassUpdates = new ArrayList<AdapterHelper.UpdateOp>();
- mSecondPassUpdates = new ArrayList<AdapterHelper.UpdateOp>();
+ mPreLayoutItems = new ArrayList<>();
+ mViewHolders = new ArrayList<>();
+ mFirstPassUpdates = new ArrayList<>();
+ mSecondPassUpdates = new ArrayList<>();
mPreProcessClone = null;
mAdapterHelper = new AdapterHelper(new AdapterHelper.Callback() {
@Override
@@ -134,7 +142,7 @@
for (ViewHolder viewHolder : mViewHolders) {
for (int i = 0; i < updateOp.itemCount; i++) {
// events are dispatched before view holders are updated for consistency
- assertFalse("update op should not match any existing view holders",
+ Assert.assertFalse("update op should not match any existing view holders",
viewHolder.getLayoutPosition() == updateOp.positionStart + i);
}
}
@@ -189,7 +197,7 @@
if (mCollectLogs) {
mLog.append(msg).append("\n");
} else {
- Log.d(TAG, msg);
+ System.out.println(TAG + ":" + msg);
}
}
@@ -205,8 +213,7 @@
}
private void addViewHolder(int position) {
- MockViewHolder viewHolder = new MockViewHolder(
- new TextView(getContext()));
+ MockViewHolder viewHolder = new MockViewHolder();
viewHolder.mPosition = position;
viewHolder.mItem = mTestAdapter.mItems.get(position);
mViewHolders.add(viewHolder);
@@ -502,7 +509,7 @@
}
@Test
- public void testScenario18() throws InterruptedException {
+ public void testScenario18() {
setupBasic(10, 1, 4);
add(2, 11);
rm(16, 1);
@@ -622,7 +629,7 @@
}
@Test
- public void testScenerio30() throws InterruptedException {
+ public void testScenerio30() {
mCollectLogs = true;
setupBasic(10, 3, 1);
rm(3, 2);
@@ -631,7 +638,7 @@
}
@Test
- public void testScenerio31() throws InterruptedException {
+ public void testScenerio31() {
mCollectLogs = true;
setupBasic(10, 3, 1);
rm(3, 1);
@@ -844,7 +851,7 @@
Random random = new Random(System.nanoTime());
for (int i = 0; i < 100; i++) {
try {
- Log.d(TAG, "running random test " + i);
+ log("running random test " + i);
randomTest(random, Math.max(40, 10 + nextInt(random, i)));
} catch (Throwable t) {
throw new Throwable("failure at random test " + i + "\n" + t.getMessage()
@@ -853,7 +860,7 @@
}
}
- public void randomTest(Random random, int opCount) {
+ private void randomTest(Random random, int opCount) {
cleanState();
if (DEBUG) {
log("randomTest");
@@ -907,14 +914,14 @@
preProcess();
}
- int nextInt(Random random, int n) {
+ private int nextInt(Random random, int n) {
if (n == 0) {
return 0;
}
return random.nextInt(n);
}
- public void assertOps(List<AdapterHelper.UpdateOp> actual,
+ private void assertOps(List<AdapterHelper.UpdateOp> actual,
AdapterHelper.UpdateOp... expected) {
assertEquals(expected.length, actual.size());
for (int i = 0; i < expected.length; i++) {
@@ -922,12 +929,12 @@
}
}
- void assertDispatch(int firstPass, int secondPass) {
+ private void assertDispatch(int firstPass, int secondPass) {
assertEquals(firstPass, mFirstPassUpdates.size());
assertEquals(secondPass, mSecondPassUpdates.size());
}
- void preProcess() {
+ private void preProcess() {
for (MockViewHolder vh : mViewHolders) {
final int ind = mTestAdapter.mItems.indexOf(vh.mItem);
assertEquals("actual adapter position should match", ind,
@@ -975,23 +982,20 @@
assertEquals(0, a2.mPendingAdded.size());
}
- AdapterHelper.UpdateOp op(int cmd, int start, int count) {
+ private AdapterHelper.UpdateOp op(int cmd, int start, int count) {
return new AdapterHelper.UpdateOp(cmd, start, count, null);
}
- AdapterHelper.UpdateOp op(int cmd, int start, int count, Object payload) {
+ private AdapterHelper.UpdateOp op(int cmd, int start, int count, Object payload) {
return new AdapterHelper.UpdateOp(cmd, start, count, payload);
}
- AdapterHelper.UpdateOp addOp(int start, int count) {
- return op(AdapterHelper.UpdateOp.ADD, start, count);
- }
-
- AdapterHelper.UpdateOp rmOp(int start, int count) {
+ private AdapterHelper.UpdateOp rmOp(int start, int count) {
return op(AdapterHelper.UpdateOp.REMOVE, start, count);
}
- AdapterHelper.UpdateOp upOp(int start, int count, Object payload) {
+ private AdapterHelper.UpdateOp upOp(int start, int count, @SuppressWarnings
+ ("SameParameterValue") Object payload) {
return op(AdapterHelper.UpdateOp.UPDATE, start, count, payload);
}
@@ -1002,7 +1006,7 @@
mTestAdapter.add(start, count);
}
- boolean isItemLaidOut(int pos) {
+ private boolean isItemLaidOut(int pos) {
for (ViewHolder viewHolder : mViewHolders) {
if (viewHolder.mOldPosition == pos) {
return true;
@@ -1018,7 +1022,7 @@
mTestAdapter.move(from, to);
}
- void rm(int start, int count) {
+ private void rm(int start, int count) {
if (DEBUG) {
log("rm(" + start + "," + count + ");");
}
@@ -1054,9 +1058,9 @@
Queue<Item> mPendingAdded;
public TestAdapter(int initialCount, AdapterHelper container) {
- mItems = new ArrayList<Item>();
+ mItems = new ArrayList<>();
mAdapterHelper = container;
- mPendingAdded = new LinkedList<Item>();
+ mPendingAdded = new LinkedList<>();
for (int i = 0; i < initialCount; i++) {
mItems.add(new Item());
}
@@ -1102,15 +1106,13 @@
));
}
- protected TestAdapter createCopy() {
+ TestAdapter createCopy() {
TestAdapter adapter = new TestAdapter(0, mAdapterHelper);
- for (Item item : mItems) {
- adapter.mItems.add(item);
- }
+ adapter.mItems.addAll(mItems);
return adapter;
}
- public void applyOps(List<AdapterHelper.UpdateOp> updates,
+ void applyOps(List<AdapterHelper.UpdateOp> updates,
TestAdapter dataSource) {
for (AdapterHelper.UpdateOp op : updates) {
switch (op.cmd) {
@@ -1140,20 +1142,16 @@
return mPendingAdded.remove();
}
- public void createFakeItemAt(int fakeAddedItemIndex) {
- Item fakeItem = new Item();
- ((LinkedList<Item>) mPendingAdded).add(fakeAddedItemIndex, fakeItem);
- }
-
public static class Item {
private static AtomicInteger itemCounter = new AtomicInteger();
+ @SuppressWarnings("unused")
private final int id;
private int mVersionCount = 0;
- private ArrayList<Object> mPayloads = new ArrayList<Object>();
+ private ArrayList<Object> mPayloads = new ArrayList<>();
public Item() {
id = itemCounter.incrementAndGet();
@@ -1164,26 +1162,23 @@
mVersionCount++;
}
- public void handleUpdate(Object payload) {
+ void handleUpdate(Object payload) {
assertSame(payload, mPayloads.get(0));
mPayloads.remove(0);
mVersionCount--;
}
- public int getUpdateCount() {
+ int getUpdateCount() {
return mVersionCount;
}
}
}
- void waitForDebugger() {
- android.os.Debug.waitForDebugger();
- }
-
static class MockViewHolder extends RecyclerView.ViewHolder {
- public Object mItem;
- public MockViewHolder(View itemView) {
- super(itemView);
+ TestAdapter.Item mItem;
+
+ MockViewHolder() {
+ super(Mockito.mock(View.class));
}
@Override