package com.tencent.mm.plugin.story.ui.sns;

import a.f.a.m;
import a.l;
import a.v;
import a.y;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.i;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.e;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.story.h.f;
import com.tencent.mm.plugin.story.model.j;
import com.tencent.mm.sdk.e.k.a;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.storage.ac;
import com.tencent.mm.ui.MMActivity;
import com.tencent.ytcommon.BuildConfig;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

@l(dWo = {1, 1, 13}, dWp = {"\u0000T\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010!\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010 \n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\u0018\u0000 !2\u00020\u00012\u00020\u0002:\u0003!\"#B\u0005¢\u0006\u0002\u0010\u0003J\b\u0010\u0016\u001a\u00020\u0017H\u0016J\b\u0010\u0018\u001a\u00020\u0005H\u0014J\u0012\u0010\u0019\u001a\u00020\u00172\b\u0010\u001a\u001a\u0004\u0018\u00010\u001bH\u0016J\b\u0010\u001c\u001a\u00020\u0017H\u0014J\u001c\u0010\u001d\u001a\u00020\u00172\b\u0010\u001e\u001a\u0004\u0018\u00010\u00102\b\u0010\u001f\u001a\u0004\u0018\u00010 H\u0016R\u0014\u0010\u0004\u001a\u00020\u0005XD¢\u0006\b\n\u0000\u001a\u0004\b\u0006\u0010\u0007R\u0014\u0010\b\u001a\u00020\u0005XD¢\u0006\b\n\u0000\u001a\u0004\b\t\u0010\u0007R\u0012\u0010\n\u001a\u00060\u000bR\u00020\u0000X.¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\rX.¢\u0006\u0002\n\u0000R2\u0010\u000e\u001a&\u0012\f\u0012\n \u0011*\u0004\u0018\u00010\u00100\u0010 \u0011*\u0012\u0012\f\u0012\n \u0011*\u0004\u0018\u00010\u00100\u0010\u0018\u00010\u00120\u000fX\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0013\u001a\u00020\u0005X\u000e¢\u0006\u0002\n\u0000R2\u0010\u0014\u001a&\u0012\f\u0012\n \u0011*\u0004\u0018\u00010\u00150\u0015 \u0011*\u0012\u0012\f\u0012\n \u0011*\u0004\u0018\u00010\u00150\u0015\u0018\u00010\u00120\u000fX\u000e¢\u0006\u0002\n\u0000¨\u0006$"}, dWq = {"Lcom/tencent/mm/plugin/story/ui/sns/StoryEntranceUI;", "Lcom/tencent/mm/ui/MMActivity;", "Lcom/tencent/mm/sdk/storage/MStorage$IOnStorageChange;", "()V", "TYPE_TIP", "", "getTYPE_TIP", "()I", "TYPE_USERNAME", "getTYPE_USERNAME", "entranceAdapter", "Lcom/tencent/mm/plugin/story/ui/sns/StoryEntranceUI$EntranceAdapter;", "entranceRecycler", "Landroid/support/v7/widget/RecyclerView;", "readNameList", "", "", "kotlin.jvm.PlatformType", "", "storyTypeIndex", "userNameList", "Lcom/tencent/mm/plugin/story/ui/sns/StoryEntranceUI$DataObject;", "finish", "", "getLayoutId", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onNotifyChange", "event", "eventData", "Lcom/tencent/mm/sdk/storage/MStorageEventData;", "Companion", "DataObject", "EntranceAdapter", "plugin-story_release"})
public final class StoryEntranceUI extends MMActivity implements a {
    private static final String TAG = TAG;
    public static final a shv = new a((byte) 0);
    private final int sho = 1;
    private final int shp = 2;
    private RecyclerView shq;
    private c shr;
    private int shs = -1;
    private List<b> sht = Collections.synchronizedList(new LinkedList());
    private List<String> shu = Collections.synchronizedList(new LinkedList());

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

    public StoryEntranceUI() {
        AppMethodBeat.i(110264);
        AppMethodBeat.o(110264);
    }

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

    public final void onCreate(Bundle bundle) {
        y yVar;
        AppMethodBeat.i(110260);
        ab.i(TAG, "StoryEntranceUI create ".concat(String.valueOf(this)));
        supportRequestWindowFeature(1);
        getWindow().addFlags(1024);
        super.onCreate(bundle);
        j.a aVar = j.rST;
        j.a.cxU().c((a) this);
        setMMTitle(2131303779);
        setBackBtn((OnMenuItemClickListener) new d(this), 2131230735);
        View findViewById = findViewById(2131828147);
        a.f.b.j.o(findViewById, "findViewById(R.id.story_entrance_recycler)");
        this.shq = (RecyclerView) findViewById;
        RecyclerView recyclerView = this.shq;
        if (recyclerView == null) {
            a.f.b.j.avw("entranceRecycler");
        }
        recyclerView.setLayoutManager((i) new LinearLayoutManager());
        this.shr = new c(this);
        RecyclerView recyclerView2 = this.shq;
        if (recyclerView2 == null) {
            a.f.b.j.avw("entranceRecycler");
        }
        recyclerView2.setItemViewCacheSize(0);
        recyclerView = this.shq;
        if (recyclerView == null) {
            a.f.b.j.avw("entranceRecycler");
        }
        c cVar = this.shr;
        if (cVar == null) {
            a.f.b.j.avw("entranceAdapter");
        }
        recyclerView.setAdapter((RecyclerView.a) cVar);
        c cVar2 = this.shr;
        if (cVar2 == null) {
            a.f.b.j.avw("entranceAdapter");
        }
        cVar2.seN = (m) new e(this);
        List cwY = com.tencent.mm.plugin.story.model.f.a.rWL.cwY();
        List cwZ = com.tencent.mm.plugin.story.model.f.a.rWL.cwZ();
        ab.i(TAG, "userNames " + cwY.size() + " lastUserNames " + cwZ.size());
        Iterable<String> iterable = cwY;
        synchronized (iterable) {
            try {
                for (String bVar : iterable) {
                    this.sht.add(new b(bVar, 1));
                }
                yVar = y.AUy;
            } catch (Throwable th) {
                AppMethodBeat.o(110260);
            }
        }
        this.shs = this.sht.size();
        if (cwZ.size() > 0) {
            this.sht.add(new b(BuildConfig.FLAVOR, 2));
        }
        iterable = cwZ;
        synchronized (iterable) {
            try {
                for (String bVar2 : iterable) {
                    this.sht.add(new b(bVar2, 1));
                }
                yVar = y.AUy;
            } catch (Throwable th2) {
                AppMethodBeat.o(110260);
            }
        }
        cVar2 = this.shr;
        if (cVar2 == null) {
            a.f.b.j.avw("entranceAdapter");
        }
        cwY = this.sht;
        a.f.b.j.o(cwY, "userNameList");
        a.f.b.j.p(cwY, "extinfoList");
        cVar2.shw.clear();
        cVar2.shw.addAll(cwY);
        cVar2.notifyDataSetChanged();
        AppMethodBeat.o(110260);
    }

    public final void onDestroy() {
        AppMethodBeat.i(110261);
        super.onDestroy();
        j.a aVar = j.rST;
        j.a.cxU().d((a) this);
        AppMethodBeat.o(110261);
    }

    public final void finish() {
        AppMethodBeat.i(110262);
        ab.i(TAG, "finish " + this.shu.size());
        if (this.sht.size() > 0) {
            String str = ((b) this.sht.get(0)).userName;
            j.a aVar = j.rST;
            f aap = j.a.cxU().aap(str);
            if (aap != null) {
                long j = aap.field_updateTime;
                if (j == 0) {
                    j = ((long) aap.field_storyPostTime) * 1000;
                }
                ab.i(TAG, "finish updateTime user:" + str + " updateTime: " + j);
                if (j > 0) {
                    e RP = g.RP();
                    a.f.b.j.o(RP, "MMKernel.storage()");
                    RP.Ry().set(ac.a.xWS, Long.valueOf(j));
                }
            }
        }
        super.finish();
        AppMethodBeat.o(110262);
    }

    public final int getLayoutId() {
        return 2130970883;
    }

    public final void a(String str, com.tencent.mm.sdk.e.m mVar) {
        AppMethodBeat.i(110263);
        if (!(str == null || mVar == null || !(mVar.obj instanceof f))) {
            switch (str.hashCode()) {
                case 398324054:
                    if (str.equals("notify_story_read")) {
                        Object obj = mVar.obj;
                        if (obj == null) {
                            v vVar = new v("null cannot be cast to non-null type com.tencent.mm.plugin.story.storage.StoryExtInfo");
                            AppMethodBeat.o(110263);
                            throw vVar;
                        }
                        this.shu.add(((f) obj).getUserName());
                        c cVar = this.shr;
                        if (cVar == null) {
                            a.f.b.j.avw("entranceAdapter");
                        }
                        cVar.notifyDataSetChanged();
                        AppMethodBeat.o(110263);
                        return;
                    }
                    break;
            }
            ab.i(TAG, "unknown event ".concat(String.valueOf(str)));
        }
        AppMethodBeat.o(110263);
    }
}
