Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,190 @@
package androidx.lifecycle;
import androidx.lifecycle.Lifecycle;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
class ClassesInfoCache {
static ClassesInfoCache c = new ClassesInfoCache();
private final Map<Class, CallbackInfo> a = new HashMap();
private final Map<Class, Boolean> b = new HashMap();
static class MethodReference {
final int a;
final Method b;
MethodReference(int i, Method method) {
this.a = i;
this.b = method;
this.b.setAccessible(true);
}
void a(LifecycleOwner lifecycleOwner, Lifecycle.Event event, Object obj) {
try {
int i = this.a;
if (i == 0) {
this.b.invoke(obj, new Object[0]);
} else if (i == 1) {
this.b.invoke(obj, lifecycleOwner);
} else {
if (i != 2) {
return;
}
this.b.invoke(obj, lifecycleOwner, event);
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e2) {
throw new RuntimeException("Failed to call observer method", e2.getCause());
}
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || MethodReference.class != obj.getClass()) {
return false;
}
MethodReference methodReference = (MethodReference) obj;
return this.a == methodReference.a && this.b.getName().equals(methodReference.b.getName());
}
public int hashCode() {
return (this.a * 31) + this.b.getName().hashCode();
}
}
ClassesInfoCache() {
}
private Method[] c(Class cls) {
try {
return cls.getDeclaredMethods();
} catch (NoClassDefFoundError e) {
throw new IllegalArgumentException("The observer class has some methods that use newer APIs which are not available in the current OS version. Lifecycles cannot access even other methods so you should make sure that your observer classes only access framework classes that are available in your min API level OR use lifecycle:compiler annotation processor.", e);
}
}
CallbackInfo a(Class cls) {
CallbackInfo callbackInfo = this.a.get(cls);
return callbackInfo != null ? callbackInfo : a(cls, null);
}
boolean b(Class cls) {
if (this.b.containsKey(cls)) {
return this.b.get(cls).booleanValue();
}
Method[] c2 = c(cls);
for (Method method : c2) {
if (((OnLifecycleEvent) method.getAnnotation(OnLifecycleEvent.class)) != null) {
a(cls, c2);
return true;
}
}
this.b.put(cls, false);
return false;
}
static class CallbackInfo {
final Map<Lifecycle.Event, List<MethodReference>> a = new HashMap();
final Map<MethodReference, Lifecycle.Event> b;
CallbackInfo(Map<MethodReference, Lifecycle.Event> map) {
this.b = map;
for (Map.Entry<MethodReference, Lifecycle.Event> entry : map.entrySet()) {
Lifecycle.Event value = entry.getValue();
List<MethodReference> list = this.a.get(value);
if (list == null) {
list = new ArrayList<>();
this.a.put(value, list);
}
list.add(entry.getKey());
}
}
void a(LifecycleOwner lifecycleOwner, Lifecycle.Event event, Object obj) {
a(this.a.get(event), lifecycleOwner, event, obj);
a(this.a.get(Lifecycle.Event.ON_ANY), lifecycleOwner, event, obj);
}
private static void a(List<MethodReference> list, LifecycleOwner lifecycleOwner, Lifecycle.Event event, Object obj) {
if (list != null) {
for (int size = list.size() - 1; size >= 0; size--) {
list.get(size).a(lifecycleOwner, event, obj);
}
}
}
}
private void a(Map<MethodReference, Lifecycle.Event> map, MethodReference methodReference, Lifecycle.Event event, Class cls) {
Lifecycle.Event event2 = map.get(methodReference);
if (event2 == null || event == event2) {
if (event2 == null) {
map.put(methodReference, event);
return;
}
return;
}
throw new IllegalArgumentException("Method " + methodReference.b.getName() + " in " + cls.getName() + " already declared with different @OnLifecycleEvent value: previous value " + event2 + ", new value " + event);
}
private CallbackInfo a(Class cls, Method[] methodArr) {
int i;
CallbackInfo a;
Class superclass = cls.getSuperclass();
HashMap hashMap = new HashMap();
if (superclass != null && (a = a(superclass)) != null) {
hashMap.putAll(a.b);
}
for (Class<?> cls2 : cls.getInterfaces()) {
for (Map.Entry<MethodReference, Lifecycle.Event> entry : a(cls2).b.entrySet()) {
a(hashMap, entry.getKey(), entry.getValue(), cls);
}
}
if (methodArr == null) {
methodArr = c(cls);
}
boolean z = false;
for (Method method : methodArr) {
OnLifecycleEvent onLifecycleEvent = (OnLifecycleEvent) method.getAnnotation(OnLifecycleEvent.class);
if (onLifecycleEvent != null) {
Class<?>[] parameterTypes = method.getParameterTypes();
if (parameterTypes.length <= 0) {
i = 0;
} else {
if (!parameterTypes[0].isAssignableFrom(LifecycleOwner.class)) {
throw new IllegalArgumentException("invalid parameter type. Must be one and instanceof LifecycleOwner");
}
i = 1;
}
Lifecycle.Event value = onLifecycleEvent.value();
if (parameterTypes.length > 1) {
if (parameterTypes[1].isAssignableFrom(Lifecycle.Event.class)) {
if (value != Lifecycle.Event.ON_ANY) {
throw new IllegalArgumentException("Second arg is supported only for ON_ANY value");
}
i = 2;
} else {
throw new IllegalArgumentException("invalid parameter type. second arg must be an event");
}
}
if (parameterTypes.length <= 2) {
a(hashMap, new MethodReference(i, method), value, cls);
z = true;
} else {
throw new IllegalArgumentException("cannot have more than 2 params");
}
}
}
CallbackInfo callbackInfo = new CallbackInfo(hashMap);
this.a.put(cls, callbackInfo);
this.b.put(cls, Boolean.valueOf(z));
return callbackInfo;
}
}

