package com.tencent.mm.plugin.story.f;

import a.f.b.j;
import a.l;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ai.f;
import com.tencent.mm.ai.m;
import com.tencent.mm.ai.p;
import com.tencent.mm.kernel.b;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.story.d.a.c;
import com.tencent.mm.plugin.story.d.a.d;
import com.tencent.mm.plugin.story.g.h;
import com.tencent.mm.plugin.story.h.k;
import com.tencent.mm.plugin.story.model.n;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.ytcommon.BuildConfig;

@l(dWo = {1, 1, 13}, dWp = {"\u0000J\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\t\n\u0002\u0010\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\u0018\u00002\u00020\u00012\u00020\u0002B\r\u0012\u0006\u0010\u0003\u001a\u00020\u0004¢\u0006\u0002\u0010\u0005J \u0010\u0013\u001a\u00020\u000e2\u0006\u0010\u0014\u001a\u00020\t2\u0006\u0010\u0015\u001a\u00020\t2\u0006\u0010\u0016\u001a\u00020\u000bH\u0002J\b\u0010\u0017\u001a\u00020\u0018H\u0016J\b\u0010\u0019\u001a\u00020\u0018H\u0016J\b\u0010\u001a\u001a\u00020\u0018H\u0016J\u0010\u0010\u001b\u001a\u00020\u00182\u0006\u0010\u001c\u001a\u00020\u0007H\u0016J\b\u0010\u001d\u001a\u00020\u0018H\u0016J\b\u0010\u001e\u001a\u00020\u0018H\u0002J\b\u0010\u001f\u001a\u00020\u0018H\u0002J,\u0010 \u001a\u00020\u00182\u0006\u0010\u0014\u001a\u00020\t2\u0006\u0010\u0015\u001a\u00020\t2\b\u0010!\u001a\u0004\u0018\u00010\u00072\b\u0010\"\u001a\u0004\u0018\u00010#H\u0016J\"\u0010$\u001a\u00020\u00182\u0006\u0010%\u001a\u00020&2\u0006\u0010'\u001a\u00020\u000e2\b\u0010(\u001a\u0004\u0018\u00010&H\u0016J\u0010\u0010)\u001a\u00020\u00182\u0006\u0010*\u001a\u00020\u000bH\u0002R\u000e\u0010\u0006\u001a\u00020\u0007XD¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\u000bX\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u000eX\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u0007X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u000bX\u000e¢\u0006\u0002\n\u0000R\u0011\u0010\u0003\u001a\u00020\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0011\u0010\u0012¨\u0006+"}, dWq = {"Lcom/tencent/mm/plugin/story/presenter/AlbumFavPresenter;", "Lcom/tencent/mm/plugin/story/contract/AlbumContract$IFavSelectPresenter;", "Lcom/tencent/mm/modelbase/IOnSceneEnd;", "view", "Lcom/tencent/mm/plugin/story/contract/AlbumContract$IFavSelectView;", "(Lcom/tencent/mm/plugin/story/contract/AlbumContract$IFavSelectView;)V", "TAG", "", "loadNpCount", "", "localCachedMinId", "", "localMinId", "mIsAll", "", "mUsername", "respMaxId", "getView", "()Lcom/tencent/mm/plugin/story/contract/AlbumContract$IFavSelectView;", "isAll", "errType", "errCode", "limitId", "loadDBData", "", "loadFpData", "loadNpData", "onCreate", "userName", "onDestory", "onHandleFp", "onHandleNp", "onSceneEnd", "errMsg", "scene", "Lcom/tencent/mm/modelbase/NetSceneBase;", "setFavorite", "storyInfo", "Lcom/tencent/mm/plugin/story/storage/StoryInfo;", "favorite", "replaced", "updateLocalMinId", "lastId", "plugin-story_release"})
public final class a implements f, c {
    final String TAG = "MicroMsg.AlbumFavPresenter";
    private String igi = BuildConfig.FLAVOR;
    private boolean rFn;
    private long rXZ;
    long rYa;
    long rYb;
    int rYc;
    final d rYd;

    public a(d dVar) {
        j.p(dVar, "view");
        AppMethodBeat.i(109497);
        this.rYd = dVar;
        AppMethodBeat.o(109497);
    }

    /* Access modifiers changed, original: final */
    public final void le(long j) {
        AppMethodBeat.i(109489);
        com.tencent.mm.plugin.story.model.j.a aVar = com.tencent.mm.plugin.story.model.j.rST;
        k cxT = com.tencent.mm.plugin.story.model.j.a.cxT();
        aVar = com.tencent.mm.plugin.story.model.j.rST;
        com.tencent.mm.plugin.story.model.j.a.cyd();
        j.p(this.igi, "userName");
        com.tencent.mm.plugin.story.h.a.a aVar2 = com.tencent.mm.plugin.story.h.a.sdm;
        int cAR = com.tencent.mm.plugin.story.h.a.cAR();
        String str = this.igi;
        String str2 = this.igi;
        com.tencent.mm.plugin.story.model.j.a aVar3 = com.tencent.mm.plugin.story.model.j.rST;
        this.rYb = cxT.b(j, cAR, str, bo.isEqual(str2, com.tencent.mm.plugin.story.model.j.a.cnk()));
        if (this.rXZ != 0) {
            this.rYb = this.rYb < this.rXZ ? this.rYb : this.rXZ;
        }
        ab.d(this.TAG, "localMinId=" + this.rYb + ", respMaxId=" + this.rXZ);
        AppMethodBeat.o(109489);
    }

