package com.tencent.mm.plugin.appbrand.ui.collection;

import a.f;
import a.f.b.t;
import a.f.b.v;
import a.g;
import a.i.k;
import a.l;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.h.c.b;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.h;
import android.support.v7.widget.RecyclerView.i;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.appbrand.appusage.LocalUsageInfo;
import com.tencent.mm.plugin.appbrand.appusage.ab;
import com.tencent.mm.plugin.appbrand.appusage.af;
import com.tencent.mm.plugin.appbrand.appusage.s;
import com.tencent.mm.plugin.appbrand.report.c;
import com.tencent.mm.plugin.appbrand.ui.AppBrandLauncherUI.Fragment;
import com.tencent.mm.plugin.appbrand.ui.collection.m.a;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.mm.sdk.platformtools.bp;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.q;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@l(dWo = {1, 1, 13}, dWp = {"\u0000n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0010\u000e\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\u0018\u00002\u00020\u00012\u00020\u0002B\u0005¢\u0006\u0002\u0010\u0003J\b\u0010\u001b\u001a\u00020\u0011H\u0016J\b\u0010\u001c\u001a\u00020\u001dH\u0002J\b\u0010\u001e\u001a\u00020\u001dH\u0016J\u0012\u0010\u001f\u001a\u00020\u001d2\b\u0010 \u001a\u0004\u0018\u00010!H\u0016J\b\u0010\"\u001a\u00020\u001dH\u0016J\b\u0010#\u001a\u00020\u001dH\u0016J\b\u0010$\u001a\u00020\u001dH\u0016J\b\u0010%\u001a\u00020\u001dH\u0016J\u001a\u0010&\u001a\u00020\u001d2\u0006\u0010'\u001a\u00020(2\b\u0010 \u001a\u0004\u0018\u00010!H\u0016J\u000e\u0010)\u001a\b\u0012\u0004\u0012\u00020+0*H\u0002J\"\u0010,\u001a\u00020\u001d2\u0006\u0010-\u001a\u00020\t2\u0010\b\u0002\u0010.\u001a\n\u0012\u0006\u0012\u0004\u0018\u0001000/H\u0002J\b\u00101\u001a\u00020\u001dH\u0002J\b\u00102\u001a\u00020\u001dH\u0002J\b\u00103\u001a\u00020\u001dH\u0002J\b\u00104\u001a\u00020\u001dH\u0002R\u000e\u0010\u0004\u001a\u00020\u0005X\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\n\u001a\u0004\u0018\u00010\u000bX\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\f\u001a\u0004\u0018\u00010\rX\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\tX\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u0005X\u0004¢\u0006\u0002\n\u0000R\u001b\u0010\u0010\u001a\u00020\u00118BX\u0002¢\u0006\f\n\u0004\b\u0014\u0010\u0015\u001a\u0004\b\u0012\u0010\u0013R\u001b\u0010\u0016\u001a\u00020\u00178BX\u0002¢\u0006\f\n\u0004\b\u001a\u0010\u0015\u001a\u0004\b\u0018\u0010\u0019¨\u00065"}, dWq = {"Lcom/tencent/mm/plugin/appbrand/ui/collection/AppBrandCollectionDisplayVerticalList;", "Lcom/tencent/mm/plugin/appbrand/ui/AppBrandLauncherUI$Fragment;", "Lcom/tencent/mm/plugin/appbrand/ui/collection/CollectionVerticalListViewHolder$IEnterWxaListener;", "()V", "mCollectionStorageListener", "Lcom/tencent/mm/sdk/storage/MStorage$IOnStorageChange;", "mDataProcessThread", "Lcom/tencent/mm/sdk/platformtools/MMHandlerThread;", "mHadEnterWxa", "", "mList", "Landroid/support/v7/widget/RecyclerView;", "mListAdapter", "Lcom/tencent/mm/plugin/appbrand/ui/collection/CollectionVerticalListAdapter;", "mRefreshOnResume", "mWxaAttrsStorageListener", "sceneFor13801", "", "getSceneFor13801", "()I", "sceneFor13801$delegate", "Lkotlin/Lazy;", "sceneIdFor13801", "", "getSceneIdFor13801", "()Ljava/lang/String;", "sceneIdFor13801$delegate", "getLayoutId", "hideLoading", "", "initView", "onActivityCreated", "savedInstanceState", "Landroid/os/Bundle;", "onDestroyView", "onEnter", "onResume", "onTitleDoubleTap", "onViewCreated", "view", "Landroid/view/View;", "queryDataList", "", "Lcom/tencent/mm/plugin/appbrand/appusage/LocalUsageInfo;", "refreshDataList", "replace", "lazyCallback", "Lkotlin/Function0;", "Ljava/lang/Runnable;", "removeStorageListeners", "setupStorageListeners", "showLoading", "updateDataListUsingDiffs", "plugin-appbrand-integration_release"})
public final class AppBrandCollectionDisplayVerticalList extends Fragment implements a {
    static final /* synthetic */ k[] eQB = new k[]{(k) v.a(new t(v.aN(AppBrandCollectionDisplayVerticalList.class), "sceneFor13801", "getSceneFor13801()I")), (k) v.a(new t(v.aN(AppBrandCollectionDisplayVerticalList.class), "sceneIdFor13801", "getSceneIdFor13801()Ljava/lang/String;"))};
    private RecyclerView iKX;
    private k iKY;
    private boolean iKZ;
    private al iLa;
    private boolean iLb;
    private final f iLc = g.g((a.f.a.a) new h(this));
    private final f iLd = g.g((a.f.a.a) new i(this));
    private final com.tencent.mm.sdk.e.k.a iLe = ((com.tencent.mm.sdk.e.k.a) new b(this));
    private final com.tencent.mm.sdk.e.k.a iLf = ((com.tencent.mm.sdk.e.k.a) new c(this));

