package com.bytedance.android.livesdk.widget;

import X.0CB;
import X.0CH;
import X.0b0;
import X.0b7;
import X.1jk;
import X.2FV;
import X.2He;
import X.4ZZ;
import X.6Is;
import X.7s1;
import X.8jA;
import X.C2675Gg0;
import X.C3514GtX;
import X.C3708Gwf;
import X.T3q;
import android.animation.ValueAnimator;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.sdk.widgets.LiveRecyclableWidget;
import java.lang.reflect.Field;
import kotlin.h.b.n;

public final class RecommendSwipeWidget extends LiveRecyclableWidget implements 6Is {
    public T3q LIZ;
    public View LIZIZ;
    public LinearLayout LIZJ;
    public LinearLayout LIZLLL;
    public 1jk LJ;
    public 1jk LJFF;
    public 1jk LJI;
    public 1jk LJII;
    public 4ZZ LJIIIIZZ;
    public 4ZZ LJIIIZ;
    public RelativeLayout LJIIJ;
    public RelativeLayout LJIIJJI;
    public float LJIIL;
    public float LJIILIIL;
    public float LJIILJJIL;
    public float LJIILL = -1.0f;
    public float LJIILLIIL;
    public boolean LJIIZILJ;
    public boolean LJIJ;
    public boolean LJIJI;
    public int LJIJJ;
    public int LJIJJLI;
    public int LJIL;

    static {
        Covode.recordClassIndex(21669);
    }

    public final int getLayoutId() {
        return 2131562035;
    }

    public final void onLoad(Object[] objArr) {
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
        super.onStateChanged(r1, r2);
    }

    public final void onUnload() {
        View view = this.LIZIZ;
        if (view != null) {
            view.clearAnimation();
        }
    }

    private void LIZLLL() {
        View view = this.LIZIZ;
        if (view != null) {
            0b7.LIZ(view, 0);
        }
    }

    public final void LIZIZ() {
        int i = this.LJIJJ;
        if (i >= 0) {
            if (this.LJIIL >= 0.5f) {
                if (this.LJIJ) {
                    this.LJIJJ = i + 1;
                } else {
                    this.LJIJJ = i - 1;
                }
                C2675Gg0.LIZ().LIZ((Object) new C3708Gwf(this.LJIJJ, this.LJIJ));
            }
            this.LJIIZILJ = false;
        }
    }

    private final void LJ() {
        float f;
        long j;
        View view = this.LIZIZ;
        if (view != null) {
            view.clearAnimation();
        }
        View view2 = this.LIZIZ;
        if (view2 != null) {
            f = view2.getTranslationY();
        } else {
            f = 0.0f;
        }
        int i = this.LJIJJLI;
        if (i > 0) {
            j = (long) ((f / ((float) i)) * 300.0f);
        } else {
            j = 0;
        }
        long abs = Math.abs(j);
        if (abs > 0) {
            ValueAnimator ofFloat = ValueAnimator.ofFloat(new float[]{f, 0.0f});
            n.LIZIZ(ofFloat, "");
            ofFloat.setDuration(abs);
            ofFloat.addUpdateListener(new C3514GtX(this));
            ofFloat.start();
        }
    }

    public final void LIZJ() {
        View view = this.LIZIZ;
        if (view != null) {
            view.setScaleX(1.0f);
        }
        View view2 = this.LIZIZ;
        if (view2 != null) {
            view2.setScaleY(1.0f);
        }
        LJ();
        if (this.LJI != null) {
            1jk r0 = this.LJI;
            if (r0 == null) {
                n.LIZ("");
            }
            r0.setAlpha(0.0f);
        }
        if (this.LJII != null) {
            1jk r02 = this.LJII;
            if (r02 == null) {
                n.LIZ("");
            }
            r02.setAlpha(0.0f);
        }
        this.LJIIL = 0.0f;
        LIZLLL();
        hide();
        this.LJIJJ = -1;
        this.LJIJJLI = 0;
    }

