package com.tencent.mm.plugin.account.bind.ui;

import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.widget.Button;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ai.f;
import com.tencent.mm.ai.p;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.account.friend.a.ag;
import com.tencent.mm.plugin.b.a;
import com.tencent.mm.pluginsdk.permission.b;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.MMWizardActivity;
import com.tencent.mm.ui.base.h;
import com.tencent.ytcommon.BuildConfig;
import java.util.List;

public class FindMContactLearmMoreUI extends MMWizardActivity {
    private String cFl;
    private ProgressDialog ehJ = null;
    private String elr = null;
    private f fQS = null;
    private List<String[]> gsD = null;
    private ag gsE;
    private Button gsW;
    private TextView gsX;
    private String gsy = BuildConfig.FLAVOR;
    private int gsz = 2;

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

    static /* synthetic */ void a(FindMContactLearmMoreUI findMContactLearmMoreUI) {
        AppMethodBeat.i(13640);
        findMContactLearmMoreUI.api();
        AppMethodBeat.o(13640);
    }

    static /* synthetic */ void b(FindMContactLearmMoreUI findMContactLearmMoreUI) {
        AppMethodBeat.i(13641);
        findMContactLearmMoreUI.aoZ();
        AppMethodBeat.o(13641);
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(13631);
        super.onCreate(bundle);
        this.elr = getIntent().getStringExtra("regsetinfo_ticket");
        this.gsy = getIntent().getStringExtra("regsetinfo_NextStep");
        this.gsz = getIntent().getIntExtra("regsetinfo_NextStyle", 2);
        initView();
        AppMethodBeat.o(13631);
    }

    public void onDestroy() {
        AppMethodBeat.i(13632);
        if (this.fQS != null) {
            g.Rg().b(431, this.fQS);
            this.fQS = null;
        }
        super.onDestroy();
        AppMethodBeat.o(13632);
    }

    public void onResume() {
        AppMethodBeat.i(13633);
        super.onResume();
        a.wz("R300_100_phone");
        StringBuilder stringBuilder = new StringBuilder();
        g.RN();
        stringBuilder = stringBuilder.append(com.tencent.mm.kernel.a.Rb()).append(",").append(getClass().getName()).append(",RE300_600,");
        g.RN();
        a.f(true, stringBuilder.append(com.tencent.mm.kernel.a.lF("RE300_600")).append(",1").toString());
        AppMethodBeat.o(13633);
    }

    public void onPause() {
        AppMethodBeat.i(13634);
        super.onPause();
        StringBuilder stringBuilder = new StringBuilder();
        g.RN();
        stringBuilder = stringBuilder.append(com.tencent.mm.kernel.a.Rb()).append(",").append(getClass().getName()).append(",RE300_600,");
        g.RN();
        a.f(false, stringBuilder.append(com.tencent.mm.kernel.a.lF("RE300_600")).append(",2").toString());
        AppMethodBeat.o(13634);
    }

    public final void initView() {
        AppMethodBeat.i(13635);
        setMMTitle(2131299860);
        this.gsW = (Button) findViewById(2131823196);
        this.gsX = (TextView) findViewById(2131822819);
        this.gsW.setOnClickListener(new 1(this));
        this.gsX.setOnClickListener(new 2(this));
        g.RP().Ry().set(12323, Boolean.TRUE);
        this.cFl = (String) g.RP().Ry().get(6, null);
        if (this.cFl == null || this.cFl.equals(BuildConfig.FLAVOR)) {
            this.cFl = (String) g.RP().Ry().get(4097, null);
        }
        AppMethodBeat.o(13635);
    }

