package com.tencent.mm.plugin.topstory.ui.video.list;

import android.support.v7.widget.RecyclerView.i;
import android.support.v7.widget.RecyclerView.r;
import android.support.v7.widget.ah;
import android.support.v7.widget.am;
import android.view.View;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.topstory.ui.video.b;
import com.tencent.mm.plugin.topstory.ui.widget.g;

public final class c extends g {
    private am amf;
    private am amg;
    b sDo;

    public c(b bVar) {
        this.sDo = bVar;
    }

    public final int[] a(i iVar, View view) {
        AppMethodBeat.i(2015);
        int[] iArr = new int[2];
        if (iVar.iG()) {
            iArr[0] = a(view, c(iVar));
        } else {
            iArr[0] = 0;
        }
        if (iVar.iH()) {
            iArr[1] = a(view, b(iVar));
        } else {
            iArr[1] = 0;
        }
        AppMethodBeat.o(2015);
        return iArr;
    }

    public final View a(i iVar) {
        AppMethodBeat.i(2016);
        View a;
        if (iVar.iH()) {
            a = a(iVar, b(iVar));
            AppMethodBeat.o(2016);
            return a;
        } else if (iVar.iG()) {
            a = a(iVar, c(iVar));
            AppMethodBeat.o(2016);
            return a;
        } else {
            AppMethodBeat.o(2016);
            return null;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:34:0x00a4  */
    /* JADX WARNING: Removed duplicated region for block: B:26:0x005d  */
    public final int a(android.support.v7.widget.RecyclerView.i r11, int r12, int r13) {
        /*
        r10 = this;
        r6 = 0;
        r1 = 1;
        r3 = -1;
        r9 = 2017; // 0x7e1 float:2.826E-42 double:9.965E-321;
        r2 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r9);
        r0 = java.lang.Math.abs(r13);
        r4 = 500; // 0x1f4 float:7.0E-43 double:2.47E-321;
        if (r0 <= r4) goto L_0x001b;
    L_0x0011:
        r0 = java.lang.Math.abs(r12);
        r4 = java.lang.Math.abs(r13);
        if (r0 < r4) goto L_0x001f;
    L_0x001b:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r9);
    L_0x001e:
        return r3;
    L_0x001f:
        r4 = r11.getItemCount();
        if (r4 != 0) goto L_0x0029;
    L_0x0025:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r9);
        goto L_0x001e;
    L_0x0029:
        r0 = r10.sDo;
        r0 = r0.cFY();
        r5 = r0 + 1;
        if (r5 != r3) goto L_0x0037;
    L_0x0033:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r9);
        goto L_0x001e;
    L_0x0037:
        r0 = r11.iG();
        if (r0 == 0) goto L_0x009c;
    L_0x003d:
        if (r12 <= 0) goto L_0x009a;
    L_0x003f:
        r0 = r1;
    L_0x0040:
        r3 = r11 instanceof android.support.v7.widget.RecyclerView.r.b;
        if (r3 == 0) goto L_0x00ac;
    L_0x0044:
        r11 = (android.support.v7.widget.RecyclerView.r.b) r11;
        r3 = r4 + -1;
        r3 = r11.bX(r3);
        if (r3 == 0) goto L_0x00ac;
    L_0x004e:
        r4 = r3.x;
        r4 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r4 < 0) goto L_0x005a;
    L_0x0054:
        r3 = r3.y;
        r3 = (r3 > r6 ? 1 : (r3 == r6 ? 0 : -1));
        if (r3 >= 0) goto L_0x00a2;
    L_0x005a:
        r3 = r1;
    L_0x005b:
        if (r3 == 0) goto L_0x00a4;
    L_0x005d:
        if (r0 != 0) goto L_0x00a9;
    L_0x005f:
        r3 = r5 + 1;
    L_0x0061:
        r4 = "MicroMsg.TopStory.TopStoryVideoPagerSnapHelper";
        r6 = "findTargetSnapPosition velocityY: %d centerPosition: %d forwardDirection: %b result: %d currentPlayPos: %d";
        r7 = 5;
        r7 = new java.lang.Object[r7];
        r8 = java.lang.Integer.valueOf(r13);
        r7[r2] = r8;
        r2 = java.lang.Integer.valueOf(r5);
        r7[r1] = r2;
        r1 = 2;
        r0 = java.lang.Boolean.valueOf(r0);
        r7[r1] = r0;
        r0 = 3;
        r1 = java.lang.Integer.valueOf(r3);
        r7[r0] = r1;
        r0 = 4;
        r1 = r10.sDo;
        r1 = r1.cFY();
        r1 = r1 + 1;
        r1 = java.lang.Integer.valueOf(r1);
        r7[r0] = r1;
        com.tencent.mm.sdk.platformtools.ab.i(r4, r6, r7);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r9);
        goto L_0x001e;
    L_0x009a:
        r0 = r2;
        goto L_0x0040;
    L_0x009c:
        if (r13 <= 0) goto L_0x00a0;
    L_0x009e:
        r0 = r1;
        goto L_0x0040;
    L_0x00a0:
        r0 = r2;
        goto L_0x0040;
    L_0x00a2:
        r3 = r2;
        goto L_0x005b;
    L_0x00a4:
        if (r0 == 0) goto L_0x00a9;
    L_0x00a6:
        r3 = r5 + 1;
        goto L_0x0061;
    L_0x00a9:
        r3 = r5 + -1;
        goto L_0x0061;
    L_0x00ac:
        r3 = r2;
        goto L_0x005b;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.topstory.ui.video.list.c.a(android.support.v7.widget.RecyclerView$i, int, int):int");
    }

    public final ah f(i iVar) {
        AppMethodBeat.i(2018);
        if (iVar instanceof r.b) {
            ah 1 = new 1(this, this.aiB.getContext());
            AppMethodBeat.o(2018);
            return 1;
        }
        AppMethodBeat.o(2018);
        return null;
    }

    private int a(View view, am amVar) {
        AppMethodBeat.i(2019);
        int bf = amVar.bf(view) - this.sDo.cGd();
        AppMethodBeat.o(2019);
        return bf;
    }

    private static View a(i iVar, am amVar) {
        View view = null;
        AppMethodBeat.i(2020);
        int childCount = iVar.getChildCount();
        if (childCount == 0) {
            AppMethodBeat.o(2020);
        } else {
            int je;
            if (iVar.getClipToPadding()) {
                je = amVar.je() + (amVar.jg() / 2);
            } else {
                je = amVar.getEnd() / 2;
            }
            int i = Integer.MAX_VALUE;
            int i2 = 0;
            while (i2 < childCount) {
                View childAt = iVar.getChildAt(i2);
                int abs = Math.abs((amVar.bf(childAt) + (amVar.bj(childAt) / 2)) - je);
                if (abs >= i) {
                    abs = i;
                    childAt = view;
                }
                i2++;
                i = abs;
                view = childAt;
            }
            AppMethodBeat.o(2020);
        }
        return view;
    }

    private am b(i iVar) {
        AppMethodBeat.i(2021);
        if (this.amf == null || this.amf.getLayoutManager() != iVar) {
            this.amf = am.e(iVar);
        }
        am amVar = this.amf;
        AppMethodBeat.o(2021);
        return amVar;
    }

    private am c(i iVar) {
        AppMethodBeat.i(2022);
        if (this.amg == null || this.amg.getLayoutManager() != iVar) {
            this.amg = am.d(iVar);
        }
        am amVar = this.amg;
        AppMethodBeat.o(2022);
        return amVar;
    }
}
