package com.strmr.ps.ui.splash;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.credentials.CredentialOption;
import androidx.lifecycle.s;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.exoplayer.ExoPlayer;
import androidx.media3.exoplayer.upstream.CmcdData;
import com.airbnb.lottie.LottieAnimationView;
import com.strmr.ps.R;
import com.strmr.ps.background.TraktSyncWorker;
import com.strmr.ps.data.local.entity.TraktAccount;
import com.strmr.ps.data.model.UpdateCheckResult;
import com.strmr.ps.data.repository.ContinueWatchingRepository;
import com.strmr.ps.data.repository.PreferencesRepository;
import com.strmr.ps.data.repository.TraktAccountRepository;
import com.strmr.ps.data.repository.TraktSyncRepository;
import com.strmr.ps.data.repository.WatchStatusRepository;
import com.strmr.ps.data.supabase.DeviceManager;
import com.strmr.ps.data.supabase.SettingsSyncManager;
import com.strmr.ps.data.update.UpdateManager;
import com.strmr.ps.util.PlatformUtils;
import dagger.hilt.android.AndroidEntryPoint;
import defpackage.bd5;
import defpackage.c74;
import defpackage.cc9;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.e6a;
import defpackage.fx4;
import defpackage.h32;
import defpackage.hf5;
import defpackage.hsa;
import defpackage.io6;
import defpackage.l9a;
import defpackage.lr3;
import defpackage.lt6;
import defpackage.lta;
import defpackage.m02;
import defpackage.m12;
import defpackage.osa;
import defpackage.pg9;
import defpackage.s38;
import defpackage.sc2;
import defpackage.sr3;
import defpackage.ua;
import defpackage.wj0;
import defpackage.y41;
import defpackage.zs6;
import java.util.List;
import kotlin.Metadata;
import kotlin.coroutines.jvm.internal.ContinuationImpl;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\b\u0007\u0018\u00002\u00020\u0001:\u0001\u0004B\u0007¢\u0006\u0004\b\u0002\u0010\u0003¨\u0006\u0005"}, d2 = {"Lcom/strmr/ps/ui/splash/SyncSplashActivity;", "Landroidx/fragment/app/t;", "<init>", "()V", CmcdData.OBJECT_TYPE_AUDIO_ONLY, "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@AndroidEntryPoint
public final class SyncSplashActivity extends c74 {
    public static final /* synthetic */ int ac = 0;
    public Dialog ab;
    public TraktAccountRepository f;
    public TraktSyncRepository i;
    public UpdateManager j;
    public ContinueWatchingRepository k;
    public WatchStatusRepository l;
    public l9a m;
    public PreferencesRepository n;
    public SettingsSyncManager o;
    public DeviceManager p;
    public cc9 q;
    public ProgressBar r;
    public TextView s;
    public TextView t;
    public LottieAnimationView u;
    public Button v;
    public boolean w;
    public boolean x;
    public final long y = 30000;
    public final long z = 60000;
    public final List aa = y41.an("Hacking the mainframe...", "Bribing the API gods...", "Downloading more RAM...", "Calibrating flux capacitors...", "Reticulating splines...", "Feeding the hamsters...", "Convincing servers to cooperate...", "Teaching AI to appreciate cinema...", "Compiling your taste in movies...", "Polishing the posters...", "Bribing the hamsters with premium organic kale...", "The server went for a coffee break, chasing it down...", "Blowing the dust off the digital film reels...", "Sticking the loose wires back together with bubblegum...", "Trying to explain the plot to the motherboard...", "Searching for the 'Any' key to continue...", "Refilling the server's espresso reservoir...", "Overclocking the popcorn machine...", "Reversing the polarity of the stream...", "Herding 404 errors back into the server...", "Optimizing the 'Enhance' button...", "Defragmenting the plot twists...", "Scanning for hidden Easter eggs...", "Upgrading the pixels to 5D...", "Checking for post-credit scenes...", "Waiting for the montage to finish...", "Consulting the script supervisor...", "Negotiating with the lead actor's agent...", "Applying digital makeup...", "Casting the background extras...", "Editing out the boom mic...", "Teaching the algorithm to cry at rom-coms...", "Asking the database for its favorite color...", "Calculating the speed of a cinematic slow-mo...", "Waking up the sleeping GPUs...", "Inflating the ego of the director AI...", "Distilling the essence of 'Coming Soon'...", "Locating the 'Wilhelm Scream' samples...");

