导航菜单

页面标题

页面副标题

Uptodown App Store v6.80 - Updates.java 源代码

正在查看: Uptodown App Store v6.80 应用的 Updates.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.uptodown.activities;

import J1.AbstractC0355q2;
import M1.J;
import N1.k;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.activity.ComponentActivity;
import androidx.activity.OnBackPressedCallback;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.documentfile.provider.DocumentFile;
import androidx.lifecycle.LifecycleOwnerKt;
import androidx.lifecycle.ViewModelLazy;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStore;
import androidx.lifecycle.viewmodel.CreationExtras;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.work.Data;
import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;
import b2.C0552a;
import c2.C0601q;
import c2.C0610v;
import c2.K0;
import com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlNode;
import com.uptodown.UptodownApp;
import com.uptodown.activities.AbstractC0740a;
import com.uptodown.activities.Updates;
import com.uptodown.activities.W;
import com.uptodown.activities.preferences.PreferencesActivity;
import com.uptodown.activities.preferences.a;
import com.uptodown.workers.DownloadUpdatesWorker;
import com.uptodown.workers.DownloadWorker;
import com.uptodown.workers.GenerateQueueWorker;
import f2.InterfaceC0915F;
import f2.InterfaceC0916G;
import f2.InterfaceC0919b;
import f2.InterfaceC0924g;
import f2.InterfaceC0935s;
import g2.C0953d;
import g2.C0965p;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import u2.C1218B;
import u2.C1233m;
import u2.H;
import u2.v;

public final class Updates extends AbstractC0355q2 {
    private ArrayList X;
    private M1.J Y;
    private boolean Z;

    private boolean f261n0;

    private final ActivityResultLauncher f266s0;

    private final h f267t0;
    private final R2.g V = R2.h.a(new d3.a() {
        @Override
        public final Object invoke() {
            c2.K0 i5;
            i5 = Updates.i5(Updates.this);
            return i5;
        }
    });
    private final R2.g W = new ViewModelLazy(kotlin.jvm.internal.D.b(W.class), new m(this), new l(this), new n(null, this));

    private ArrayList f260m0 = new ArrayList();

    private q f262o0 = new q();

    private a f263p0 = new a();

    private t f264q0 = new t();

    private f f265r0 = new f();

    public static final class a implements InterfaceC0919b {
        a() {
        }

        @Override
        public void a(int i) {
            ArrayList b;
            ArrayList b4;
            if (UptodownApp.F.a0()) {
                M1.J j = Updates.this.Y;
                C0953d c0953d = null;
                if (((j == null || (b4 = j.b()) == null) ? null : b4.get(i)) instanceof J.a) {
                    M1.J j4 = Updates.this.Y;
                    kotlin.jvm.internal.m.b(j4);
                    Object obj = j4.b().get(i);
                    kotlin.jvm.internal.m.c(obj, "null cannot be cast to non-null type com.uptodown.adapters.UpdatesAdapter.AppUpdateData");
                    c0953d = ((J.a) obj).a();
                } else {
                    M1.J j5 = Updates.this.Y;
                    if (((j5 == null || (b = j5.b()) == null) ? null : b.get(i)) instanceof C0953d) {
                        M1.J j6 = Updates.this.Y;
                        kotlin.jvm.internal.m.b(j6);
                        Object obj2 = j6.b().get(i);
                        kotlin.jvm.internal.m.c(obj2, "null cannot be cast to non-null type com.uptodown.models.App");
                        c0953d = (C0953d) obj2;
                    }
                }
                if (c0953d != null) {
                    Updates.this.Q3(c0953d, i);
                }
            }
        }

        @Override
        public void b(int i) {
            ArrayList b;
            ArrayList b4;
            if (UptodownApp.F.a0()) {
                M1.J j = Updates.this.Y;
                C0953d c0953d = null;
                if (((j == null || (b4 = j.b()) == null) ? null : b4.get(i)) instanceof J.a) {
                    M1.J j4 = Updates.this.Y;
                    kotlin.jvm.internal.m.b(j4);
                    Object obj = j4.b().get(i);
                    kotlin.jvm.internal.m.c(obj, "null cannot be cast to non-null type com.uptodown.adapters.UpdatesAdapter.AppUpdateData");
                    c0953d = ((J.a) obj).a();
                } else {
                    M1.J j5 = Updates.this.Y;
                    if (((j5 == null || (b = j5.b()) == null) ? null : b.get(i)) instanceof C0953d) {
                        M1.J j6 = Updates.this.Y;
                        kotlin.jvm.internal.m.b(j6);
                        Object obj2 = j6.b().get(i);
                        kotlin.jvm.internal.m.c(obj2, "null cannot be cast to non-null type com.uptodown.models.App");
                        c0953d = (C0953d) obj2;
                    }
                }
                if (c0953d == null || c0953d.b() <= 0) {
                    return;
                }
                Updates.this.D2(c0953d.b());
            }
        }
    }

    static final class b extends kotlin.coroutines.jvm.internal.l implements d3.p {
        int a;

        b(V2.d dVar) {
            super(2, dVar);
        }

        public static final void m(kotlin.jvm.internal.z zVar, Updates updates, View view) {
            UptodownApp.a aVar = UptodownApp.F;
            if (aVar.a0()) {
                zVar.a = true;
                updates.k5();
                updates.T5();
                updates.startActivity(new Intent(updates.getApplicationContext(), (Class<?>) PreferencesActivity.class), aVar.a(updates));
                AlertDialog k22 = updates.k2();
                if (k22 != null) {
                    k22.dismiss();
                }
            }
        }

        public static final void n(kotlin.jvm.internal.z zVar, Updates updates, View view) {
            zVar.a = true;
            AlertDialog k22 = updates.k2();
            if (k22 != null) {
                k22.dismiss();
            }
            updates.k5();
            updates.T5();
        }

        public static final void o(kotlin.jvm.internal.z zVar, Updates updates, View view) {
            zVar.a = true;
            AlertDialog k22 = updates.k2();
            if (k22 != null) {
                k22.dismiss();
            }
            updates.f261n0 = true;
            updates.L5();
        }

        public static final void p(kotlin.jvm.internal.z zVar, Updates updates, DialogInterface dialogInterface) {
            if (zVar.a) {
                return;
            }
            updates.k5();
            updates.T5();
        }

        @Override
        public final V2.d create(Object obj, V2.d dVar) {
            return Updates.this.new b(dVar);
        }

