package com.scb.phone.view.fragment.ccrredemption.ecoupon; import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import butterknife.BindView; import butterknife.ButterKnife; import com.scb.phone.R; import com.scb.phone.view.activity.ccrredemption.ecoupon.ECouponRedemptionDetailActivity; import com.scb.phone.view.activity.ccrredemption.ecoupon.MyECouponActivity; import com.scb.phone.view.fragment.ccrredemption.ecoupon.MyECouponFragment; import java.util.ArrayList; import java.util.List; import o.C0484Hp; import o.C12067erH; import o.C14957gcv; import o.C3154asE; import o.EnumC12146esh; import o.InterfaceC10108dwY; import o.InterfaceC12069erJ; import o.InterfaceC12072erM; import o.InterfaceC13391fZD; import o.InterfaceC9040dcH; import o.ZI; /* loaded from: classes5.dex */ public final class MyECouponFragment extends Hilt_MyECouponFragment implements InterfaceC9040dcH.jbe, InterfaceC12069erJ, InterfaceC10108dwY, InterfaceC12072erM { public static final IeS d = new IeS(0); private C12067erH c; private boolean g; private String h; private int i; @BindView public ImageView ivErrorIcon; private boolean j = true; @BindView public ViewGroup llErrorLayout; @InterfaceC13391fZD public C3154asE presenter; @BindView public RecyclerView rvCouponList; @BindView public TextView tvErrorGeneric; @BindView public TextView tvErrorTitle; /* loaded from: classes5.dex */ public static final class IeS { private IeS() { } public static MyECouponFragment e(String str, boolean z, boolean z2) { C14957gcv.e(str, ""); MyECouponFragment myECouponFragment = new MyECouponFragment(); Bundle bundle = new Bundle(); bundle.putString("EXTRA_MY_E_COUPON_CARD_REF_KEY", str); bundle.putBoolean("EXTRA_MY_E_COUPON_IS_VALID_KEY", z); bundle.putBoolean("EXTRA_E_COUPON_IS_FROM_DEEP_LINK_FLOW", z2); myECouponFragment.setArguments(bundle); return myECouponFragment; } public /* synthetic */ IeS(byte b) { this(); } } @Override // androidx.fragment.app.Fragment public final void onCreate(Bundle bundle) { super.onCreate(bundle); Bundle arguments = getArguments(); if (arguments != null) { String str = ""; C14957gcv.e("EXTRA_MY_E_COUPON_CARD_REF_KEY", ""); if (arguments != null) { String string = arguments.getString("EXTRA_MY_E_COUPON_CARD_REF_KEY", ""); C14957gcv.c((Object) string, ""); str = string; } this.h = str; this.j = arguments.getBoolean("EXTRA_MY_E_COUPON_IS_VALID_KEY"); this.g = arguments.getBoolean("EXTRA_E_COUPON_IS_FROM_DEEP_LINK_FLOW"); } } @Override // androidx.fragment.app.Fragment public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { C14957gcv.e(layoutInflater, ""); return layoutInflater.inflate(R.layout.2131559777, viewGroup, false); } @Override // androidx.fragment.app.Fragment public final void onViewCreated(View view, Bundle bundle) { C14957gcv.e(view, ""); super.onViewCreated(view, bundle); ButterKnife.c(this, view); C12067erH c12067erH = new C12067erH(this); C14957gcv.e(c12067erH, ""); this.c = c12067erH; } @Override // androidx.fragment.app.Fragment public final void onStart() { super.onStart(); FragmentActivity activity = getActivity(); C14957gcv.d(activity, ""); MyECouponFragment myECouponFragment = this; C14957gcv.e(myECouponFragment, ""); ((MyECouponActivity) activity).m = myECouponFragment; final C3154asE c3154asE = this.presenter; String str = null; if (c3154asE == null) { C14957gcv.a(""); c3154asE = null; } c3154asE.e((C3154asE) this); String str2 = this.h; if (str2 == null) { C14957gcv.a(""); } else { str = str2; } boolean z = this.j; C14957gcv.e(str, ""); c3154asE.e = str; c3154asE.d = z; ZI.IeS ieS = new ZI.IeS(c3154asE) { // from class: o.asC private C3154asE b; @Override // o.ZI.IeS public final void e(Object obj) { C3154asE.c(this.b, (InterfaceC9040dcH.jbe) obj); } { this.b = c3154asE; } }; if (c3154asE.f != 0) { ieS.e(c3154asE.f); } c(this.i, 0); } @Override // androidx.fragment.app.Fragment public final void setUserVisibleHint(boolean z) { super.setUserVisibleHint(z); if (z && isResumed()) { c(this.i, 0); } } @Override // o.InterfaceC9040dcH.jbe public final void g() { ViewGroup viewGroup = this.llErrorLayout; TextView textView = null; if (viewGroup == null) { C14957gcv.a(""); viewGroup = null; } viewGroup.setVisibility(0); ImageView imageView = this.ivErrorIcon; if (imageView == null) { C14957gcv.a(""); imageView = null; } imageView.setImageResource(R.drawable.ic_yellow_warning); TextView textView2 = this.tvErrorTitle; if (textView2 == null) { C14957gcv.a(""); textView2 = null; } textView2.setText(getString(R.string.my_e_coupon_error_title)); TextView textView3 = this.tvErrorGeneric; if (textView3 != null) { textView = textView3; } else { C14957gcv.a(""); } textView.setText(getString(R.string.my_e_coupon_error_generic)); } @Override // o.InterfaceC9040dcH.jbe public final void i() { ViewGroup viewGroup = this.llErrorLayout; TextView textView = null; if (viewGroup == null) { C14957gcv.a(""); viewGroup = null; } viewGroup.setVisibility(0); ImageView imageView = this.ivErrorIcon; if (imageView == null) { C14957gcv.a(""); imageView = null; } imageView.setImageResource(R.drawable.box_empty); TextView textView2 = this.tvErrorTitle; if (textView2 == null) { C14957gcv.a(""); textView2 = null; } textView2.setText(getString(R.string.my_e_coupon_no_coupon_title)); TextView textView3 = this.tvErrorGeneric; if (textView3 != null) { textView = textView3; } else { C14957gcv.a(""); } textView.setText(getString(R.string.my_e_coupon_no_coupon_generic)); } @Override // o.InterfaceC9040dcH.jbe public final void b() { v("myecoupon_landing_invalid"); } @Override // o.InterfaceC9040dcH.jbe public final void c() { v("myecoupon_landing_valid"); } @Override // o.InterfaceC9040dcH.jbe public final void e() { RecyclerView recyclerView = this.rvCouponList; C12067erH c12067erH = null; if (recyclerView == null) { C14957gcv.a(""); recyclerView = null; } C12067erH c12067erH2 = this.c; if (c12067erH2 == null) { C14957gcv.a(""); c12067erH2 = null; } c12067erH2.b = this.j; getContext(); recyclerView.setLayoutManager(new LinearLayoutManager()); C12067erH c12067erH3 = this.c; if (c12067erH3 != null) { c12067erH = c12067erH3; } else { C14957gcv.a(""); } recyclerView.setAdapter(c12067erH); } /* loaded from: classes5.dex */ public static final class HBt extends RecyclerView.dAO { private MyECouponFragment a; HBt(MyECouponFragment myECouponFragment) { this.a = myECouponFragment; } @Override // androidx.recyclerview.widget.RecyclerView.dAO public final void onScrolled(RecyclerView recyclerView, int i, int i2) { C14957gcv.e(recyclerView, ""); super.onScrolled(recyclerView, i, i2); if (i == 0 && i2 == 0) { return; } RecyclerView.tOB tob = recyclerView.x; C14957gcv.d(tob, ""); if (MyECouponFragment.d(recyclerView, (LinearLayoutManager) tob)) { C3154asE c3154asE = this.a.presenter; if (c3154asE == null) { C14957gcv.a(""); c3154asE = null; } c3154asE.d(); } } } @Override // o.InterfaceC9040dcH.jbe public final void h() { RecyclerView recyclerView = this.rvCouponList; if (recyclerView == null) { C14957gcv.a(""); recyclerView = null; } HBt hBt = new HBt(this); if (recyclerView.S == null) { recyclerView.S = new ArrayList(); } recyclerView.S.add(hBt); } @Override // o.InterfaceC9040dcH.jbe public final void a(List list) { C14957gcv.e(list, ""); C12067erH c12067erH = this.c; if (c12067erH == null) { C14957gcv.a(""); c12067erH = null; } C14957gcv.e(list, ""); c12067erH.d.addAll(list); c12067erH.notifyDataSetChanged(); } @Override // o.InterfaceC9053dcU public final void k() { C12067erH c12067erH = this.c; if (c12067erH == null) { C14957gcv.a(""); c12067erH = null; } c12067erH.a = true; c12067erH.i = EnumC12146esh.SHOWING_LOADER; c12067erH.e(); c12067erH.notifyDataSetChanged(); o(); } @Override // o.InterfaceC9053dcU public final void f() { C12067erH c12067erH = this.c; if (c12067erH == null) { C14957gcv.a(""); c12067erH = null; } c12067erH.a = false; c12067erH.i = EnumC12146esh.HIDDEN_LOADER; c12067erH.e(); c12067erH.notifyDataSetChanged(); } @Override // o.InterfaceC9053dcU public final void m() { C12067erH c12067erH = this.c; if (c12067erH == null) { C14957gcv.a(""); c12067erH = null; } View.OnClickListener onClickListener = new View.OnClickListener(this) { // from class: o.eKO private MyECouponFragment d; @Override // android.view.View.OnClickListener public final void onClick(View view) { MyECouponFragment.d(this.d); } { this.d = this; } }; c12067erH.a = true; c12067erH.g = onClickListener; c12067erH.i = EnumC12146esh.SHOWING_ERROR; c12067erH.e(); c12067erH.notifyDataSetChanged(); o(); } @Override // o.InterfaceC9053dcU public final void l() { C12067erH c12067erH = this.c; if (c12067erH == null) { C14957gcv.a(""); c12067erH = null; } c12067erH.a = false; c12067erH.i = EnumC12146esh.HIDDEN_ERROR; c12067erH.e(); c12067erH.notifyDataSetChanged(); } @Override // o.InterfaceC9040dcH.jbe public final void c(C0484Hp c0484Hp) { String str; C14957gcv.e(c0484Hp, ""); Context context = getContext(); if (context != null) { ECouponRedemptionDetailActivity.HBt hBt = ECouponRedemptionDetailActivity.b; String str2 = this.h; if (str2 == null) { C14957gcv.a(""); str = null; } else { str = str2; } context.startActivity(ECouponRedemptionDetailActivity.HBt.ZL_(context, str, c0484Hp.m, c0484Hp.f, c0484Hp.n, this.g)); } } @Override // o.InterfaceC12069erJ public final void b(final C0484Hp c0484Hp) { C14957gcv.e(c0484Hp, ""); C3154asE c3154asE = this.presenter; if (c3154asE == null) { C14957gcv.a(""); c3154asE = null; } C14957gcv.e(c0484Hp, ""); ZI.IeS ieS = new ZI.IeS(c0484Hp) { // from class: o.asG private C0484Hp a; @Override // o.ZI.IeS public final void e(Object obj) { C3154asE.a(this.a, (InterfaceC9040dcH.jbe) obj); } { this.a = c0484Hp; } }; if (c3154asE.f != 0) { ieS.e(c3154asE.f); } } @Override // o.InterfaceC9040dcH.jbe public final void j() { C12067erH c12067erH = this.c; if (c12067erH == null) { C14957gcv.a(""); c12067erH = null; } MyECouponFragment myECouponFragment = this; C14957gcv.e(myECouponFragment, ""); c12067erH.c = myECouponFragment; } @Override // o.InterfaceC9040dcH.jbe public final void d() { C12067erH c12067erH = this.c; if (c12067erH == null) { C14957gcv.a(""); c12067erH = null; } c12067erH.d.clear(); c12067erH.notifyDataSetChanged(); } @Override // com.scb.phone.view.fragment.BaseFragment, androidx.fragment.app.Fragment public final void onDestroy() { RecyclerView recyclerView = this.rvCouponList; C3154asE c3154asE = null; if (recyclerView == null) { C14957gcv.a(""); recyclerView = null; } recyclerView.setAdapter(null); C3154asE c3154asE2 = this.presenter; if (c3154asE2 != null) { c3154asE = c3154asE2; } else { C14957gcv.a(""); } c3154asE.w_(); super.onDestroy(); } @Override // o.InterfaceC9040dcH.jbe public final void a() { ViewGroup viewGroup = this.llErrorLayout; if (viewGroup == null) { C14957gcv.a(""); viewGroup = null; } viewGroup.setVisibility(8); } @Override // o.InterfaceC9040dcH.jbe public final void b(int i) { C12067erH c12067erH = this.c; if (c12067erH == null) { C14957gcv.a(""); c12067erH = null; } c12067erH.d.remove(i); c12067erH.notifyDataSetChanged(); } @Override // o.InterfaceC12072erM public final void a(final int i) { C3154asE c3154asE = this.presenter; if (c3154asE == null) { C14957gcv.a(""); c3154asE = null; } ZI.IeS ieS = new ZI.IeS(i) { // from class: o.asL private int b; @Override // o.ZI.IeS public final void e(Object obj) { ((InterfaceC9040dcH.jbe) obj).b(this.b); } { this.b = i; } }; if (c3154asE.f != 0) { ieS.e(c3154asE.f); } c3154asE.c.remove(i); } private final void o() { RecyclerView recyclerView = this.rvCouponList; if (recyclerView == null) { C14957gcv.a(""); recyclerView = null; } recyclerView.postDelayed(new Runnable(this) { // from class: o.eKT private MyECouponFragment a; @Override // java.lang.Runnable public final void run() { MyECouponFragment.e(this.a); } { this.a = this; } }, 100L); } private final int n() { RecyclerView recyclerView = this.rvCouponList; RecyclerView recyclerView2 = null; if (recyclerView == null) { C14957gcv.a(""); recyclerView = null; } RecyclerView.tOB tob = recyclerView.x; int i_ = tob != null ? tob.i_() : 0; RecyclerView recyclerView3 = this.rvCouponList; if (recyclerView3 != null) { recyclerView2 = recyclerView3; } else { C14957gcv.a(""); } View childAt = recyclerView2.getChildAt(i_ - 2); if (childAt != null) { return childAt.getHeight(); } return 0; } private final void c(int i, int i2) { final C3154asE c3154asE = this.presenter; if (c3154asE == null) { C14957gcv.a(""); c3154asE = null; } ZI.IeS ieS = new ZI.IeS() { // from class: o.asO @Override // o.ZI.IeS public final void e(Object obj) { ((InterfaceC9040dcH.jbe) obj).d(); } }; if (c3154asE.f != 0) { ieS.e(c3154asE.f); } boolean z = true; if ((!c3154asE.d || i != 0 || i2 != 0) && (c3154asE.d || i != 1 || i2 != 0)) { z = false; } ZI.IeS ieS2 = new ZI.IeS(c3154asE) { // from class: o.asH private C3154asE c; @Override // o.ZI.IeS public final void e(Object obj) { C3154asE.d(this.c, (InterfaceC9040dcH.jbe) obj); } { this.c = c3154asE; } }; if (!z || c3154asE.f == 0) { return; } ieS2.e(c3154asE.f); } public static /* synthetic */ void e(MyECouponFragment myECouponFragment) { C14957gcv.e(myECouponFragment, ""); RecyclerView recyclerView = myECouponFragment.rvCouponList; if (recyclerView == null) { C14957gcv.a(""); recyclerView = null; } recyclerView.scrollBy(myECouponFragment.n(), myECouponFragment.n()); } public static /* synthetic */ void d(MyECouponFragment myECouponFragment) { C14957gcv.e(myECouponFragment, ""); C3154asE c3154asE = myECouponFragment.presenter; if (c3154asE == null) { C14957gcv.a(""); c3154asE = null; } c3154asE.d(); } public static final /* synthetic */ boolean d(RecyclerView recyclerView, LinearLayoutManager linearLayoutManager) { return recyclerView.isShown() && !recyclerView.canScrollVertically(1) && linearLayoutManager.i() == linearLayoutManager.r() - 1; } @Override // o.InterfaceC10108dwY public final void a(int i, int i2) { ViewGroup viewGroup = this.llErrorLayout; if (viewGroup == null) { C14957gcv.a(""); viewGroup = null; } viewGroup.setVisibility(8); c(i, i2); this.i = i; } }