    @Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\b\u0086\u0003\u0018\u00002\u00020\u0001R\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0003\u0010\u0004¨\u0006\u0005"}, d2 = {"Lcom/strmr/ps/ui/splash/SyncSplashActivity$a;", "", "", "TAG", "Ljava/lang/String;", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class a {
    }

    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public /* synthetic */ class b {
        static {
            int[] iArr = new int[hsa.c.values().length];
            try {
                iArr[1] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[2] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[3] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                iArr[5] = 4;
            } catch (NoSuchFieldError unused4) {
            }
        }
    }

    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class c implements zs6, sr3 {
        public final /* synthetic */ lt6 a;

        public c(lt6 lt6Var) {
            this.a = lt6Var;
        }

        @Override // defpackage.zs6
        public final /* synthetic */ void a(Object obj) {
            this.a.invoke(obj);
        }

        @Override // defpackage.sr3
        public final lr3 b() {
            return this.a;
        }

        public final boolean equals(Object obj) {
            if (!(obj instanceof zs6) || !(obj instanceof sr3)) {
                return false;
            }
            return this.a.equals(((sr3) obj).b());
        }

        public final int hashCode() {
            return this.a.hashCode();
        }
    }

    /* JADX WARN: Can't wrap try/catch for region: R(23:51|(1:56)(1:55)|132|57|58|142|59|60|(1:147)|138|63|(1:65)(1:69)|70|(3:144|72|(11:74|75|130|76|77|136|78|79|140|80|(1:148)))|93|(9:134|95|(0)(2:97|98)|104|105|112|(1:114)(1:115)|116|(2:118|(1:120)(2:121|122))(7:123|(1:149)|15|126|43|(0)(0)|(18:48|51|(1:53)|56|132|57|58|142|59|60|(0)|138|63|(0)(0)|70|(0)|93|(0))))|103|104|105|112|(0)(0)|116|(0)(0)) */
    /* JADX WARN: Code restructure failed: missing block: B:106:0x01d8, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:109:0x01dd, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:67:0x0166, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:68:0x0167, code lost:
    
        r5 = r5;
        r7 = r7;
     */
    /* JADX WARN: Code restructure failed: missing block: B:99:0x01c8, code lost:
    
        if (r0.a() == true) goto L127;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Path cross not found for [B:103:0x01d1, B:134:0x01bf], limit reached: 141 */
    /* JADX WARN: Path cross not found for [B:134:0x01bf, B:103:0x01d1], limit reached: 141 */
    /* JADX WARN: Path cross not found for [B:144:0x016f, B:93:0x01b9], limit reached: 141 */
    /* JADX WARN: Path cross not found for [B:53:0x0122, B:56:0x0136], limit reached: 141 */
    /* JADX WARN: Path cross not found for [B:93:0x01b9, B:144:0x016f], limit reached: 141 */
    /* JADX WARN: Removed duplicated region for block: B:114:0x01f1  */
    /* JADX WARN: Removed duplicated region for block: B:115:0x01f3  */
    /* JADX WARN: Removed duplicated region for block: B:118:0x01f9  */
    /* JADX WARN: Removed duplicated region for block: B:123:0x022f  */
    /* JADX WARN: Removed duplicated region for block: B:134:0x01bf A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:144:0x016f A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:147:? A[RETURN, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:45:0x010d  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x0112  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x0115  */
    /* JADX WARN: Removed duplicated region for block: B:65:0x0163 A[Catch: Exception -> 0x0166, TRY_ENTER, TRY_LEAVE, TryCatch #7 {Exception -> 0x0166, blocks: (B:59:0x014c, B:65:0x0163), top: B:142:0x014c }] */
    /* JADX WARN: Removed duplicated region for block: B:69:0x016a  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    /* JADX WARN: Type inference failed for: r14v20 */
    /* JADX WARN: Type inference failed for: r14v21 */
    /* JADX WARN: Type inference failed for: r14v4 */
    /* JADX WARN: Type inference failed for: r14v5 */
    /* JADX WARN: Type inference failed for: r14v7, types: [long] */
    /* JADX WARN: Type inference failed for: r14v9 */
    /* JADX WARN: Type inference failed for: r16v0 */
    /* JADX WARN: Type inference failed for: r16v1 */
    /* JADX WARN: Type inference failed for: r16v2 */
    /* JADX WARN: Type inference failed for: r16v3 */
    /* JADX WARN: Type inference failed for: r16v4 */
    /* JADX WARN: Type inference failed for: r16v5 */
    /* JADX WARN: Type inference failed for: r5v0 */
    /* JADX WARN: Type inference failed for: r5v10 */
    /* JADX WARN: Type inference failed for: r5v14, types: [long] */
    /* JADX WARN: Type inference failed for: r5v15 */
    /* JADX WARN: Type inference failed for: r5v16 */
    /* JADX WARN: Type inference failed for: r5v17 */
    /* JADX WARN: Type inference failed for: r5v19, types: [long] */
    /* JADX WARN: Type inference failed for: r5v20 */
    /* JADX WARN: Type inference failed for: r5v24 */
    /* JADX WARN: Type inference failed for: r5v25 */
    /* JADX WARN: Type inference failed for: r5v26 */
    /* JADX WARN: Type inference failed for: r5v27 */
    /* JADX WARN: Type inference failed for: r5v28 */
    /* JADX WARN: Type inference failed for: r5v29 */
    /* JADX WARN: Type inference failed for: r5v30 */
    /* JADX WARN: Type inference failed for: r5v5 */
    /* JADX WARN: Type inference failed for: r5v6 */
    /* JADX WARN: Type inference failed for: r5v7 */
    /* JADX WARN: Type inference failed for: r5v8 */
    /* JADX WARN: Type inference failed for: r7v0 */
    /* JADX WARN: Type inference failed for: r7v1 */
    /* JADX WARN: Type inference failed for: r7v14 */
    /* JADX WARN: Type inference failed for: r7v19 */
    /* JADX WARN: Type inference failed for: r7v2 */
    /* JADX WARN: Type inference failed for: r7v20 */
    /* JADX WARN: Type inference failed for: r7v21 */
    /* JADX WARN: Type inference failed for: r7v22 */
    /* JADX WARN: Type inference failed for: r7v23 */
    /* JADX WARN: Type inference failed for: r7v24 */
    /* JADX WARN: Type inference failed for: r7v25 */
    /* JADX WARN: Type inference failed for: r7v26 */
    /* JADX WARN: Type inference failed for: r7v27 */
    /* JADX WARN: Type inference failed for: r7v28 */
    /* JADX WARN: Type inference failed for: r7v29 */
    /* JADX WARN: Type inference failed for: r7v3 */
    /* JADX WARN: Type inference failed for: r7v4 */
    /* JADX WARN: Type inference failed for: r7v5 */
    /* JADX WARN: Type inference failed for: r7v6, types: [android.content.Context, com.strmr.ps.ui.splash.SyncSplashActivity] */
    /* JADX WARN: Type inference failed for: r7v7, types: [android.app.Activity, com.strmr.ps.ui.splash.SyncSplashActivity] */
    /* JADX WARN: Type inference failed for: r7v8, types: [android.app.Activity, com.strmr.ps.ui.splash.SyncSplashActivity] */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:126:0x0244 -> B:43:0x00ff). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object e(SyncSplashActivity syncSplashActivity, ContinuationImpl continuationImpl) throws Throwable {
        com.strmr.ps.ui.splash.a aVar;
        long jCurrentTimeMillis;
        int i;
        Exception e;
        long j;
        long jCurrentTimeMillis2;
        ?? r7;
        ?? r5;
        ?? r72;
        ?? r52;
        ?? r14;
        long j2;
        long j3;
        int i2;
        ?? r73;
        long j4;
        long j5;
        hsa hsaVar;
        ?? r53;
        fx4 fx4Var;
        Integer statsShowsWatched;
        Integer statsMoviesWatched;
        SyncSplashActivity syncSplashActivity2 = syncSplashActivity;
        if (continuationImpl instanceof com.strmr.ps.ui.splash.a) {
            aVar = (com.strmr.ps.ui.splash.a) continuationImpl;
            int i3 = aVar.j;
            if ((i3 & Integer.MIN_VALUE) != 0) {
                aVar.j = i3 - Integer.MIN_VALUE;
            } else {
                aVar = new com.strmr.ps.ui.splash.a(syncSplashActivity2, continuationImpl);
            }
        }
        Object objF = aVar.f;
        ck1 ck1Var = ck1.a;
        int i4 = aVar.j;
        ?? r54 = 4;
        ?? r74 = 2;
        boolean z = true;
        if (i4 == 0) {
            s38.b(objF);
            TraktSyncWorker.a.c(syncSplashActivity2);
            osa osaVarD = osa.d(syncSplashActivity2);
            bd5.a(osaVarD.c.f().t("trakt_initial_sync"), lta.y, osaVarD.d).f(syncSplashActivity2, new c(new lt6(syncSplashActivity2, 11)));
            jCurrentTimeMillis = System.currentTimeMillis();
            m12 m12Var = sc2.a;
            m02 m02Var = m02.c;
            com.strmr.ps.ui.splash.b bVar = new com.strmr.ps.ui.splash.b(syncSplashActivity2, null);
            aVar.a = syncSplashActivity2;
            aVar.b = jCurrentTimeMillis;
            aVar.j = 1;
            objF = wj0.f(m02Var, bVar, aVar);
            if (objF == ck1Var) {
                return ck1Var;
            }
        } else if (i4 != 1) {
            try {
            } catch (Exception e2) {
                e = e2;
                i = i4;
                r52 = r54;
                r72 = r74;
                Log.e("SyncSplashActivity", "Error polling WorkManager", e);
                long j6 = j;
                r14 = r52;
                j2 = jCurrentTimeMillis2;
                j3 = j6;
                r73 = r72;
                i2 = i;
                boolean z2 = r73.x;
                j4 = j2;
                if (!z2) {
                }
                if (j4 <= j5) {
                }
            }
            if (i4 != 2) {
                if (i4 == 3) {
                    long j7 = aVar.d;
                    int i5 = aVar.e;
                    long j8 = aVar.c;
                    long j9 = aVar.b;
                    SyncSplashActivity syncSplashActivity3 = aVar.a;
                    s38.b(objF);
                    return e6a.a;
                }
                if (i4 != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                i2 = aVar.e;
                j3 = aVar.c;
                long j10 = aVar.b;
                SyncSplashActivity syncSplashActivity4 = aVar.a;
                s38.b(objF);
                ?? r75 = syncSplashActivity4;
                Object obj = null;
                ?? r142 = j10;
                r5 = r142;
                j = j3;
                z = true;
                r7 = r75;
                fx4Var = (fx4) aVar.getB().cb(fx4.b.a);
                if ((fx4Var != null ? fx4Var.isActive() : z) && !r7.w) {
                    jCurrentTimeMillis2 = System.currentTimeMillis() - r5;
                    if (i2 == 0 || jCurrentTimeMillis2 <= r7.y) {
                        i = i2;
                    } else {
                        long j11 = jCurrentTimeMillis2 / ((long) 1000);
                        r7.runOnUiThread(new pg9(r7, 1));
                        i = 1;
                    }
                    m12 m12Var2 = sc2.a;
                    m02 m02Var2 = m02.c;
                    com.strmr.ps.ui.splash.c cVar = new com.strmr.ps.ui.splash.c(r7, null);
                    aVar.a = r7;
                    aVar.b = r5;
                    aVar.c = j;
                    aVar.e = i;
                    aVar.d = jCurrentTimeMillis2;
                    aVar.j = 2;
                    objF = wj0.f(m02Var2, cVar, aVar);
                    r5 = r5;
                    r7 = r7;
                    if (objF == ck1Var) {
                        return ck1Var;
                    }
                    List list = (List) objF;
                    cr4.d(list);
                    hsaVar = (hsa) y41.ab(list);
                    if ((hsaVar != null ? hsaVar.b : null) == hsa.c.d) {
                        try {
                        } catch (Exception e3) {
                            e = e3;
                        }
                        if (cr4.b(hsaVar.d.b("error_type"), "auth")) {
                            Log.w("SyncSplashActivity", "Sync failed with auth error - proceeding without sync");
                            try {
                            } catch (Exception e4) {
                                e = e4;
                                r53 = r5;
                                r52 = r53;
                                r72 = r7;
                                Log.e("SyncSplashActivity", "Error polling WorkManager", e);
                                long j62 = j;
                                r14 = r52;
                                j2 = jCurrentTimeMillis2;
                                j3 = j62;
                                r73 = r72;
                                i2 = i;
                                boolean z22 = r73.x;
                                j4 = j2;
                                if (!z22) {
                                }
                                if (j4 <= j5) {
                                }
                            }
                            r7.runOnUiThread(new pg9(r7, 2));
                            aVar.a = r7;
                            aVar.b = r5;
                            aVar.c = j;
                            aVar.e = i;
                            aVar.d = jCurrentTimeMillis2;
                            try {
                            } catch (Exception e5) {
                                e = e5;
                                r53 = r5;
                            }
                            aVar.j = 3;
                            try {
                            } catch (Exception e6) {
                                e = e6;
                                r53 = r5;
                                r52 = r53;
                                r72 = r7;
                                Log.e("SyncSplashActivity", "Error polling WorkManager", e);
                                long j622 = j;
                                r14 = r52;
                                j2 = jCurrentTimeMillis2;
                                j3 = j622;
                                r73 = r72;
                                i2 = i;
                                boolean z222 = r73.x;
                                j4 = j2;
                                if (!z222) {
                                }
                                if (j4 <= j5) {
                                }
                            }
                            if (h32.a(ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS, aVar) == ck1Var) {
                                return ck1Var;
                            }
                        }
                    }
                    ?? r16 = r5;
                    if (hsaVar != null) {
                        try {
                        } catch (Exception e7) {
                            e = e7;
                            r52 = r16;
                            r72 = r7;
                            Log.e("SyncSplashActivity", "Error polling WorkManager", e);
                            long j6222 = j;
                            r14 = r52;
                            j2 = jCurrentTimeMillis2;
                            j3 = j6222;
                            r73 = r72;
                            i2 = i;
                            boolean z2222 = r73.x;
                            j4 = j2;
                            if (!z2222) {
                            }
                            if (j4 <= j5) {
                            }
                        }
                        hsa.c cVar2 = hsaVar.b;
                        if (cVar2 == null) {
                        }
                        j2 = jCurrentTimeMillis2;
                        j3 = j;
                        r14 = r16;
                        r73 = r7;
                        i2 = i;
                        boolean z22222 = r73.x;
                        j4 = j2;
                        j5 = !z22222 ? j3 : r73.z;
                        if (j4 <= j5) {
                            Log.w("SyncSplashActivity", "Sync timeout after " + (j5 / ((long) 1000)) + "s (hasProgress=" + z22222 + ")");
                            TextView textView = r73.s;
                            if (textView == null) {
                                cr4.n("statusText");
                                throw null;
                            }
                            textView.setText(r73.getString(R.string.sync_continuing_background));
                        } else {
                            obj = null;
                            aVar.a = r73;
                            aVar.b = r14;
                            aVar.c = j3;
                            aVar.e = i2;
                            aVar.j = 4;
                            r75 = r73;
                            r142 = r14;
                            if (h32.a(500L, aVar) == ck1Var) {
                                return ck1Var;
                            }
                            r5 = r142;
                            j = j3;
                            z = true;
                            r7 = r75;
                            fx4Var = (fx4) aVar.getB().cb(fx4.b.a);
                            if (fx4Var != null ? fx4Var.isActive() : z) {
                                jCurrentTimeMillis2 = System.currentTimeMillis() - r5;
                                if (i2 == 0) {
                                }
                                i = i2;
                                m12 m12Var22 = sc2.a;
                                m02 m02Var22 = m02.c;
                                com.strmr.ps.ui.splash.c cVar3 = new com.strmr.ps.ui.splash.c(r7, null);
                                aVar.a = r7;
                                aVar.b = r5;
                                aVar.c = j;
                                aVar.e = i;
                                aVar.d = jCurrentTimeMillis2;
                                aVar.j = 2;
                                objF = wj0.f(m02Var22, cVar3, aVar);
                                r5 = r5;
                                r7 = r7;
                                if (objF == ck1Var) {
                                }
                                List list2 = (List) objF;
                                cr4.d(list2);
                                hsaVar = (hsa) y41.ab(list2);
                                if ((hsaVar != null ? hsaVar.b : null) == hsa.c.d) {
                                }
                                ?? r162 = r5;
                                if (hsaVar != null) {
                                }
                            }
                        }
                    }
                    j2 = jCurrentTimeMillis2;
                    j3 = j;
                    r14 = r162;
                    r73 = r7;
                    i2 = i;
                    boolean z222222 = r73.x;
                    j4 = j2;
                    if (!z222222) {
                    }
                    if (j4 <= j5) {
                    }
                }
                return e6a.a;
            }
            jCurrentTimeMillis2 = aVar.d;
            int i6 = aVar.e;
            j = aVar.c;
            long j12 = aVar.b;
            SyncSplashActivity syncSplashActivity5 = aVar.a;
            s38.b(objF);
            i = i6;
            r5 = j12;
            r7 = syncSplashActivity5;
            List list22 = (List) objF;
            cr4.d(list22);
            hsaVar = (hsa) y41.ab(list22);
            if ((hsaVar != null ? hsaVar.b : null) == hsa.c.d) {
            }
            ?? r1622 = r5;
            if (hsaVar != null) {
            }
            j2 = jCurrentTimeMillis2;
            j3 = j;
            r14 = r1622;
            r73 = r7;
            i2 = i;
            boolean z2222222 = r73.x;
            j4 = j2;
            if (!z2222222) {
            }
            if (j4 <= j5) {
            }
        } else {
            jCurrentTimeMillis = aVar.b;
            syncSplashActivity2 = aVar.a;
            s38.b(objF);
        }
        TraktAccount traktAccount = (TraktAccount) objF;
        long jMin = Math.min((((long) (((((traktAccount == null || (statsMoviesWatched = traktAccount.getStatsMoviesWatched()) == null) ? 0 : statsMoviesWatched.intValue()) + ((traktAccount == null || (statsShowsWatched = traktAccount.getStatsShowsWatched()) == null) ? 0 : statsShowsWatched.intValue())) / CredentialOption.PRIORITY_OIDC_OR_SIMILAR) * 60)) * 1000) + 180000, 900000L);
        long j13 = jMin / ((long) 1000);
        r7 = syncSplashActivity2;
        i2 = 0;
        j = jMin;
        r5 = jCurrentTimeMillis;
        fx4Var = (fx4) aVar.getB().cb(fx4.b.a);
        if (fx4Var != null ? fx4Var.isActive() : z) {
        }
        return e6a.a;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0015  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object f(SyncSplashActivity syncSplashActivity, ContinuationImpl continuationImpl) {
        d dVar;
        if (continuationImpl instanceof d) {
            dVar = (d) continuationImpl;
            int i = dVar.c;
            if ((i & Integer.MIN_VALUE) != 0) {
                dVar.c = i - Integer.MIN_VALUE;
            } else {
                dVar = new d(syncSplashActivity, continuationImpl);
            }
        }
        Object objA = dVar.a;
        ck1 ck1Var = ck1.a;
        int i2 = dVar.c;
        try {
            if (i2 == 0) {
                s38.b(objA);
                UpdateManager updateManager = syncSplashActivity.j;
                if (updateManager == null) {
                    cr4.n("updateManager");
                    throw null;
                }
                dVar.c = 1;
                objA = updateManager.a(dVar);
                if (objA == ck1Var) {
                    return ck1Var;
                }
            } else {
                if (i2 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(objA);
            }
            UpdateCheckResult updateCheckResult = (UpdateCheckResult) objA;
            if (updateCheckResult instanceof UpdateCheckResult.UpdateAvailable) {
                ((UpdateCheckResult.UpdateAvailable) updateCheckResult).getUpdateInfo().getVersion();
                ((UpdateCheckResult.UpdateAvailable) updateCheckResult).isForced();
                return (UpdateCheckResult.UpdateAvailable) updateCheckResult;
            }
            if (updateCheckResult instanceof UpdateCheckResult.NoUpdateAvailable) {
                return null;
            }
            if (!(updateCheckResult instanceof UpdateCheckResult.Error)) {
                throw new io6();
            }
            Log.w("SyncSplashActivity", "Update check failed: " + ((UpdateCheckResult.Error) updateCheckResult).getMessage());
            return null;
        } catch (Exception e) {
            Log.e("SyncSplashActivity", "Unexpected error during update check", e);
            return null;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:17:0x0042  */
    /* JADX WARN: Removed duplicated region for block: B:18:0x0047  */
    /* JADX WARN: Removed duplicated region for block: B:20:0x004a  */
    /* JADX WARN: Removed duplicated region for block: B:25:0x005b  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x0078  */
    /* JADX WARN: Removed duplicated region for block: B:28:0x007f  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:21:0x0054 -> B:23:0x0057). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object g(SyncSplashActivity syncSplashActivity, ContinuationImpl continuationImpl) {
        r rVar;
        fx4 fx4Var;
        if (continuationImpl instanceof r) {
            rVar = (r) continuationImpl;
            int i = rVar.d;
            if ((i & Integer.MIN_VALUE) != 0) {
                rVar.d = i - Integer.MIN_VALUE;
            } else {
                rVar = new r(syncSplashActivity, continuationImpl);
            }
        }
        Object obj = rVar.b;
        ck1 ck1Var = ck1.a;
        int i2 = rVar.d;
        if (i2 == 0) {
            s38.b(obj);
            fx4Var = (fx4) rVar.getB().cb(fx4.b.a);
            if (fx4Var == null ? fx4Var.isActive() : true) {
            }
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            syncSplashActivity = rVar.a;
            s38.b(obj);
            TextView textView = syncSplashActivity.t;
            if (textView == null) {
                textView.animate().alpha(0.0f).setDuration(200L).withEndAction(new pg9(syncSplashActivity, 0)).start();
                fx4Var = (fx4) rVar.getB().cb(fx4.b.a);
                if (fx4Var == null ? fx4Var.isActive() : true) {
                    return e6a.a;
                }
                rVar.a = syncSplashActivity;
                rVar.d = 1;
                if (h32.a(2500L, rVar) == ck1Var) {
                    return ck1Var;
                }
                TextView textView2 = syncSplashActivity.t;
                if (textView2 == null) {
                    cr4.n("funMessageText");
                    throw null;
                }
            }
        }
    }

    @Override // android.app.Activity, android.view.ContextThemeWrapper, android.content.ContextWrapper
    public final void attachBaseContext(Context context) {
        cr4.g(context, "newBase");
        super.attachBaseContext(hf5.a(context));
    }

    public final ContinueWatchingRepository h() {
        ContinueWatchingRepository continueWatchingRepository = this.k;
        if (continueWatchingRepository != null) {
            return continueWatchingRepository;
        }
        cr4.n("continueWatchingRepository");
        throw null;
    }

    public final DeviceManager i() {
        DeviceManager deviceManager = this.p;
        if (deviceManager != null) {
            return deviceManager;
        }
        cr4.n("deviceManager");
        throw null;
    }

    @Override // defpackage.c74, androidx.fragment.app.t, defpackage.j91, defpackage.n91, android.app.Activity
    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setRequestedOrientation(!PlatformUtils.a.a(this) ? 1 : 0);
        setContentView(R.layout.activity_sync_splash);
        this.r = (ProgressBar) findViewById(R.id.sync_progress);
        this.s = (TextView) findViewById(R.id.status_text);
        this.t = (TextView) findViewById(R.id.fun_message_text);
        this.u = (LottieAnimationView) findViewById(R.id.splash_animation);
        this.v = (Button) findViewById(R.id.skip_sync_button);
        LottieAnimationView lottieAnimationView = this.u;
        if (lottieAnimationView == null) {
            cr4.n("splashAnimation");
            throw null;
        }
        lottieAnimationView.setSpeed(0.9f);
        Button button = this.v;
        if (button == null) {
            cr4.n("skipSyncButton");
            throw null;
        }
        button.setOnClickListener(new ua(this, 22));
        wj0.c(s.a(this), null, null, new q(this, null), 3);
    }

    @Override // defpackage.c74, androidx.fragment.app.t, android.app.Activity
    public final void onDestroy() {
        super.onDestroy();
        Dialog dialog = this.ab;
        if (dialog != null) {
            dialog.dismiss();
        }
        this.ab = null;
    }
}