    public final int LIZ() {
        int measuredHeight;
        int measuredHeight2;
        if (this.LJIJ) {
            int LIZ2 = 0b0.LIZ(76.0f);
            4ZZ r0 = this.LJIIIIZZ;
            if (r0 == null) {
                n.LIZ("");
            }
            int measuredHeight3 = LIZ2 + r0.getMeasuredHeight();
            1jk r02 = this.LJI;
            if (r02 == null) {
                n.LIZ("");
            }
            measuredHeight = measuredHeight3 + r02.getMeasuredHeight();
            1jk r03 = this.LJ;
            if (r03 == null) {
                n.LIZ("");
            }
            measuredHeight2 = r03.getMeasuredHeight();
        } else {
            int LIZ3 = 0b0.LIZ(76.0f);
            4ZZ r04 = this.LJIIIZ;
            if (r04 == null) {
                n.LIZ("");
            }
            int measuredHeight4 = LIZ3 + r04.getMeasuredHeight();
            1jk r05 = this.LJII;
            if (r05 == null) {
                n.LIZ("");
            }
            measuredHeight = measuredHeight4 + r05.getMeasuredHeight();
            1jk r06 = this.LJFF;
            if (r06 == null) {
                n.LIZ("");
            }
            measuredHeight2 = r06.getMeasuredHeight();
        }
        return measuredHeight + measuredHeight2;
    }

    public final void onInit(Object[] objArr) {
        View findViewById = findViewById(2131367107);
        n.LIZIZ(findViewById, "");
        this.LIZLLL = (LinearLayout) findViewById;
        View findViewById2 = findViewById(2131367100);
        n.LIZIZ(findViewById2, "");
        this.LIZJ = (LinearLayout) findViewById2;
        1jk findViewById3 = findViewById(2131371533);
        n.LIZIZ(findViewById3, "");
        this.LJ = findViewById3;
        1jk findViewById4 = findViewById(2131371659);
        n.LIZIZ(findViewById4, "");
        this.LJFF = findViewById4;
        1jk findViewById5 = findViewById(2131370934);
        n.LIZIZ(findViewById5, "");
        this.LJI = findViewById5;
        1jk findViewById6 = findViewById(2131364240);
        n.LIZIZ(findViewById6, "");
        this.LJII = findViewById6;
        4ZZ findViewById7 = findViewById(2131365868);
        n.LIZIZ(findViewById7, "");
        this.LJIIIIZZ = findViewById7;
        4ZZ findViewById8 = findViewById(2131365867);
        n.LIZIZ(findViewById8, "");
        this.LJIIIZ = findViewById8;
        View findViewById9 = findViewById(2131369431);
        n.LIZIZ(findViewById9, "");
        this.LJIIJ = (RelativeLayout) findViewById9;
        View findViewById10 = findViewById(2131369434);
        n.LIZIZ(findViewById10, "");
        this.LJIIJJI = (RelativeLayout) findViewById10;
        LinearLayout linearLayout = this.LIZLLL;
        if (linearLayout == null) {
            n.LIZ("");
        }
        linearLayout.setVisibility(8);
        LinearLayout linearLayout2 = this.LIZJ;
        if (linearLayout2 == null) {
            n.LIZ("");
        }
        linearLayout2.setVisibility(8);
        1jk r0 = this.LJI;
        if (r0 == null) {
            n.LIZ("");
        }
        r0.setAlpha(0.0f);
        1jk r02 = this.LJII;
        if (r02 == null) {
            n.LIZ("");
        }
        r02.setAlpha(0.0f);
    }

    public static Object LIZ(Context context, String str) {
        Object obj;
        MethodCollector.i(2044);
        if (Build.VERSION.SDK_INT > 27 || !"clipboard".equals(str)) {
            if (!2FV.LIZIZ && "connectivity".equals(str)) {
                try {
                    new 7s1().LIZ();
                    2FV.LIZIZ = true;
                    obj = context.getSystemService(str);
                } catch (Throwable unused) {
                }
            }
            obj = context.getSystemService(str);
        } else if (2FV.LIZ) {
            synchronized (ClipboardManager.class) {
                try {
                    obj = context.getSystemService(str);
                    if (Thread.currentThread() != Looper.getMainLooper().getThread()) {
                        Field declaredField = ClipboardManager.class.getDeclaredField("mHandler");
                        declaredField.setAccessible(true);
                        declaredField.set(obj, new 2He((Handler) declaredField.get(obj)));
                    }
                } catch (Exception e) {
                    8jA.LIZ(e, "ClipboardManager Handler Reflect Fail");
                } catch (Throwable th) {
                    MethodCollector.o(2044);
                    throw th;
                }
                2FV.LIZ = false;
            }
        } else {
            obj = context.getSystemService(str);
        }
        MethodCollector.o(2044);
        return obj;
    }
}
