package com.mexico.inloancash.utils;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import ඓ.K.K.K.C1293;

public class India_DatePickerView extends View {

    /* renamed from: ʬ  reason: contains not printable characters */
    public List<String> f2857;

    /* renamed from: Ԕ  reason: contains not printable characters */
    public float f2858;

    /* renamed from: ؿ  reason: contains not printable characters */
    public boolean f2859;

    /* renamed from: ݜ  reason: contains not printable characters */
    public C0531 f2860;

    /* renamed from: ඓ  reason: contains not printable characters */
    public Paint f2861;

    /* renamed from: ᓣ  reason: contains not printable characters */
    public AbstractC0530 f2862;

    /* renamed from: ᕣ  reason: contains not printable characters */
    public int f2863;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public float f2864;

    /* renamed from: ῲ  reason: contains not printable characters */
    public boolean f2865;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public float f2866;

    /* renamed from: 㑃  reason: contains not printable characters */
    public int f2867;

    /* renamed from: 㗗  reason: contains not printable characters */
    public boolean f2868;

    /* renamed from: 㗽  reason: contains not printable characters */
    public Timer f2869;

    /* renamed from: 㳳  reason: contains not printable characters */
    public float f2870;

    /* renamed from: 㴹  reason: contains not printable characters */
    public Paint f2871;

    /* renamed from: 㸾  reason: contains not printable characters */
    public int f2872;

    /* renamed from: 㿎  reason: contains not printable characters */
    public float f2873;

    /* renamed from: 䀟  reason: contains not printable characters */
    public Handler f2874;

    /* renamed from: 䁗  reason: contains not printable characters */
    public float f2875;

    /* renamed from: com.mexico.inloancash.utils.India_DatePickerView$ʬ  reason: contains not printable characters */
    public interface AbstractC0530 {
        /* renamed from: K  reason: contains not printable characters */
        void m1638(String str);
    }

    /* renamed from: com.mexico.inloancash.utils.India_DatePickerView$ῲ  reason: contains not printable characters */
    public class C0531 extends TimerTask {

        /* renamed from: ῲ  reason: contains not printable characters */
        public Handler f2876;

        public C0531(India_DatePickerView india_DatePickerView, Handler handler) {
            this.f2876 = handler;
        }

        public void run() {
            Handler handler = this.f2876;
            handler.sendMessage(handler.obtainMessage());
        }
    }

    /* renamed from: com.mexico.inloancash.utils.India_DatePickerView$K  reason: contains not printable characters */
    public class HandlerC0532 extends Handler {
        public HandlerC0532() {
        }

        public void handleMessage(Message message) {
            if (Math.abs(India_DatePickerView.this.f2858) < 10.0f) {
                India_DatePickerView india_DatePickerView = India_DatePickerView.this;
                india_DatePickerView.f2858 = 0.0f;
                C0531 r4 = india_DatePickerView.f2860;
                if (r4 != null) {
                    r4.cancel();
                    India_DatePickerView india_DatePickerView2 = India_DatePickerView.this;
                    india_DatePickerView2.f2860 = null;
                    AbstractC0530 r0 = india_DatePickerView2.f2862;
                    if (r0 != null) {
                        r0.m1638(india_DatePickerView2.f2857.get(india_DatePickerView2.f2872));
                    }
                }
            } else {
                India_DatePickerView india_DatePickerView3 = India_DatePickerView.this;
                float f = india_DatePickerView3.f2858;
                india_DatePickerView3.f2858 = f - ((f / Math.abs(f)) * 10.0f);
            }
            India_DatePickerView.this.invalidate();
        }
    }

    public India_DatePickerView(Context context) {
        super(context);
        this.f2865 = true;
        this.f2866 = 80.0f;
        this.f2873 = 40.0f;
        this.f2864 = 255.0f;
        this.f2870 = 120.0f;
        this.f2858 = 0.0f;
        this.f2868 = false;
        this.f2859 = true;
        this.f2874 = new HandlerC0532();
    }

