package defpackage;

import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import androidx.fragment.app.t;
import androidx.lifecycle.h;
import com.strmr.ps.R;
import com.strmr.ps.data.local.entity.PlayerSettings;
import com.strmr.ps.data.model.tmdb.TMDBEpisode;
import com.strmr.ps.data.subtitle.OpenSubtitlesProvider;
import com.strmr.ps.ui.actor.ActorDetailsFragment;
import com.strmr.ps.ui.contextmenu.a;
import com.strmr.ps.ui.contextmenu.f;
import com.strmr.ps.ui.genre.GenreFragment;
import com.strmr.ps.ui.mobile.grid.MobileGridFragment;
import com.strmr.ps.ui.mobile.settings.MobileAboutFragment;
import com.strmr.ps.ui.mobile.settings.MobileAddonsFragment;
import com.strmr.ps.ui.mobile.settings.MobileDisplayFragment;
import com.strmr.ps.ui.mobile.settings.i;
import com.strmr.ps.ui.mobile.usercollection.MobileUserCollectionContentFragment;
import com.strmr.ps.ui.widget.AutoScrollTextView;
import com.strmr.ps.util.PlatformUtils;
import defpackage.bka;
import defpackage.cr4;
import defpackage.e6a;
import defpackage.ec7;
import defpackage.wj0;
import defpackage.zw8;
import java.io.File;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import kotlin.reflect.KClass;