    public final void onCreate(String str) {
        AppMethodBeat.i(109490);
        j.p(str, "userName");
        this.igi = str;
        le(this.rYa);
        b RO = g.RO();
        j.o(RO, "MMKernel.network()");
        RO.Rg().a(273, (f) this);
        AppMethodBeat.o(109490);
    }

    public final void bMO() {
        AppMethodBeat.i(109491);
        b RO = g.RO();
        j.o(RO, "MMKernel.network()");
        RO.Rg().b(273, (f) this);
        AppMethodBeat.o(109491);
    }

    public final void cxo() {
        AppMethodBeat.i(109492);
        com.tencent.mm.plugin.story.model.j.a aVar = com.tencent.mm.plugin.story.model.j.rST;
        com.tencent.mm.plugin.story.model.j.a.cno().post((Runnable) new a(this));
        AppMethodBeat.o(109492);
    }

    public final void cxk() {
        AppMethodBeat.i(109493);
        this.rYc--;
        ab.i(this.TAG, "loadNpData username=" + this.igi + " maxId=" + this.rXZ);
        if (!this.rFn) {
            b RO = g.RO();
            j.o(RO, "MMKernel.network()");
            p Rg = RO.Rg();
            String str = this.igi;
            long j = this.rXZ;
            String str2 = this.igi;
            com.tencent.mm.plugin.story.model.j.a aVar = com.tencent.mm.plugin.story.model.j.rST;
            boolean isEqual = bo.isEqual(str2, com.tencent.mm.plugin.story.model.j.a.cnk());
            String str3 = BuildConfig.FLAVOR;
            com.tencent.mm.plugin.story.h.a.a aVar2 = com.tencent.mm.plugin.story.h.a.sdm;
            Rg.d((m) new com.tencent.mm.plugin.story.model.a.j(str, j, isEqual, str3, com.tencent.mm.plugin.story.h.a.cBr()));
        }
        AppMethodBeat.o(109493);
    }

    public final void cxl() {
        AppMethodBeat.i(109494);
        ab.i(this.TAG, "loadFpData username=" + this.igi + " maxId=" + this.rXZ);
        b RO = g.RO();
        j.o(RO, "MMKernel.network()");
        p Rg = RO.Rg();
        String str = this.igi;
        String str2 = this.igi;
        com.tencent.mm.plugin.story.model.j.a aVar = com.tencent.mm.plugin.story.model.j.rST;
        boolean isEqual = bo.isEqual(str2, com.tencent.mm.plugin.story.model.j.a.cnk());
        String str3 = BuildConfig.FLAVOR;
        com.tencent.mm.plugin.story.h.a.a aVar2 = com.tencent.mm.plugin.story.h.a.sdm;
        Rg.d((m) new com.tencent.mm.plugin.story.model.a.j(str, 0, isEqual, str3, com.tencent.mm.plugin.story.h.a.cBr()));
        AppMethodBeat.o(109494);
    }