    public boolean dispatchTouchEvent(MotionEvent motionEvent) {
        return this.f2859 && super.dispatchTouchEvent(motionEvent);
    }

    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (this.f2868) {
            float r0 = m1635(((float) this.f2863) / 4.0f, this.f2858);
            float f = this.f2866;
            float f2 = this.f2873;
            this.f2861.setTextSize(C1293.m3403(f, f2, r0, f2));
            Paint paint = this.f2861;
            float f3 = this.f2864;
            float f4 = this.f2870;
            paint.setAlpha((int) C1293.m3403(f3, f4, r0, f4));
            float f5 = (float) ((((double) this.f2863) / 2.0d) + ((double) this.f2858));
            Paint.FontMetricsInt fontMetricsInt = this.f2861.getFontMetricsInt();
            double d = ((double) fontMetricsInt.top) / 2.0d;
            String str = this.f2857.get(this.f2872);
            canvas.drawText(str, (float) (((double) this.f2867) / 2.0d), (float) (((double) f5) - (d + (((double) fontMetricsInt.bottom) / 2.0d))), this.f2861);
            for (int i = 1; this.f2872 - i >= 0; i++) {
                m1637(canvas, i, -1);
            }
            for (int i2 = 1; this.f2872 + i2 < this.f2857.size(); i2++) {
                m1637(canvas, i2, 1);
            }
        }
    }

    public void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
        this.f2863 = getMeasuredHeight();
        this.f2867 = getMeasuredWidth();
        this.f2866 = ((float) this.f2863) / 7.0f;
        this.f2873 = this.f2866 / 2.2f;
        this.f2868 = true;
        invalidate();
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            C0531 r0 = this.f2860;
            if (r0 != null) {
                r0.cancel();
                this.f2860 = null;
            }
            this.f2875 = motionEvent.getY();
        } else if (actionMasked != 1) {
            if (actionMasked == 2) {
                this.f2858 = (motionEvent.getY() - this.f2875) + this.f2858;
                float f = this.f2858;
                float f2 = this.f2873;
                if (f > (f2 * 2.8f) / 2.0f) {
                    if (this.f2865 || this.f2872 != 0) {
                        if (!this.f2865) {
                            this.f2872--;
                        }
                        m1634();
                        this.f2858 -= this.f2873 * 2.8f;
                    } else {
                        this.f2875 = motionEvent.getY();
                        invalidate();
                        return true;
                    }
                } else if (f < (f2 * -2.8f) / 2.0f) {
                    if (this.f2872 == this.f2857.size() - 1) {
                        this.f2875 = motionEvent.getY();
                        invalidate();
                        return true;
                    }
                    if (!this.f2865) {
                        this.f2872++;
                    }
                    m1636();
                    this.f2858 = (this.f2873 * 2.8f) + this.f2858;
                }
                this.f2875 = motionEvent.getY();
                invalidate();
            }
        } else if (((double) Math.abs(this.f2858)) < 1.0E-4d) {
            this.f2858 = 0.0f;
        } else {
            C0531 r10 = this.f2860;
            if (r10 != null) {
                r10.cancel();
                this.f2860 = null;
            }
            this.f2860 = new C0531(this, this.f2874);
            this.f2869.schedule(this.f2860, 0, 10);
        }
        return true;
    }

    public void setCanScroll(boolean z) {
        this.f2859 = z;
    }

    public void setData(List<String> list) {
        this.f2857 = list;
        this.f2872 = list.size() / 4;
        invalidate();
    }

    public void setIsLoop(boolean z) {
        this.f2865 = z;
    }

    public void setOnSelectListener(AbstractC0530 r1) {
        this.f2862 = r1;
    }

    public void setSelected(int i) {
        this.f2872 = i;
        if (this.f2865) {
            int size = (this.f2857.size() / 2) - this.f2872;
            int i2 = 0;
            if (size < 0) {
                while (i2 < (-size)) {
                    m1636();
                    this.f2872--;
                    i2++;
                }
            } else if (size > 0) {
                while (i2 < size) {
                    m1634();
                    this.f2872++;
                    i2++;
                }
            }
        }
        invalidate();
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public final void m1634() {
        if (this.f2865) {
            List<String> list = this.f2857;
            List<String> list2 = this.f2857;
            list2.remove(list2.size() - 1);
            this.f2857.add(0, list.get(list.size() - 1));
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m1636() {
        if (this.f2865) {
            this.f2857.remove(0);
            this.f2857.add(this.f2857.get(0));
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m1637(Canvas canvas, int i, int i2) {
        float f = (float) i2;
        float f2 = (this.f2858 * f) + (this.f2873 * 2.8f * ((float) i));
        float r0 = m1635(((float) this.f2863) / 4.0f, f2);
        float f3 = this.f2866;
        float f4 = this.f2873;
        this.f2871.setTextSize(C1293.m3403(f3, f4, r0, f4));
        Paint paint = this.f2871;
        float f5 = this.f2864;
        float f6 = this.f2870;
        paint.setAlpha((int) C1293.m3403(f5, f6, r0, f6));
        Paint.FontMetricsInt fontMetricsInt = this.f2871.getFontMetricsInt();
        canvas.drawText(this.f2857.get((i2 * i) + this.f2872), (float) (((double) this.f2867) / 2.0d), (float) (((double) ((float) ((((double) this.f2863) / 2.0d) + ((double) (f * f2))))) - ((((double) fontMetricsInt.top) / 2.0d) + (((double) fontMetricsInt.bottom) / 2.0d))), this.f2871);
    }

    public void setSelected(String str) {
        for (int i = 0; i < this.f2857.size(); i++) {
            if (this.f2857.get(i).equals(str)) {
                setSelected(i);
                return;
            }
        }
    }

    public India_DatePickerView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f2865 = true;
        this.f2866 = 80.0f;
        this.f2873 = 40.0f;
        this.f2864 = 255.0f;
        this.f2870 = 120.0f;
        this.f2858 = 0.0f;
        this.f2868 = false;
        this.f2859 = true;
        this.f2874 = new HandlerC0532();
        this.f2869 = new Timer();
        this.f2857 = new ArrayList();
        this.f2861 = new Paint(1);
        this.f2861.setStyle(Paint.Style.FILL);
        this.f2861.setTextAlign(Paint.Align.CENTER);
        this.f2861.setColor(Color.parseColor("#1E2429"));
        this.f2871 = new Paint(1);
        this.f2871.setStyle(Paint.Style.FILL);
        this.f2871.setTextAlign(Paint.Align.CENTER);
        this.f2871.setColor(Color.parseColor("#5E5F60"));
    }

    /* renamed from: K  reason: contains not printable characters */
    public final float m1635(float f, float f2) {
        float pow = (float) (1.0d - Math.pow((double) (f2 / f), 2.0d));
        if (pow < 0.0f) {
            return 0.0f;
        }
        return pow;
    }

    public India_DatePickerView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.f2865 = true;
        this.f2866 = 80.0f;
        this.f2873 = 40.0f;
        this.f2864 = 255.0f;
        this.f2870 = 120.0f;
        this.f2858 = 0.0f;
        this.f2868 = false;
        this.f2859 = true;
        this.f2874 = new HandlerC0532();
    }
}
