package defpackage;

import android.content.Context;
import android.content.DialogInterface;
import android.widget.Toast;
import com.strmr.ps.R;
import com.strmr.ps.data.repository.RpdbRepository;
import com.strmr.ps.ui.mobile.settings.MobileAccountsFragment;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: loaded from: classes3.dex */
public final /* synthetic */ class ey5 implements DialogInterface.OnClickListener {
    public final /* synthetic */ int a;
    public final /* synthetic */ MobileAccountsFragment b;

    public /* synthetic */ ey5(MobileAccountsFragment mobileAccountsFragment, int i) {
        this.a = i;
        this.b = mobileAccountsFragment;
    }

    @Override // android.content.DialogInterface.OnClickListener
    public final void onClick(DialogInterface dialogInterface, int i) {
        switch (this.a) {
            case 0:
                MobileAccountsFragment mobileAccountsFragment = this.b;
                wj0.c(n41.e(mobileAccountsFragment, "getViewLifecycleOwner(...)"), null, null, new vz5(mobileAccountsFragment, null), 3);
                break;
            case 1:
                MobileAccountsFragment mobileAccountsFragment2 = this.b;
                mobileAccountsFragment2.s().clearApiKey();
                mobileAccountsFragment2.ad();
                Toast.makeText(mobileAccountsFragment2.getContext(), mobileAccountsFragment2.getString(R.string.toast_disconnected, mobileAccountsFragment2.getString(R.string.omdb_name)), 0).show();
                mobileAccountsFragment2.ab();
                break;
            default:
                MobileAccountsFragment mobileAccountsFragment3 = this.b;
                if (i == 0) {
                    List<q07<String, String>> poster_types = RpdbRepository.INSTANCE.getPOSTER_TYPES();
                    List<q07<String, String>> list = poster_types;
                    ArrayList arrayList = new ArrayList(y41.p(list, 10));
                    Iterator<T> it = list.iterator();
                    while (it.hasNext()) {
                        arrayList.add((String) ((q07) it.next()).b);
                    }
                    String[] strArr = (String[]) arrayList.toArray(new String[0]);
                    String posterType = mobileAccountsFragment3.w().getPosterType();
                    Iterator<q07<String, String>> it2 = poster_types.iterator();
                    int i2 = 0;
                    while (true) {
                        if (!it2.hasNext()) {
                            i2 = -1;
                        } else if (!cr4.b(it2.next().a, posterType)) {
                            i2++;
                        }
                    }
                    int i3 = i2 >= 0 ? i2 : 0;
                    Context contextRequireContext = mobileAccountsFragment3.requireContext();
                    cr4.f(contextRequireContext, "requireContext(...)");
                    new gv3(contextRequireContext, R.style.StrmrDialogTheme).setTitle((CharSequence) "Poster Type").setSingleChoiceItems((CharSequence[]) strArr, i3, (DialogInterface.OnClickListener) new x3(mobileAccountsFragment3, poster_types, 11)).setNegativeButton((CharSequence) "Cancel", (DialogInterface.OnClickListener) null).show();
                    break;
                } else if (i == 1) {
                    mobileAccountsFragment3.w().clearApiKey();
                    mobileAccountsFragment3.ad();
                    Toast.makeText(mobileAccountsFragment3.getContext(), "Disconnected from RPDB", 0).show();
                    mobileAccountsFragment3.ac();
                    break;
                }
                break;
        }
    }
}
