package com.tencent.mm.plugin.brandservice.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.bp.d;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.messenger.foundation.a.j;
import com.tencent.mm.plugin.websearch.api.ai;
import com.tencent.mm.protocal.protobuf.bvo;
import com.tencent.mm.protocal.protobuf.mn;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.storage.RegionCodeDecoder;
import com.tencent.mm.storage.ad;
import com.tencent.mm.ui.base.sortview.a;
import com.tencent.mm.ui.base.sortview.a.b;
import com.tencent.ytcommon.BuildConfig;
import java.io.IOException;

public class a$b extends b {
    public final boolean a(Context context, a aVar, Object... objArr) {
        AppMethodBeat.i(13861);
        if (aVar instanceof a) {
            a aVar2 = (a) aVar;
            if (aVar.getData() instanceof mn) {
                mn mnVar = (mn) aVar.getData();
                if (mnVar.vQv == null || mnVar.vQv.vQb == null) {
                    ab.e("MicroMsg.BizContactDataItem", "The brItem.ContactItem or brItem.ContactItem.ContactItem is null.");
                    AppMethodBeat.o(13861);
                    return false;
                }
                int i;
                String str;
                String str2;
                c cVar = null;
                String str3 = BuildConfig.FLAVOR;
                if (objArr != null) {
                    c cVar2;
                    if (objArr.length <= 0 || !(objArr[0] instanceof c)) {
                        cVar2 = null;
                    } else {
                        cVar2 = (c) objArr[0];
                    }
                    if (objArr.length <= 2 || !(objArr[2] instanceof Integer)) {
                        i = 0;
                    } else {
                        i = ((Integer) objArr[2]).intValue();
                    }
                    if (objArr.length <= 3 || !(objArr[3] instanceof String)) {
                        cVar = cVar2;
                    } else {
                        str3 = (String) objArr[3];
                        cVar = cVar2;
                    }
                } else {
                    i = 0;
                }
                String str4 = mnVar.vQv.mZj;
                bvo bvo = mnVar.vQv.vQb;
                if (bvo.wyX != null) {
                    str = bvo.wyX.wVI;
                } else {
                    str = null;
                }
                if (bvo.wcB != null) {
                    str2 = bvo.wcB.wVI;
                } else {
                    str2 = null;
                }
                if (bo.isNullOrNil(str2)) {
                    ab.e("MicroMsg.BizContactDataItem", "onItemClick but username is null");
                    AppMethodBeat.o(13861);
                    return false;
                }
                int i2;
                ai.adO(str2);
                if (bo.isNullOrNil(str4)) {
                    ad aoO = ((j) g.K(j.class)).XM().aoO(str2);
                    Intent intent = new Intent();
                    Bundle bundle = new Bundle();
                    bundle.putString("Contact_Ext_Args_Search_Id", str3);
                    bundle.putInt("Contact_Ext_Args_Index", aVar2.aWn());
                    bundle.putString("Contact_Ext_Args_Query_String", BuildConfig.FLAVOR);
                    bundle.putInt("Contact_Scene", i);
                    intent.putExtra("Contact_Ext_Args", bundle);
                    intent.putExtra("Contact_User", str2);
                    intent.putExtra("Contact_Scene", i);
                    if (!com.tencent.mm.n.a.jh(aoO.field_type)) {
                        intent.putExtra("Contact_Alias", bvo.guS);
                        intent.putExtra("Contact_Nick", str);
                        intent.putExtra("Contact_Signature", bvo.guQ);
                        intent.putExtra("Contact_RegionCode", RegionCodeDecoder.aC(bvo.guW, bvo.guO, bvo.guP));
                        intent.putExtra("Contact_Sex", bvo.guN);
                        intent.putExtra("Contact_VUser_Info", bvo.wBU);
                        intent.putExtra("Contact_VUser_Info_Flag", bvo.wBT);
                        intent.putExtra("Contact_KWeibo_flag", bvo.wBX);
                        intent.putExtra("Contact_KWeibo", bvo.wBV);
                        intent.putExtra("Contact_KWeiboNick", bvo.wBW);
                        if (bvo.wWC != null) {
                            try {
                                intent.putExtra("Contact_customInfo", bvo.wWC.toByteArray());
                            } catch (IOException e) {
                                ab.printErrStackTrace("MicroMsg.BizContactDataItem", e, BuildConfig.FLAVOR, new Object[0]);
                            }
                        }
                    }
                    com.tencent.mm.plugin.brandservice.b.gkE.c(intent, context);
                    i2 = 1;
                } else {
                    i2 = 8;
                    Intent intent2 = new Intent();
                    intent2.putExtra("rawUrl", str4);
                    intent2.putExtra("useJs", true);
                    intent2.putExtra("vertical_scroll", true);
                    d.b(context, "webview", ".ui.tools.WebViewUI", intent2);
                }
                c.b aWm = aVar2.aWm();
                if (!(aWm == null || cVar == null)) {
                    aWm.a(cVar, aVar, i2, str2, aVar2.aWn(), aVar2.getPosition());
                }
                AppMethodBeat.o(13861);
                return true;
            }
            ab.e("MicroMsg.BizContactDataItem", "The DataItem is not a instance of BusinessResultItem.");
            AppMethodBeat.o(13861);
            return false;
        }
        AppMethodBeat.o(13861);
        return false;
    }