View File

@@ -0,0 +1,23 @@
package androidx.lifecycle;
import androidx.lifecycle.Lifecycle;
/* loaded from: classes.dex */
public class CompositeGeneratedAdaptersObserver implements GenericLifecycleObserver {
private final GeneratedAdapter[] a;
CompositeGeneratedAdaptersObserver(GeneratedAdapter[] generatedAdapterArr) {
this.a = generatedAdapterArr;
}
@Override // androidx.lifecycle.GenericLifecycleObserver
public void a(LifecycleOwner lifecycleOwner, Lifecycle.Event event) {
MethodCallsLogger methodCallsLogger = new MethodCallsLogger();
for (GeneratedAdapter generatedAdapter : this.a) {
generatedAdapter.a(lifecycleOwner, event, false, methodCallsLogger);
}
for (GeneratedAdapter generatedAdapter2 : this.a) {
generatedAdapter2.a(lifecycleOwner, event, true, methodCallsLogger);
}
}
}

View File

@@ -0,0 +1,16 @@
package androidx.lifecycle;
/* loaded from: classes.dex */
interface FullLifecycleObserver extends LifecycleObserver {
void a(LifecycleOwner lifecycleOwner);
void b(LifecycleOwner lifecycleOwner);
void c(LifecycleOwner lifecycleOwner);
void d(LifecycleOwner lifecycleOwner);
void e(LifecycleOwner lifecycleOwner);
void f(LifecycleOwner lifecycleOwner);
}

View File

