package d3;

import V2.Q2;
import android.content.Context;
import android.os.Bundle;
import androidx.compose.runtime.State;
import androidx.lifecycle.EnumC1107p;
import androidx.lifecycle.InterfaceC1111u;
import androidx.lifecycle.InterfaceC1113w;
import androidx.media3.exoplayer.ExoPlayer;
import com.debridstream.tv.PlayerViewModel;
import g.AbstractC2055i;
import g.C2047a;
import g.C2051e;
import g.InterfaceC2048b;
import h.AbstractC2068b;
import java.util.LinkedHashMap;
import java.util.concurrent.atomic.AtomicBoolean;

/* JADX INFO: renamed from: d3.q0, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class C1917q0 implements InterfaceC1111u {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f15920a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ Object f15921b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ Object f15922c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ Object f15923d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ Object f15924e;

    public /* synthetic */ C1917q0(Object obj, Object obj2, Object obj3, Object obj4, int i6) {
        this.f15920a = i6;
        this.f15921b = obj;
        this.f15922c = obj2;
        this.f15923d = obj3;
        this.f15924e = obj4;
    }

    @Override // androidx.lifecycle.InterfaceC1111u
    public final void a(InterfaceC1113w interfaceC1113w, EnumC1107p enumC1107p) {
        ExoPlayer exoPlayer;
        ExoPlayer exoPlayer2;
        Object obj = this.f15924e;
        Object obj2 = this.f15923d;
        Object obj3 = this.f15922c;
        Object obj4 = this.f15921b;
        switch (this.f15920a) {
            case 0:
                int i6 = m2.f15822a[enumC1107p.ordinal()];
                State state = (State) obj3;
                if (i6 == 1) {
                    if (((AtomicBoolean) obj4).compareAndSet(true, false) && (exoPlayer = (ExoPlayer) state.getValue()) != null) {
                        exoPlayer.setPlayWhenReady(true);
                    }
                } else if (i6 == 2 && (exoPlayer2 = (ExoPlayer) state.getValue()) != null) {
                    long duration = exoPlayer2.getDuration();
                    Long lValueOf = Long.valueOf(duration);
                    if (duration <= 0) {
                        lValueOf = null;
                    }
                    long jLongValue = lValueOf != null ? lValueOf.longValue() : 0L;
                    if (jLongValue > 0) {
                        PlayerViewModel playerViewModel = (PlayerViewModel) obj2;
                        if (((Q2) playerViewModel.getUiState().getValue()).f7502g != null) {
                            long currentPosition = exoPlayer2.getCurrentPosition();
                            long j4 = currentPosition < 0 ? 0L : currentPosition;
                            a5.c cVar = g3.p.f16541a;
                            Context applicationContext = ((Context) obj).getApplicationContext();
                            kotlin.jvm.internal.o.g(applicationContext, "getApplicationContext(...)");
                            g3.p.b(applicationContext, playerViewModel, j4, jLongValue, "lifecycle_on_stop");
                        }
                    }
                }
                break;
            default:
                AbstractC2055i abstractC2055i = (AbstractC2055i) obj4;
                String str = (String) obj3;
                if (EnumC1107p.ON_START == enumC1107p) {
                    InterfaceC2048b interfaceC2048b = (InterfaceC2048b) obj2;
                    AbstractC2068b abstractC2068b = (AbstractC2068b) obj;
                    abstractC2055i.f16450e.put(str, new C2051e(abstractC2068b, interfaceC2048b));
                    LinkedHashMap linkedHashMap = abstractC2055i.f16451f;
                    if (linkedHashMap.containsKey(str)) {
                        Object obj5 = linkedHashMap.get(str);
                        linkedHashMap.remove(str);
                        interfaceC2048b.onActivityResult(obj5);
                    }
                    Bundle bundle = abstractC2055i.f16452g;
                    C2047a c2047a = (C2047a) android.support.v4.media.session.b.s(bundle, str, C2047a.class);
                    if (c2047a != null) {
                        bundle.remove(str);
                        interfaceC2048b.onActivityResult(abstractC2068b.parseResult(c2047a.f16435a, c2047a.f16436b));
                    }
                } else if (EnumC1107p.ON_STOP == enumC1107p) {
                    abstractC2055i.f16450e.remove(str);
                } else if (EnumC1107p.ON_DESTROY == enumC1107p) {
                    abstractC2055i.f(str);
                }
                break;
        }
    }
}