    /* JADX WARNING: Removed duplicated region for block: B:21:0x00c6  */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x013c  */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x00d8  */
    public final void onSceneEnd(int r11, int r12, java.lang.String r13, com.tencent.mm.ai.m r14) {
        /*
        r10 = this;
        r8 = 0;
        r7 = 109495; // 0x1abb7 float:1.53435E-40 double:5.40977E-319;
        r6 = 32;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r7);
        r0 = r10.TAG;
        r1 = new java.lang.StringBuilder;
        r2 = "LogStory: ";
        r1.<init>(r2);
        r1 = r1.append(r11);
        r1 = r1.append(r6);
        r1 = r1.append(r12);
        r1 = r1.append(r6);
        r1 = r1.append(r13);
        r1 = r1.append(r6);
        r1 = r1.append(r14);
        r1 = r1.toString();
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1);
        r0 = r14 instanceof com.tencent.mm.plugin.story.model.a.j;
        if (r0 == 0) goto L_0x0136;
    L_0x003b:
        r0 = r14;
        r0 = (com.tencent.mm.plugin.story.model.a.j) r0;
        r0 = r0.userName;
        r1 = r10.igi;
        r0 = com.tencent.mm.sdk.platformtools.bo.isEqual(r0, r1);
        if (r0 == 0) goto L_0x0136;
    L_0x0048:
        r0 = r14;
        r0 = (com.tencent.mm.plugin.story.model.a.j) r0;
        r0 = r0.cvd;
        r1 = com.tencent.mm.plugin.story.h.a.sdm;
        r1 = com.tencent.mm.plugin.story.h.a.cBr();
        if (r0 != r1) goto L_0x0136;
    L_0x0055:
        r1 = r10.TAG;
        r0 = new java.lang.StringBuilder;
        r2 = "onSceneEnd username=";
        r0.<init>(r2);
        r2 = r10.igi;
        r0 = r0.append(r2);
        r2 = " respMaxId=";
        r0 = r0.append(r2);
        r2 = r10.rXZ;
        r0 = r0.append(r2);
        r0 = r0.append(r6);
        r0 = r0.append(r11);
        r0 = r0.append(r6);
        r0 = r0.append(r12);
        r2 = r0.append(r6);
        r0 = r14;
        r0 = (com.tencent.mm.plugin.story.model.a.j) r0;
        r4 = r0.qKi;
        r0 = r2.append(r4);
        r0 = r0.toString();
        com.tencent.mm.sdk.platformtools.ab.d(r1, r0);
        r0 = r14;
        r0 = (com.tencent.mm.plugin.story.model.a.j) r0;
        r0 = r0.qKi;
        r2 = com.tencent.mm.plugin.story.h.a.sdm;
        r2 = com.tencent.mm.plugin.story.h.a.cAW();
        if (r12 == r2) goto L_0x00bf;
    L_0x00a3:
        r2 = com.tencent.mm.plugin.story.h.a.sdm;
        r2 = com.tencent.mm.plugin.story.h.a.cAX();
        if (r12 == r2) goto L_0x00bf;
    L_0x00ab:
        if (r11 != 0) goto L_0x00b3;
    L_0x00ad:
        if (r12 != 0) goto L_0x00b3;
    L_0x00af:
        r2 = (r0 > r8 ? 1 : (r0 == r8 ? 0 : -1));
        if (r2 == 0) goto L_0x00bf;
    L_0x00b3:
        r2 = com.tencent.mm.plugin.story.h.a.sdm;
        r2 = com.tencent.mm.plugin.story.h.a.cAV();
        if (r12 != r2) goto L_0x013a;
    L_0x00bb:
        r0 = (r0 > r8 ? 1 : (r0 == r8 ? 0 : -1));
        if (r0 != 0) goto L_0x013a;
    L_0x00bf:
        r0 = 1;
    L_0x00c0:
        r10.rFn = r0;
        r0 = r10.rFn;
        if (r0 == 0) goto L_0x00cb;
    L_0x00c6:
        r0 = r10.rYd;
        r0.cxn();
    L_0x00cb:
        r0 = r14;
        r0 = (com.tencent.mm.plugin.story.model.a.j) r0;
        r0 = r0.qKi;
        r10.rXZ = r0;
        r14 = (com.tencent.mm.plugin.story.model.a.j) r14;
        r0 = r14.qIW;
        if (r0 == 0) goto L_0x013c;
    L_0x00d8:
        r0 = com.tencent.mm.plugin.story.model.j.rST;
        r1 = com.tencent.mm.plugin.story.model.j.a.cno();
        r0 = new com.tencent.mm.plugin.story.f.a$b;
        r0.<init>(r10);
        r0 = (java.lang.Runnable) r0;
        r1.post(r0);
    L_0x00e8:
        r0 = r10.TAG;
        r1 = new java.lang.StringBuilder;
        r2 = "onSceneEnd username=";
        r1.<init>(r2);
        r2 = r10.igi;
        r1 = r1.append(r2);
        r2 = " respMaxId=";
        r1 = r1.append(r2);
        r2 = r10.rXZ;
        r1 = r1.append(r2);
        r1 = r1.append(r6);
        r1 = r1.append(r11);
        r1 = r1.append(r6);
        r1 = r1.append(r12);
        r2 = " isAll:";
        r1 = r1.append(r2);
        r2 = r10.rFn;
        r1 = r1.append(r2);
        r2 = " limitId:";
        r1 = r1.append(r2);
        r2 = r10.rXZ;
        r1 = r1.append(r2);
        r1 = r1.toString();
        com.tencent.mm.sdk.platformtools.ab.d(r0, r1);
    L_0x0136:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
        return;
    L_0x013a:
        r0 = 0;
        goto L_0x00c0;
    L_0x013c:
        r0 = com.tencent.mm.plugin.story.model.j.rST;
        r1 = com.tencent.mm.plugin.story.model.j.a.cno();
        r0 = new com.tencent.mm.plugin.story.f.a$c;
        r0.<init>(r10);
        r0 = (java.lang.Runnable) r0;
        r1.post(r0);
        goto L_0x00e8;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.story.f.a.onSceneEnd(int, int, java.lang.String, com.tencent.mm.ai.m):void");
    }

    public final void a(com.tencent.mm.plugin.story.h.j jVar) {
        AppMethodBeat.i(138798);
        j.p(jVar, "storyInfo");
        ab.i(this.TAG, "LogStory: setFavorite storyId:" + jVar.field_storyID + " localid:" + ((int) jVar.xDa) + " targetFavorite:true replacedStory:" + null);
        com.tencent.mm.plugin.story.model.n.a aVar = n.rTi;
        com.tencent.mm.plugin.story.model.n.a.h(jVar.field_storyID, (int) jVar.xDa, true);
        h hVar = h.scu;
        h.a(1, String.valueOf(jVar.field_storyID), 0, 0, 1);
        AppMethodBeat.o(138798);
    }
}