        @Override
        public final Object invokeSuspend(Object obj) {
            W2.b.c();
            if (this.a != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            R2.n.b(obj);
            final kotlin.jvm.internal.z zVar = new kotlin.jvm.internal.z();
            AlertDialog k22 = Updates.this.k2();
            if (k22 != null) {
                k22.dismiss();
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(Updates.this);
            C0601q c = C0601q.c(Updates.this.getLayoutInflater());
            kotlin.jvm.internal.m.d(c, "inflate(...)");
            final Updates updates = Updates.this;
            TextView textView = c.f;
            k.a aVar = N1.k.g;
            textView.setTypeface(aVar.w());
            c.c.setTypeface(aVar.x());
            c.e.setTypeface(aVar.w());
            c.b.setTypeface(aVar.w());
            c.d.setTypeface(aVar.w());
            c.e.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    Updates.b.m(kotlin.jvm.internal.z.this, updates, view);
                }
            });
            c.b.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    Updates.b.n(kotlin.jvm.internal.z.this, updates, view);
                }
            });
            c.d.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    Updates.b.o(kotlin.jvm.internal.z.this, updates, view);
                }
            });
            builder.setView(c.getRoot());
            Updates.this.K2(builder.create());
            AlertDialog k23 = Updates.this.k2();
            kotlin.jvm.internal.m.b(k23);
            final Updates updates2 = Updates.this;
            k23.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public final void onDismiss(DialogInterface dialogInterface) {
                    Updates.b.p(kotlin.jvm.internal.z.this, updates2, dialogInterface);
                }
            });
            if (!Updates.this.isFinishing() && Updates.this.k2() != null) {
                Updates.this.X2();
            }
            return R2.s.a;
        }

        @Override
        public final Object invoke(o3.J j, V2.d dVar) {
            return ((b) create(j, dVar)).invokeSuspend(R2.s.a);
        }
    }

    static final class c extends kotlin.coroutines.jvm.internal.l implements d3.p {
        int a;
        final String c;
        final String d;
        final ArrayList e;
        final boolean f;

        c(String str, String str2, ArrayList arrayList, boolean z, V2.d dVar) {
            super(2, dVar);
            this.c = str;
            this.d = str2;
            this.e = arrayList;
            this.f = z;
        }

        public static final void k(Updates updates, boolean z, String str, View view) {
            updates.j2();
            UptodownApp.a aVar = UptodownApp.F;
            if (!aVar.U("GenerateQueueWorker", updates) && !aVar.U("downloadApkWorker", updates)) {
                updates.B4(true);
                GenerateQueueWorker.e.a(updates, z, str);
            } else {
                String string = updates.getString(2131952002);
                kotlin.jvm.internal.m.d(string, "getString(...)");
                updates.V1(string);
            }
        }

        public static final void l(Updates updates, String str, View view) {
            updates.j2();
            UptodownApp.F.K0(null);
            if (!updates.f260m0.isEmpty()) {
                if (kotlin.jvm.internal.m.a(((C0953d) updates.f260m0.get(0)).o(), str)) {
                    updates.f260m0.remove(0);
                }
                updates.m5();
            }
            updates.m5();
        }

        @Override
        public final V2.d create(Object obj, V2.d dVar) {
            return Updates.this.new c(this.c, this.d, this.e, this.f, dVar);
        }

        @Override
        public final Object invokeSuspend(Object obj) {
            W2.b.c();
            if (this.a != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            R2.n.b(obj);
            if (!Updates.this.isFinishing()) {
                Updates.this.j2();
                AlertDialog.Builder builder = new AlertDialog.Builder(Updates.this);
                C0610v c = C0610v.c(Updates.this.getLayoutInflater());
                kotlin.jvm.internal.m.d(c, "inflate(...)");
                v.a aVar = u2.v.v;
                Context applicationContext = Updates.this.getApplicationContext();
                kotlin.jvm.internal.m.d(applicationContext, "getApplicationContext(...)");
                u2.v a = aVar.a(applicationContext);
                a.a();
                C0953d W = a.W(this.c);
                a.i();
                String str = this.d;
                ArrayList arrayList = this.e;
                final Updates updates = Updates.this;
                final boolean z = this.f;
                final String str2 = this.c;
                TextView textView = c.f;
                k.a aVar2 = N1.k.g;
                textView.setTypeface(aVar2.w());
                c.f.setText(W != null ? W.m() : null);
                c.d.setTypeface(aVar2.x());
                c.d.setText(str);
                c.c.setTypeface(aVar2.x());
                Iterator it = arrayList.iterator();
                kotlin.jvm.internal.m.d(it, "iterator(...)");
                String str3 = TtmlNode.ANONYMOUS_REGION_ID;
                while (it.hasNext()) {
                    Object next = it.next();
                    kotlin.jvm.internal.m.d(next, "next(...)");
                    str3 = str3 + "- " + ((String) next) + '\n';
                }
                c.c.setText(str3);
                TextView textView2 = c.e;
                k.a aVar3 = N1.k.g;
                textView2.setTypeface(aVar3.w());
                c.e.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        Updates.c.k(Updates.this, z, str2, view);
                    }
                });
                c.b.setTypeface(aVar3.w());
                c.b.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        Updates.c.l(Updates.this, str2, view);
                    }
                });
                builder.setCancelable(false);
                builder.setView(c.getRoot());
                Updates.this.K2(builder.create());
                if (!Updates.this.isFinishing() && Updates.this.k2() != null) {
                    Updates.this.X2();
                }
            }
            return R2.s.a;
        }

        @Override
        public final Object invoke(o3.J j, V2.d dVar) {
            return ((c) create(j, dVar)).invokeSuspend(R2.s.a);
        }
    }

    static final class d extends kotlin.coroutines.jvm.internal.l implements d3.p {
        int a;
        final String b;
        final Updates c;
        final String d;

        d(String str, Updates updates, String str2, V2.d dVar) {
            super(2, dVar);
            this.b = str;
            this.c = updates;
            this.d = str2;
        }

        @Override
        public final V2.d create(Object obj, V2.d dVar) {
            return new d(this.b, this.c, this.d, dVar);
        }

        @Override
        public final Object invokeSuspend(Object obj) {
            W2.b.c();
            if (this.a != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            R2.n.b(obj);
            if (kotlin.jvm.internal.m.a(this.b, "app_installed")) {
                this.c.H5(false);
            } else {
                int r5 = this.c.r5(this.d);
                if (kotlin.jvm.internal.m.a(this.b, "app_updated")) {
                    if (r5 >= 0) {
                        ArrayList arrayList = this.c.X;
                        if (arrayList != null) {
                            M1.J j = this.c.Y;
                            kotlin.jvm.internal.m.b(j);
                            kotlin.coroutines.jvm.internal.b.a(kotlin.jvm.internal.G.a(arrayList).remove(j.b().get(r5)));
                        }
                        M1.J j4 = this.c.Y;
                        kotlin.jvm.internal.m.b(j4);
                        j4.h(r5);
                    }
                    UptodownApp.F.K0(null);
                    this.c.m5();
                } else if (kotlin.jvm.internal.m.a(this.b, "app_uninstalled") && r5 >= 0) {
                    ArrayList arrayList2 = this.c.X;
                    if (arrayList2 != null) {
                        M1.J j5 = this.c.Y;
                        kotlin.jvm.internal.m.b(j5);
                        kotlin.coroutines.jvm.internal.b.a(kotlin.jvm.internal.G.a(arrayList2).remove(j5.b().get(r5)));
                    }
                    M1.J j6 = this.c.Y;
                    kotlin.jvm.internal.m.b(j6);
                    j6.b().remove(r5);
                    M1.J j7 = this.c.Y;
                    kotlin.jvm.internal.m.b(j7);
                    j7.notifyItemRemoved(r5);
                }
            }
            return R2.s.a;
        }

        @Override
        public final Object invoke(o3.J j, V2.d dVar) {
            return ((d) create(j, dVar)).invokeSuspend(R2.s.a);
        }
    }

    public static final class e implements Animation.AnimationListener {
        e() {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationStart(Animation animation) {
            Updates.this.q5().g.setPadding(0, 0, 0, 0);
        }
    }

    public static final class f implements InterfaceC0935s {
        f() {
        }

        @Override
        public void a() {
            if (UptodownApp.F.a0()) {
                ?? r02 = Updates.this;
                String string = r02.getString(2131951944);
                kotlin.jvm.internal.m.d(string, "getString(...)");
                r02.V1(string);
            }
        }
    }

    public static final class g implements S1.d {
        final File b;
        final g2.P c;

        g(File file, g2.P p) {
            this.b = file;
            this.c = p;
        }

        @Override
        public void a(DocumentFile docFile) {
            kotlin.jvm.internal.m.e(docFile, "docFile");
        }

        @Override
        public void b(Object file, int i, int i4, long j) {
            kotlin.jvm.internal.m.e(file, "file");
        }

        @Override
        public void c(File file) {
            kotlin.jvm.internal.m.e(file, "file");
        }

        @Override
        public void d(DocumentFile docFile) {
            kotlin.jvm.internal.m.e(docFile, "docFile");
        }

        @Override
        public void e(int i, String currentFilename, long j, long j4) {
            kotlin.jvm.internal.m.e(currentFilename, "currentFilename");
        }

        @Override
        public void f(File file) {
            kotlin.jvm.internal.m.e(file, "file");
        }

        @Override
        public void g() {
        }

        @Override
        public void h(Object file) {
            kotlin.jvm.internal.m.e(file, "file");
        }

        @Override
        public void i() {
            Updates updates = Updates.this;
            File file = this.b;
            kotlin.jvm.internal.m.b(file);
            updates.y2(file, this.c.f());
        }
    }

    public static final class h extends OnBackPressedCallback {
        h() {
            super(true);
        }

        public void handleOnBackPressed() {
            if (Updates.this.f260m0.isEmpty()) {
                Updates.this.finish();
                return;
            }
            Updates.this.f260m0 = new ArrayList();
            Updates.this.T5();
        }
    }

    static final class i extends kotlin.coroutines.jvm.internal.l implements d3.p {
        int a;

        static final class a implements r3.f {
            final Updates a;

            public static final class C0184a implements InterfaceC0924g {
                final Updates a;

                static final class C0185a extends kotlin.coroutines.jvm.internal.l implements d3.p {
                    int a;
                    final Updates b;
                    final String c;
                    final long d;

                    C0185a(Updates updates, String str, long j, V2.d dVar) {
                        super(2, dVar);
                        this.b = updates;
                        this.c = str;
                        this.d = j;
                    }

                    @Override
                    public final V2.d create(Object obj, V2.d dVar) {
                        return new C0185a(this.b, this.c, this.d, dVar);
                    }

                    @Override
                    public final Object invokeSuspend(Object obj) {
                        W2.b.c();
                        if (this.a != 0) {
                            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                        }
                        R2.n.b(obj);
                        int r5 = this.b.r5(this.c);
                        if (r5 >= 0 && this.b.Y != null) {
                            M1.J j = this.b.Y;
                            kotlin.jvm.internal.m.b(j);
                            if (j.b().get(r5) instanceof J.a) {
                                M1.J j4 = this.b.Y;
                                ArrayList b = j4 != null ? j4.b() : null;
                                kotlin.jvm.internal.m.b(b);
                                Object obj2 = b.get(r5);
                                kotlin.jvm.internal.m.c(obj2, "null cannot be cast to non-null type com.uptodown.adapters.UpdatesAdapter.AppUpdateData");
                                ((J.a) obj2).a().b0(this.d);
                                M1.J j5 = this.b.Y;
                                if (j5 != null) {
                                    j5.notifyItemChanged(r5);
                                }
                            }
                        }
                        return R2.s.a;
                    }

                    @Override
                    public final Object invoke(o3.J j, V2.d dVar) {
                        return ((C0185a) create(j, dVar)).invokeSuspend(R2.s.a);
                    }
                }

                C0184a(Updates updates) {
                    this.a = updates;
                }

                @Override
                public void a(String packageName, long j) {
                    kotlin.jvm.internal.m.e(packageName, "packageName");
                    o3.g.d(LifecycleOwnerKt.getLifecycleScope(this.a), o3.Y.c(), (o3.L) null, new C0185a(this.a, packageName, j, null), 2, (Object) null);
                }
            }

            a(Updates updates) {
                this.a = updates;
            }

            public final Object emit(u2.H h, V2.d dVar) {
                if (h instanceof H.a) {
                    this.a.q5().b.setVisibility(0);
                    if (this.a.q5().h.isRefreshing()) {
                        this.a.q5().h.setRefreshing(false);
                    }
                } else if (h instanceof H.c) {
                    H.c cVar = (H.c) h;
                    this.a.X = ((W.b) cVar.a()).d();
                    this.a.I5(((W.b) cVar.a()).d(), ((W.b) cVar.a()).c(), ((W.b) cVar.a()).b(), ((W.b) cVar.a()).a());
                    this.a.T5();
                    this.a.q5().b.setVisibility(8);
                    if (!((Boolean) this.a.s5().f().getValue()).booleanValue()) {
                        new C0552a(new C0184a(this.a), LifecycleOwnerKt.getLifecycleScope(this.a), this.a);
                        this.a.s5().f().setValue(kotlin.coroutines.jvm.internal.b.a(true));
                    }
                } else if (!(h instanceof H.b)) {
                    throw new R2.k();
                }
                return R2.s.a;
            }
        }

        i(V2.d dVar) {
            super(2, dVar);
        }

        @Override
        public final V2.d create(Object obj, V2.d dVar) {
            return Updates.this.new i(dVar);
        }

        @Override
        public final Object invokeSuspend(Object obj) {
            Object c = W2.b.c();
            int i = this.a;
            if (i == 0) {
                R2.n.b(obj);
                r3.I g = Updates.this.s5().g();
                a aVar = new a(Updates.this);
                this.a = 1;
                if (g.collect(aVar, this) == c) {
                    return c;
                }
            } else {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                R2.n.b(obj);
            }
            throw new R2.d();
        }

        @Override
        public final Object invoke(o3.J j, V2.d dVar) {
            return ((i) create(j, dVar)).invokeSuspend(R2.s.a);
        }
    }

    public static final class j implements Animation.AnimationListener {
        j() {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            Updates.this.q5().g.setPadding(0, 0, 0, (int) Updates.this.getResources().getDimension(2131165271));
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationStart(Animation animation) {
        }
    }

    static final class k extends kotlin.coroutines.jvm.internal.l implements d3.p {
        int a;
        final ArrayList c;

        k(ArrayList arrayList, V2.d dVar) {
            super(2, dVar);
            this.c = arrayList;
        }

        public static final void m(kotlin.jvm.internal.z zVar, Updates updates, View view) {
            UptodownApp.a aVar = UptodownApp.F;
            if (aVar.a0()) {
                zVar.a = true;
                updates.k5();
                updates.T5();
                updates.startActivity(new Intent(updates.getApplicationContext(), (Class<?>) PreferencesActivity.class), aVar.a(updates));
                AlertDialog k22 = updates.k2();
                if (k22 != null) {
                    k22.dismiss();
                }
            }
        }

        public static final void n(kotlin.jvm.internal.z zVar, Updates updates, View view) {
            zVar.a = true;
            AlertDialog k22 = updates.k2();
            if (k22 != null) {
                k22.dismiss();
            }
            updates.k5();
            updates.T5();
        }

        public static final void o(kotlin.jvm.internal.z zVar, ArrayList arrayList, Updates updates, View view) {
            zVar.a = true;
            if (arrayList != null) {
                C0953d c0953d = arrayList.size() == 1 ? (C0953d) arrayList.get(0) : null;
                if (!UptodownApp.F.N(updates)) {
                    updates.C4(c0953d != null ? c0953d.o() : null, true);
                    updates.T5();
                } else if (c0953d != null) {
                    updates.l4(c0953d);
                }
            }
            AlertDialog k22 = updates.k2();
            if (k22 != null) {
                k22.dismiss();
            }
        }

        public static final void p(kotlin.jvm.internal.z zVar, Updates updates, DialogInterface dialogInterface) {
            if (zVar.a) {
                return;
            }
            updates.k5();
            updates.T5();
        }

        @Override
        public final V2.d create(Object obj, V2.d dVar) {
            return Updates.this.new k(this.c, dVar);
        }

        @Override
        public final Object invokeSuspend(Object obj) {
            W2.b.c();
            if (this.a != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            R2.n.b(obj);
            AlertDialog k22 = Updates.this.k2();
            if (k22 != null) {
                k22.dismiss();
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(Updates.this);
            C0601q c = C0601q.c(Updates.this.getLayoutInflater());
            kotlin.jvm.internal.m.d(c, "inflate(...)");
            final kotlin.jvm.internal.z zVar = new kotlin.jvm.internal.z();
            final Updates updates = Updates.this;
            final ArrayList arrayList = this.c;
            TextView textView = c.f;
            k.a aVar = N1.k.g;
            textView.setTypeface(aVar.w());
            c.c.setTypeface(aVar.x());
            c.e.setTypeface(aVar.w());
            c.b.setTypeface(aVar.w());
            c.d.setTypeface(aVar.w());
            c.e.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    Updates.k.m(kotlin.jvm.internal.z.this, updates, view);
                }
            });
            c.b.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    Updates.k.n(kotlin.jvm.internal.z.this, updates, view);
                }
            });
            c.d.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    Updates.k.o(kotlin.jvm.internal.z.this, arrayList, updates, view);
                }
            });
            builder.setView(c.getRoot());
            Updates.this.K2(builder.create());
            AlertDialog k23 = Updates.this.k2();
            kotlin.jvm.internal.m.b(k23);
            final Updates updates2 = Updates.this;
            k23.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public final void onDismiss(DialogInterface dialogInterface) {
                    Updates.k.p(kotlin.jvm.internal.z.this, updates2, dialogInterface);
                }
            });
            if (!Updates.this.isFinishing() && Updates.this.k2() != null) {
                Updates.this.X2();
            }
            return R2.s.a;
        }

        @Override
        public final Object invoke(o3.J j, V2.d dVar) {
            return ((k) create(j, dVar)).invokeSuspend(R2.s.a);
        }
    }

    public static final class l extends kotlin.jvm.internal.n implements d3.a {
        final ComponentActivity a;

        public l(ComponentActivity componentActivity) {
            super(0);
            this.a = componentActivity;
        }

        @Override
        public final ViewModelProvider.Factory invoke() {
            return this.a.getDefaultViewModelProviderFactory();
        }
    }

    public static final class m extends kotlin.jvm.internal.n implements d3.a {
        final ComponentActivity a;

        public m(ComponentActivity componentActivity) {
            super(0);
            this.a = componentActivity;
        }

        @Override
        public final ViewModelStore invoke() {
            return this.a.getViewModelStore();
        }
    }

    public static final class n extends kotlin.jvm.internal.n implements d3.a {
        final d3.a a;
        final ComponentActivity b;

        public n(d3.a aVar, ComponentActivity componentActivity) {
            super(0);
            this.a = aVar;
            this.b = componentActivity;
        }

        @Override
        public final CreationExtras invoke() {
            CreationExtras creationExtras;
            d3.a aVar = this.a;
            return (aVar == null || (creationExtras = (CreationExtras) aVar.invoke()) == null) ? this.b.getDefaultViewModelCreationExtras() : creationExtras;
        }
    }

    static final class o extends kotlin.coroutines.jvm.internal.l implements d3.p {
        int a;
        final Boolean c;
        final Integer d;

        o(Boolean bool, Integer num, V2.d dVar) {
            super(2, dVar);
            this.c = bool;
            this.d = num;
        }

        @Override
        public final V2.d create(Object obj, V2.d dVar) {
            return Updates.this.new o(this.c, this.d, dVar);
        }

        @Override
        public final Object invokeSuspend(Object obj) {
            W2.b.c();
            if (this.a != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            R2.n.b(obj);
            if (Updates.this.q5().h.isRefreshing()) {
                Updates.this.q5().h.setRefreshing(false);
            }
            Updates.this.B4(false);
            Updates.this.H5(false);
            if (((Boolean) Updates.this.s5().h().getValue()).booleanValue()) {
                if (kotlin.jvm.internal.m.a(this.c, kotlin.coroutines.jvm.internal.b.a(true))) {
                    Integer num = this.d;
                    if (num != null && num.intValue() == 1) {
                        ?? r5 = Updates.this;
                        String string = r5.getString(2131952400);
                        kotlin.jvm.internal.m.d(string, "getString(...)");
                        r5.r0(string);
                    } else {
                        ?? r52 = Updates.this;
                        String string2 = r52.getString(2131952400);
                        kotlin.jvm.internal.m.d(string2, "getString(...)");
                        r52.r0(string2);
                    }
                } else {
                    ?? r53 = Updates.this;
                    String string3 = r53.getString(2131952405);
                    kotlin.jvm.internal.m.d(string3, "getString(...)");
                    r53.r0(string3);
                }
                Updates.this.s5().h().setValue(kotlin.coroutines.jvm.internal.b.a(false));
            }
            M1.J j = Updates.this.Y;
            if (j != null) {
                M1.J j4 = Updates.this.Y;
                Integer b = j4 != null ? kotlin.coroutines.jvm.internal.b.b(j4.c()) : null;
                kotlin.jvm.internal.m.b(b);
                j.notifyItemChanged(b.intValue());
            }
            return R2.s.a;
        }

        @Override
        public final Object invoke(o3.J j, V2.d dVar) {
            return ((o) create(j, dVar)).invokeSuspend(R2.s.a);
        }
    }

    static final class p extends kotlin.coroutines.jvm.internal.l implements d3.p {
        int a;

        p(V2.d dVar) {
            super(2, dVar);
        }

        @Override
        public final V2.d create(Object obj, V2.d dVar) {
            return Updates.this.new p(dVar);
        }

        @Override
        public final Object invokeSuspend(Object obj) {
            W2.b.c();
            if (this.a != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            R2.n.b(obj);
            M1.J j = Updates.this.Y;
            if (j != null) {
                M1.J j4 = Updates.this.Y;
                Integer b = j4 != null ? kotlin.coroutines.jvm.internal.b.b(j4.c()) : null;
                kotlin.jvm.internal.m.b(b);
                j.notifyItemChanged(b.intValue());
            }
            return R2.s.a;
        }

        @Override
        public final Object invoke(o3.J j, V2.d dVar) {
            return ((p) create(j, dVar)).invokeSuspend(R2.s.a);
        }
    }

    public static final class q implements InterfaceC0915F {
        q() {
        }

        @Override
        public void a(int i) {
            ArrayList b;
            if (UptodownApp.F.a0()) {
                M1.J j = Updates.this.Y;
                if (((j == null || (b = j.b()) == null) ? null : b.get(i)) instanceof J.a) {
                    M1.J j4 = Updates.this.Y;
                    kotlin.jvm.internal.m.b(j4);
                    Object obj = j4.b().get(i);
                    kotlin.jvm.internal.m.c(obj, "null cannot be cast to non-null type com.uptodown.adapters.UpdatesAdapter.AppUpdateData");
                    Updates.this.Q3(((J.a) obj).a(), i);
                }
            }
        }

        @Override
        public void b(int i) {
            ArrayList b;
            ArrayList b4;
            if (UptodownApp.F.a0()) {
                M1.J j = Updates.this.Y;
                C0953d c0953d = null;
                if (((j == null || (b4 = j.b()) == null) ? null : b4.get(i)) instanceof J.a) {
                    M1.J j4 = Updates.this.Y;
                    kotlin.jvm.internal.m.b(j4);
                    Object obj = j4.b().get(i);
                    kotlin.jvm.internal.m.c(obj, "null cannot be cast to non-null type com.uptodown.adapters.UpdatesAdapter.AppUpdateData");
                    c0953d = ((J.a) obj).a();
                } else {
                    M1.J j5 = Updates.this.Y;
                    if (((j5 == null || (b = j5.b()) == null) ? null : b.get(i)) instanceof C0953d) {
                        M1.J j6 = Updates.this.Y;
                        kotlin.jvm.internal.m.b(j6);
                        Object obj2 = j6.b().get(i);
                        kotlin.jvm.internal.m.c(obj2, "null cannot be cast to non-null type com.uptodown.models.App");
                        c0953d = (C0953d) obj2;
                    }
                }
                if (c0953d == null || c0953d.b() <= 0) {
                    return;
                }
                Updates.this.D2(c0953d.b());
            }
        }

        @Override
        public void c(int i) {
            if (Updates.this.F5(i)) {
                M1.J j = Updates.this.Y;
                kotlin.jvm.internal.m.b(j);
                Object obj = j.b().get(i);
                kotlin.jvm.internal.m.c(obj, "null cannot be cast to non-null type com.uptodown.adapters.UpdatesAdapter.AppUpdateData");
                ((J.a) obj).a().a0(true);
                M1.J j4 = Updates.this.Y;
                kotlin.jvm.internal.m.b(j4);
                j4.notifyItemChanged(i);
            }
        }

        @Override
        public void d(int i) {
            if (UptodownApp.F.a0() && Updates.this.F5(i)) {
                M1.J j = Updates.this.Y;
                kotlin.jvm.internal.m.b(j);
                Object obj = j.b().get(i);
                kotlin.jvm.internal.m.c(obj, "null cannot be cast to non-null type com.uptodown.adapters.UpdatesAdapter.AppUpdateData");
                Updates.this.t4(((J.a) obj).a());
                Updates.this.T5();
                M1.J j4 = Updates.this.Y;
                kotlin.jvm.internal.m.b(j4);
                j4.notifyItemChanged(i);
            }
        }

        @Override
        public void e(int i) {
            if (UptodownApp.F.a0()) {
                Updates.this.j5(i);
                M1.J j = Updates.this.Y;
                if (j != null) {
                    j.m(false);
                }
            }
        }

        @Override
        public void f(int i) {
            if (Updates.this.F5(i)) {
                M1.J j = Updates.this.Y;
                kotlin.jvm.internal.m.b(j);
                Object obj = j.b().get(i);
                kotlin.jvm.internal.m.c(obj, "null cannot be cast to non-null type com.uptodown.adapters.UpdatesAdapter.AppUpdateData");
                ((J.a) obj).a().a0(false);
                M1.J j4 = Updates.this.Y;
                kotlin.jvm.internal.m.b(j4);
                j4.notifyItemChanged(i);
            }
        }
    }

    static final class r extends kotlin.coroutines.jvm.internal.l implements d3.p {
        int a;
        final Bundle b;
        final int c;
        final Updates d;

        r(Bundle bundle, int i, Updates updates, V2.d dVar) {
            super(2, dVar);
            this.b = bundle;
            this.c = i;
            this.d = updates;
        }

        @Override
        public final V2.d create(Object obj, V2.d dVar) {
            return new r(this.b, this.c, this.d, dVar);
        }

        @Override
        public final Object invokeSuspend(Object obj) {
            int p5;
            M1.J j;
            ArrayList E;
            ArrayList arrayList;
            W2.b.c();
            if (this.a != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            R2.n.b(obj);
            Bundle bundle = this.b;
            r0 = null;
            r0 = null;
            C0953d c0953d = null;
            String string = bundle != null ? bundle.getString("packagename") : null;
            int i = this.c;
            boolean z = true;
            if (i != 110) {
                if (i == 201) {
                    this.d.P5(string);
                    M1.J j4 = this.d.Y;
                    if (j4 != null) {
                        j4.d(string);
                    }
                    R2.s sVar = R2.s.a;
                } else if (i != 205 && i != 206) {
                    switch (i) {
                        case 102:
                            if (!this.d.s2()) {
                                ?? r02 = this.d;
                                String string2 = r02.getString(2131951959);
                                kotlin.jvm.internal.m.d(string2, "getString(...)");
                                r02.V1(string2);
                            }
                            if (!this.d.f260m0.isEmpty()) {
                                this.d.f260m0.remove(0);
                                this.d.m5();
                            }
                            R2.s sVar2 = R2.s.a;
                            break;
                        case 103:
                            UptodownApp.a aVar = UptodownApp.F;
                            if (aVar.D().isEmpty() && ((E = aVar.E()) == null || E.isEmpty())) {
                                this.d.H5(false);
                            }
                            R2.s sVar3 = R2.s.a;
                            break;
                        case 104:
                            ?? r03 = this.d;
                            String string3 = r03.getString(2131952403);
                            kotlin.jvm.internal.m.d(string3, "getString(...)");
                            r03.r0(string3);
                            this.d.T5();
                            R2.s sVar4 = R2.s.a;
                            break;
                        case 105:
                            Bundle bundle2 = this.b;
                            ArrayList parcelableArrayList = bundle2 != null ? Build.VERSION.SDK_INT >= 33 ? bundle2.getParcelableArrayList("apps_parcelable", C0953d.class) : bundle2.getParcelableArrayList("apps_parcelable") : null;
                            if (parcelableArrayList != null) {
                                this.d.K5(parcelableArrayList);
                            }
                            R2.s sVar5 = R2.s.a;
                            break;
                        case 106:
                            this.d.m5();
                            R2.s sVar6 = R2.s.a;
                            break;
                        case 107:
                            this.d.P5(string);
                            M1.J j5 = this.d.Y;
                            if (j5 != null) {
                                j5.notifyDataSetChanged();
                            }
                            R2.s sVar7 = R2.s.a;
                            break;
                        case 108:
                            if (this.d.f260m0.isEmpty() && (arrayList = this.d.X) != null && !arrayList.isEmpty()) {
                                ArrayList arrayList2 = this.d.X;
                                kotlin.jvm.internal.m.b(arrayList2);
                                Iterator it = arrayList2.iterator();
                                kotlin.jvm.internal.m.d(it, "iterator(...)");
                                while (true) {
                                    if (it.hasNext()) {
                                        Object next = it.next();
                                        kotlin.jvm.internal.m.d(next, "next(...)");
                                        J.a aVar2 = (J.a) next;
                                        if (m3.m.q(aVar2.a().o(), string, false, 2, null)) {
                                            u2.v a = u2.v.v.a(this.d);
                                            a.a();
                                            C0965p a4 = aVar2.b().a();
                                            kotlin.jvm.internal.m.b(a4);
                                            C0965p e0 = a.e0(a4.q());
                                            a.i();
                                            if (e0 != null && e0.f()) {
                                                c0953d = aVar2.a();
                                            }
                                        }
                                    }
                                }
                                if (c0953d != null) {
                                    this.d.f260m0.add(c0953d);
                                }
                            }
                            this.d.m5();
                            R2.s sVar8 = R2.s.a;
                            break;
                        default:
                            R2.s sVar9 = R2.s.a;
                            break;
                    }
                } else {
                    R2.s sVar10 = R2.s.a;
                }
                z = false;
            } else {
                this.d.T5();
                new AbstractC0740a.b();
            }
            if (this.d.q4()) {
                this.d.D4(this.c);
            }
            if (z && (p5 = this.d.p5(string)) > -1 && (j = this.d.Y) != null) {
                j.notifyItemChanged(p5);
            }
            return R2.s.a;
        }

        @Override
        public final Object invoke(o3.J j, V2.d dVar) {
            return ((r) create(j, dVar)).invokeSuspend(R2.s.a);
        }
    }

    static final class s extends kotlin.coroutines.jvm.internal.l implements d3.p {
        int a;
        final String c;
        final int d;

        s(String str, int i, V2.d dVar) {
            super(2, dVar);
            this.c = str;
            this.d = i;
        }

        @Override
        public final V2.d create(Object obj, V2.d dVar) {
            return Updates.this.new s(this.c, this.d, dVar);
        }

        @Override
        public final java.lang.Object invokeSuspend(java.lang.Object r8) {
            throw new UnsupportedOperationException("Method not decompiled: com.uptodown.activities.Updates.s.invokeSuspend(java.lang.Object):java.lang.Object");
        }

        @Override
        public final Object invoke(o3.J j, V2.d dVar) {
            return ((s) create(j, dVar)).invokeSuspend(R2.s.a);
        }
    }

    public static final class t implements InterfaceC0916G {
        t() {
        }

        @Override
        public void a() {
            if (UptodownApp.F.a0()) {
                Updates.this.G5();
            }
        }

        @Override
        public void b() {
            UptodownApp.a aVar = UptodownApp.F;
            if (aVar.a0() && UptodownApp.a.P0(aVar, Updates.this, false, 2, null)) {
                Updates.this.s5().h().setValue(Boolean.TRUE);
            }
        }
    }

    public Updates() {
        ActivityResultLauncher registerForActivityResult = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
            public final void onActivityResult(Object obj) {
                Updates.o5(Updates.this, (ActivityResult) obj);
            }
        });
        kotlin.jvm.internal.m.d(registerForActivityResult, "registerForActivityResult(...)");
        this.f266s0 = registerForActivityResult;
        this.f267t0 = new h();
    }

    public static final void A5(Updates updates) {
        if (UptodownApp.a.P0(UptodownApp.F, updates, false, 2, null)) {
            updates.s5().h().setValue(Boolean.TRUE);
        } else {
            updates.q5().h.setRefreshing(false);
        }
    }

    private final void B5() {
        if (N1.k.g.i() == null) {
            UptodownApp.a aVar = UptodownApp.F;
            if (aVar.C() == null) {
                if (this.f260m0.isEmpty()) {
                    T5();
                    return;
                }
                Object remove = this.f260m0.remove(0);
                kotlin.jvm.internal.m.d(remove, "removeAt(...)");
                C0953d c0953d = (C0953d) remove;
                v.a aVar2 = u2.v.v;
                Context applicationContext = getApplicationContext();
                kotlin.jvm.internal.m.d(applicationContext, "getApplicationContext(...)");
                u2.v a4 = aVar2.a(applicationContext);
                a4.a();
                String o3 = c0953d.o();
                kotlin.jvm.internal.m.b(o3);
                g2.P C02 = a4.C0(o3);
                C0965p b4 = C02 != null ? C02.b(this) : null;
                a4.i();
                R5(c0953d.m());
                if (b4 != null && b4.f()) {
                    aVar.K0(c0953d);
                    File n4 = b4.n();
                    if (n4 != null) {
                        if (C02.n() == 1) {
                            C5(C02, n4);
                        } else {
                            y2(n4, null);
                        }
                        if (this.f260m0.isEmpty()) {
                            k5();
                            return;
                        }
                        return;
                    }
                }
                m5();
                return;
            }
        }
        T5();
    }

    private final void C5(g2.P p3, File file) {
        ApplicationInfo applicationInfo;
        if (!file.isDirectory()) {
            file = new File(file.getAbsolutePath()).getParentFile();
        }
        File file2 = file;
        g gVar = new g(file2, p3);
        try {
            PackageManager packageManager = getPackageManager();
            kotlin.jvm.internal.m.d(packageManager, "getPackageManager(...)");
            applicationInfo = W1.s.a(packageManager, p3.h(), 128);
        } catch (PackageManager.NameNotFoundException e4) {
            e4.printStackTrace();
            applicationInfo = null;
        }
        if (applicationInfo == null) {
            String string = getString(N1.i.M);
            kotlin.jvm.internal.m.d(string, "getString(...)");
            V1(string);
            R2.s sVar = R2.s.a;
            return;
        }
        File file3 = new File(applicationInfo.sourceDir);
        ArrayList arrayList = new ArrayList();
        arrayList.add(file3);
        kotlin.jvm.internal.m.b(file2);
        new R1.b(arrayList, file2, gVar, false, this);
    }

    public final boolean F5(int i4) {
        M1.J j4 = this.Y;
        if (j4 == null || i4 < 0) {
            return false;
        }
        kotlin.jvm.internal.m.b(j4);
        if (i4 >= j4.getItemCount()) {
            return false;
        }
        M1.J j5 = this.Y;
        ArrayList b4 = j5 != null ? j5.b() : null;
        if (b4 == null || b4.isEmpty()) {
            return false;
        }
        M1.J j6 = this.Y;
        ArrayList b5 = j6 != null ? j6.b() : null;
        kotlin.jvm.internal.m.b(b5);
        if (b5.size() <= i4) {
            return false;
        }
        M1.J j7 = this.Y;
        ArrayList b6 = j7 != null ? j7.b() : null;
        kotlin.jvm.internal.m.b(b6);
        return b6.get(i4) instanceof J.a;
    }

    public final void G5() {
        this.f266s0.launch(new Intent(getApplicationContext(), (Class<?>) GdprPrivacySettings.class), UptodownApp.F.b(this));
    }

    public final void H5(boolean z) {
        s5().e(this, z);
    }

    public final void I5(ArrayList arrayList, ArrayList arrayList2, ArrayList arrayList3, ArrayList arrayList4) {
        if (this.Y == null) {
            this.Y = new M1.J(this.f262o0, this.f263p0, this.f264q0, this.f265r0);
            q5().g.setAdapter(this.Y);
        }
        M1.J j4 = this.Y;
        if (j4 != null) {
            j4.k(arrayList, arrayList2, arrayList3, arrayList4, this);
        }
    }

    private final void J5() {
        if (this.f260m0.size() > 0) {
            q5().l.setVisibility(8);
            q5().f.setVisibility(0);
        } else {
            q5().l.setVisibility(0);
            q5().f.setVisibility(8);
        }
        RelativeLayout rlBottomBoxDownloadButtonUpdates = q5().d;
        kotlin.jvm.internal.m.d(rlBottomBoxDownloadButtonUpdates, "rlBottomBoxDownloadButtonUpdates");
        if (rlBottomBoxDownloadButtonUpdates.getVisibility() == 8) {
            y2.n nVar = new y2.n(this);
            RelativeLayout rlBottomBoxDownloadButtonUpdates2 = q5().d;
            kotlin.jvm.internal.m.d(rlBottomBoxDownloadButtonUpdates2, "rlBottomBoxDownloadButtonUpdates");
            nVar.g(rlBottomBoxDownloadButtonUpdates2, 2130772030, new j());
            y2.n nVar2 = new y2.n(this);
            RelativeLayout rlBottomBoxShadow = q5().e;
            kotlin.jvm.internal.m.d(rlBottomBoxShadow, "rlBottomBoxShadow");
            nVar2.h(rlBottomBoxShadow, 2130772030);
            q5().d.setVisibility(0);
        }
    }

    public final void K5(ArrayList arrayList) {
        if (o4()) {
            o3.g.d(LifecycleOwnerKt.getLifecycleScope(this), o3.Y.c(), (o3.L) null, new k(arrayList, null), 2, (Object) null);
        }
    }

    public final void L5() {
        UptodownApp.a aVar = UptodownApp.F;
        if (aVar.U("downloadApkWorker", this) || aVar.U("GenerateQueueWorker", this) || aVar.U("DownloadUpdatesWorker", this)) {
            M1.J j4 = this.Y;
            if (j4 != null) {
                j4.m(false);
                return;
            }
            return;
        }
        this.f260m0 = new ArrayList();
        ArrayList arrayList = this.X;
        kotlin.jvm.internal.m.b(arrayList);
        Iterator it = arrayList.iterator();
        kotlin.jvm.internal.m.d(it, "iterator(...)");
        while (it.hasNext()) {
            Object next = it.next();
            kotlin.jvm.internal.m.d(next, "next(...)");
            this.f260m0.add(((J.a) next).a());
        }
        Iterator it2 = this.f260m0.iterator();
        kotlin.jvm.internal.m.d(it2, "iterator(...)");
        while (it2.hasNext()) {
            Object next2 = it2.next();
            kotlin.jvm.internal.m.d(next2, "next(...)");
            l4((C0953d) next2);
        }
        M1.J j5 = this.Y;
        if (j5 != null) {
            j5.e();
        }
        T5();
        m5();
    }

    public final void P5(String str) {
        g2.P C02;
        if (this.f260m0.size() > 0) {
            UptodownApp.a aVar = UptodownApp.F;
            if (aVar.E() != null) {
                ArrayList E = aVar.E();
                kotlin.jvm.internal.m.b(E);
                if (E.size() > 0) {
                    Object obj = this.f260m0.get(0);
                    kotlin.jvm.internal.m.d(obj, "get(...)");
                    C0953d c0953d = (C0953d) obj;
                    u2.v a4 = u2.v.v.a(this);
                    a4.a();
                    C0965p c0965p = null;
                    if (str != null && (C02 = a4.C0(str)) != null) {
                        c0965p = C02.b(this);
                    }
                    a4.i();
                    q5().f.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public final void onClick(View view) {
                            Updates.Q5(view);
                        }
                    });
                    q5().m.setText(c0953d.m());
                    q5().k.setText(getString(2131951934, String.valueOf(this.f260m0.size())));
                    if (c0965p != null) {
                        q5().c.setIndeterminate(false);
                        q5().c.setProgress(c0965p.x());
                    }
                }
            }
        }
    }

    public static final void Q5(View view) {
    }

    private final void R5(String str) {
        if (this.f260m0.size() > 0) {
            UptodownApp.a aVar = UptodownApp.F;
            if (aVar.E() != null) {
                ArrayList E = aVar.E();
                kotlin.jvm.internal.m.b(E);
                if (E.size() > 0) {
                    q5().m.setText(str);
                    q5().k.setText(getString(2131951934, String.valueOf(this.f260m0.size())));
                    q5().c.setIndeterminate(true);
                }
            }
        }
    }

    public final void T5() {
        ArrayList arrayList = this.X;
        if (arrayList != null) {
            kotlin.jvm.internal.m.b(arrayList);
            if (arrayList.size() > 1) {
                J5();
                return;
            }
        }
        t5();
    }

    public static final K0 i5(Updates updates) {
        return K0.c(updates.getLayoutInflater());
    }

    public final void j5(int i4) {
        if (F5(i4)) {
            M1.J j4 = this.Y;
            kotlin.jvm.internal.m.b(j4);
            Object obj = j4.b().get(i4);
            kotlin.jvm.internal.m.c(obj, "null cannot be cast to non-null type com.uptodown.adapters.UpdatesAdapter.AppUpdateData");
            J.a aVar = (J.a) obj;
            Iterator it = this.f260m0.iterator();
            int i5 = 0;
            while (true) {
                if (!it.hasNext()) {
                    i5 = -1;
                    break;
                }
                int i6 = i5 + 1;
                if (m3.m.q(((C0953d) it.next()).o(), aVar.a().o(), false, 2, null)) {
                    break;
                } else {
                    i5 = i6;
                }
            }
            if (i5 >= 0) {
                this.f260m0.remove(i5);
            }
            s4(aVar.a());
            M1.J j5 = this.Y;
            if (j5 != null) {
                j5.notifyItemChanged(i4);
            }
        }
    }

    public final void k5() {
        ArrayList b4;
        this.f260m0 = new ArrayList();
        Integer num = null;
        UptodownApp.F.K0(null);
        t5();
        M1.J j4 = this.Y;
        if (j4 != null && (b4 = j4.b()) != null) {
            num = Integer.valueOf(b4.size());
        }
        if (num == null || num.intValue() <= 0) {
            return;
        }
        int intValue = num.intValue();
        for (int i4 = 0; i4 < intValue; i4++) {
            j5(i4);
        }
    }

    private final void l5() {
        if (C1218B.a.f() || this.f261n0) {
            L5();
        } else {
            o3.g.d(LifecycleOwnerKt.getLifecycleScope(this), o3.Y.c(), (o3.L) null, new b(null), 2, (Object) null);
        }
    }

    public final void m5() {
        if (!this.f260m0.isEmpty() && N1.k.g.i() == null) {
            UptodownApp.a aVar = UptodownApp.F;
            if (aVar.C() == null && !aVar.U("GenerateQueueWorker", this) && !aVar.U("downloadApkWorker", this)) {
                Object obj = this.f260m0.get(0);
                kotlin.jvm.internal.m.d(obj, "get(...)");
                C0953d c0953d = (C0953d) obj;
                u2.v a4 = u2.v.v.a(this);
                a4.a();
                String o3 = c0953d.o();
                kotlin.jvm.internal.m.b(o3);
                g2.P C02 = a4.C0(o3);
                C0965p b4 = C02 != null ? C02.b(this) : null;
                a4.i();
                R5(c0953d.m());
                if (b4 != null && b4.f()) {
                    String o4 = c0953d.o();
                    kotlin.jvm.internal.m.b(o4);
                    aVar.e0(o4);
                    B5();
                    return;
                }
                if (aVar.N(this)) {
                    return;
                }
                Data build = new Data.Builder().putBoolean("downloadAnyway", this.f261n0).build();
                kotlin.jvm.internal.m.d(build, "build(...)");
                WorkManager.getInstance(this).enqueue(new OneTimeWorkRequest.Builder(DownloadUpdatesWorker.class).addTag("DownloadUpdatesWorker").setInputData(build).build());
                return;
            }
        }
        M1.J j4 = this.Y;
        if (j4 != null) {
            j4.m(false);
        }
        T5();
    }

    public static final void o5(Updates updates, ActivityResult activityResult) {
        if (activityResult.getResultCode() == -1) {
            updates.L2();
            updates.H5(false);
        }
    }

    public final int p5(String str) {
        M1.J j4;
        if (str == null || (j4 = this.Y) == null) {
            return -1;
        }
        kotlin.jvm.internal.m.b(j4);
        ArrayList b4 = j4.b();
        Iterator it = b4.iterator();
        int i4 = 0;
        while (it.hasNext()) {
            int i5 = i4 + 1;
            if (it.next() instanceof J.a) {
                Object obj = b4.get(i4);
                kotlin.jvm.internal.m.c(obj, "null cannot be cast to non-null type com.uptodown.adapters.UpdatesAdapter.AppUpdateData");
                if (m3.m.p(((J.a) obj).a().o(), str, true)) {
                    return i4;
                }
            }
            i4 = i5;
        }
        return -1;
    }

    public final K0 q5() {
        return (K0) this.V.getValue();
    }

    public final int r5(String str) {
        M1.J j4 = this.Y;
        ArrayList b4 = j4 != null ? j4.b() : null;
        if (b4 == null || b4.isEmpty()) {
            return -1;
        }
        M1.J j5 = this.Y;
        ArrayList b5 = j5 != null ? j5.b() : null;
        kotlin.jvm.internal.m.b(b5);
        int i4 = 0;
        for (Object obj : b5) {
            int i5 = i4 + 1;
            if ((obj instanceof J.a) && m3.m.p(((J.a) obj).a().o(), str, true)) {
                return i4;
            }
            i4 = i5;
        }
        return -1;
    }

    public final W s5() {
        return (W) this.W.getValue();
    }

    private final void t5() {
        q5().l.setVisibility(0);
        q5().f.setVisibility(8);
        RelativeLayout rlBottomBoxDownloadButtonUpdates = q5().d;
        kotlin.jvm.internal.m.d(rlBottomBoxDownloadButtonUpdates, "rlBottomBoxDownloadButtonUpdates");
        if (rlBottomBoxDownloadButtonUpdates.getVisibility() == 0) {
            y2.n nVar = new y2.n(this);
            RelativeLayout rlBottomBoxDownloadButtonUpdates2 = q5().d;
            kotlin.jvm.internal.m.d(rlBottomBoxDownloadButtonUpdates2, "rlBottomBoxDownloadButtonUpdates");
            nVar.g(rlBottomBoxDownloadButtonUpdates2, 2130772034, new e());
            y2.n nVar2 = new y2.n(this);
            RelativeLayout rlBottomBoxShadow = q5().e;
            kotlin.jvm.internal.m.d(rlBottomBoxShadow, "rlBottomBoxShadow");
            nVar2.i(rlBottomBoxShadow, 2130772034);
            q5().d.setVisibility(8);
        }
    }

    private final void u5() {
        setContentView(q5().getRoot());
        Drawable drawable = ContextCompat.getDrawable(this, N1.e.c);
        if (drawable != null) {
            q5().i.setNavigationIcon(drawable);
            q5().i.setNavigationContentDescription(getString(2131951721));
        }
        q5().i.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                Updates.v5(Updates.this, view);
            }
        });
        TextView textView = q5().n;
        k.a aVar = N1.k.g;
        textView.setTypeface(aVar.w());
        q5().i.inflateMenu(2131689480);
        Drawable drawable2 = ContextCompat.getDrawable(this, 2131231448);
        if (drawable2 != null) {
            q5().i.setOverflowIcon(drawable2);
        }
        a.C0191a c0191a = com.uptodown.activities.preferences.a.a;
        boolean b0 = c0191a.b0(this);
        q5().i.getMenu().findItem(2131361889).setChecked(b0);
        q5().i.getMenu().findItem(2131361890).setChecked(c0191a.c0(this));
        Toolbar toolbarUpdates = q5().i;
        kotlin.jvm.internal.m.d(toolbarUpdates, "toolbarUpdates");
        k4(2131361890, b0, toolbarUpdates);
        q5().i.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            public final boolean onMenuItemClick(MenuItem menuItem) {
                boolean w5;
                w5 = Updates.w5(Updates.this, menuItem);
                return w5;
            }
        });
        q5().g.setLayoutManager(new LinearLayoutManager(this, 1, false));
        DefaultItemAnimator defaultItemAnimator = new DefaultItemAnimator();
        defaultItemAnimator.setSupportsChangeAnimations(false);
        int dimension = (int) getResources().getDimension(2131166020);
        q5().g.addItemDecoration(new w2.l(dimension, dimension));
        q5().g.setItemAnimator(defaultItemAnimator);
        q5().b.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                Updates.x5(view);
            }
        });
        q5().l.setTypeface(aVar.w());
        q5().l.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                Updates.y5(Updates.this, view);
            }
        });
        q5().m.setTypeface(aVar.w());
        q5().k.setTypeface(aVar.x());
        q5().j.setTypeface(aVar.w());
        q5().j.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                Updates.z5(Updates.this, view);
            }
        });
        q5().h.setColorSchemeColors(new int[]{ContextCompat.getColor(this, 2131100314), ContextCompat.getColor(this, 2131100316)});
        q5().h.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            public final void onRefresh() {
                Updates.A5(Updates.this);
            }
        });
    }

    public static final void v5(Updates updates, View view) {
        updates.finish();
    }

    public static final boolean w5(Updates updates, MenuItem item) {
        kotlin.jvm.internal.m.e(item, "item");
        if (item.getItemId() == 2131361889) {
            boolean isChecked = item.isChecked();
            item.setChecked(!isChecked);
            a.C0191a c0191a = com.uptodown.activities.preferences.a.a;
            Context applicationContext = updates.getApplicationContext();
            kotlin.jvm.internal.m.d(applicationContext, "getApplicationContext(...)");
            c0191a.Y0(applicationContext, !isChecked);
            if (isChecked) {
                Context applicationContext2 = updates.getApplicationContext();
                kotlin.jvm.internal.m.d(applicationContext2, "getApplicationContext(...)");
                c0191a.Z0(applicationContext2, false);
                Toolbar toolbarUpdates = updates.q5().i;
                kotlin.jvm.internal.m.d(toolbarUpdates, "toolbarUpdates");
                updates.k4(2131361890, false, toolbarUpdates);
                Toolbar toolbarUpdates2 = updates.q5().i;
                kotlin.jvm.internal.m.d(toolbarUpdates2, "toolbarUpdates");
                updates.F3(2131361890, false, toolbarUpdates2);
                updates.H5(true);
            } else {
                Toolbar toolbarUpdates3 = updates.q5().i;
                kotlin.jvm.internal.m.d(toolbarUpdates3, "toolbarUpdates");
                updates.k4(2131361890, true, toolbarUpdates3);
                if (UptodownApp.a.P0(UptodownApp.F, updates, false, 2, null)) {
                    updates.s5().h().setValue(Boolean.TRUE);
                }
            }
        } else if (item.getItemId() == 2131361890) {
            boolean isChecked2 = item.isChecked();
            item.setChecked(!isChecked2);
            a.C0191a c0191a2 = com.uptodown.activities.preferences.a.a;
            Context applicationContext3 = updates.getApplicationContext();
            kotlin.jvm.internal.m.d(applicationContext3, "getApplicationContext(...)");
            c0191a2.Z0(applicationContext3, !isChecked2);
            if (isChecked2) {
                updates.H5(true);
            } else if (UptodownApp.a.P0(UptodownApp.F, updates, false, 2, null)) {
                updates.s5().h().setValue(Boolean.TRUE);
            }
        }
        return true;
    }

    public static final void x5(View view) {
    }

    public static final void y5(Updates updates, View view) {
        if (UptodownApp.F.a0()) {
            updates.l5();
        }
    }

    public static final void z5(Updates updates, View view) {
        if (UptodownApp.F.a0()) {
            updates.k5();
            updates.T5();
        }
    }

    public final void D5() {
        M1.J j4 = this.Y;
        if (j4 != null) {
            j4.i();
        }
        UptodownApp.F.K0(null);
        m5();
    }

    public final void E5(String str) {
        M1.J j4 = this.Y;
        if (j4 != null) {
            j4.i();
        }
        M1.J j5 = this.Y;
        if (j5 != null) {
            j5.g(this, str);
        }
        UptodownApp.F.K0(null);
        m5();
        C0953d D = new C1233m().D(this, str);
        String m4 = D != null ? D.m() : null;
        if (m4 == null || m4.length() == 0) {
            return;
        }
        String string = getString(2131952082, D != null ? D.m() : null);
        kotlin.jvm.internal.m.d(string, "getString(...)");
        r0(string);
    }

    @Override
    public void I2() {
        M1.J j4 = this.Y;
        if (j4 != null) {
            j4.i();
        }
    }

    @Override
    public void J3(String packagename, boolean z, ArrayList missingFeatures) {
        kotlin.jvm.internal.m.e(packagename, "packagename");
        kotlin.jvm.internal.m.e(missingFeatures, "missingFeatures");
        String string = getString(2131952320);
        kotlin.jvm.internal.m.d(string, "getString(...)");
        o3.g.d(LifecycleOwnerKt.getLifecycleScope(this), o3.Y.c(), (o3.L) null, new c(packagename, string, missingFeatures, z, null), 2, (Object) null);
    }

    public final void M5(Boolean bool, Integer num) {
        o3.g.d(LifecycleOwnerKt.getLifecycleScope(this), o3.Y.c(), (o3.L) null, new o(bool, num, null), 2, (Object) null);
    }

    public final void N5() {
        o3.g.d(LifecycleOwnerKt.getLifecycleScope(this), o3.Y.c(), (o3.L) null, new p(null), 2, (Object) null);
    }

    public final void O5(int i4, Bundle bundle) {
        o3.g.d(LifecycleOwnerKt.getLifecycleScope(this), o3.Y.c(), (o3.L) null, new r(bundle, i4, this, null), 2, (Object) null);
    }

    @Override
    public void R2(File xapkFile) {
        kotlin.jvm.internal.m.e(xapkFile, "xapkFile");
        M1.J j4 = this.Y;
        if (j4 != null) {
            j4.i();
        }
        M1.J j5 = this.Y;
        if (j5 != null) {
            j5.f(xapkFile, this);
        }
    }

    @Override
    public void S2(File file, int i4) {
        kotlin.jvm.internal.m.e(file, "file");
        M1.J j4 = this.Y;
        if (j4 != null) {
            j4.f(file, this);
        }
    }

    public final void S5(int i4, String str) {
        o3.g.d(LifecycleOwnerKt.getLifecycleScope(this), o3.Y.c(), (o3.L) null, new s(str, i4, null), 2, (Object) null);
    }

    @Override
    public void V2(File xapkFile) {
        kotlin.jvm.internal.m.e(xapkFile, "xapkFile");
        M1.J j4 = this.Y;
        if (j4 != null) {
            j4.l(xapkFile, this);
        }
    }

    public final Object n5(String str, String str2, V2.d dVar) {
        Object g4 = o3.g.g(o3.Y.c(), new d(str, this, str2, null), dVar);
        return g4 == W2.b.c() ? g4 : R2.s.a;
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        u5();
        a.C0191a c0191a = com.uptodown.activities.preferences.a.a;
        Context applicationContext = getApplicationContext();
        kotlin.jvm.internal.m.d(applicationContext, "getApplicationContext(...)");
        this.Z = c0191a.S(applicationContext);
        o3.g.d(LifecycleOwnerKt.getLifecycleScope(this), o3.Y.c(), (o3.L) null, new i(null), 2, (Object) null);
        getOnBackPressedDispatcher().addCallback(this, this.f267t0);
        H5(true);
    }

    protected void onDestroy() {
        super.onDestroy();
        if (DownloadWorker.d.h()) {
            WorkManager.getInstance(this).cancelAllWorkByTag("DownloadUpdatesWorker");
            UptodownApp.F.g();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        M1.J j4 = this.Y;
        if (j4 != null) {
            j4.notifyDataSetChanged();
        }
        u2.F.a.h(this);
        m5();
    }

    @Override
    public void u4(int i4, int i5) {
        H5(false);
    }

    @Override
    public void v4(int i4, int i5) {
        H5(false);
    }

    @Override
    protected void y4() {
        H5(false);
    }
}