package com.scb.phone.view.fragment.cardmanagement; import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.RadioButton; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import com.scb.phone.R; import com.scb.phone.view.activity.cardmanagement.TermAndConditionStatementChannelActivity; import com.scb.phone.view.custom.cardmanagement.CustomCardApplyViewComponent; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import o.C0367Fb; import o.C0424Gh; import o.C14957gcv; import o.C2852amS; import o.C2859amZ; import o.InterfaceC13391fZD; import o.InterfaceC9068dcj; import o.ZI; import o.pug; /* loaded from: classes5.dex */ public final class ChangeChannelStatementApplyAllFragment extends Hilt_ChangeChannelStatementApplyAllFragment implements InterfaceC9068dcj.Sts, CustomCardApplyViewComponent.Sts { public static final IeS c = new IeS(0); @BindView public Button btnNext; @BindView public RadioButton ckbNo; @BindView public CheckBox ckbSelectAll; @BindView public LinearLayout ckbSelectAllLayout; @BindView public RadioButton ckbYes; private String d; private ArrayList f; private boolean g; private String h; private C0367Fb i; private List j; private String k; private ArrayList l = new ArrayList<>(); @InterfaceC13391fZD public C2852amS presenter; @BindView public LinearLayout viewCardLayout; /* loaded from: classes5.dex */ public static final class IeS { private IeS() { } public /* synthetic */ IeS(byte b) { this(); } } @OnClick public final void onClickNext() { final String str; final String str2; final String str3; List list; this.l.clear(); if (this.g && (list = this.j) != null) { ArrayList arrayList = new ArrayList(); for (Object obj : list) { if (((C0424Gh) obj).a) { arrayList.add(obj); } } ArrayList arrayList2 = arrayList; C14957gcv.e(arrayList2, ""); ArrayList arrayList3 = new ArrayList(arrayList2.size()); Iterator it = arrayList2.iterator(); while (it.hasNext()) { arrayList3.add(Boolean.valueOf(this.l.add(((C0424Gh) it.next()).b))); } } C2852amS c2852amS = this.presenter; C0367Fb c0367Fb = null; if (c2852amS == null) { C14957gcv.a(""); c2852amS = null; } final ArrayList arrayList4 = this.l; String str4 = this.h; if (str4 == null) { C14957gcv.a(""); str = null; } else { str = str4; } String str5 = this.d; if (str5 == null) { C14957gcv.a(""); str2 = null; } else { str2 = str5; } String str6 = this.k; if (str6 == null) { C14957gcv.a(""); str3 = null; } else { str3 = str6; } C14957gcv.e(arrayList4, ""); C14957gcv.e(str, ""); C14957gcv.e(str2, ""); C14957gcv.e(str3, ""); C0367Fb c0367Fb2 = c2852amS.a; if (c0367Fb2 == null) { C14957gcv.a(""); } else { c0367Fb = c0367Fb2; } arrayList4.add(0, c0367Fb.g); final C2852amS c2852amS2 = c2852amS; ZI.IeS ieS = new ZI.IeS(c2852amS2, str, str2, str3, arrayList4) { // from class: o.amR private String a; private String b; private String c; private ArrayList d; private C2852amS e; @Override // o.ZI.IeS public final void e(Object obj2) { C2852amS.b(this.e, this.b, this.c, this.a, this.d, (InterfaceC9068dcj.Sts) obj2); } { this.e = c2852amS2; this.b = str; this.c = str2; this.a = str3; this.d = arrayList4; } }; if (c2852amS.f != 0) { ieS.e(c2852amS.f); } } @OnClick public final void onClickNo() { f(); } @OnClick public final void onClickYes() { this.g = true; RadioButton radioButton = this.ckbNo; C2852amS c2852amS = null; if (radioButton == null) { C14957gcv.a(""); radioButton = null; } radioButton.setChecked(false); boolean z = this.g; RadioButton radioButton2 = this.ckbYes; if (radioButton2 == null) { C14957gcv.a(""); radioButton2 = null; } radioButton2.setChecked(z); C2852amS c2852amS2 = this.presenter; if (c2852amS2 != null) { c2852amS = c2852amS2; } else { C14957gcv.a(""); } ZI.IeS ieS = new ZI.IeS() { // from class: o.amT @Override // o.ZI.IeS public final void e(Object obj) { C2852amS.c((InterfaceC9068dcj.Sts) obj); } }; if (c2852amS.f != 0) { ieS.e(c2852amS.f); } } @OnClick public final void onClickSelectAll() { this.g = true; RadioButton radioButton = this.ckbNo; CheckBox checkBox = null; if (radioButton == null) { C14957gcv.a(""); radioButton = null; } radioButton.setChecked(false); boolean z = this.g; RadioButton radioButton2 = this.ckbYes; if (radioButton2 == null) { C14957gcv.a(""); radioButton2 = null; } radioButton2.setChecked(z); C2852amS c2852amS = this.presenter; if (c2852amS == null) { C14957gcv.a(""); c2852amS = null; } CheckBox checkBox2 = this.ckbSelectAll; if (checkBox2 != null) { checkBox = checkBox2; } else { C14957gcv.a(""); } C2859amZ c2859amZ = new C2859amZ(checkBox.isChecked(), c2852amS); if (c2852amS.f != 0) { c2859amZ.e(c2852amS.f); } } @Override // androidx.fragment.app.Fragment public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { C14957gcv.e(layoutInflater, ""); return layoutInflater.inflate(R.layout.2131559495, viewGroup, false); } @Override // androidx.fragment.app.Fragment public final void onCreate(Bundle bundle) { String string; String string2; String string3; super.onCreate(bundle); Bundle arguments = getArguments(); if (arguments != null) { C14957gcv.e("EXTRA_CHANNEL_KEY", ""); if (arguments == null) { string = ""; } else { string = arguments.getString("EXTRA_CHANNEL_KEY", ""); C14957gcv.c((Object) string, ""); } this.h = string; C14957gcv.e("EXTRA_ADDRESS_KEY", ""); if (arguments == null) { string2 = ""; } else { string2 = arguments.getString("EXTRA_ADDRESS_KEY", ""); C14957gcv.c((Object) string2, ""); } this.d = string2; C14957gcv.e("EXTRA_MASK_CARD_KEY", ""); if (arguments == null) { string3 = ""; } else { string3 = arguments.getString("EXTRA_MASK_CARD_KEY", ""); C14957gcv.c((Object) string3, ""); } this.k = string3; C0367Fb c0367Fb = (C0367Fb) arguments.getParcelable("EXTRA_CREDIT_CARD_DISPLAY_KEY"); if (c0367Fb != null) { C14957gcv.c(c0367Fb, ""); this.i = c0367Fb; } ArrayList parcelableArrayList = arguments.getParcelableArrayList("EXTRA_CREDIT_CARD_DISPLAY_LIST_KEY"); if (parcelableArrayList != null) { C14957gcv.c(parcelableArrayList, ""); this.f = parcelableArrayList; } } } @Override // androidx.fragment.app.Fragment public final void onViewCreated(View view, Bundle bundle) { C14957gcv.e(view, ""); super.onViewCreated(view, bundle); ButterKnife.c(this, view); C2852amS c2852amS = this.presenter; ArrayList arrayList = null; if (c2852amS == null) { C14957gcv.a(""); c2852amS = null; } c2852amS.e((C2852amS) this); final C2852amS c2852amS2 = this.presenter; if (c2852amS2 == null) { C14957gcv.a(""); c2852amS2 = null; } C0367Fb c0367Fb = this.i; if (c0367Fb == null) { C14957gcv.a(""); c0367Fb = null; } ArrayList arrayList2 = this.f; if (arrayList2 == null) { C14957gcv.a(""); } else { arrayList = arrayList2; } C14957gcv.e(c0367Fb, ""); C14957gcv.e(arrayList, ""); c2852amS2.a = c0367Fb; c2852amS2.b = arrayList; ZI.IeS ieS = new ZI.IeS(c2852amS2) { // from class: o.amV private C2852amS a; @Override // o.ZI.IeS public final void e(Object obj) { C2852amS.e(this.a, (InterfaceC9068dcj.Sts) obj); } { this.a = c2852amS2; } }; if (c2852amS2.f != 0) { ieS.e(c2852amS2.f); } } @Override // androidx.fragment.app.Fragment public final void onStart() { super.onStart(); f(); } @Override // o.InterfaceC9068dcj.Sts public final void c(C0367Fb c0367Fb, ArrayList arrayList, String str, String str2, String str3, ArrayList arrayList2) { C14957gcv.e(c0367Fb, ""); C14957gcv.e(arrayList, ""); C14957gcv.e(str, ""); C14957gcv.e(str2, ""); C14957gcv.e(str3, ""); C14957gcv.e(arrayList2, ""); Context context = getContext(); if (context != null) { TermAndConditionStatementChannelActivity.HBt hBt = TermAndConditionStatementChannelActivity.m; context.startActivity(TermAndConditionStatementChannelActivity.HBt.Zv_(context, "creditcards_changechannel", c0367Fb, arrayList, str, str2, str3, arrayList2)); } } @Override // o.InterfaceC9068dcj.Sts public final void a(boolean z) { Button button = this.btnNext; if (button == null) { C14957gcv.a(""); button = null; } button.setEnabled(z); } @Override // o.InterfaceC9068dcj.Sts public final void c() { CheckBox checkBox = this.ckbSelectAll; C2852amS c2852amS = null; if (checkBox == null) { C14957gcv.a(""); checkBox = null; } boolean z = false; checkBox.setChecked(false); C2852amS c2852amS2 = this.presenter; if (c2852amS2 != null) { c2852amS = c2852amS2; } else { C14957gcv.a(""); } C2859amZ c2859amZ = new C2859amZ(z, c2852amS); if (c2852amS.f != 0) { c2859amZ.e(c2852amS.f); } d(); } private final View a(Context context, C0424Gh c0424Gh, boolean z, boolean z2, int i) { View view = null; CustomCardApplyViewComponent customCardApplyViewComponent = new CustomCardApplyViewComponent(context, null, 0); customCardApplyViewComponent.setIndex(i); customCardApplyViewComponent.setKey(c0424Gh.b); customCardApplyViewComponent.setTitle(c0424Gh.d); if (z) { View view2 = customCardApplyViewComponent.divider; if (view2 != null) { view = view2; } else { C14957gcv.a(""); } view.setVisibility(4); customCardApplyViewComponent.b(false); } else { View view3 = customCardApplyViewComponent.divider; if (view3 != null) { view = view3; } else { C14957gcv.a(""); } view.setVisibility(0); customCardApplyViewComponent.b(true); } customCardApplyViewComponent.setSelect(z2); customCardApplyViewComponent.setListener(this); return customCardApplyViewComponent; } @Override // com.scb.phone.view.custom.cardmanagement.CustomCardApplyViewComponent.Sts public final void a(int i, String str, boolean z) { C14957gcv.e(str, ""); List list = this.j; CheckBox checkBox = null; C0424Gh c0424Gh = list != null ? list.get(i) : null; if (c0424Gh != null) { c0424Gh.a = z; } List list2 = this.j; if (list2 != null) { ArrayList arrayList = new ArrayList(); for (Object obj : list2) { if (!((C0424Gh) obj).a) { arrayList.add(obj); } } ArrayList arrayList2 = arrayList; CheckBox checkBox2 = this.ckbSelectAll; if (checkBox2 != null) { checkBox = checkBox2; } else { C14957gcv.a(""); } checkBox.setChecked(arrayList2.isEmpty()); } d(); } @Override // o.InterfaceC9068dcj.Sts public final void c(boolean z) { LinearLayout linearLayout = null; if (z) { LinearLayout linearLayout2 = this.ckbSelectAllLayout; if (linearLayout2 == null) { C14957gcv.a(""); linearLayout2 = null; } linearLayout2.setVisibility(0); LinearLayout linearLayout3 = this.viewCardLayout; if (linearLayout3 != null) { linearLayout = linearLayout3; } else { C14957gcv.a(""); } linearLayout.setVisibility(0); return; } LinearLayout linearLayout4 = this.ckbSelectAllLayout; if (linearLayout4 == null) { C14957gcv.a(""); linearLayout4 = null; } linearLayout4.setVisibility(8); LinearLayout linearLayout5 = this.viewCardLayout; if (linearLayout5 != null) { linearLayout = linearLayout5; } else { C14957gcv.a(""); } linearLayout.setVisibility(8); } @Override // o.InterfaceC9068dcj.Sts public final void b() { c("change_stmt_channel_applycard", new pug[0]); } private final void d() { List list = this.j; if (list != null) { ArrayList arrayList = new ArrayList(); for (Object obj : list) { if (((C0424Gh) obj).a) { arrayList.add(obj); } } boolean z = !arrayList.isEmpty(); Button button = this.btnNext; if (button == null) { C14957gcv.a(""); button = null; } button.setEnabled(z); } } private final void f() { this.g = false; RadioButton radioButton = this.ckbNo; final C2852amS c2852amS = null; if (radioButton == null) { C14957gcv.a(""); radioButton = null; } radioButton.setChecked(true); boolean z = this.g; RadioButton radioButton2 = this.ckbYes; if (radioButton2 == null) { C14957gcv.a(""); radioButton2 = null; } radioButton2.setChecked(z); C2852amS c2852amS2 = this.presenter; if (c2852amS2 != null) { c2852amS = c2852amS2; } else { C14957gcv.a(""); } ZI.IeS ieS = new ZI.IeS(c2852amS) { // from class: o.amP private C2852amS e; @Override // o.ZI.IeS public final void e(Object obj) { C2852amS.d(this.e, (InterfaceC9068dcj.Sts) obj); } { this.e = c2852amS; } }; if (c2852amS.f != 0) { ieS.e(c2852amS.f); } } @Override // o.InterfaceC9068dcj.Sts public final void d(List list) { List list2; LinearLayout linearLayout; C14957gcv.e(list, ""); LinearLayout linearLayout2 = this.viewCardLayout; if (linearLayout2 == null) { C14957gcv.a(""); linearLayout2 = null; } linearLayout2.removeAllViews(); this.j = list; Context context = getContext(); if (context == null || (list2 = this.j) == null) { return; } int i = 0; for (Object obj : list2) { if (i >= 0) { C0424Gh c0424Gh = (C0424Gh) obj; LinearLayout linearLayout3 = this.viewCardLayout; if (linearLayout3 != null) { linearLayout = linearLayout3; } else { C14957gcv.a(""); linearLayout = null; } linearLayout.addView(a(context, c0424Gh, i == list.size() - 1, false, i)); i++; } else { throw new ArithmeticException("Index overflow has happened."); } } } @Override // o.InterfaceC9068dcj.Sts public final void a(boolean z, List list) { List list2; LinearLayout linearLayout; C14957gcv.e(list, ""); LinearLayout linearLayout2 = this.viewCardLayout; if (linearLayout2 == null) { C14957gcv.a(""); linearLayout2 = null; } linearLayout2.removeAllViews(); this.j = list; Context context = getContext(); if (context == null || (list2 = this.j) == null) { return; } int i = 0; for (Object obj : list2) { if (i >= 0) { C0424Gh c0424Gh = (C0424Gh) obj; LinearLayout linearLayout3 = this.viewCardLayout; if (linearLayout3 != null) { linearLayout = linearLayout3; } else { C14957gcv.a(""); linearLayout = null; } linearLayout.addView(a(context, c0424Gh, i == list.size() - 1, z, i)); i++; } else { throw new ArithmeticException("Index overflow has happened."); } } } }