    @l(dWo = {1, 1, 13}, dWp = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0000\u001a\u00020\u0001H\n¢\u0006\u0002\b\u0002¨\u0006\u0003"}, dWq = {"<anonymous>", "", "run", "com/tencent/mm/plugin/appbrand/ui/collection/AppBrandCollectionDisplayVerticalList$updateDataListUsingDiffs$2$1"})
    static final class j implements Runnable {
        final /* synthetic */ List gYO;
        final /* synthetic */ AppBrandCollectionDisplayVerticalList iLg;
        final /* synthetic */ b iLn;

        j(b bVar, AppBrandCollectionDisplayVerticalList appBrandCollectionDisplayVerticalList, List list) {
            this.iLn = bVar;
            this.iLg = appBrandCollectionDisplayVerticalList;
            this.gYO = list;
        }

        public final void run() {
            AppMethodBeat.i(135018);
            k b = this.iLg.iKY;
            if (b != null) {
                b.aO(this.gYO);
                this.iLn.a((RecyclerView.a) b);
                AppMethodBeat.o(135018);
                return;
            }
            AppMethodBeat.o(135018);
        }
    }

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

    public AppBrandCollectionDisplayVerticalList() {
        AppMethodBeat.i(135030);
        AppMethodBeat.o(135030);
    }

    public static final /* synthetic */ List aMW() {
        AppMethodBeat.i(135031);
        List aMU = aMU();
        AppMethodBeat.o(135031);
        return aMU;
    }

    public static final /* synthetic */ void aMX() {
    }

    public final int getLayoutId() {
        return -1;
    }

    private static List<LocalUsageInfo> aMU() {
        AppMethodBeat.i(135021);
        List a = ((af) com.tencent.mm.kernel.g.K(af.class)).a(Integer.MAX_VALUE, af.a.DESC);
        if (a == null) {
            a = (List) a.a.v.AUP;
        }
        Collection arrayList = new ArrayList();
        for (Object next : a) {
            if ((((LocalUsageInfo) next) != null ? 1 : null) != null) {
                arrayList.add(next);
            }
        }
        List list = (List) arrayList;
        AppMethodBeat.o(135021);
        return list;
    }

    static /* synthetic */ void a(AppBrandCollectionDisplayVerticalList appBrandCollectionDisplayVerticalList) {
        AppMethodBeat.i(135023);
        appBrandCollectionDisplayVerticalList.a(true, (a.f.a.a) f.iLi);
        AppMethodBeat.o(135023);
    }

    private final void a(boolean z, a.f.a.a<? extends Runnable> aVar) {
        AppMethodBeat.i(135022);
        Runnable runnable = (Runnable) new g(this, z, aVar);
        al alVar = this.iLa;
        if (alVar == null) {
            a.f.b.j.dWJ();
        }
        if (alVar.doO()) {
            runnable.run();
            AppMethodBeat.o(135022);
            return;
        }
        alVar = this.iLa;
        if (alVar == null) {
            a.f.b.j.dWJ();
        }
        alVar.aa(runnable);
        AppMethodBeat.o(135022);
    }

    public final void onActivityCreated(Bundle bundle) {
        AppMethodBeat.i(135024);
        super.onActivityCreated(bundle);
        FragmentActivity activity = getActivity();
        if (!(activity instanceof MMActivity)) {
            activity = null;
        }
        MMActivity mMActivity = (MMActivity) activity;
        if (mMActivity != null) {
            mMActivity.a(0, getString(2131296849), (OnMenuItemClickListener) new d(this), q.b.ymw);
            AppMethodBeat.o(135024);
            return;
        }
        AppMethodBeat.o(135024);
    }

    public final void onResume() {
        AppMethodBeat.i(135025);
        super.onResume();
        if (this.iKZ) {
            a(this);
            this.iKZ = false;
        }
        if (this.iLb) {
            c.pG(2);
            this.iLb = false;
        }
        AppMethodBeat.o(135025);
    }

    public final void onViewCreated(View view, Bundle bundle) {
        AppMethodBeat.i(135026);
        a.f.b.j.p(view, "view");
        super.onViewCreated(view, bundle);
        this.iLa = new al("AppBrandLauncherCollectionList");
        a(false, (a.f.a.a) new e(this));
        AppMethodBeat.o(135026);
    }

    public final void initView() {
        AppMethodBeat.i(135027);
        RecyclerView recyclerView = new RecyclerView((Context) getActivity());
        getActivity();
        recyclerView.setLayoutManager((i) new a(this));
        k kVar = new k(new ArrayList(), (a) this);
        this.iKY = kVar;
        recyclerView.setAdapter((RecyclerView.a) kVar);
        recyclerView.setBackgroundColor(-1);
        recyclerView.b((h) new l());
        recyclerView.setItemAnimator(null);
        this.iKX = recyclerView;
        View contentView = getContentView();
        if (contentView == null) {
            a.v vVar = new a.v("null cannot be cast to non-null type android.widget.FrameLayout");
            AppMethodBeat.o(135027);
            throw vVar;
        }
        FrameLayout frameLayout = (FrameLayout) contentView;
        RecyclerView recyclerView2 = this.iKX;
        if (recyclerView2 == null) {
            a.f.b.j.dWJ();
        }
        frameLayout.addView((View) recyclerView2, new LayoutParams(-1, -2));
        AppMethodBeat.o(135027);
    }

    public final void aMf() {
        AppMethodBeat.i(135028);
        RecyclerView recyclerView = this.iKX;
        if (recyclerView != null) {
            recyclerView.smoothScrollToPosition(0);
            AppMethodBeat.o(135028);
            return;
        }
        AppMethodBeat.o(135028);
    }

    public final void onDestroyView() {
        AppMethodBeat.i(135029);
        super.onDestroyView();
        ((s) com.tencent.mm.plugin.appbrand.app.f.E(s.class)).d(this.iLe);
        com.tencent.mm.plugin.appbrand.app.f.auO().d(this.iLf);
        al alVar = this.iLa;
        if (alVar != null) {
            alVar.quit();
            AppMethodBeat.o(135029);
            return;
        }
        AppMethodBeat.o(135029);
    }

    public final void aMV() {
        this.iLb = true;
    }

    public static final /* synthetic */ int c(AppBrandCollectionDisplayVerticalList appBrandCollectionDisplayVerticalList) {
        AppMethodBeat.i(135032);
        int intValue = ((Number) appBrandCollectionDisplayVerticalList.iLc.getValue()).intValue();
        AppMethodBeat.o(135032);
        return intValue;
    }

    public static final /* synthetic */ String d(AppBrandCollectionDisplayVerticalList appBrandCollectionDisplayVerticalList) {
        AppMethodBeat.i(135033);
        String str = (String) appBrandCollectionDisplayVerticalList.iLd.getValue();
        AppMethodBeat.o(135033);
        return str;
    }

    public static final /* synthetic */ void f(AppBrandCollectionDisplayVerticalList appBrandCollectionDisplayVerticalList) {
        AppMethodBeat.i(135034);
        s sVar = (s) com.tencent.mm.plugin.appbrand.app.f.E(s.class);
        com.tencent.mm.sdk.e.k.a aVar = appBrandCollectionDisplayVerticalList.iLe;
        al alVar = appBrandCollectionDisplayVerticalList.iLa;
        if (alVar == null) {
            a.f.b.j.dWJ();
        }
        sVar.a(aVar, alVar.getLooper());
        com.tencent.mm.plugin.appbrand.config.q auO = com.tencent.mm.plugin.appbrand.app.f.auO();
        aVar = appBrandCollectionDisplayVerticalList.iLf;
        alVar = appBrandCollectionDisplayVerticalList.iLa;
        if (alVar == null) {
            a.f.b.j.dWJ();
        }
        auO.a(aVar, alVar.getLooper());
        AppMethodBeat.o(135034);
    }

    public static final /* synthetic */ void g(AppBrandCollectionDisplayVerticalList appBrandCollectionDisplayVerticalList) {
        AppMethodBeat.i(135035);
        if (appBrandCollectionDisplayVerticalList.iKY != null) {
            k kVar = appBrandCollectionDisplayVerticalList.iKY;
            if (kVar == null) {
                a.f.b.j.dWJ();
            }
            ArrayList aNd = kVar.aNd();
            List aMU = aMU();
            if (aMU.isEmpty()) {
                appBrandCollectionDisplayVerticalList.runOnUiThread((Runnable) new k(appBrandCollectionDisplayVerticalList));
                AppMethodBeat.o(135035);
                return;
            }
            try {
                appBrandCollectionDisplayVerticalList.runOnUiThread(new j(android.support.v7.h.c.a((android.support.v7.h.c.a) new ab(aNd, aMU), true), appBrandCollectionDisplayVerticalList, aMU));
                AppMethodBeat.o(135035);
                return;
            } catch (NullPointerException e) {
                com.tencent.mm.sdk.platformtools.ab.printErrStackTrace("MicroMsg.AppBrandCollectionDisplayVerticalList", e, "calculateDiff, oldList.size=" + aNd.size() + ", newList.size=" + aMU.size(), new Object[0]);
                if (bp.dpL()) {
                    Throwable th = e;
                    AppMethodBeat.o(135035);
                    throw th;
                }
            }
        }
        AppMethodBeat.o(135035);
    }
}
