package com.tencent.mm.plugin.subapp.ui.pluginapp;

import android.content.Intent;
import android.os.Bundle;
import android.os.Looper;
import android.widget.ListView;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ah.o;
import com.tencent.mm.api.b;
import com.tencent.mm.bp.d;
import com.tencent.mm.protocal.protobuf.but;
import com.tencent.mm.protocal.protobuf.buv;
import com.tencent.mm.protocal.protobuf.bvk;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ak;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.applet.a;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

public class ContactSearchResultUI extends MMActivity {
    private static ak feP = new ak(Looper.getMainLooper());
    private LinkedList<but> fjr = new LinkedList();
    private ListView svg;
    private a svh;
    private LinkedList<bvk> svi = new LinkedList();
    private Map<String, b> svj;

    public void onWindowFocusChanged(boolean z) {
        super.onWindowFocusChanged(z);
        AppMethodBeat.at(this, z);
    }

    public ContactSearchResultUI() {
        AppMethodBeat.i(25519);
        AppMethodBeat.o(25519);
    }

    static {
        AppMethodBeat.i(25524);
        AppMethodBeat.o(25524);
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(25520);
        super.onCreate(bundle);
        initView();
        AppMethodBeat.o(25520);
    }

    public final void initView() {
        AppMethodBeat.i(25521);
        setMMTitle(2131298763);
        setBackBtn(new 1(this));
        this.svj = new HashMap();
        this.svg = (ListView) findViewById(2131823139);
        this.svg.setEmptyView((TextView) findViewById(2131821749));
        byte[] byteArrayExtra = getIntent().getByteArrayExtra("result");
        int intExtra = getIntent().getIntExtra("add_more_friend_search_scene", 0);
        if (byteArrayExtra != null) {
            try {
                buv buv = (buv) new buv().parseFrom(byteArrayExtra);
                if (buv != null) {
                    this.fjr = buv.woe;
                    this.svi = buv.wWn;
                }
            } catch (Exception e) {
                ab.printErrStackTrace("MicroMsg.ContactSearchResultUI", e, "SearchContactResponse", new Object[0]);
                try {
                    this.svi.add((bvk) new bvk().parseFrom(byteArrayExtra));
                } catch (Exception e2) {
                    ab.printErrStackTrace("MicroMsg.ContactSearchResultUI", e2, "SearchOpenIMContactItem", new Object[0]);
                }
            }
        }
        if (this.fjr.size() == 0 && this.svi.isEmpty()) {
            AppMethodBeat.o(25521);
            return;
        }
        this.svh = new a(this, this);
        this.svg.setAdapter(this.svh);
        this.svg.setOnItemClickListener(new 2(this, intExtra));
        this.svg.setOnScrollListener(new a());
        AppMethodBeat.o(25521);
    }

    public final int getLayoutId() {
        return 2130969239;
    }

    public void onDestroy() {
        AppMethodBeat.i(25522);
        o.acv().cancel();
        if (this.svj != null) {
            this.svj.clear();
        }
        super.onDestroy();
        AppMethodBeat.o(25522);
    }

    static /* synthetic */ void a(ContactSearchResultUI contactSearchResultUI, bvk bvk) {
        int i = 1;
        AppMethodBeat.i(25523);
        Intent intent = new Intent();
        if (2 == bvk.wWh) {
            i = 15;
        } else if (1 != bvk.wWh) {
            i = 0;
        }
        b.a(intent, bvk, i);
        d.b(contactSearchResultUI, "profile", ".ui.ContactInfoUI", intent);
        AppMethodBeat.o(25523);
    }
}