    private void api() {
        AppMethodBeat.i(13636);
        ab.i("MicroMsg.FindMContactLearmMoreUI", "summerper checkPermission checkContacts[%b],stack[%s]", new Object[]{Boolean.valueOf(b.a(this, "android.permission.READ_CONTACTS", 48, null, null)), bo.dpG()});
        if (b.a(this, "android.permission.READ_CONTACTS", 48, null, null)) {
            p Rg = g.Rg();
            3 3 = new 3(this);
            this.fQS = 3;
            Rg.a(431, 3);
            AppCompatActivity appCompatActivity = this.mController.ylL;
            getString(2131297061);
            this.ehJ = h.b(appCompatActivity, getString(2131296965), true, new 4(this));
            g.RS().a(new al.a() {
                public final boolean acg() {
                    AppMethodBeat.i(13626);
                    if (FindMContactLearmMoreUI.this.gsD == null || FindMContactLearmMoreUI.this.gsD.size() == 0) {
                        if (FindMContactLearmMoreUI.this.ehJ != null) {
                            FindMContactLearmMoreUI.this.ehJ.dismiss();
                            FindMContactLearmMoreUI.this.ehJ = null;
                        }
                        FindMContactLearmMoreUI.b(FindMContactLearmMoreUI.this);
                    } else {
                        FindMContactLearmMoreUI.this.gsE = new ag(FindMContactLearmMoreUI.this.elr, FindMContactLearmMoreUI.this.gsD);
                        g.Rg().a(FindMContactLearmMoreUI.this.gsE, 0);
                    }
                    AppMethodBeat.o(13626);
                    return false;
                }

                public final boolean acf() {
                    AppMethodBeat.i(13627);
                    try {
                        FindMContactLearmMoreUI.this.gsD = com.tencent.mm.pluginsdk.a.cJ(FindMContactLearmMoreUI.this);
                        ab.d("MicroMsg.FindMContactLearmMoreUI", "tigerreg mobileList size " + (FindMContactLearmMoreUI.this.gsD == null ? 0 : FindMContactLearmMoreUI.this.gsD.size()));
                    } catch (Exception e) {
                        ab.printErrStackTrace("MicroMsg.FindMContactLearmMoreUI", e, BuildConfig.FLAVOR, new Object[0]);
                    }
                    AppMethodBeat.o(13627);
                    return true;
                }

                public final String toString() {
                    AppMethodBeat.i(13628);
                    String str = super.toString() + "|doUpload";
                    AppMethodBeat.o(13628);
                    return str;
                }
            });
            ((com.tencent.mm.plugin.account.a.a.a) g.M(com.tencent.mm.plugin.account.a.a.a.class)).syncUploadMContactStatus(true, false);
            ((com.tencent.mm.plugin.account.a.a.a) g.M(com.tencent.mm.plugin.account.a.a.a.class)).syncAddrBookAndUpload();
            AppMethodBeat.o(13636);
            return;
        }
        AppMethodBeat.o(13636);
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        AppMethodBeat.i(13637);
        if (i == 4 && keyEvent.getRepeatCount() == 0) {
            aoZ();
            AppMethodBeat.o(13637);
            return true;
        }
        boolean onKeyDown = super.onKeyDown(i, keyEvent);
        AppMethodBeat.o(13637);
        return onKeyDown;
    }

    private void aoZ() {
        AppMethodBeat.i(13638);
        aqX();
        Ni(1);
        AppMethodBeat.o(13638);
    }

    public final int getLayoutId() {
        return 2130969556;
    }

    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        AppMethodBeat.i(13639);
        if (iArr == null || iArr.length <= 0) {
            ab.i("MicroMsg.FindMContactLearmMoreUI", "onRequestPermissionsResult grantResults length 0. requestCode[%d], tid[%d]", new Object[]{Integer.valueOf(i), Long.valueOf(Thread.currentThread().getId())});
            AppMethodBeat.o(13639);
            return;
        }
        ab.i("MicroMsg.FindMContactLearmMoreUI", "onRequestPermissionsResult requestCode[%d],grantResults[%d] tid[%d]", new Object[]{Integer.valueOf(i), Integer.valueOf(iArr[0]), Long.valueOf(Thread.currentThread().getId())});
        switch (i) {
            case 48:
                if (iArr[0] != 0) {
                    h.a(this, getString(2131301922), getString(2131301936), getString(2131300878), getString(2131296868), false, new OnClickListener() {
                        public final void onClick(DialogInterface dialogInterface, int i) {
                            AppMethodBeat.i(13629);
                            dialogInterface.dismiss();
                            FindMContactLearmMoreUI.this.startActivity(new Intent("android.settings.MANAGE_APPLICATIONS_SETTINGS"));
                            AppMethodBeat.o(13629);
                        }
                    }, new OnClickListener() {
                        public final void onClick(DialogInterface dialogInterface, int i) {
                            AppMethodBeat.i(13630);
                            dialogInterface.dismiss();
                            AppMethodBeat.o(13630);
                        }
                    });
                    break;
                }
                api();
                AppMethodBeat.o(13639);
                return;
        }
        AppMethodBeat.o(13639);
    }
}
