package com.tencent.mm.plugin.order.ui.a;

import android.content.Context;
import android.graphics.Bitmap;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.g;
import com.tencent.mm.model.r;
import com.tencent.mm.plugin.messenger.foundation.a.j;
import com.tencent.mm.plugin.order.model.MallTransactionObject;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.storage.ad;
import com.tencent.mm.ui.base.preference.Preference;
import com.tencent.mm.ui.base.preference.PreferenceSmallCategory;
import com.tencent.mm.ui.base.preference.f;
import com.tencent.mm.wallet_core.ui.c;
import com.tencent.mm.wallet_core.ui.e;
import com.tencent.ttpic.baseutils.IOUtils;
import java.util.ArrayList;
import java.util.List;

public final class a implements com.tencent.mm.plugin.order.model.a.a {
    public c peq;

    public final List<Preference> a(Context context, f fVar, MallTransactionObject mallTransactionObject) {
        Object obj;
        CharSequence string;
        f fVar2;
        ad aoO;
        String Oj;
        f fVar3;
        String string2;
        Object obj2;
        h hVar;
        AppMethodBeat.i(43893);
        ArrayList arrayList = new ArrayList();
        if (mallTransactionObject.coq == 2) {
            obj = 1;
        } else {
            obj = null;
        }
        if (!(bo.isNullOrNil(mallTransactionObject.pcn) || bo.isNullOrNil(mallTransactionObject.hgW))) {
            d dVar = new d(context);
            dVar.kWC = mallTransactionObject.hgW;
            dVar.mName = mallTransactionObject.pcn;
            dVar.mOnClickListener = new 1(this, mallTransactionObject, context);
            arrayList.add(dVar);
            arrayList.add(new PreferenceSmallCategory(context));
        }
        i iVar = new i(context);
        iVar.peQ = e.e(mallTransactionObject.kCJ, mallTransactionObject.pcl);
        if (obj != null) {
            string = context.getString(2131305034);
        } else if (mallTransactionObject.cQO == 11) {
            string = context.getString(2131305071);
        } else {
            string = context.getString(2131305033);
        }
        iVar.setTitle(string);
        if (!bo.isNullOrNil(mallTransactionObject.pcd)) {
            iVar.UA(mallTransactionObject.pcd);
        }
        arrayList.add(iVar);
        boolean z = false;
        if (mallTransactionObject.kCJ != mallTransactionObject.pcr) {
            h hVar2 = new h(context);
            hVar2.peN = false;
            hVar2.peO = true;
            arrayList.add(hVar2);
            fVar2 = new f(context);
            fVar2.setContent(e.e(mallTransactionObject.pcr, mallTransactionObject.pcl));
            fVar2.setTitle(2131305060);
            arrayList.add(fVar2);
            z = true;
        }
        if (!(mallTransactionObject.kCJ == mallTransactionObject.pcr || bo.isNullOrNil(mallTransactionObject.pcq))) {
            g gVar = new g(context);
            gVar.setTitle(2131305046);
            gVar.iFE = fVar;
            String[] split = mallTransactionObject.pcq.split(IOUtils.LINE_SEPARATOR_UNIX);
            if (split.length == 1) {
                gVar.peG = split[0];
            } else {
                gVar.peG = context.getString(2131305048, new Object[]{Integer.valueOf(split.length), e.e(mallTransactionObject.pcr - mallTransactionObject.kCJ, mallTransactionObject.pcl)});
                gVar.a(split, TruncateAt.MIDDLE);
            }
            arrayList.add(gVar);
        }
        h hVar3 = new h(context);
        hVar3.peN = z;
        hVar3.peO = true;
        arrayList.add(hVar3);
        if (obj == null && !bo.isNullOrNil(mallTransactionObject.pcA)) {
            g.RQ();
            aoO = ((j) g.K(j.class)).XM().aoO(mallTransactionObject.pcA);
            if (aoO != null && ((int) aoO.ewQ) > 0) {
                Oj = aoO.Oj();
                fVar3 = new f(context);
                fVar3.setTitle(2131305074);
                fVar3.setContent(Oj);
                arrayList.add(fVar3);
            }
        }
        if (!(mallTransactionObject.cQO != 31 || obj == null || bo.isNullOrNil(mallTransactionObject.pcH))) {
            g.RQ();
            aoO = ((j) g.K(j.class)).XM().aoO(mallTransactionObject.pcH);
            if (aoO != null && ((int) aoO.ewQ) > 0) {
                Oj = aoO.Oj();
                fVar3 = new f(context);
                fVar3.setTitle(2131305058);
                fVar3.setContent(Oj);
                arrayList.add(fVar3);
            }
        }
        if (!bo.isNullOrNil(mallTransactionObject.desc)) {
            if (obj != null) {
                fVar2 = new f(context);
                if (mallTransactionObject.cQO == 32 || mallTransactionObject.cQO == 33 || mallTransactionObject.cQO == 31) {
                    fVar2.setTitle(2131305038);
                } else {
                    fVar2.setTitle(2131305058);
                }
                fVar2.setContent(mallTransactionObject.desc);
                arrayList.add(fVar2);
            } else {
                fVar2 = new f(context);
                if (mallTransactionObject.cQO == 31) {
                    fVar2.setTitle(2131305067);
                } else {
                    fVar2.setTitle(2131305044);
                }
                if (bo.isNullOrNil(mallTransactionObject.pcb)) {
                    fVar2.setContent(mallTransactionObject.desc);
                } else {
                    string2 = context.getString(2131305037);
                    fVar2.a(mallTransactionObject.desc + " " + string2, mallTransactionObject.desc.length() + 1, string2.length() + (mallTransactionObject.desc.length() + 1), new 2(this, mallTransactionObject, fVar2, fVar));
                }
                arrayList.add(fVar2);
            }
        }
        if (!bo.isNullOrNil(mallTransactionObject.pcL)) {
            fVar2 = new f(context);
            fVar2.setTitle(2131305086);
            fVar2.setContent(mallTransactionObject.pcL);
            arrayList.add(fVar2);
        }
        if (!bo.isNullOrNil(mallTransactionObject.pcK)) {
            fVar2 = new f(context);
            fVar2.setTitle(2131305087);
            fVar2.setContent(mallTransactionObject.pcK);
            arrayList.add(fVar2);
        }
        if (!TextUtils.isEmpty(mallTransactionObject.pcC)) {
            fVar2 = new f(context);
            fVar2.setTitle(2131305036);
            fVar2.setContent(mallTransactionObject.pcC);
            arrayList.add(fVar2);
        }
        if (!bo.isNullOrNil(mallTransactionObject.pca)) {
            fVar2 = new f(context);
            fVar2.setTitle(2131305059);
            fVar2.setContent(mallTransactionObject.pca);
            arrayList.add(fVar2);
        }
        if (!bo.isNullOrNil(mallTransactionObject.pcf)) {
            fVar2 = new f(context);
            fVar2.setTitle(2131305075);
            if (mallTransactionObject.cQO != 31 || r.Yz().equals(mallTransactionObject.pcA) || mallTransactionObject.pcB <= 0 || bo.isNullOrNil(mallTransactionObject.pcA) || bo.isNullOrNil(mallTransactionObject.cAa)) {
                fVar2.setContent(mallTransactionObject.pcf);
                if (!bo.isNullOrNil(mallTransactionObject.pcg)) {
                    fVar2.Uz(mallTransactionObject.pcg);
                }
            } else {
                string2 = context.getString(2131302456);
                fVar2.a(mallTransactionObject.pcf + " " + string2, mallTransactionObject.pcf.length() + 1, (string2.length() + mallTransactionObject.pcf.length()) + 1, new 3(this, context, mallTransactionObject));
            }
            arrayList.add(fVar2);
        }
        fVar2 = new f(context);
        fVar2.setTitle(2131305041);
        fVar2.setContent(e.kC(mallTransactionObject.fDG));
        arrayList.add(fVar2);
        if (!bo.isNullOrNil(mallTransactionObject.pcj)) {
            f fVar4 = new f(context);
            fVar4.setTitle(2131305062);
            Oj = mallTransactionObject.pcj;
            if (!bo.isNullOrNil(mallTransactionObject.pck)) {
                Oj = Oj + "(" + mallTransactionObject.pck + ")";
            }
            fVar4.setContent(Oj);
            arrayList.add(fVar4);
        }
        if (!bo.isNullOrNil(mallTransactionObject.cAa)) {
            fVar2 = new f(context);
            fVar2.setTitle(2131305082);
            fVar2.setContent(mallTransactionObject.cAa);
            arrayList.add(fVar2);
        }
        if (!bo.isNullOrNil(mallTransactionObject.pci)) {
            fVar2 = new f(context);
            fVar2.setTitle(2131305072);
            if (mallTransactionObject.cQO == 8) {
                fVar2.setContent(context.getString(2131305073));
                c cVar = new c(context);
                Bitmap b = com.tencent.mm.bw.a.a.b(context, mallTransactionObject.pci, 5, 0);
                cVar.pey = e.atx(mallTransactionObject.pci);
                cVar.fru = b;
                cVar.mOnClickListener = new 4(this, b, mallTransactionObject);
                arrayList.add(fVar2);
                arrayList.add(cVar);
            } else {
                fVar2.setContent(mallTransactionObject.pci);
                arrayList.add(fVar2);
            }
        }
        if (mallTransactionObject.pbM.size() == 0) {
            obj2 = null;
        } else {
            obj2 = 1;
        }
        if (obj2 != null || (bo.isNullOrNil(mallTransactionObject.pcv) && bo.isNullOrNil(mallTransactionObject.pcm) && bo.isNullOrNil(mallTransactionObject.pbP))) {
            hVar = new h(context);
            hVar.peN = true;
            hVar.jlN = false;
            arrayList.add(hVar);
        } else {
            hVar = new h(context);
            hVar.peN = true;
            arrayList.add(hVar);
            arrayList.add(com.tencent.mm.plugin.order.model.a.a(context, mallTransactionObject));
        }
        if (obj2 != null) {
            j jVar = new j(context);
            if (mallTransactionObject.pbN == 1) {
                if (!(bo.isNullOrNil(mallTransactionObject.pcv) && bo.isNullOrNil(mallTransactionObject.pcm) && bo.isNullOrNil(mallTransactionObject.pbP))) {
                    if (bo.isNullOrNil(mallTransactionObject.pcw)) {
                        jVar.peR = context.getString(2131305080);
                    } else {
                        jVar.peR = mallTransactionObject.pcw;
                    }
                    jVar.peS = new 5(this, mallTransactionObject, context);
                }
            } else if (!bo.isNullOrNil(mallTransactionObject.pcw)) {
                jVar.peR = mallTransactionObject.pcw;
                jVar.peS = new 6(this, context, mallTransactionObject);
            }
            jVar.pbM = mallTransactionObject.pbM;
            jVar.mOnClickListener = new 7(this, context, mallTransactionObject);
            hVar = new h(context);
            hVar.peN = true;
            arrayList.add(hVar);
            arrayList.add(jVar);
        }
        AppMethodBeat.o(43893);
        return arrayList;
    }
}
