package com.tencent.mm.plugin.appbrand.report.model;

import android.content.Intent;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.appbrand.o;
import com.tencent.mm.plugin.appbrand.page.aq;
import com.tencent.mm.plugin.appbrand.page.w;
import com.tencent.mm.plugin.report.service.h;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import java.util.LinkedList;

public final class b implements g {
    private final o gOq;
    private Intent iAH;
    private boolean iAI = false;
    k iAJ = null;
    private m iAK = null;
    p iAL = null;
    private volatile i iAM = null;
    private boolean irv = false;
    private final String mAppId;

    public b(o oVar) {
        AppMethodBeat.i(132582);
        this.mAppId = oVar.mAppId;
        this.gOq = oVar;
        resetSession();
        AppMethodBeat.o(132582);
    }

    public final i aHX() {
        return this.iAM;
    }

    public final void F(Intent intent) {
        this.iAH = intent;
    }

    public final Intent aHY() {
        return this.iAH;
    }

    public final void resetSession() {
        AppMethodBeat.i(132583);
        if (bo.isNullOrNil(this.mAppId)) {
            ab.e("MicroMsg.AppBrandPageContainerReporter", "resetSession with dummy model, stack %s", new Object[]{bo.l(new Throwable())});
            this.iAM = i.iBj;
            this.iAK = m.aLw();
            this.iAJ = k.aLv();
            this.iAL = p.aLy();
            AppMethodBeat.o(132583);
            return;
        }
        String xz = this.gOq.atI().xz();
        String d = a.d(this.gOq.atI().hgF);
        this.iAM = new d(d);
        this.iAJ = k.a(this.gOq, xz, this.iAM);
        LinkedList linkedList = new LinkedList();
        linkedList.push(bo.nullAsNil(d));
        this.iAL = p.a(this.gOq, xz, linkedList);
        this.iAK = m.b(this.gOq, xz, this.iAM);
        AppMethodBeat.o(132583);
    }

    public final p aHZ() {
        return this.iAL;
    }

    public final void aIa() {
        this.iAI = true;
    }

    public final void a(w wVar, w wVar2, aq aqVar) {
        w wVar3;
        AppMethodBeat.i(132584);
        if (aq.ivd == aqVar) {
            resetSession();
        }
        Object obj = (aq.ivd == aqVar || wVar2 == null || bo.isNullOrNil(wVar2.aBm()) || wVar2 == wVar) ? 1 : null;
        i iVar = this.iAM;
        if (obj != null) {
            wVar3 = null;
        } else {
            wVar3 = wVar2;
        }
        iVar.a(wVar, wVar3, aqVar);
        if (obj == null) {
            wVar2.ito.M(new 1(this, wVar, wVar2));
            AppMethodBeat.o(132584);
            return;
        }
        a(wVar, null);
        AppMethodBeat.o(132584);
    }

    /* Access modifiers changed, original: final */
    public final void a(w wVar, w wVar2) {
        AppMethodBeat.i(132585);
        if (wVar2 != null) {
            this.iAJ.n(wVar2);
            this.iAL.a(wVar2, wVar.aBm());
        }
        this.iAK.p(wVar);
        AppMethodBeat.o(132585);
    }

    public final void b(w wVar) {
        AppMethodBeat.i(132586);
        this.irv = true;
        this.iAM.b(wVar);
        wVar.ito.M(new 2(this, wVar));
        AppMethodBeat.o(132586);
    }

    public final void aHW() {
        AppMethodBeat.i(132587);
        h(0, 4);
        AppMethodBeat.o(132587);
    }

    public final void a(w wVar) {
        AppMethodBeat.i(132588);
        if (wVar == null || this.irv) {
            AppMethodBeat.o(132588);
            return;
        }
        b(wVar);
        AppMethodBeat.o(132588);
    }

    public final void c(w wVar) {
        AppMethodBeat.i(132589);
        this.iAH = null;
        if (this.iAI) {
            this.iAI = false;
            AppMethodBeat.o(132589);
            return;
        }
        this.iAM.c(wVar);
        this.iAK.p(wVar);
        AppMethodBeat.o(132589);
    }

    public final void a(long j, aq aqVar) {
        int i;
        AppMethodBeat.i(132590);
        switch (3.iAR[aqVar.ordinal()]) {
            case 1:
                i = 1;
                break;
            case 2:
            case 3:
            case 4:
                i = 3;
                break;
            default:
                i = 2;
                break;
        }
        h(j, i);
        h.pYm.a(390, 0, 1, false);
        switch (((int) j) / 250) {
            case 0:
                i = 1;
                break;
            case 1:
                i = 2;
                break;
            case 2:
                i = 3;
                break;
            case 3:
                i = 4;
                break;
            case 4:
            case 5:
                i = 5;
                break;
            case 6:
            case 7:
                i = 6;
                break;
            default:
                i = 7;
                break;
        }
        h.pYm.a(390, (long) i, 1, false);
        AppMethodBeat.o(132590);
    }

    private void h(long j, int i) {
        AppMethodBeat.i(132591);
        int i2 = this.gOq.atH().hhd.gVu;
        h.pYm.e(13543, new Object[]{this.mAppId, Integer.valueOf(i2), Long.valueOf(j), Integer.valueOf(i)});
        AppMethodBeat.o(132591);
    }
}