/* JADX INFO: loaded from: classes3.dex */
public final /* synthetic */ class ah implements qq3 {
    public final /* synthetic */ int a;
    public final /* synthetic */ Object b;

    public /* synthetic */ ah(Object obj, int i) {
        this.a = i;
        this.b = obj;
    }

    /* JADX WARN: Removed duplicated region for block: B:110:0x0244  */
    /* JADX WARN: Removed duplicated region for block: B:162:0x03ac A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:175:0x03da  */
    /* JADX WARN: Removed duplicated region for block: B:275:0x05e7 A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:287:0x0622  */
    /* JADX WARN: Removed duplicated region for block: B:35:0x00a4 A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:48:0x00d2  */
    /* JADX WARN: Removed duplicated region for block: B:97:0x0216 A[ADDED_TO_REGION] */
    /* JADX WARN: Type inference failed for: r1v29, types: [java.lang.Object, java.util.Map] */
    @Override // defpackage.qq3
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invoke() {
        List list;
        String str;
        Iterator it;
        boolean z;
        String str2;
        String str3;
        String strAb;
        String airDate;
        List list2;
        String str4;
        boolean z2;
        Iterator it2;
        zw8.a aVar;
        String strAb2;
        int i;
        List list3;
        Iterator it3;
        boolean z3;
        zw8.a aVar2;
        String str5;
        String strAb3;
        int i2;
        Iterator it4;
        boolean z4;
        zw8.a aVar3;
        String str6;
        String strAb4;
        int i3;
        int i4 = this.a;
        String str7 = "";
        String str8 = "desc";
        e6a e6aVar = e6a.a;
        Object obj = this.b;
        switch (i4) {
            case 0:
                ((an) obj).requireActivity().finishAffinity();
                break;
            case 1:
                ActorDetailsFragment actorDetailsFragment = (ActorDetailsFragment) obj;
                cf1 cf1Var = actorDetailsFragment.m;
                if (cf1Var != null) {
                    List listBo = y41.bo(cf1Var.m);
                    if (!listBo.isEmpty()) {
                        af1 af1Var = (af1) y41.af(actorDetailsFragment.y, listBo);
                        if (af1Var == null) {
                            af1Var = (af1) y41.z(listBo);
                        }
                        String str9 = af1Var.d;
                        if (str9 != null) {
                            List listC = zw8.c(str9);
                            if (!listC.isEmpty()) {
                                String str10 = str9.equals("actor_movies") ? actorDetailsFragment.s : actorDetailsFragment.u;
                                String str11 = str9.equals("actor_movies") ? actorDetailsFragment.t : actorDetailsFragment.v;
                                zw8.a aVarB = zw8.b(str9);
                                String str12 = af1Var.a;
                                if (str12 == null && (str12 = actorDetailsFragment.j) == null) {
                                    str12 = "Content";
                                }
                                ArrayList arrayList = new ArrayList();
                                String str13 = str12;
                                if (str10 != null) {
                                    list = listC;
                                    String string = actorDetailsFragment.getString(R.string.sort_reset_default);
                                    cr4.f(string, "getString(...)");
                                    str = str11;
                                    arrayList.add(new a.z(PlayerSettings.SUBTITLE_FONT_DEFAULT, "asc", string, false));
                                } else {
                                    list = listC;
                                    str = str11;
                                }
                                Iterator it5 = list.iterator();
                                while (it5.hasNext()) {
                                    zw8.b bVar = (zw8.b) it5.next();
                                    String str14 = bVar.a;
                                    String str15 = bVar.c;
                                    if (cr4.b(str10, str14)) {
                                        it = it5;
                                    } else {
                                        it = it5;
                                        if (str10 == null) {
                                            if (cr4.b(aVarB != null ? aVarB.a : null, str14)) {
                                            }
                                            if (!z || str10 == null) {
                                                str2 = str7;
                                                str3 = str8;
                                                strAb = str2;
                                            } else {
                                                if (str != null) {
                                                    str15 = str;
                                                }
                                                if (str15.equals("asc")) {
                                                    str2 = str7;
                                                    str3 = str8;
                                                    strAb = vw2.ab("  (", actorDetailsFragment.getString(R.string.sort_ascending), ")");
                                                } else {
                                                    str2 = str7;
                                                    str3 = str8;
                                                    strAb = vw2.ab("  (", actorDetailsFragment.getString(R.string.sort_descending), ")");
                                                }
                                                str15 = str15.equals("asc") ? str3 : "asc";
                                            }
                                            arrayList.add(new a.z(str14, str15, vw2.k(bVar.b, strAb), z));
                                            str8 = str3;
                                            it5 = it;
                                            str7 = str2;
                                        }
                                        z = false;
                                        if (z) {
                                            str2 = str7;
                                            str3 = str8;
                                            strAb = str2;
                                        }
                                        arrayList.add(new a.z(str14, str15, vw2.k(bVar.b, strAb), z));
                                        str8 = str3;
                                        it5 = it;
                                        str7 = str2;
                                    }
                                    z = true;
                                    if (z) {
                                    }
                                    arrayList.add(new a.z(str14, str15, vw2.k(bVar.b, strAb), z));
                                    str8 = str3;
                                    it5 = it;
                                    str7 = str2;
                                }
                                int i5 = f.e;
                                Context contextRequireContext = actorDetailsFragment.requireContext();
                                cr4.f(contextRequireContext, "requireContext(...)");
                                String string2 = actorDetailsFragment.getString(R.string.sort_dialog_title, str13);
                                cr4.f(string2, "getString(...)");
                                f.a.a(contextRequireContext, string2, arrayList, new q2(actorDetailsFragment, str9, 5));
                            }
                        }
                    }
                }
                break;
            case 2:
                break;
            case 3:
                AutoScrollTextView autoScrollTextView = (AutoScrollTextView) obj;
                if (autoScrollTextView.b) {
                    autoScrollTextView.setScrollY(0);
                    autoScrollTextView.postDelayed(new l20(autoScrollTextView, 2), autoScrollTextView.startDelay);
                }
                break;
            case 4:
                break;
            case 5:
                int i6 = j91.a;
                ((j91) obj).reportFullyDrawn();
                break;
            case 6:
                int i7 = f.e;
                ((f) obj).dismiss();
                break;
            case 7:
                break;
            case 8:
                ((hx4) obj).bw();
                break;
            case 9:
                bn0 bn0Var = (bn0) obj;
                int i8 = m32.f;
                break;
            case 10:
                t activity = ((gd2) obj).getActivity();
                if (activity != null) {
                    activity.recreate();
                }
                break;
            case 11:
                break;
            case 12:
                List list4 = ((co2) obj).a;
                ArrayList arrayList2 = new ArrayList();
                for (Object obj2 : list4) {
                    TMDBEpisode tMDBEpisode = (TMDBEpisode) obj2;
                    if (tMDBEpisode.getEpisodeNumber() != null && (airDate = tMDBEpisode.getAirDate()) != null && !n89.ab(airDate)) {
                        arrayList2.add(obj2);
                    }
                }
                List listBj = y41.bj(new do2(), arrayList2);
                if (listBj.size() < 2) {
                    pk2 pk2Var = pk2.a;
                } else {
                    LinkedHashSet linkedHashSet = new LinkedHashSet();
                    LinkedHashSet linkedHashSet2 = new LinkedHashSet();
                    int size = listBj.size() - 1;
                    for (int i9 = 0; i9 < size; i9++) {
                        try {
                            String airDate2 = ((TMDBEpisode) listBj.get(i9)).getAirDate();
                            cr4.d(airDate2);
                            LocalDate localDate = LocalDate.parse(airDate2);
                            int i10 = i9 + 1;
                            String airDate3 = ((TMDBEpisode) listBj.get(i10)).getAirDate();
                            cr4.d(airDate3);
                            if (ChronoUnit.DAYS.between(localDate, LocalDate.parse(airDate3)) >= 21) {
                                Integer episodeNumber = ((TMDBEpisode) listBj.get(i9)).getEpisodeNumber();
                                cr4.d(episodeNumber);
                                linkedHashSet2.add(episodeNumber);
                                Integer episodeNumber2 = ((TMDBEpisode) listBj.get(i10)).getEpisodeNumber();
                                cr4.d(episodeNumber2);
                                linkedHashSet.add(episodeNumber2);
                            }
                        } catch (Exception unused) {
                        }
                    }
                }
                break;
            case 13:
                final GenreFragment genreFragment = (GenreFragment) obj;
                genreFragment.l();
                List list5 = zw8.a;
                boolean z5 = genreFragment.l().e;
                List listAu = (List) zw8.n.get("genre");
                if (listAu == null) {
                    listAu = ik2.a;
                }
                if (!z5) {
                    listAu = y41.au(zw8.k, listAu);
                }
                if (!listAu.isEmpty()) {
                    String str16 = genreFragment.l().r;
                    String str17 = genreFragment.l().s;
                    zw8.a aVarB2 = zw8.b("genre");
                    ArrayList arrayList3 = new ArrayList();
                    if (str16 != null) {
                        String string3 = genreFragment.getString(R.string.sort_reset_default);
                        cr4.f(string3, "getString(...)");
                        list2 = listAu;
                        arrayList3.add(new a.z(PlayerSettings.SUBTITLE_FONT_DEFAULT, "asc", string3, false));
                    } else {
                        list2 = listAu;
                    }
                    Iterator it6 = list2.iterator();
                    while (it6.hasNext()) {
                        zw8.b bVar2 = (zw8.b) it6.next();
                        String str18 = bVar2.a;
                        String str19 = bVar2.c;
                        if (cr4.b(str16, str18)) {
                            str4 = str16;
                        } else {
                            str4 = str16;
                            if (str16 == null) {
                                if (cr4.b(aVarB2 != null ? aVarB2.a : null, str18)) {
                                }
                                if (!z2 || str4 == null) {
                                    it2 = it6;
                                    aVar = aVarB2;
                                    strAb2 = "";
                                } else {
                                    if (str17 != null) {
                                        str19 = str17;
                                    }
                                    if (str19.equals("asc")) {
                                        it2 = it6;
                                        aVar = aVarB2;
                                        i = R.string.sort_ascending;
                                    } else {
                                        it2 = it6;
                                        aVar = aVarB2;
                                        i = R.string.sort_descending;
                                    }
                                    strAb2 = vw2.ab("  (", genreFragment.getString(i), ")");
                                    str19 = str19.equals("asc") ? "desc" : "asc";
                                }
                                arrayList3.add(new a.z(str18, str19, vw2.k(bVar2.b, strAb2), z2));
                                str16 = str4;
                                it6 = it2;
                                aVarB2 = aVar;
                            }
                            z2 = false;
                            if (z2) {
                                it2 = it6;
                                aVar = aVarB2;
                                strAb2 = "";
                            }
                            arrayList3.add(new a.z(str18, str19, vw2.k(bVar2.b, strAb2), z2));
                            str16 = str4;
                            it6 = it2;
                            aVarB2 = aVar;
                        }
                        z2 = true;
                        if (z2) {
                        }
                        arrayList3.add(new a.z(str18, str19, vw2.k(bVar2.b, strAb2), z2));
                        str16 = str4;
                        it6 = it2;
                        aVarB2 = aVar;
                    }
                    int i11 = f.e;
                    Context contextRequireContext2 = genreFragment.requireContext();
                    cr4.f(contextRequireContext2, "requireContext(...)");
                    String string4 = genreFragment.getString(R.string.sort_dialog_title, genreFragment.l().d);
                    cr4.f(string4, "getString(...)");
                    f.a.a(contextRequireContext2, string4, arrayList3, new sq3() { // from class: com.strmr.ps.ui.genre.a
                        @Override // defpackage.sq3
                        public final Object invoke(Object obj3) {
                            com.strmr.ps.ui.contextmenu.a aVar4 = (com.strmr.ps.ui.contextmenu.a) obj3;
                            cr4.g(aVar4, "action");
                            if (aVar4 instanceof a.z) {
                                a.z zVar = (a.z) aVar4;
                                String str20 = zVar.c;
                                String str21 = str20.equals(PlayerSettings.SUBTITLE_FONT_DEFAULT) ? null : str20;
                                String str22 = str20.equals(PlayerSettings.SUBTITLE_FONT_DEFAULT) ? null : zVar.d;
                                GenreViewModel genreViewModelL = genreFragment.l();
                                genreViewModelL.r = str21;
                                genreViewModelL.s = str22;
                                genreViewModelL.b.setSubPageSort(genreViewModelL.q, str21, str22);
                                genreViewModelL.n = 1;
                                genreViewModelL.p = true;
                                wj0.c(bka.a(genreViewModelL), null, null, new f(genreViewModelL, null), 3);
                            }
                            return e6a.a;
                        }
                    });
                }
                break;
            case 14:
                ((com.strmr.ps.ui.grid.a) obj).m().s();
                break;
            case 15:
                break;
            case 16:
                int i12 = qb5.f;
                ((qb5) obj).dismiss();
                break;
            case 17:
                ((MobileAboutFragment) obj).requireActivity().finishAffinity();
                break;
            case 18:
                MobileAddonsFragment mobileAddonsFragment = (MobileAddonsFragment) obj;
                View viewInflate = LayoutInflater.from(mobileAddonsFragment.requireContext()).inflate(R.layout.dialog_addon_install, (ViewGroup) null);
                EditText editText = (EditText) viewInflate.findViewById(R.id.addon_url_input);
                Context contextRequireContext3 = mobileAddonsFragment.requireContext();
                cr4.f(contextRequireContext3, "requireContext(...)");
                new gv3(contextRequireContext3, R.style.StrmrDialogTheme).setTitle((CharSequence) "Install Addon").setMessage((CharSequence) "Enter the fully configured addon URL").setView(viewInflate).setPositiveButton((CharSequence) "Install", (DialogInterface.OnClickListener) new i(editText, mobileAddonsFragment)).setNegativeButton((CharSequence) "Cancel", (DialogInterface.OnClickListener) null).show();
                break;
            case 19:
                t activity2 = ((MobileDisplayFragment) obj).getActivity();
                if (activity2 != null) {
                    activity2.recreate();
                }
                break;
            case 20:
                ((MobileGridFragment) obj).m().s();
                break;
            case 21:
                ((MobileUserCollectionContentFragment) obj).m().l();
                break;
            case 22:
                xk6 xk6Var = (xk6) obj;
                xk6Var.l();
                List listC2 = zw8.c("network");
                if (!listC2.isEmpty()) {
                    String str20 = xk6Var.l().aa;
                    String str21 = xk6Var.l().ab;
                    zw8.a aVarB3 = zw8.b("network");
                    ArrayList arrayList4 = new ArrayList();
                    if (str20 != null) {
                        String string5 = xk6Var.getString(R.string.sort_reset_default);
                        cr4.f(string5, "getString(...)");
                        list3 = listC2;
                        arrayList4.add(new a.z(PlayerSettings.SUBTITLE_FONT_DEFAULT, "asc", string5, false));
                    } else {
                        list3 = listC2;
                    }
                    Iterator it7 = list3.iterator();
                    while (it7.hasNext()) {
                        zw8.b bVar3 = (zw8.b) it7.next();
                        String str22 = bVar3.a;
                        String str23 = bVar3.c;
                        if (cr4.b(str20, str22)) {
                            it3 = it7;
                        } else {
                            it3 = it7;
                            if (str20 == null) {
                                if (cr4.b(aVarB3 != null ? aVarB3.a : null, str22)) {
                                }
                                if (!z3 || str20 == null) {
                                    aVar2 = aVarB3;
                                    str5 = str20;
                                    strAb3 = "";
                                } else {
                                    if (str21 != null) {
                                        str23 = str21;
                                    }
                                    if (str23.equals("asc")) {
                                        aVar2 = aVarB3;
                                        str5 = str20;
                                        i2 = R.string.sort_ascending;
                                    } else {
                                        aVar2 = aVarB3;
                                        str5 = str20;
                                        i2 = R.string.sort_descending;
                                    }
                                    strAb3 = vw2.ab("  (", xk6Var.getString(i2), ")");
                                    str23 = str23.equals("asc") ? "desc" : "asc";
                                }
                                arrayList4.add(new a.z(str22, str23, vw2.k(bVar3.b, strAb3), z3));
                                it7 = it3;
                                aVarB3 = aVar2;
                                str20 = str5;
                            }
                            z3 = false;
                            if (z3) {
                                aVar2 = aVarB3;
                                str5 = str20;
                                strAb3 = "";
                            }
                            arrayList4.add(new a.z(str22, str23, vw2.k(bVar3.b, strAb3), z3));
                            it7 = it3;
                            aVarB3 = aVar2;
                            str20 = str5;
                        }
                        z3 = true;
                        if (z3) {
                        }
                        arrayList4.add(new a.z(str22, str23, vw2.k(bVar3.b, strAb3), z3));
                        it7 = it3;
                        aVarB3 = aVar2;
                        str20 = str5;
                    }
                    int i13 = f.e;
                    Context contextRequireContext4 = xk6Var.requireContext();
                    cr4.f(contextRequireContext4, "requireContext(...)");
                    String string6 = xk6Var.getString(R.string.sort_dialog_title, xk6Var.l().f);
                    cr4.f(string6, "getString(...)");
                    f.a.a(contextRequireContext4, string6, arrayList4, new uk6(xk6Var, 2));
                }
                break;
            case 23:
                break;
            case 24:
                break;
            case 25:
                Object obj3 = OpenSubtitlesProvider.e;
                File file = new File(((OpenSubtitlesProvider) obj).c.getCacheDir(), "subtitles");
                if (!file.exists()) {
                    file.mkdirs();
                }
                break;
            case 26:
                Context context = ((PlatformUtils) obj).a;
                if (!context.getPackageManager().hasSystemFeature("android.software.leanback") && !context.getSharedPreferences("app_preferences", 0).getBoolean("force_tv_ui", false)) {
                    if ((context.getResources().getConfiguration().screenLayout & 15) >= 3) {
                    }
                }
                break;
            case 27:
                jc7 jc7Var = (jc7) obj;
                di8 di8VarC = ji8.c("kotlinx.serialization.Polymorphic", ec7.a.a, new bi8[0], new lt6(jc7Var, 2));
                KClass kClass = jc7Var.a;
                cr4.g(kClass, "context");
                break;
            case 28:
                com.strmr.ps.ui.rowitems.a aVar4 = (com.strmr.ps.ui.rowitems.a) obj;
                aVar4.l();
                List listC3 = zw8.c("row_items");
                if (!listC3.isEmpty()) {
                    String str24 = aVar4.l().j;
                    String str25 = aVar4.l().k;
                    zw8.a aVarB4 = zw8.b("row_items");
                    ArrayList arrayList5 = new ArrayList();
                    if (str24 != null) {
                        String string7 = aVar4.getString(R.string.sort_reset_default);
                        cr4.f(string7, "getString(...)");
                        arrayList5.add(new a.z(PlayerSettings.SUBTITLE_FONT_DEFAULT, "asc", string7, false));
                    }
                    Iterator it8 = listC3.iterator();
                    while (it8.hasNext()) {
                        zw8.b bVar4 = (zw8.b) it8.next();
                        String str26 = bVar4.a;
                        String str27 = bVar4.c;
                        if (cr4.b(str24, str26)) {
                            it4 = it8;
                        } else {
                            it4 = it8;
                            if (str24 == null) {
                                if (cr4.b(aVarB4 != null ? aVarB4.a : null, str26)) {
                                }
                                if (!z4 || str24 == null) {
                                    aVar3 = aVarB4;
                                    str6 = str24;
                                    strAb4 = "";
                                } else {
                                    if (str25 != null) {
                                        str27 = str25;
                                    }
                                    if (str27.equals("asc")) {
                                        aVar3 = aVarB4;
                                        str6 = str24;
                                        i3 = R.string.sort_ascending;
                                    } else {
                                        aVar3 = aVarB4;
                                        str6 = str24;
                                        i3 = R.string.sort_descending;
                                    }
                                    strAb4 = vw2.ab("  (", aVar4.getString(i3), ")");
                                    str27 = str27.equals("asc") ? "desc" : "asc";
                                }
                                arrayList5.add(new a.z(str26, str27, vw2.k(bVar4.b, strAb4), z4));
                                it8 = it4;
                                aVarB4 = aVar3;
                                str24 = str6;
                            }
                            z4 = false;
                            if (z4) {
                                aVar3 = aVarB4;
                                str6 = str24;
                                strAb4 = "";
                            }
                            arrayList5.add(new a.z(str26, str27, vw2.k(bVar4.b, strAb4), z4));
                            it8 = it4;
                            aVarB4 = aVar3;
                            str24 = str6;
                        }
                        z4 = true;
                        if (z4) {
                        }
                        arrayList5.add(new a.z(str26, str27, vw2.k(bVar4.b, strAb4), z4));
                        it8 = it4;
                        aVarB4 = aVar3;
                        str24 = str6;
                    }
                    int i14 = f.e;
                    Context contextRequireContext5 = aVar4.requireContext();
                    cr4.f(contextRequireContext5, "requireContext(...)");
                    String string8 = aVar4.getString(R.string.sort_dialog_title, aVar4.l().d);
                    cr4.f(string8, "getString(...)");
                    f.a.a(contextRequireContext5, string8, arrayList5, new l78(aVar4, 3));
                }
                break;
            default:
                g88 g88Var = (g88) obj;
                h hVar = g88Var.a;
                yh6 yh6Var = hVar instanceof yh6 ? (yh6) hVar : null;
                if (yh6Var != null) {
                    yh6Var.d();
                } else {
                    g88Var.c();
                }
                break;
        }
        return e6aVar;
    }
}
