package com.tencent.mm.plugin.appbrand.widget.desktop;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.appbrand.appusage.af;
import com.tencent.mm.plugin.appbrand.appusage.ag;
import com.tencent.mm.plugin.appbrand.widget.desktop.AppBrandDesktopDragView.b;
import com.tencent.mm.plugin.appbrand.widget.desktop.AppBrandDesktopView.c;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;

class AppBrandDesktopView$1 implements b {
    final /* synthetic */ AppBrandDesktopView iXS;

    AppBrandDesktopView$1(AppBrandDesktopView appBrandDesktopView) {
        this.iXS = appBrandDesktopView;
    }

    public final void bI(Object obj) {
        AppMethodBeat.i(133821);
        if (obj == null) {
            AppMethodBeat.o(133821);
            return;
        }
        if (obj instanceof c) {
            c cVar = (c) obj;
            if (cVar.iXW != null) {
                AppBrandDesktopView.a(this.iXS);
                ab.i("MicroMsg.AppBrandDesktopView", "alvinluo usage to collection reorderCollection result: %b", new Object[]{Boolean.valueOf(AppBrandDesktopView.b(this.iXS))});
                if (!(AppBrandDesktopView.c(this.iXS) == null || bo.isNullOrNil(cVar.iXW.appId))) {
                    AppBrandDesktopView.c(this.iXS).ET(cVar.iXW.appId);
                }
                AppBrandDesktopView.a(this.iXS, ((c) obj).position);
            }
        }
        AppMethodBeat.o(133821);
    }

    public final void bJ(Object obj) {
        AppMethodBeat.i(133822);
        if (obj == null) {
            AppMethodBeat.o(133822);
            return;
        }
        if (obj instanceof c) {
            c cVar = (c) obj;
            if (cVar.type == 1 && cVar.iXW != null) {
                AppBrandDesktopView.a(this.iXS);
                af afVar = (af) g.K(af.class);
                if (afVar == null) {
                    AppMethodBeat.o(133822);
                    return;
                }
                if (afVar.aD(cVar.iXW.username, cVar.iXW.har)) {
                    AppBrandDesktopView.a(this.iXS, ((c) obj).position);
                }
                if (!(AppBrandDesktopView.c(this.iXS) == null || bo.isNullOrNil(cVar.iXW.appId))) {
                    AppBrandDesktopView.c(this.iXS).ES(cVar.iXW.appId);
                }
            }
        }
        AppMethodBeat.o(133822);
    }

    public final void bK(Object obj) {
        AppMethodBeat.i(133823);
        if (obj == null) {
            AppMethodBeat.o(133823);
            return;
        }
        c cVar = (c) obj;
        if (cVar.iXW != null) {
            boolean aE;
            ab.d("MicroMsg.AppBrandDesktopView", "alvinluo AppBrandDesktopView removeUsage username: %s, versionType: %d", new Object[]{cVar.iXW.username, Integer.valueOf(cVar.iXW.har)});
            AppBrandDesktopView.a(this.iXS);
            ag agVar = (ag) g.K(ag.class);
            if (agVar != null) {
                aE = agVar.aE(cVar.iXW.username, cVar.iXW.har);
            } else {
                aE = false;
            }
            if (!(AppBrandDesktopView.c(this.iXS) == null || cVar.iXW == null || bo.isNullOrNil(cVar.iXW.appId))) {
                AppBrandDesktopView.c(this.iXS).ER(cVar.iXW.appId);
            }
            if (AppBrandDesktopView.d(this.iXS) != null) {
                if (aE) {
                    AppBrandDesktopView.b(this.iXS, cVar.position);
                    AppMethodBeat.o(133823);
                    return;
                }
                ab.e("MicroMsg.AppBrandDesktopView", "alvinluo removeUsage failed");
                cVar.type = 2;
                AppBrandDesktopView.e(this.iXS).add(cVar.position, cVar);
                AppBrandDesktopView.d(this.iXS).setDataList(AppBrandDesktopView.e(this.iXS));
                if (AppBrandDesktopView.f(this.iXS) != null) {
                    AppBrandDesktopView.f(this.iXS).getAdapter().cg(cVar.position);
                }
            }
        }
        AppMethodBeat.o(133823);
    }

    public final void e(int i, int i2, Object obj) {
        AppMethodBeat.i(133824);
        AppBrandDesktopView.a(this.iXS);
        ab.i("MicroMsg.AppBrandDesktopView", "alvinluo collection reorderCollection result: %b, startPos: %d, endPos: %d", new Object[]{Boolean.valueOf(AppBrandDesktopView.b(this.iXS)), Integer.valueOf(i), Integer.valueOf(i2)});
        if (!(!(obj instanceof c) || AppBrandDesktopView.c(this.iXS) == null || ((c) obj).iXW == null || bo.isNullOrNil(((c) obj).iXW.appId))) {
            com.tencent.mm.plugin.appbrand.widget.recentview.b c;
            if (i < i2) {
                c = AppBrandDesktopView.c(this.iXS);
                ab.v("MicroMsg.AppBrandRecentViewReporter", "alvinluo moveCollectionBackward id: %s", new Object[]{((c) obj).iXW.appId});
                c.jnc++;
                c.jnj.append(r1 + ":");
            } else if (i > i2) {
                c = AppBrandDesktopView.c(this.iXS);
                ab.v("MicroMsg.AppBrandRecentViewReporter", "alvinluo moveCollectionForward id: %s", new Object[]{((c) obj).iXW.appId});
                c.jnb++;
                c.jnh.append(r1 + ":");
            }
        }
        AppBrandDesktopView.a(this.iXS, AppBrandDesktopView.g(this.iXS));
        AppMethodBeat.o(133824);
    }
}
