package com.ss.android.ugc.aweme.ecommerce.pdp;

import X.2Pr;
import X.2te;
import X.2uR;
import X.3SM;
import X.3YD;
import X.3cA;
import X.3cC;
import X.3cI;
import X.4r1;
import X.C5558C3u;
import X.C5559C3v;
import X.C5560C3w;
import X.C6489CbV;
import X.CG9;
import X.M12;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.ecommerce.api.model.Icon;
import com.ss.android.ugc.aweme.ecommerce.common.ECBaseFragment;
import com.ss.android.ugc.aweme.ecommerce.pdp.repository.dto.ShopPolicy;
import com.ss.android.ugc.aweme.ecommerce.service.vo.Image;
import com.ss.android.ugc.aweme.utils.ActivityStack;
import java.util.ArrayList;
import java.util.List;
import kotlin.h.b.n;

public final class PoliciesFragment extends ECBaseFragment implements 3YD {
    public static 4r1<? super 2Pr> LIZ;
    public static final C5560C3w LIZIZ = new C5560C3w((byte) 0);
    public SparseArray LIZJ;

    static {
        Covode.recordClassIndex(71142);
    }

    public final View LIZ(int i) {
        if (this.LIZJ == null) {
            this.LIZJ = new SparseArray();
        }
        View view = (View) this.LIZJ.get(i);
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LIZJ.put(i, findViewById);
        return findViewById;
    }

    public final void LJII() {
        SparseArray sparseArray = this.LIZJ;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    public final String ck_() {
        return "retailer_policies";
    }

    public final /* synthetic */ void onDestroyView() {
        super.onDestroyView();
        LJII();
    }

    public final void onDestroy() {
        PoliciesFragment.super.onDestroy();
        4r1<? super 2Pr> r1 = LIZ;
        if (r1 != null) {
            2Pr r0 = 2Pr.LIZ;
            2te.constructor-impl(r0);
            r1.resumeWith(r0);
        }
        LIZ = null;
    }

    public final 2uR ch_() {
        2uR r4 = new 2uR();
        3cC r2 = new 3cC();
        String string = getString(2131824202);
        n.LIZIZ(string, "");
        r2.LIZ(string);
        r4.LIZ(r2);
        3cA r1 = new 3cA();
        r1.LIZ(2131755740);
        r1.LIZIZ = true;
        r1.LIZ(new C5559C3v(this));
        r4.LIZIZ(new 3cI[]{r1});
        return r4;
    }

    public final void onStop() {
        String str;
        PoliciesFragment.super.onStop();
        CG9 LIZ2 = CG9.LJJIZ.LIZ(getActivity());
        if (LIZ2 != null) {
            long cg_ = cg_();
            if (ActivityStack.isAppBackGround()) {
                str = "close";
            } else {
                str = "return";
            }
            LIZ2.LIZ("retailer_policies", cg_, str);
        }
    }

    /* JADX WARNING: type inference failed for: r1v4, types: [X.C3u, android.view.View] */
    public final void onViewCreated(View view, Bundle bundle) {
        Parcelable[] parcelableArr;
        Image image;
        MethodCollector.i(797);
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        Bundle arguments = getArguments();
        if (arguments != null) {
            parcelableArr = arguments.getParcelableArray("data");
        } else {
            parcelableArr = null;
        }
        if (!(parcelableArr instanceof ShopPolicy[])) {
            parcelableArr = null;
        }
        ShopPolicy[] shopPolicyArr = (ShopPolicy[]) parcelableArr;
        if (shopPolicyArr != null) {
            List<?> arrayList = new ArrayList<>(shopPolicyArr.length);
            for (ShopPolicy shopPolicy : shopPolicyArr) {
                Context context = view.getContext();
                n.LIZIZ(context, "");
                C5558C3u c3u = new C5558C3u(context, (byte) 0);
                int i = 3SM.LJ;
                c3u.setTitle(shopPolicy.LIZ);
                c3u.setDesc(shopPolicy.LIZIZ);
                Icon icon = shopPolicy.LIZJ;
                if (icon != null) {
                    image = icon.LIZ;
                } else {
                    image = null;
                }
                c3u.setIcon(image);
                c3u.setPadding(i, i, i, i);
                arrayList.add(c3u);
            }
            for (? addView : arrayList) {
                ((LinearLayout) LIZ(2131369849)).addView(addView);
            }
        }
        CG9 LIZ2 = CG9.LJJIZ.LIZ(getContext());
        if (LIZ2 != null) {
            LIZ2.LIZ("retailer_policies", (Boolean) null);
            MethodCollector.o(797);
            return;
        }
        MethodCollector.o(797);
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        return C6489CbV.LIZ(getContext(), 2131559112, viewGroup, false);
    }
}
