package defpackage;

import android.content.Context;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.button.MaterialButton;
import com.strmr.ps.R;
import com.strmr.ps.data.model.UpdateCheckResult;
import com.strmr.ps.data.model.UpdateInfo;
import com.strmr.ps.data.repository.UpdateRepository;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.ui.settings.fragments.AboutFragment$checkForUpdates$1", f = "AboutFragment.kt", i = {}, l = {221}, m = "invokeSuspend", n = {}, s = {})
final class ak extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public int a;
    public final /* synthetic */ an b;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public ak(an anVar, Continuation continuation) {
        super(2, continuation);
        this.b = anVar;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        return new ak(this.b, continuation);
    }

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((ak) create((ak1) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Object invokeSuspend(Object obj) {
        ck1 ck1Var = ck1.a;
        int i = this.a;
        an anVar = this.b;
        if (i == 0) {
            s38.b(obj);
            UpdateRepository updateRepository = anVar.f;
            if (updateRepository == null) {
                cr4.n("updateRepository");
                throw null;
            }
            this.a = 1;
            obj = updateRepository.checkForUpdate(this);
            if (obj == ck1Var) {
                return ck1Var;
            }
        } else {
            if (i != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
        }
        UpdateCheckResult updateCheckResult = (UpdateCheckResult) obj;
        ProgressBar progressBar = anVar.o;
        if (progressBar == null) {
            cr4.n("updateProgress");
            throw null;
        }
        progressBar.setVisibility(8);
        MaterialButton materialButton = anVar.k;
        if (materialButton == null) {
            cr4.n("checkUpdateButton");
            throw null;
        }
        materialButton.setEnabled(true);
        if (updateCheckResult instanceof UpdateCheckResult.UpdateAvailable) {
            UpdateInfo updateInfo = ((UpdateCheckResult.UpdateAvailable) updateCheckResult).getUpdateInfo();
            l9a l9aVar = anVar.i;
            if (l9aVar == null) {
                cr4.n("updateDialogFactory");
                throw null;
            }
            Context contextRequireContext = anVar.requireContext();
            cr4.f(contextRequireContext, "requireContext(...)");
            i85 viewLifecycleOwner = anVar.getViewLifecycleOwner();
            cr4.f(viewLifecycleOwner, "getViewLifecycleOwner(...)");
            k9a k9aVarA = l9aVar.a(contextRequireContext, updateInfo, viewLifecycleOwner, new ah(anVar, 0));
            k9aVarA.show();
            anVar.s = k9aVarA;
        } else if (updateCheckResult instanceof UpdateCheckResult.NoUpdateAvailable) {
            TextView textView = anVar.p;
            if (textView == null) {
                cr4.n("updateStatusText");
                throw null;
            }
            textView.setVisibility(0);
            TextView textView2 = anVar.p;
            if (textView2 == null) {
                cr4.n("updateStatusText");
                throw null;
            }
            textView2.setText(anVar.getString(R.string.no_update_available));
            TextView textView3 = anVar.p;
            if (textView3 == null) {
                cr4.n("updateStatusText");
                throw null;
            }
            textView3.setTextColor(sf1.getColor(anVar.requireContext(), R.color.text_secondary));
        } else {
            if (!(updateCheckResult instanceof UpdateCheckResult.Error)) {
                throw new io6();
            }
            TextView textView4 = anVar.p;
            if (textView4 == null) {
                cr4.n("updateStatusText");
                throw null;
            }
            textView4.setVisibility(0);
            TextView textView5 = anVar.p;
            if (textView5 == null) {
                cr4.n("updateStatusText");
                throw null;
            }
            textView5.setText(anVar.getString(R.string.update_check_failed));
            TextView textView6 = anVar.p;
            if (textView6 == null) {
                cr4.n("updateStatusText");
                throw null;
            }
            textView6.setTextColor(sf1.getColor(anVar.requireContext(), R.color.error_color));
            Toast.makeText(anVar.requireContext(), ((UpdateCheckResult.Error) updateCheckResult).getMessage(), 1).show();
        }
        return e6a.a;
    }
}