    public final View c(Context context, View view) {
        AppMethodBeat.i(13862);
        if (view == null) {
            view = View.inflate(context, 2130970571, null);
        }
        AppMethodBeat.o(13862);
        return view;
    }

    public final void a(Context context, a.a aVar, a aVar2) {
        int i = 8;
        AppMethodBeat.i(13863);
        if (context == null || aVar == null || aVar2 == null || aVar2.getData() == null) {
            ab.e("MicroMsg.BizContactDataItem", "Context or ViewHolder or DataItem or DataItem.data is null.");
            AppMethodBeat.o(13863);
        } else if (!(aVar instanceof a$a)) {
            ab.e("MicroMsg.BizContactDataItem", "The DataItem is not a instance of BizContactViewHolder.");
            AppMethodBeat.o(13863);
        } else if (aVar2 instanceof a) {
            int i2;
            a$a a_a = (a$a) aVar;
            a aVar3 = (a) aVar2;
            a_a.username = aVar3.username;
            a_a.iconUrl = aVar3.iconUrl;
            com.tencent.mm.pluginsdk.ui.a.b.r(a_a.ejo, aVar3.username);
            View view = a_a.jKL;
            if (aVar3.jKI) {
                i2 = 0;
            } else {
                i2 = 8;
            }
            view.setVisibility(i2);
            View view2 = a_a.jKP;
            if (aVar3.jKJ) {
                i = 0;
            }
            view2.setVisibility(i);
            com.tencent.mm.plugin.brandservice.b.a.b(a_a.emg, aVar3.nickName);
            boolean b = com.tencent.mm.plugin.brandservice.b.a.b(a_a.jKO, aVar3.jKH);
            boolean b2 = com.tencent.mm.plugin.brandservice.b.a.b(a_a.jKN, aVar3.jKG);
            if (com.tencent.mm.plugin.brandservice.b.a.b(a_a.jKM, aVar3.jKF)) {
                if (b || b2) {
                    a_a.jKM.setMaxLines(1);
                } else {
                    a_a.jKM.setMaxLines(2);
                }
            }
            ab.d("MicroMsg.BizContactDataItem", "fillingView , nickName : %s, followFriends : %s.", new Object[]{aVar3.nickName, aVar3.jKG});
            AppMethodBeat.o(13863);
        } else {
            ab.e("MicroMsg.BizContactDataItem", "The ViewHolder is not a instance of BusinessResultItem.");
            AppMethodBeat.o(13863);
        }
    }

    public final void a(View view, a.a aVar) {
        AppMethodBeat.i(13864);
        if (!(view == null || aVar == null || !(aVar instanceof a$a))) {
            a$a a_a = (a$a) aVar;
            a_a.jKK = (TextView) view.findViewById(2131821069);
            a_a.jKP = view.findViewById(2131824269);
            a_a.ejo = (ImageView) view.findViewById(2131823652);
            a_a.emg = (TextView) view.findViewById(2131824267);
            a_a.jKL = view.findViewById(2131824270);
            a_a.jKN = (TextView) view.findViewById(2131824274);
            a_a.jKM = (TextView) view.findViewById(2131824272);
            a_a.jKO = (TextView) view.findViewById(2131824271);
        }
        AppMethodBeat.o(13864);
    }
}
