mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-14 09:57:16 +01:00
94 lines
5.4 KiB
Java
94 lines
5.4 KiB
Java
package androidx.lifecycle;
|
|
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import androidx.lifecycle.Lifecycle;
|
|
import kotlin.Metadata;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u0000:\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\b\u0016\u0018\u00002\u00020\u0001:\u0001\u0018B\u000f\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0004\b\u0004\u0010\u0005J\u0010\u0010\f\u001a\u00020\r2\u0006\u0010\u000e\u001a\u00020\u000fH\u0002J\b\u0010\u0010\u001a\u00020\rH\u0016J\b\u0010\u0011\u001a\u00020\rH\u0016J\b\u0010\u0012\u001a\u00020\rH\u0016J\b\u0010\u0013\u001a\u00020\rH\u0016R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\n\u001a\u0004\u0018\u00010\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0014\u001a\u00020\u00158VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u0016\u0010\u0017¨\u0006\u0019"}, d2 = {"Landroidx/lifecycle/ServiceLifecycleDispatcher;", "", "provider", "Landroidx/lifecycle/LifecycleOwner;", "<init>", "(Landroidx/lifecycle/LifecycleOwner;)V", "registry", "Landroidx/lifecycle/LifecycleRegistry;", "handler", "Landroid/os/Handler;", "lastDispatchRunnable", "Landroidx/lifecycle/ServiceLifecycleDispatcher$DispatchRunnable;", "postDispatchRunnable", "", "event", "Landroidx/lifecycle/Lifecycle$Event;", "onServicePreSuperOnCreate", "onServicePreSuperOnBind", "onServicePreSuperOnStart", "onServicePreSuperOnDestroy", "lifecycle", "Landroidx/lifecycle/Lifecycle;", "getLifecycle", "()Landroidx/lifecycle/Lifecycle;", "DispatchRunnable", "lifecycle-service"}, k = 1, mv = {2, 0, 0}, xi = 48)
|
|
/* loaded from: classes14.dex */
|
|
public class ServiceLifecycleDispatcher {
|
|
|
|
@NotNull
|
|
private final Handler handler;
|
|
|
|
@Nullable
|
|
private DispatchRunnable lastDispatchRunnable;
|
|
|
|
@NotNull
|
|
private final LifecycleRegistry registry;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u0000$\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0002\n\u0000\b\u0000\u0018\u00002\u00020\u0001B\u0017\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0004\b\u0006\u0010\u0007J\b\u0010\f\u001a\u00020\rH\u0016R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u0011\u0010\u0004\u001a\u00020\u0005¢\u0006\b\n\u0000\u001a\u0004\b\b\u0010\tR\u000e\u0010\n\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\u000e"}, d2 = {"Landroidx/lifecycle/ServiceLifecycleDispatcher$DispatchRunnable;", "Ljava/lang/Runnable;", "registry", "Landroidx/lifecycle/LifecycleRegistry;", "event", "Landroidx/lifecycle/Lifecycle$Event;", "<init>", "(Landroidx/lifecycle/LifecycleRegistry;Landroidx/lifecycle/Lifecycle$Event;)V", "getEvent", "()Landroidx/lifecycle/Lifecycle$Event;", "wasExecuted", "", "run", "", "lifecycle-service"}, k = 1, mv = {2, 0, 0}, xi = 48)
|
|
public static final class DispatchRunnable implements Runnable {
|
|
|
|
@NotNull
|
|
private final Lifecycle.Event event;
|
|
|
|
@NotNull
|
|
private final LifecycleRegistry registry;
|
|
private boolean wasExecuted;
|
|
|
|
public DispatchRunnable(@NotNull LifecycleRegistry lifecycleRegistry, @NotNull Lifecycle.Event event) {
|
|
lifecycleRegistry.getClass();
|
|
event.getClass();
|
|
this.registry = lifecycleRegistry;
|
|
this.event = event;
|
|
}
|
|
|
|
@NotNull
|
|
public final Lifecycle.Event getEvent() {
|
|
return this.event;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (this.wasExecuted) {
|
|
return;
|
|
}
|
|
this.registry.handleLifecycleEvent(this.event);
|
|
this.wasExecuted = true;
|
|
}
|
|
}
|
|
|
|
public ServiceLifecycleDispatcher(@NotNull LifecycleOwner lifecycleOwner) {
|
|
lifecycleOwner.getClass();
|
|
this.registry = new LifecycleRegistry(lifecycleOwner);
|
|
this.handler = new Handler(Looper.getMainLooper());
|
|
}
|
|
|
|
private final void postDispatchRunnable(Lifecycle.Event event) {
|
|
DispatchRunnable dispatchRunnable = this.lastDispatchRunnable;
|
|
if (dispatchRunnable != null) {
|
|
dispatchRunnable.run();
|
|
}
|
|
DispatchRunnable dispatchRunnable2 = new DispatchRunnable(this.registry, event);
|
|
this.lastDispatchRunnable = dispatchRunnable2;
|
|
this.handler.postAtFrontOfQueue(dispatchRunnable2);
|
|
}
|
|
|
|
@NotNull
|
|
public Lifecycle getLifecycle() {
|
|
return this.registry;
|
|
}
|
|
|
|
public void onServicePreSuperOnBind() {
|
|
postDispatchRunnable(Lifecycle.Event.ON_START);
|
|
}
|
|
|
|
public void onServicePreSuperOnCreate() {
|
|
postDispatchRunnable(Lifecycle.Event.ON_CREATE);
|
|
}
|
|
|
|
public void onServicePreSuperOnDestroy() {
|
|
postDispatchRunnable(Lifecycle.Event.ON_STOP);
|
|
postDispatchRunnable(Lifecycle.Event.ON_DESTROY);
|
|
}
|
|
|
|
public void onServicePreSuperOnStart() {
|
|
postDispatchRunnable(Lifecycle.Event.ON_START);
|
|
}
|
|
}
|