@@ -0,0 +1,76 @@
package androidx.lifecycle;
import androidx.lifecycle.Lifecycle;
/* loaded from: classes.dex */
class FullLifecycleObserverAdapter implements GenericLifecycleObserver {
private final FullLifecycleObserver a;
/* renamed from: androidx.lifecycle.FullLifecycleObserverAdapter$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] a = new int[Lifecycle.Event.values().length];
static {
try {
a[Lifecycle.Event.ON_CREATE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[Lifecycle.Event.ON_START.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
a[Lifecycle.Event.ON_RESUME.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
a[Lifecycle.Event.ON_PAUSE.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
a[Lifecycle.Event.ON_STOP.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
a[Lifecycle.Event.ON_DESTROY.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
a[Lifecycle.Event.ON_ANY.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
}
}
FullLifecycleObserverAdapter(FullLifecycleObserver fullLifecycleObserver) {
this.a = fullLifecycleObserver;
}
@Override // androidx.lifecycle.GenericLifecycleObserver
public void a(LifecycleOwner lifecycleOwner, Lifecycle.Event event) {
switch (AnonymousClass1.a[event.ordinal()]) {
case 1:
this.a.b(lifecycleOwner);
return;
case 2:
this.a.f(lifecycleOwner);
return;
case 3:
this.a.a(lifecycleOwner);
return;
case 4:
this.a.c(lifecycleOwner);
return;
case 5:
this.a.d(lifecycleOwner);
return;
case 6:
this.a.e(lifecycleOwner);
return;
case 7:
throw new IllegalArgumentException("ON_ANY must not been send by anybody");
default:
return;
}
}
}

View File

@@ -0,0 +1,8 @@
package androidx.lifecycle;
import androidx.lifecycle.Lifecycle;
/* loaded from: classes.dex */
public interface GeneratedAdapter {
void a(LifecycleOwner lifecycleOwner, Lifecycle.Event event, boolean z, MethodCallsLogger methodCallsLogger);
}

View File

@@ -0,0 +1,8 @@
package androidx.lifecycle;
import androidx.lifecycle.Lifecycle;
/* loaded from: classes.dex */
public interface GenericLifecycleObserver extends LifecycleObserver {
void a(LifecycleOwner lifecycleOwner, Lifecycle.Event event);
}

View File

@@ -0,0 +1,33 @@
package androidx.lifecycle;
/* loaded from: classes.dex */
public abstract class Lifecycle {
public enum Event {
ON_CREATE,
ON_START,
ON_RESUME,
ON_PAUSE,
ON_STOP,
ON_DESTROY,
ON_ANY
}
public enum State {
DESTROYED,
INITIALIZED,
CREATED,
STARTED,
RESUMED;
public boolean isAtLeast(State state) {
return compareTo(state) >= 0;
}
}
public abstract State a();
public abstract void a(LifecycleObserver lifecycleObserver);
public abstract void b(LifecycleObserver lifecycleObserver);
}

View File

@@ -0,0 +1,5 @@
package androidx.lifecycle;
/* loaded from: classes.dex */
public interface LifecycleObserver {
}

View File

@@ -0,0 +1,6 @@
package androidx.lifecycle;
/* loaded from: classes.dex */
public interface LifecycleOwner {
Lifecycle getLifecycle();
}

View File

@@ -0,0 +1,292 @@
package androidx.lifecycle;
import android.util.Log;
import androidx.arch.core.internal.FastSafeIterableMap;
import androidx.arch.core.internal.SafeIterableMap;
import androidx.lifecycle.Lifecycle;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
/* loaded from: classes.dex */
public class LifecycleRegistry extends Lifecycle {
private final WeakReference<LifecycleOwner> c;
private FastSafeIterableMap<LifecycleObserver, ObserverWithState> a = new FastSafeIterableMap<>();
private int d = 0;
private boolean e = false;
private boolean f = false;
private ArrayList<Lifecycle.State> g = new ArrayList<>();
private Lifecycle.State b = Lifecycle.State.INITIALIZED;
/* renamed from: androidx.lifecycle.LifecycleRegistry$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] a;
static final /* synthetic */ int[] b = new int[Lifecycle.State.values().length];
static {
try {
b[Lifecycle.State.INITIALIZED.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
b[Lifecycle.State.CREATED.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
b[Lifecycle.State.STARTED.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
b[Lifecycle.State.RESUMED.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
b[Lifecycle.State.DESTROYED.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
a = new int[Lifecycle.Event.values().length];
try {
a[Lifecycle.Event.ON_CREATE.ordinal()] = 1;
} catch (NoSuchFieldError unused6) {
}
try {
a[Lifecycle.Event.ON_STOP.ordinal()] = 2;
} catch (NoSuchFieldError unused7) {
}
try {
a[Lifecycle.Event.ON_START.ordinal()] = 3;
} catch (NoSuchFieldError unused8) {
}
try {
a[Lifecycle.Event.ON_PAUSE.ordinal()] = 4;
} catch (NoSuchFieldError unused9) {
}
try {
a[Lifecycle.Event.ON_RESUME.ordinal()] = 5;
} catch (NoSuchFieldError unused10) {
}
try {
a[Lifecycle.Event.ON_DESTROY.ordinal()] = 6;
} catch (NoSuchFieldError unused11) {
}
try {
a[Lifecycle.Event.ON_ANY.ordinal()] = 7;
} catch (NoSuchFieldError unused12) {
}
}
}
static class ObserverWithState {
Lifecycle.State a;
GenericLifecycleObserver b;
ObserverWithState(LifecycleObserver lifecycleObserver, Lifecycle.State state) {
this.b = Lifecycling.a(lifecycleObserver);
this.a = state;
}
void a(LifecycleOwner lifecycleOwner, Lifecycle.Event event) {
Lifecycle.State b = LifecycleRegistry.b(event);
this.a = LifecycleRegistry.a(this.a, b);
this.b.a(lifecycleOwner, event);
this.a = b;
}
}
public LifecycleRegistry(LifecycleOwner lifecycleOwner) {
this.c = new WeakReference<>(lifecycleOwner);
}
private boolean b() {
if (this.a.size() == 0) {
return true;
}
Lifecycle.State state = this.a.a().getValue().a;
Lifecycle.State state2 = this.a.d().getValue().a;
return state == state2 && this.b == state2;
}
private void c(Lifecycle.State state) {
if (this.b == state) {
return;
}
this.b = state;
if (this.e || this.d != 0) {
this.f = true;
return;
}
this.e = true;
d();
this.e = false;
}
private void d(Lifecycle.State state) {
this.g.add(state);
}
private static Lifecycle.Event e(Lifecycle.State state) {
int i = AnonymousClass1.b[state.ordinal()];
if (i != 1) {
if (i == 2) {
return Lifecycle.Event.ON_START;
}
if (i == 3) {
return Lifecycle.Event.ON_RESUME;
}
if (i == 4) {
throw new IllegalArgumentException();
}
if (i != 5) {
throw new IllegalArgumentException("Unexpected state value " + state);
}
}
return Lifecycle.Event.ON_CREATE;
}
public void a(Lifecycle.State state) {
c(state);
}
private void d() {
LifecycleOwner lifecycleOwner = this.c.get();
if (lifecycleOwner == null) {
Log.w("LifecycleRegistry", "LifecycleOwner is garbage collected, you shouldn't try dispatch new events from it.");
return;
}
while (!b()) {
this.f = false;
if (this.b.compareTo(this.a.a().getValue().a) < 0) {
a(lifecycleOwner);
}
Map.Entry<LifecycleObserver, ObserverWithState> d = this.a.d();
if (!this.f && d != null && this.b.compareTo(d.getValue().a) > 0) {
b(lifecycleOwner);
}
}
this.f = false;
}
public void a(Lifecycle.Event event) {
c(b(event));
}
@Override // androidx.lifecycle.Lifecycle
public void a(LifecycleObserver lifecycleObserver) {
LifecycleOwner lifecycleOwner;
Lifecycle.State state = this.b;
Lifecycle.State state2 = Lifecycle.State.DESTROYED;
if (state != state2) {
state2 = Lifecycle.State.INITIALIZED;
}
ObserverWithState observerWithState = new ObserverWithState(lifecycleObserver, state2);
if (this.a.b(lifecycleObserver, observerWithState) == null && (lifecycleOwner = this.c.get()) != null) {
boolean z = this.d != 0 || this.e;
Lifecycle.State c = c(lifecycleObserver);
this.d++;
while (observerWithState.a.compareTo(c) < 0 && this.a.contains(lifecycleObserver)) {
d(observerWithState.a);
observerWithState.a(lifecycleOwner, e(observerWithState.a));
c();
c = c(lifecycleObserver);
}
if (!z) {
d();
}
this.d--;
}
}
@Override // androidx.lifecycle.Lifecycle
public void b(LifecycleObserver lifecycleObserver) {
this.a.remove(lifecycleObserver);
}
static Lifecycle.State b(Lifecycle.Event event) {
switch (AnonymousClass1.a[event.ordinal()]) {
case 1:
case 2:
return Lifecycle.State.CREATED;
case 3:
case 4:
return Lifecycle.State.STARTED;
case 5:
return Lifecycle.State.RESUMED;
case 6:
return Lifecycle.State.DESTROYED;
default:
throw new IllegalArgumentException("Unexpected event value " + event);
}
}
private Lifecycle.State c(LifecycleObserver lifecycleObserver) {
Map.Entry<LifecycleObserver, ObserverWithState> b = this.a.b(lifecycleObserver);
Lifecycle.State state = null;
Lifecycle.State state2 = b != null ? b.getValue().a : null;
if (!this.g.isEmpty()) {
state = this.g.get(r0.size() - 1);
}
return a(a(this.b, state2), state);
}
private static Lifecycle.Event b(Lifecycle.State state) {
int i = AnonymousClass1.b[state.ordinal()];
if (i == 1) {
throw new IllegalArgumentException();
}
if (i == 2) {
return Lifecycle.Event.ON_DESTROY;
}
if (i == 3) {
return Lifecycle.Event.ON_STOP;
}
if (i == 4) {
return Lifecycle.Event.ON_PAUSE;
}
if (i != 5) {
throw new IllegalArgumentException("Unexpected state value " + state);
}
throw new IllegalArgumentException();
}
private void c() {
this.g.remove(r0.size() - 1);
}
/* JADX WARN: Multi-variable type inference failed */
private void b(LifecycleOwner lifecycleOwner) {
SafeIterableMap<LifecycleObserver, ObserverWithState>.IteratorWithAdditions b = this.a.b();
while (b.hasNext() && !this.f) {
Map.Entry next = b.next();
ObserverWithState observerWithState = (ObserverWithState) next.getValue();
while (observerWithState.a.compareTo(this.b) < 0 && !this.f && this.a.contains(next.getKey())) {
d(observerWithState.a);
observerWithState.a(lifecycleOwner, e(observerWithState.a));
c();
}
}
}
@Override // androidx.lifecycle.Lifecycle
public Lifecycle.State a() {
return this.b;
}
private void a(LifecycleOwner lifecycleOwner) {
Iterator<Map.Entry<LifecycleObserver, ObserverWithState>> descendingIterator = this.a.descendingIterator();
while (descendingIterator.hasNext() && !this.f) {
Map.Entry<LifecycleObserver, ObserverWithState> next = descendingIterator.next();
ObserverWithState value = next.getValue();
while (value.a.compareTo(this.b) > 0 && !this.f && this.a.contains(next.getKey())) {
Lifecycle.Event b = b(value.a);
d(b(b));
value.a(lifecycleOwner, b);
c();
}
}
}
static Lifecycle.State a(Lifecycle.State state, Lifecycle.State state2) {
return (state2 == null || state2.compareTo(state) >= 0) ? state : state2;
}
}

View File

@@ -0,0 +1,8 @@
package androidx.lifecycle;
@Deprecated
/* loaded from: classes.dex */
public interface LifecycleRegistryOwner extends LifecycleOwner {
@Override // androidx.lifecycle.LifecycleOwner
LifecycleRegistry getLifecycle();
}

View File

@@ -0,0 +1,128 @@
package androidx.lifecycle;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
public class Lifecycling {
private static Map<Class, Integer> a = new HashMap();
private static Map<Class, List<Constructor<? extends GeneratedAdapter>>> b = new HashMap();
static GenericLifecycleObserver a(Object obj) {
if (obj instanceof FullLifecycleObserver) {
return new FullLifecycleObserverAdapter((FullLifecycleObserver) obj);
}
if (obj instanceof GenericLifecycleObserver) {
return (GenericLifecycleObserver) obj;
}
Class<?> cls = obj.getClass();
if (b(cls) != 2) {
return new ReflectiveGenericLifecycleObserver(obj);
}
List<Constructor<? extends GeneratedAdapter>> list = b.get(cls);
if (list.size() == 1) {
return new SingleGeneratedAdapterObserver(a(list.get(0), obj));
}
GeneratedAdapter[] generatedAdapterArr = new GeneratedAdapter[list.size()];
for (int i = 0; i < list.size(); i++) {
generatedAdapterArr[i] = a(list.get(i), obj);
}
return new CompositeGeneratedAdaptersObserver(generatedAdapterArr);
}
private static int b(Class<?> cls) {
if (a.containsKey(cls)) {
return a.get(cls).intValue();
}
int d = d(cls);
a.put(cls, Integer.valueOf(d));
return d;
}
private static boolean c(Class<?> cls) {
return cls != null && LifecycleObserver.class.isAssignableFrom(cls);
}
private static int d(Class<?> cls) {
if (cls.getCanonicalName() == null) {
return 1;
}
Constructor<? extends GeneratedAdapter> a2 = a(cls);
if (a2 != null) {
b.put(cls, Collections.singletonList(a2));
return 2;
}
if (ClassesInfoCache.c.b(cls)) {
return 1;
}
Class<? super Object> superclass = cls.getSuperclass();
ArrayList arrayList = null;
if (c(superclass)) {
if (b(superclass) == 1) {
return 1;
}
arrayList = new ArrayList(b.get(superclass));
}
for (Class<?> cls2 : cls.getInterfaces()) {
if (c(cls2)) {
if (b(cls2) == 1) {
return 1;
}
if (arrayList == null) {
arrayList = new ArrayList();
}
arrayList.addAll(b.get(cls2));
}
}
if (arrayList == null) {
return 1;
}
b.put(cls, arrayList);
return 2;
}
private static GeneratedAdapter a(Constructor<? extends GeneratedAdapter> constructor, Object obj) {
try {
return constructor.newInstance(obj);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InstantiationException e2) {
throw new RuntimeException(e2);
} catch (InvocationTargetException e3) {
throw new RuntimeException(e3);
}
}
private static Constructor<? extends GeneratedAdapter> a(Class<?> cls) {
try {
Package r0 = cls.getPackage();
String canonicalName = cls.getCanonicalName();
String name = r0 != null ? r0.getName() : "";
if (!name.isEmpty()) {
canonicalName = canonicalName.substring(name.length() + 1);
}
String a2 = a(canonicalName);
if (!name.isEmpty()) {
a2 = name + "." + a2;
}
Constructor declaredConstructor = Class.forName(a2).getDeclaredConstructor(cls);
if (!declaredConstructor.isAccessible()) {
declaredConstructor.setAccessible(true);
}
return declaredConstructor;
} catch (ClassNotFoundException unused) {
return null;
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
public static String a(String str) {
return str.replace(".", "_") + "_LifecycleAdapter";
}
}

View File

@@ -0,0 +1,194 @@
package androidx.lifecycle;
import androidx.arch.core.executor.ArchTaskExecutor;
import androidx.arch.core.internal.SafeIterableMap;
import androidx.lifecycle.Lifecycle;
/* loaded from: classes.dex */
public abstract class LiveData<T> {
static final Object i = new Object();
final Object a = new Object();
private SafeIterableMap<Observer<? super T>, LiveData<T>.ObserverWrapper> b = new SafeIterableMap<>();
int c = 0;
private volatile Object d;
volatile Object e;
private int f;
private boolean g;
private boolean h;
private abstract class ObserverWrapper {
final Observer<? super T> a;
boolean b;
int c = -1;
ObserverWrapper(Observer<? super T> observer) {
this.a = observer;
}
void a() {
}
void a(boolean z) {
if (z == this.b) {
return;
}
this.b = z;
boolean z2 = LiveData.this.c == 0;
LiveData.this.c += this.b ? 1 : -1;
if (z2 && this.b) {
LiveData.this.a();
}
LiveData liveData = LiveData.this;
if (liveData.c == 0 && !this.b) {
liveData.b();
}
if (this.b) {
LiveData.this.a(this);
}
}
boolean a(LifecycleOwner lifecycleOwner) {
return false;
}
abstract boolean b();
}
public LiveData() {
Object obj = i;
this.d = obj;
this.e = obj;
this.f = -1;
new Runnable() { // from class: androidx.lifecycle.LiveData.1
/* JADX WARN: Multi-variable type inference failed */
@Override // java.lang.Runnable
public void run() {
Object obj2;
synchronized (LiveData.this.a) {
obj2 = LiveData.this.e;
LiveData.this.e = LiveData.i;
}
LiveData.this.a((LiveData) obj2);
}
};
}
private void b(LiveData<T>.ObserverWrapper observerWrapper) {
if (observerWrapper.b) {
if (!observerWrapper.b()) {
observerWrapper.a(false);
return;
}
int i2 = observerWrapper.c;
int i3 = this.f;
if (i2 >= i3) {
return;
}
observerWrapper.c = i3;
observerWrapper.a.a((Object) this.d);
}
}
protected void a() {
}
void a(LiveData<T>.ObserverWrapper observerWrapper) {
if (this.g) {
this.h = true;
return;
}
this.g = true;
do {
this.h = false;
if (observerWrapper != null) {
b(observerWrapper);
observerWrapper = null;
} else {
SafeIterableMap<Observer<? super T>, LiveData<T>.ObserverWrapper>.IteratorWithAdditions b = this.b.b();
while (b.hasNext()) {
b((ObserverWrapper) b.next().getValue());
if (this.h) {
break;
}
}
}
} while (this.h);
this.g = false;
}
protected void b() {
}
class LifecycleBoundObserver extends LiveData<T>.ObserverWrapper implements GenericLifecycleObserver {
final LifecycleOwner e;
LifecycleBoundObserver(LifecycleOwner lifecycleOwner, Observer<? super T> observer) {
super(observer);
this.e = lifecycleOwner;
}
@Override // androidx.lifecycle.GenericLifecycleObserver
public void a(LifecycleOwner lifecycleOwner, Lifecycle.Event event) {
if (this.e.getLifecycle().a() == Lifecycle.State.DESTROYED) {
LiveData.this.a((Observer) this.a);
} else {
a(b());
}
}
@Override // androidx.lifecycle.LiveData.ObserverWrapper
boolean b() {
return this.e.getLifecycle().a().isAtLeast(Lifecycle.State.STARTED);
}
@Override // androidx.lifecycle.LiveData.ObserverWrapper
boolean a(LifecycleOwner lifecycleOwner) {
return this.e == lifecycleOwner;
}
@Override // androidx.lifecycle.LiveData.ObserverWrapper
void a() {
this.e.getLifecycle().b(this);
}
}
public void a(LifecycleOwner lifecycleOwner, Observer<? super T> observer) {
a("observe");
if (lifecycleOwner.getLifecycle().a() == Lifecycle.State.DESTROYED) {
return;
}
LifecycleBoundObserver lifecycleBoundObserver = new LifecycleBoundObserver(lifecycleOwner, observer);
LiveData<T>.ObserverWrapper b = this.b.b(observer, lifecycleBoundObserver);
if (b != null && !b.a(lifecycleOwner)) {
throw new IllegalArgumentException("Cannot add the same observer with different lifecycles");
}
if (b != null) {
return;
}
lifecycleOwner.getLifecycle().a(lifecycleBoundObserver);
}
public void a(Observer<? super T> observer) {
a("removeObserver");
LiveData<T>.ObserverWrapper remove = this.b.remove(observer);
if (remove == null) {
return;
}
remove.a();
remove.a(false);
}
protected void a(T t) {
a("setValue");
this.f++;
this.d = t;
a((ObserverWrapper) null);
}
private static void a(String str) {
if (ArchTaskExecutor.b().a()) {
return;
}
throw new IllegalStateException("Cannot invoke " + str + " on a background thread");
}
}

View File

@@ -0,0 +1,10 @@
package androidx.lifecycle;
import java.util.HashMap;
/* loaded from: classes.dex */
public class MethodCallsLogger {
public MethodCallsLogger() {
new HashMap();
}
}

View File

@@ -0,0 +1,9 @@
package androidx.lifecycle;
/* loaded from: classes.dex */
public class MutableLiveData<T> extends LiveData<T> {
@Override // androidx.lifecycle.LiveData
public void a(T t) {
super.a((MutableLiveData<T>) t);
}
}

View File

@@ -0,0 +1,6 @@
package androidx.lifecycle;
/* loaded from: classes.dex */
public interface Observer<T> {
void a(T t);
}

View File

@@ -0,0 +1,14 @@
package androidx.lifecycle;
import androidx.lifecycle.Lifecycle;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
/* loaded from: classes.dex */
public @interface OnLifecycleEvent {
Lifecycle.Event value();
}

View File

@@ -0,0 +1,20 @@
package androidx.lifecycle;
import androidx.lifecycle.ClassesInfoCache;
import androidx.lifecycle.Lifecycle;
/* loaded from: classes.dex */
class ReflectiveGenericLifecycleObserver implements GenericLifecycleObserver {
private final Object a;
private final ClassesInfoCache.CallbackInfo b;
ReflectiveGenericLifecycleObserver(Object obj) {
this.a = obj;
this.b = ClassesInfoCache.c.a(this.a.getClass());
}
@Override // androidx.lifecycle.GenericLifecycleObserver
public void a(LifecycleOwner lifecycleOwner, Lifecycle.Event event) {
this.b.a(lifecycleOwner, event, this.a);
}
}

View File

@@ -0,0 +1,99 @@
package androidx.lifecycle;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.ComponentCallbacks2;
import android.os.Bundle;
import androidx.lifecycle.Lifecycle;
/* loaded from: classes.dex */
public class ReportFragment extends Fragment {
private ActivityInitializationListener a;
interface ActivityInitializationListener {
void a();
void b();
void onStart();
}
public static void a(Activity activity) {
FragmentManager fragmentManager = activity.getFragmentManager();
if (fragmentManager.findFragmentByTag("androidx.lifecycle.LifecycleDispatcher.report_fragment_tag") == null) {
fragmentManager.beginTransaction().add(new ReportFragment(), "androidx.lifecycle.LifecycleDispatcher.report_fragment_tag").commit();
fragmentManager.executePendingTransactions();
}
}
private void b(ActivityInitializationListener activityInitializationListener) {
if (activityInitializationListener != null) {
activityInitializationListener.b();
}
}
private void c(ActivityInitializationListener activityInitializationListener) {
if (activityInitializationListener != null) {
activityInitializationListener.onStart();
}
}
@Override // android.app.Fragment
public void onActivityCreated(Bundle bundle) {
super.onActivityCreated(bundle);
a(this.a);
a(Lifecycle.Event.ON_CREATE);
}
@Override // android.app.Fragment
public void onDestroy() {
super.onDestroy();
a(Lifecycle.Event.ON_DESTROY);
this.a = null;
}
@Override // android.app.Fragment
public void onPause() {
super.onPause();
a(Lifecycle.Event.ON_PAUSE);
}
@Override // android.app.Fragment
public void onResume() {
super.onResume();
b(this.a);
a(Lifecycle.Event.ON_RESUME);
}
@Override // android.app.Fragment
public void onStart() {
super.onStart();
c(this.a);
a(Lifecycle.Event.ON_START);
}
@Override // android.app.Fragment
public void onStop() {
super.onStop();
a(Lifecycle.Event.ON_STOP);
}
private void a(ActivityInitializationListener activityInitializationListener) {
if (activityInitializationListener != null) {
activityInitializationListener.a();
}
}
private void a(Lifecycle.Event event) {
ComponentCallbacks2 activity = getActivity();
if (activity instanceof LifecycleRegistryOwner) {
((LifecycleRegistryOwner) activity).getLifecycle().a(event);
} else if (activity instanceof LifecycleOwner) {
Lifecycle lifecycle = ((LifecycleOwner) activity).getLifecycle();
if (lifecycle instanceof LifecycleRegistry) {
((LifecycleRegistry) lifecycle).a(event);
}
}
}
}

View File

@@ -0,0 +1,18 @@
package androidx.lifecycle;
import androidx.lifecycle.Lifecycle;
/* loaded from: classes.dex */
public class SingleGeneratedAdapterObserver implements GenericLifecycleObserver {
private final GeneratedAdapter a;
SingleGeneratedAdapterObserver(GeneratedAdapter generatedAdapter) {
this.a = generatedAdapter;
}
@Override // androidx.lifecycle.GenericLifecycleObserver
public void a(LifecycleOwner lifecycleOwner, Lifecycle.Event event) {
this.a.a(lifecycleOwner, event, false, null);
this.a.a(lifecycleOwner, event, true, null);
}
}

View File

@@ -0,0 +1,7 @@
package androidx.lifecycle;
/* loaded from: classes.dex */
public abstract class ViewModel {
protected void a() {
}
}

View File

@@ -0,0 +1,34 @@
package androidx.lifecycle;
/* loaded from: classes.dex */
public class ViewModelProvider {
private final Factory a;
private final ViewModelStore b;
public interface Factory {
<T extends ViewModel> T a(Class<T> cls);
}
public ViewModelProvider(ViewModelStore viewModelStore, Factory factory) {
this.a = factory;
this.b = viewModelStore;
}
public <T extends ViewModel> T a(Class<T> cls) {
String canonicalName = cls.getCanonicalName();
if (canonicalName == null) {
throw new IllegalArgumentException("Local and anonymous classes can not be ViewModels");
}
return (T) a("androidx.lifecycle.ViewModelProvider.DefaultKey:" + canonicalName, cls);
}
public <T extends ViewModel> T a(String str, Class<T> cls) {
T t = (T) this.b.a(str);
if (cls.isInstance(t)) {
return t;
}
T t2 = (T) this.a.a(cls);
this.b.a(str, t2);
return t2;
}
}

View File

@@ -0,0 +1,28 @@
package androidx.lifecycle;
import java.util.HashMap;
import java.util.Iterator;
/* loaded from: classes.dex */
public class ViewModelStore {
private final HashMap<String, ViewModel> a = new HashMap<>();
final void a(String str, ViewModel viewModel) {
ViewModel put = this.a.put(str, viewModel);
if (put != null) {
put.a();
}
}
final ViewModel a(String str) {
return this.a.get(str);
}
public final void a() {
Iterator<ViewModel> it = this.a.values().iterator();
while (it.hasNext()) {
it.next().a();
}
this.a.clear();
}
}

View File

@@ -0,0 +1,6 @@
package androidx.lifecycle;
/* loaded from: classes.dex */
public interface ViewModelStoreOwner {
ViewModelStore getViewModelStore();
}