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

import a.f.a.m;
import a.f.b.j;
import a.f.b.k;
import a.l;
import a.y;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.g.b.a.ar;
import com.tencent.mm.plugin.story.api.o;
import com.tencent.mm.plugin.story.g.h;
import com.tencent.mm.plugin.story.ui.StoryBrowseUI;
import com.tencent.mm.plugin.story.ui.sns.c.b;
import com.tencent.ytcommon.BuildConfig;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;

@l(dWo = {1, 1, 13}, dWp = {"\u0000\u0014\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0000\u0010\u0000\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H\n¢\u0006\u0002\b\u0006"}, dWq = {"<anonymous>", "", "position", "", "item", "Lcom/tencent/mm/plugin/story/ui/sns/StoryEntranceView$DataObject;", "invoke"})
final class c$2 extends k implements m<Integer, b, y> {
    final /* synthetic */ Context jWS;
    final /* synthetic */ c shL;
    final /* synthetic */ OnClickListener shM;

    c$2(c cVar, Context context, OnClickListener onClickListener) {
        this.shL = cVar;
        this.jWS = context;
        this.shM = onClickListener;
        super(2);
    }

    public final /* synthetic */ Object m(Object obj, Object obj2) {
        int i;
        b bVar;
        y yVar;
        AppMethodBeat.i(110267);
        int intValue = ((Number) obj).intValue();
        b bVar2 = (b) obj2;
        j.p(bVar2, "item");
        LinkedList linkedList = new LinkedList();
        HashMap hashMap = new HashMap();
        int i2;
        h hVar;
        if (bVar2.type == 5) {
            for (Entry entry : c.d(this.shL).entrySet()) {
                String str = (String) entry.getKey();
                ArrayList<Number> arrayList = (ArrayList) entry.getValue();
                ArrayList arrayList2 = new ArrayList();
                for (Number longValue : arrayList) {
                    arrayList2.add(Long.valueOf(longValue.longValue()));
                }
                hashMap.put(str, arrayList2);
            }
            if (c.e(this.shL) != -1) {
                i2 = intValue - 1;
            } else {
                i2 = intValue;
            }
            hVar = h.scu;
            h.cAs().FP();
            i = i2;
        } else if (bVar2.type == 1) {
            ar cAs;
            StringBuilder stringBuilder;
            h hVar2;
            if (intValue <= c.e(this.shL) || c.e(this.shL) == -1) {
                i2 = intValue;
            } else {
                i2 = intValue - c.e(this.shL);
            }
            if (intValue >= c.f(this.shL) && c.f(this.shL) != -1) {
                i2--;
                hVar = h.scu;
                h.cAs().bG(12);
                hVar = h.scu;
                cAs = h.cAs();
                stringBuilder = new StringBuilder("12_");
                hVar2 = h.scu;
                cAs.fC(stringBuilder.append(h.cAL()).toString());
            }
            if (intValue >= c.g(this.shL) && c.g(this.shL) != -1) {
                i2--;
                hVar = h.scu;
                h.cAs().bG(13);
                hVar = h.scu;
                cAs = h.cAs();
                stringBuilder = new StringBuilder("13_");
                hVar2 = h.scu;
                cAs.fC(stringBuilder.append(h.cAL()).toString());
            }
            i = i2;
        } else {
            i = intValue;
        }
        List h = c.h(this.shL);
        j.o(h, "userNameList");
        Iterable<b> iterable = h;
        synchronized (iterable) {
            try {
                for (b bVar3 : iterable) {
                    if ((bVar3.type == bVar2.type ? 1 : null) == null) {
                        bVar3 = null;
                    }
                    if (bVar3 != null) {
                        linkedList.add(bVar3.userName);
                    }
                }
                yVar = y.AUy;
            } catch (Throwable th) {
                AppMethodBeat.o(110267);
            }
        }
        com.tencent.mm.plugin.report.service.h.pYm.k(1015, 6, 1);
        h = c.h(this.shL);
        j.o(h, "userNameList");
        Iterable iterable2 = h;
        synchronized (iterable2) {
            try {
                int i3 = 0;
                for (Object next : iterable2) {
                    int i4 = i3 + 1;
                    if (i3 < 0) {
                        a.a.j.dWs();
                    }
                    bVar3 = (b) next;
                    Object obj3 = (bVar3.type != bVar2.type || i3 >= intValue) ? null : 1;
                    if (obj3 == null) {
                        bVar3 = null;
                    }
                    if (bVar3 != null) {
                        linkedList.add(bVar3.userName);
                        i3 = i4;
                    } else {
                        i3 = i4;
                    }
                }
                yVar = y.AUy;
            } catch (Throwable th2) {
                AppMethodBeat.o(110267);
            }
        }
        h hVar3 = h.scu;
        h.cAs().fA((String) linkedList.get(i));
        long c = o.rQN.c(linkedList, hashMap);
        Intent intent = new Intent(this.jWS, StoryBrowseUI.class);
        intent.putExtra("v_position", i);
        intent.putExtra("data_seed_key", c);
        intent.putExtra("gallery_session_id", BuildConfig.FLAVOR);
        intent.putExtra("gallery_is_for_sns", true);
        this.jWS.startActivity(intent);
        OnClickListener onClickListener = this.shM;
        if (onClickListener != null) {
            onClickListener.onClick((View) this.shL);
        }
        y yVar2 = y.AUy;
        AppMethodBeat.o(110267);
        return yVar2;
    }
}
