Remove package private FullLifecycleObserver
It is not needed anymore because DefaultLifecycleObserver
now lives in common module and can be directly used.
Test: ./gradlew :lifecycle:lifecycle-common:test
Change-Id: Ibfe78131bd7e913562aa8fa51afce3bd2664fc80
diff --git a/lifecycle/common/api/2.2.0-alpha02.txt b/lifecycle/common/api/2.2.0-alpha02.txt
index 0624d75..1d2105f 100644
--- a/lifecycle/common/api/2.2.0-alpha02.txt
+++ b/lifecycle/common/api/2.2.0-alpha02.txt
@@ -1,7 +1,7 @@
// Signature format: 3.0
package androidx.lifecycle {
- public interface DefaultLifecycleObserver extends androidx.lifecycle.LifecycleObserver androidx.lifecycle.LifecycleObserver {
+ public interface DefaultLifecycleObserver extends androidx.lifecycle.LifecycleObserver {
method public default void onCreate(androidx.lifecycle.LifecycleOwner);
method public default void onDestroy(androidx.lifecycle.LifecycleOwner);
method public default void onPause(androidx.lifecycle.LifecycleOwner);
diff --git a/lifecycle/common/api/current.txt b/lifecycle/common/api/current.txt
index 0624d75..1d2105f 100644
--- a/lifecycle/common/api/current.txt
+++ b/lifecycle/common/api/current.txt
@@ -1,7 +1,7 @@
// Signature format: 3.0
package androidx.lifecycle {
- public interface DefaultLifecycleObserver extends androidx.lifecycle.LifecycleObserver androidx.lifecycle.LifecycleObserver {
+ public interface DefaultLifecycleObserver extends androidx.lifecycle.LifecycleObserver {
method public default void onCreate(androidx.lifecycle.LifecycleOwner);
method public default void onDestroy(androidx.lifecycle.LifecycleOwner);
method public default void onPause(androidx.lifecycle.LifecycleOwner);
diff --git a/lifecycle/common/src/main/java/androidx/lifecycle/DefaultLifecycleObserver.java b/lifecycle/common/src/main/java/androidx/lifecycle/DefaultLifecycleObserver.java
index 89e614d..4ccb307 100644
--- a/lifecycle/common/src/main/java/androidx/lifecycle/DefaultLifecycleObserver.java
+++ b/lifecycle/common/src/main/java/androidx/lifecycle/DefaultLifecycleObserver.java
@@ -29,7 +29,7 @@
* annotations will be ignored.
*/
@SuppressWarnings("unused")
-public interface DefaultLifecycleObserver extends FullLifecycleObserver {
+public interface DefaultLifecycleObserver extends LifecycleObserver {
/**
* Notifies that {@code ON_CREATE} event occurred.
@@ -39,7 +39,6 @@
*
* @param owner the component, whose state was changed
*/
- @Override
default void onCreate(@NonNull LifecycleOwner owner) {
}
@@ -50,7 +49,6 @@
*
* @param owner the component, whose state was changed
*/
- @Override
default void onStart(@NonNull LifecycleOwner owner) {
}
@@ -62,7 +60,6 @@
*
* @param owner the component, whose state was changed
*/
- @Override
default void onResume(@NonNull LifecycleOwner owner) {
}
@@ -74,7 +71,6 @@
*
* @param owner the component, whose state was changed
*/
- @Override
default void onPause(@NonNull LifecycleOwner owner) {
}
@@ -86,7 +82,6 @@
*
* @param owner the component, whose state was changed
*/
- @Override
default void onStop(@NonNull LifecycleOwner owner) {
}
@@ -98,7 +93,6 @@
*
* @param owner the component, whose state was changed
*/
- @Override
default void onDestroy(@NonNull LifecycleOwner owner) {
}
}
diff --git a/lifecycle/common/src/main/java/androidx/lifecycle/FullLifecycleObserverAdapter.java b/lifecycle/common/src/main/java/androidx/lifecycle/DefaultLifecycleObserverAdapter.java
similarity index 89%
rename from lifecycle/common/src/main/java/androidx/lifecycle/FullLifecycleObserverAdapter.java
rename to lifecycle/common/src/main/java/androidx/lifecycle/DefaultLifecycleObserverAdapter.java
index 10223d4..ede3c4c 100644
--- a/lifecycle/common/src/main/java/androidx/lifecycle/FullLifecycleObserverAdapter.java
+++ b/lifecycle/common/src/main/java/androidx/lifecycle/DefaultLifecycleObserverAdapter.java
@@ -18,12 +18,12 @@
import androidx.annotation.NonNull;
-class FullLifecycleObserverAdapter implements LifecycleEventObserver {
+class DefaultLifecycleObserverAdapter implements LifecycleEventObserver {
- private final FullLifecycleObserver mFullLifecycleObserver;
+ private final DefaultLifecycleObserver mFullLifecycleObserver;
private final LifecycleEventObserver mLifecycleEventObserver;
- FullLifecycleObserverAdapter(FullLifecycleObserver fullLifecycleObserver,
+ DefaultLifecycleObserverAdapter(DefaultLifecycleObserver fullLifecycleObserver,
LifecycleEventObserver lifecycleEventObserver) {
mFullLifecycleObserver = fullLifecycleObserver;
mLifecycleEventObserver = lifecycleEventObserver;
diff --git a/lifecycle/common/src/main/java/androidx/lifecycle/FullLifecycleObserver.java b/lifecycle/common/src/main/java/androidx/lifecycle/FullLifecycleObserver.java
deleted file mode 100644
index c959d03..0000000
--- a/lifecycle/common/src/main/java/androidx/lifecycle/FullLifecycleObserver.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 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 androidx.lifecycle;
-
-interface FullLifecycleObserver extends LifecycleObserver {
-
- void onCreate(LifecycleOwner owner);
-
- void onStart(LifecycleOwner owner);
-
- void onResume(LifecycleOwner owner);
-
- void onPause(LifecycleOwner owner);
-
- void onStop(LifecycleOwner owner);
-
- void onDestroy(LifecycleOwner owner);
-}
diff --git a/lifecycle/common/src/main/java/androidx/lifecycle/Lifecycling.java b/lifecycle/common/src/main/java/androidx/lifecycle/Lifecycling.java
index 2abb6ec..9ccdd96 100644
--- a/lifecycle/common/src/main/java/androidx/lifecycle/Lifecycling.java
+++ b/lifecycle/common/src/main/java/androidx/lifecycle/Lifecycling.java
@@ -66,13 +66,13 @@
@NonNull
static LifecycleEventObserver lifecycleEventObserver(Object object) {
boolean isLifecycleEventObserver = object instanceof LifecycleEventObserver;
- boolean isFullLifecycleObserver = object instanceof FullLifecycleObserver;
- if (isLifecycleEventObserver && isFullLifecycleObserver) {
- return new FullLifecycleObserverAdapter((FullLifecycleObserver) object,
+ boolean isDefaultLifecycleObserver = object instanceof DefaultLifecycleObserver;
+ if (isLifecycleEventObserver && isDefaultLifecycleObserver) {
+ return new DefaultLifecycleObserverAdapter((DefaultLifecycleObserver) object,
(LifecycleEventObserver) object);
}
- if (isFullLifecycleObserver) {
- return new FullLifecycleObserverAdapter((FullLifecycleObserver) object, null);
+ if (isDefaultLifecycleObserver) {
+ return new DefaultLifecycleObserverAdapter((DefaultLifecycleObserver) object, null);
}
if (isLifecycleEventObserver) {
diff --git a/lifecycle/common/src/test/java/androidx/lifecycle/FullLifecycleObserverTest.java b/lifecycle/common/src/test/java/androidx/lifecycle/DefaultLifecycleObserverTest.java
similarity index 92%
rename from lifecycle/common/src/test/java/androidx/lifecycle/FullLifecycleObserverTest.java
rename to lifecycle/common/src/test/java/androidx/lifecycle/DefaultLifecycleObserverTest.java
index 8a6500b..e336ef0 100644
--- a/lifecycle/common/src/test/java/androidx/lifecycle/FullLifecycleObserverTest.java
+++ b/lifecycle/common/src/test/java/androidx/lifecycle/DefaultLifecycleObserverTest.java
@@ -42,7 +42,7 @@
import org.mockito.Mockito;
@RunWith(JUnit4.class)
-public class FullLifecycleObserverTest {
+public class DefaultLifecycleObserverTest {
private LifecycleOwner mOwner;
private Lifecycle mLifecycle;
@@ -55,8 +55,8 @@
@Test
public void eachEvent() {
- FullLifecycleObserver obj = mock(FullLifecycleObserver.class);
- FullLifecycleObserverAdapter observer = new FullLifecycleObserverAdapter(obj, null);
+ DefaultLifecycleObserver obj = mock(DefaultLifecycleObserver.class);
+ DefaultLifecycleObserverAdapter observer = new DefaultLifecycleObserverAdapter(obj, null);
when(mLifecycle.getCurrentState()).thenReturn(CREATED);
observer.onStateChanged(mOwner, ON_CREATE);
@@ -92,7 +92,7 @@
@Test
public void fullLifecycleObserverAndLifecycleEventObserver() {
- class AllObservers implements FullLifecycleObserver, LifecycleEventObserver {
+ class AllObservers implements DefaultLifecycleObserver, LifecycleEventObserver {
@Override
public void onCreate(LifecycleOwner owner) {
@@ -132,7 +132,7 @@
}
AllObservers obj = mock(AllObservers.class);
- FullLifecycleObserverAdapter observer = new FullLifecycleObserverAdapter(obj, obj);
+ DefaultLifecycleObserverAdapter observer = new DefaultLifecycleObserverAdapter(obj, obj);
when(mLifecycle.getCurrentState()).thenReturn(CREATED);
observer.onStateChanged(mOwner, ON_CREATE);
@@ -173,7 +173,7 @@
}
public void fullLifecycleObserverAndAnnotations() {
- class AnnotatedFullLifecycleObserver implements FullLifecycleObserver {
+ class AnnotatedFullLifecycleObserver implements DefaultLifecycleObserver {
@OnLifecycleEvent(ON_ANY)
public void onAny() {
throw new IllegalStateException("Annotations in FullLifecycleObserver "
diff --git a/lifecycle/common/src/test/java/androidx/lifecycle/LifecyclingTest.java b/lifecycle/common/src/test/java/androidx/lifecycle/LifecyclingTest.java
index 5854dce..2c6cfe0 100644
--- a/lifecycle/common/src/test/java/androidx/lifecycle/LifecyclingTest.java
+++ b/lifecycle/common/src/test/java/androidx/lifecycle/LifecyclingTest.java
@@ -116,7 +116,7 @@
@Test
public void fullLifecycleObserverAndAnnotations() {
- class AnnotatedFullLifecycleObserver implements FullLifecycleObserver {
+ class AnnotatedFullLifecycleObserver implements DefaultLifecycleObserver {
@OnLifecycleEvent(ON_ANY)
public void onAny() {
throw new IllegalStateException("Annotations in FullLifecycleObserver "