Exploit database

GH-14fb583d3d1bd2da10251bb1a37b93d6

gitchw/ghostlock-cve-2026-43499

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

165 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files25

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

workspace/decomp/HeyOTA/sources/com/heytap/wearable/support/widget/HeyNumberPicker.java

Java · 60,829 bytes
package com.heytap.wearable.support.widget;

import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.media.MediaPlayer;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.widget.Scroller;
import com.heytap.wearable.R$integer;
import com.heytap.wearable.R$styleable;
import com.heytap.wearable.support.recycler.v4.ViewConfigurationCompat;
import com.heytap.wearable.support.util.HeyWidgetUtils;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/* loaded from: classes.dex */
public class HeyNumberPicker extends View {
    int angle;
    private float currY;
    float dispatchLocationX;
    float dispatchLocationY;
    private float downY;
    private float downYGlobal;
    private boolean isPlaySoundInScrolling;
    private Locale locale;
    private String mAlterHint;
    private CharSequence[] mAlterTextArrayWithMeasureHint;
    private CharSequence[] mAlterTextArrayWithoutMeasureHint;
    private Context mContext;
    private int mCrownTargetValue;
    private int mCurrDrawFirstItemIndex;
    private int mCurrDrawFirstItemY;
    private int mCurrDrawGlobalY;
    private boolean mCurrentItemIndexEffect;
    private int mDefatulTextSize;
    private int mDelta;
    private String[] mDisplayedValues;
    private String mEmptyItemHint;
    private boolean mFlagMayPress;
    private String mFontFamily;
    private float mFriction;
    private Handler mHandlerInMainThread;
    private Handler mHandlerInNewThread;
    private HandlerThread mHandlerThread;
    private boolean mHasInit;
    private VibrateHelper mHelper;
    private int mInScrollingPickedNewValue;
    private int mInScrollingPickedOldValue;
    private int mItemHeight;
    private int mItemPaddingHorizontal;
    private int mItemPaddingVertical;
    private int mMarginEndOfHint;
    private int mMarginStartOfHint;
    private int mMaxHeightOfDisplayedValues;
    private int mMaxShowIndex;
    private int mMaxValue;
    private int mMaxWidthOfAlterArrayWithMeasureHint;
    private int mMaxWidthOfAlterArrayWithoutMeasureHint;
    private int mMaxWidthOfDisplayedValues;
    private MediaPlayer mMediaPlayer;
    private int mMinShowIndex;
    private int mMinValue;
    private int mMiniVelocityFling;
    private int mNotWrapLimitYBottom;
    private int mNotWrapLimitYTop;
    private OnScrollListener mOnScrollListener;
    private OnValueChangeListener mOnValueChangeListener;
    private OnValueChangeListenerInScrolling mOnValueChangeListenerInScrolling;
    private OnValueChangeListenerRelativeToRaw mOnValueChangeListenerRaw;
    private TextPaint mPaintText;
    private boolean mPendingWrapToLinear;
    private int mPrevPickedIndex;
    private BroadcastReceiver mReceiver;
    private boolean mRespondChangeInMainThread;
    private boolean mRespondChangeOnDetach;
    private int mScaledTouchSlop;
    private int mScrollState;
    private Scroller mScroller;
    private int mSelectedTextSize;
    private int mShownCount;
    private int mSmartMode;
    private int mSpecModeH;
    private int mSpecModeW;
    private int mTextColorNormal;
    private int mTextColorSelected;
    private int mTextColorSelectedFocused;
    private int mTextColorSelectedUnFocused;
    private String mTextEllipsize;
    private ValueAnimator mTextSelectedColorAnimator;
    private int mTextSizeHint;
    private int mTextSizeNormal;
    private float mTextSizeNormalCenterYOffset;
    private int mTextSizeSelected;
    private float mTextSizeSelectedCenterYOffset;
    private Map<String, Integer> mTextWidthCache;
    private VelocityTracker mVelocityTracker;
    private float mVerticalScrollFactor;
    private float mViewCenterX;
    private int mViewHeight;
    private int mViewWidth;
    private int mWidthOfAlterHint;
    private int mWidthOfHintText;
    private boolean mWrapSelectorWheel;
    private boolean mWrapSelectorWheelCheck;
    int swipeFlag;
    int tempValue;

    /* loaded from: classes.dex */
    public interface OnScrollListener {
        void onScrollStateChange(HeyNumberPicker heyNumberPicker, int i);
    }

    /* loaded from: classes.dex */
    public interface OnValueChangeListener {
        void onValueChange(HeyNumberPicker heyNumberPicker, int i, int i2);
    }

    /* loaded from: classes.dex */
    public interface OnValueChangeListenerInScrolling {
        void onValueChangeInScrolling(HeyNumberPicker heyNumberPicker, int i, int i2);
    }

    /* loaded from: classes.dex */
    public interface OnValueChangeListenerRelativeToRaw {
        void onValueChangeRelativeToRaw(HeyNumberPicker heyNumberPicker, int i, int i2, String[] strArr);
    }

    private int getEvaluateColor(float f, int i, int i2) {
        int i3 = (i & (-16777216)) >>> 24;
        int i4 = (i & 16711680) >>> 16;
        int i5 = (i & 65280) >>> 8;
        return (((int) (i3 + (((((-16777216) & i2) >>> 24) - i3) * f))) << 24) | (((int) (i4 + ((((16711680 & i2) >>> 16) - i4) * f))) << 16) | (((int) (i5 + ((((65280 & i2) >>> 8) - i5) * f))) << 8) | ((int) (((i & 255) >>> 0) + ((((i2 & 255) >>> 0) - r8) * f)));
    }

    private float getEvaluateSize(float f, float f2, float f3) {
        return f2 + ((f3 - f2) * f);
    }

    public HeyNumberPicker(Context context) {
        super(context);
        this.mTextColorNormal = 1728053247;
        this.mTextColorSelected = -1;
        this.mTextColorSelectedFocused = -14385921;
        this.mTextColorSelectedUnFocused = -1;
        this.mTextSizeNormal = 0;
        this.mTextSizeSelected = 0;
        this.mTextSizeHint = 0;
        this.mWidthOfHintText = 0;
        this.mWidthOfAlterHint = 0;
        this.mMarginStartOfHint = 0;
        this.mMarginEndOfHint = 0;
        this.mItemPaddingVertical = 0;
        this.mItemPaddingHorizontal = 0;
        this.mShownCount = 3;
        this.mMinShowIndex = -1;
        this.mMaxShowIndex = -1;
        this.mMinValue = 0;
        this.mMaxValue = 0;
        this.mMaxWidthOfDisplayedValues = 0;
        this.mMaxHeightOfDisplayedValues = 0;
        this.mMaxWidthOfAlterArrayWithMeasureHint = 0;
        this.mMaxWidthOfAlterArrayWithoutMeasureHint = 0;
        this.mPrevPickedIndex = 0;
        this.mMiniVelocityFling = 150;
        this.mScaledTouchSlop = 8;
        this.mFriction = 1.0f;
        this.mTextSizeNormalCenterYOffset = 0.0f;
        this.mTextSizeSelectedCenterYOffset = 0.0f;
        this.mWrapSelectorWheel = true;
        this.mCurrentItemIndexEffect = false;
        this.mHasInit = false;
        this.mWrapSelectorWheelCheck = true;
        this.mPendingWrapToLinear = false;
        this.mRespondChangeOnDetach = false;
        this.mRespondChangeInMainThread = true;
        this.mPaintText = new TextPaint();
        this.mTextWidthCache = new ConcurrentHashMap();
        this.mCrownTargetValue = -2;
        this.mScrollState = 0;
        this.mReceiver = new BroadcastReceiver() { // from class: com.heytap.wearable.support.widget.HeyNumberPicker.1
            @Override // android.content.BroadcastReceiver
            public void onReceive(Context context2, Intent intent) {
                HeyNumberPicker.this.mSmartMode = intent.getIntExtra("balance_mode", -1);
            }
        };
        this.tempValue = -1;
        this.isPlaySoundInScrolling = false;
        this.downYGlobal = 0.0f;
        this.downY = 0.0f;
        this.currY = 0.0f;
        this.mFlagMayPress = false;
        this.swipeFlag = -1;
        this.mCurrDrawFirstItemIndex = 0;
        this.mCurrDrawFirstItemY = 0;
        this.mCurrDrawGlobalY = 0;
        this.mSpecModeW = 0;
        this.mSpecModeH = 0;
        init(context);
    }

    public HeyNumberPicker(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.mTextColorNormal = 1728053247;
        this.mTextColorSelected = -1;
        this.mTextColorSelectedFocused = -14385921;
        this.mTextColorSelectedUnFocused = -1;
        this.mTextSizeNormal = 0;
        this.mTextSizeSelected = 0;
        this.mTextSizeHint = 0;
        this.mWidthOfHintText = 0;
        this.mWidthOfAlterHint = 0;
        this.mMarginStartOfHint = 0;
        this.mMarginEndOfHint = 0;
        this.mItemPaddingVertical = 0;
        this.mItemPaddingHorizontal = 0;
        this.mShownCount = 3;
        this.mMinShowIndex = -1;
        this.mMaxShowIndex = -1;
        this.mMinValue = 0;
        this.mMaxValue = 0;
        this.mMaxWidthOfDisplayedValues = 0;
        this.mMaxHeightOfDisplayedValues = 0;
        this.mMaxWidthOfAlterArrayWithMeasureHint = 0;
        this.mMaxWidthOfAlterArrayWithoutMeasureHint = 0;
        this.mPrevPickedIndex = 0;
        this.mMiniVelocityFling = 150;
        this.mScaledTouchSlop = 8;
        this.mFriction = 1.0f;
        this.mTextSizeNormalCenterYOffset = 0.0f;
        this.mTextSizeSelectedCenterYOffset = 0.0f;
        this.mWrapSelectorWheel = true;
        this.mCurrentItemIndexEffect = false;
        this.mHasInit = false;
        this.mWrapSelectorWheelCheck = true;
        this.mPendingWrapToLinear = false;
        this.mRespondChangeOnDetach = false;
        this.mRespondChangeInMainThread = true;
        this.mPaintText = new TextPaint();
        this.mTextWidthCache = new ConcurrentHashMap();
        this.mCrownTargetValue = -2;
        this.mScrollState = 0;
        this.mReceiver = new BroadcastReceiver() { // from class: com.heytap.wearable.support.widget.HeyNumberPicker.1
            @Override // android.content.BroadcastReceiver
            public void onReceive(Context context2, Intent intent) {
                HeyNumberPicker.this.mSmartMode = intent.getIntExtra("balance_mode", -1);
            }
        };
        this.tempValue = -1;
        this.isPlaySoundInScrolling = false;
        this.downYGlobal = 0.0f;
        this.downY = 0.0f;
        this.currY = 0.0f;
        this.mFlagMayPress = false;
        this.swipeFlag = -1;
        this.mCurrDrawFirstItemIndex = 0;
        this.mCurrDrawFirstItemY = 0;
        this.mCurrDrawGlobalY = 0;
        this.mSpecModeW = 0;
        this.mSpecModeH = 0;
        initAttr(context, attributeSet);
        init(context);
    }

    public HeyNumberPicker(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.mTextColorNormal = 1728053247;
        this.mTextColorSelected = -1;
        this.mTextColorSelectedFocused = -14385921;
        this.mTextColorSelectedUnFocused = -1;
        this.mTextSizeNormal = 0;
        this.mTextSizeSelected = 0;
        this.mTextSizeHint = 0;
        this.mWidthOfHintText = 0;
        this.mWidthOfAlterHint = 0;
        this.mMarginStartOfHint = 0;
        this.mMarginEndOfHint = 0;
        this.mItemPaddingVertical = 0;
        this.mItemPaddingHorizontal = 0;
        this.mShownCount = 3;
        this.mMinShowIndex = -1;
        this.mMaxShowIndex = -1;
        this.mMinValue = 0;
        this.mMaxValue = 0;
        this.mMaxWidthOfDisplayedValues = 0;
        this.mMaxHeightOfDisplayedValues = 0;
        this.mMaxWidthOfAlterArrayWithMeasureHint = 0;
        this.mMaxWidthOfAlterArrayWithoutMeasureHint = 0;
        this.mPrevPickedIndex = 0;
        this.mMiniVelocityFling = 150;
        this.mScaledTouchSlop = 8;
        this.mFriction = 1.0f;
        this.mTextSizeNormalCenterYOffset = 0.0f;
        this.mTextSizeSelectedCenterYOffset = 0.0f;
        this.mWrapSelectorWheel = true;
        this.mCurrentItemIndexEffect = false;
        this.mHasInit = false;
        this.mWrapSelectorWheelCheck = true;
        this.mPendingWrapToLinear = false;
        this.mRespondChangeOnDetach = false;
        this.mRespondChangeInMainThread = true;
        this.mPaintText = new TextPaint();
        this.mTextWidthCache = new ConcurrentHashMap();
        this.mCrownTargetValue = -2;
        this.mScrollState = 0;
        this.mReceiver = new BroadcastReceiver() { // from class: com.heytap.wearable.support.widget.HeyNumberPicker.1
            @Override // android.content.BroadcastReceiver
            public void onReceive(Context context2, Intent intent) {
                HeyNumberPicker.this.mSmartMode = intent.getIntExtra("balance_mode", -1);
            }
        };
        this.tempValue = -1;
        this.isPlaySoundInScrolling = false;
        this.downYGlobal = 0.0f;
        this.downY = 0.0f;
        this.currY = 0.0f;
        this.mFlagMayPress = false;
        this.swipeFlag = -1;
        this.mCurrDrawFirstItemIndex = 0;
        this.mCurrDrawFirstItemY = 0;
        this.mCurrDrawGlobalY = 0;
        this.mSpecModeW = 0;
        this.mSpecModeH = 0;
        initAttr(context, attributeSet);
        init(context);
    }

    private void initAttr(Context context, AttributeSet attributeSet) {
        if (attributeSet == null) {
            return;
        }
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.HeyNumberPicker);
        int indexCount = obtainStyledAttributes.getIndexCount();
        for (int i = 0; i < indexCount; i++) {
            int index = obtainStyledAttributes.getIndex(i);
            if (index == R$styleable.HeyNumberPicker_heyShownCount) {
                this.mShownCount = obtainStyledAttributes.getInt(index, 3);
            } else if (index == R$styleable.HeyNumberPicker_heyTextArray) {
                this.mDisplayedValues = convertCharSequenceArrayToStringArray(obtainStyledAttributes.getTextArray(index));
            } else if (index == R$styleable.HeyNumberPicker_heyTextColorNormal) {
                this.mTextColorNormal = obtainStyledAttributes.getColor(index, 1728053247);
            } else if (index == R$styleable.HeyNumberPicker_heyTextColorSelected) {
                int color = obtainStyledAttributes.getColor(index, -1);
                this.mTextColorSelectedUnFocused = color;
                this.mTextColorSelected = color;
            } else if (index == R$styleable.HeyNumberPicker_heyTextColorSelectedFocused) {
                this.mTextColorSelectedFocused = obtainStyledAttributes.getColor(index, -14385921);
            } else if (index == R$styleable.HeyNumberPicker_heyTextSizeNormal) {
                this.mTextSizeNormal = obtainStyledAttributes.getDimensionPixelSize(index, this.mDefatulTextSize);
            } else if (index == R$styleable.HeyNumberPicker_heyTextSizeSelected) {
                this.mTextSizeSelected = obtainStyledAttributes.getDimensionPixelSize(index, this.mSelectedTextSize);
            } else if (index == R$styleable.HeyNumberPicker_heyMinValue) {
                this.mMinShowIndex = obtainStyledAttributes.getInteger(index, 0);
            } else if (index == R$styleable.HeyNumberPicker_heyMaxValue) {
                this.mMaxShowIndex = obtainStyledAttributes.getInteger(index, 0);
            } else if (index == R$styleable.HeyNumberPicker_heyWrapSelectorWheel) {
                this.mWrapSelectorWheel = obtainStyledAttributes.getBoolean(index, true);
            } else if (index == R$styleable.HeyNumberPicker_heyItemPaddingVertical) {
                this.mItemPaddingVertical = 0;
            } else if (index == R$styleable.HeyNumberPicker_heyItemPaddingHorizontal) {
                this.mItemPaddingHorizontal = 0;
            } else if (index == R$styleable.HeyNumberPicker_heyRespondChangeOnDetached) {
                this.mRespondChangeOnDetach = obtainStyledAttributes.getBoolean(index, false);
            } else if (index == R$styleable.HeyNumberPicker_heyRespondChangeInMainThread) {
                this.mRespondChangeInMainThread = obtainStyledAttributes.getBoolean(index, true);
            } else if (index == R$styleable.HeyNumberPicker_heyTextEllipsize) {
                this.mTextEllipsize = "end";
            } else if (index == R$styleable.HeyNumberPicker_heyFontFamily) {
                this.mFontFamily = obtainStyledAttributes.getString(index);
            }
        }
        obtainStyledAttributes.recycle();
    }

    private void init(Context context) {
        this.mContext = context;
        this.mScroller = new Scroller(context);
        this.locale = context.getResources().getConfiguration().getLocales().get(0);
        this.mMiniVelocityFling = ViewConfiguration.get(getContext()).getScaledMinimumFlingVelocity();
        this.mScaledTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
        this.mPaintText.setColor(this.mTextColorNormal);
        this.mPaintText.setAntiAlias(true);
        this.mPaintText.setTextAlign(Paint.Align.CENTER);
        if (TextUtils.isEmpty(this.mFontFamily)) {
            this.mFontFamily = "oppo_fonts";
        }
        this.mPaintText.setTypeface(Typeface.create(this.mFontFamily, 0));
        this.mContext.getResources().getInteger(R$integer.heytap_first_item_fraction);
        this.mContext.getResources().getInteger(R$integer.heytap_second_item_fraction);
        this.mContext.getResources().getInteger(R$integer.heytap_third_item_fraction);
        this.mVerticalScrollFactor = ViewConfigurationCompat.getScaledVerticalScrollFactor(ViewConfiguration.get(context), context);
        int i = this.mShownCount;
        if (i % 2 == 0) {
            this.mShownCount = i + 1;
        }
        if (this.mMinShowIndex == -1 || this.mMaxShowIndex == -1) {
            updateValueForInit();
        }
        initHandler();
        setFocusable(true);
        setFocusableInTouchMode(true);
    }

    @SuppressLint({"HandlerLeak"})
    private void initHandler() {
        HandlerThread handlerThread = new HandlerThread("HandlerThread-For-Refreshing");
        this.mHandlerThread = handlerThread;
        handlerThread.start();
        if (this.mHandlerThread.getLooper() != null) {
            this.mHandlerInNewThread = new Handler(this.mHandlerThread.getLooper()) { // from class: com.heytap.wearable.support.widget.HeyNumberPicker.2
                @Override // android.os.Handler
                public void handleMessage(Message message) {
                    int willPickIndexByGlobalY;
                    int i;
                    int i2 = message.what;
                    if (i2 != 1) {
                        if (i2 == 2) {
                            HeyNumberPicker.this.respondPickedValueChanged(message.arg1, message.arg2, message.obj);
                            return;
                        }
                        if (i2 == 3) {
                            HeyNumberPicker.this.mCrownTargetValue = -2;
                            return;
                        }
                        if (i2 != 4) {
                            return;
                        }
                        HeyNumberPicker.this.stopScrolling();
                        Log.d("HeyNumberPicker", "onGenericMotionEvent: 333 msg.arg1 = " + message.arg1);
                        HeyNumberPicker.this.smoothScrollToValue(message.arg1);
                        return;
                    }
                    int i3 = 0;
                    if (!HeyNumberPicker.this.mScroller.isFinished()) {
                        if (HeyNumberPicker.this.mScrollState == 0) {
                            HeyNumberPicker.this.onScrollStateChange(1);
                        }
                        HeyNumberPicker heyNumberPicker = HeyNumberPicker.this;
                        if (heyNumberPicker.tempValue != heyNumberPicker.getValue()) {
                            HeyNumberPicker heyNumberPicker2 = HeyNumberPicker.this;
                            heyNumberPicker2.tempValue = heyNumberPicker2.getValue();
                            HeyNumberPicker.this.isPlaySoundInScrolling = true;
                            HeyNumberPicker.this.vibrate();
                        }
                        HeyNumberPicker.this.mHandlerInNewThread.sendMessageDelayed(HeyNumberPicker.this.getMsg(1, 0, 0, message.obj), 32L);
                        return;
                    }
                    if (!HeyNumberPicker.this.isPlaySoundInScrolling) {
                        HeyNumberPicker.this.isPlaySoundInScrolling = false;
                        HeyNumberPicker.this.vibrate();
                    }
                    HeyNumberPicker heyNumberPicker3 = HeyNumberPicker.this;
                    heyNumberPicker3.tempValue = -1;
                    if (heyNumberPicker3.mCurrDrawFirstItemY != 0) {
                        if (HeyNumberPicker.this.mScrollState == 0) {
                            HeyNumberPicker.this.onScrollStateChange(1);
                        }
                        if (HeyNumberPicker.this.mCurrDrawFirstItemY < (-HeyNumberPicker.this.mItemHeight) / 2) {
                            i = (int) (((HeyNumberPicker.this.mItemHeight + HeyNumberPicker.this.mCurrDrawFirstItemY) * 300.0f) / HeyNumberPicker.this.mItemHeight);
                            HeyNumberPicker.this.mScroller.startScroll(0, HeyNumberPicker.this.mCurrDrawGlobalY, 0, HeyNumberPicker.this.mCurrDrawFirstItemY + HeyNumberPicker.this.mItemHeight, 300);
                            HeyNumberPicker heyNumberPicker4 = HeyNumberPicker.this;
                            willPickIndexByGlobalY = heyNumberPicker4.getWillPickIndexByGlobalY(heyNumberPicker4.mCurrDrawGlobalY + HeyNumberPicker.this.mItemHeight + HeyNumberPicker.this.mCurrDrawFirstItemY);
                        } else {
                            i = (int) (((-HeyNumberPicker.this.mCurrDrawFirstItemY) * 300.0f) / HeyNumberPicker.this.mItemHeight);
                            HeyNumberPicker.this.mScroller.startScroll(0, HeyNumberPicker.this.mCurrDrawGlobalY, 0, HeyNumberPicker.this.mCurrDrawFirstItemY, 300);
                            HeyNumberPicker heyNumberPicker5 = HeyNumberPicker.this;
                            willPickIndexByGlobalY = heyNumberPicker5.getWillPickIndexByGlobalY(heyNumberPicker5.mCurrDrawGlobalY + HeyNumberPicker.this.mCurrDrawFirstItemY);
                        }
                        i3 = i;
                        HeyNumberPicker.this.postInvalidate();
                    } else {
                        HeyNumberPicker.this.onScrollStateChange(0);
                        HeyNumberPicker heyNumberPicker6 = HeyNumberPicker.this;
                        willPickIndexByGlobalY = heyNumberPicker6.getWillPickIndexByGlobalY(heyNumberPicker6.mCurrDrawGlobalY);
                    }
                    HeyNumberPicker heyNumberPicker7 = HeyNumberPicker.this;
                    Message msg = heyNumberPicker7.getMsg(2, heyNumberPicker7.mPrevPickedIndex, willPickIndexByGlobalY, message.obj);
                    if (HeyNumberPicker.this.mRespondChangeInMainThread) {
                        HeyNumberPicker.this.mHandlerInMainThread.sendMessageDelayed(msg, i3 * 2);
                    } else {
                        HeyNumberPicker.this.mHandlerInNewThread.sendMessageDelayed(msg, i3 * 2);
                    }
                }
            };
        }
        this.mHandlerInMainThread = new Handler() { // from class: com.heytap.wearable.support.widget.HeyNumberPicker.3
            @Override // android.os.Handler
            public void handleMessage(Message message) {
                super.handleMessage(message);
                int i = message.what;
                if (i == 2) {
                    HeyNumberPicker.this.respondPickedValueChanged(message.arg1, message.arg2, message.obj);
                } else {
                    if (i != 3) {
                        return;
                    }
                    HeyNumberPicker.this.requestLayout();
                }
            }
        };
    }

    private void respondPickedValueChangedInScrolling(int i, int i2) {
        this.mOnValueChangeListenerInScrolling.onValueChangeInScrolling(this, i, i2);
    }

    @Override // android.view.View
    protected void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
        updateMaxWHOfDisplayedValues(false);
        setMeasuredDimension(measureWidth(i), measureHeight(i2));
    }

    @Override // android.view.View
    protected void onSizeChanged(int i, int i2, int i3, int i4) {
        int i5;
        super.onSizeChanged(i, i2, i3, i4);
        this.mViewWidth = i;
        this.mViewHeight = i2;
        this.mItemHeight = (int) (((((i2 * 1.0d) - getPaddingTop()) - getPaddingBottom()) / this.mShownCount) + 0.5d);
        this.mViewCenterX = ((this.mViewWidth + getPaddingLeft()) - getPaddingRight()) / 2.0f;
        boolean z = false;
        if (getOneRecycleSize() > 1) {
            if (this.mHasInit) {
                i5 = getValue() - this.mMinValue;
            } else if (this.mCurrentItemIndexEffect) {
                i5 = this.mCurrDrawFirstItemIndex + ((this.mShownCount - 1) / 2);
            }
            if (this.mWrapSelectorWheel && this.mWrapSelectorWheelCheck) {
                z = true;
            }
            correctPositionByDefaultValue(i5, z);
            updateFontAttr();
            updateNotWrapYLimit();
            this.mHasInit = true;
        }
        i5 = 0;
        if (this.mWrapSelectorWheel) {
            z = true;
        }
        correctPositionByDefaultValue(i5, z);
        updateFontAttr();
        updateNotWrapYLimit();
        this.mHasInit = true;
    }

    @Override // android.view.View
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        HandlerThread handlerThread = this.mHandlerThread;
        if (handlerThread == null || !handlerThread.isAlive()) {
            initHandler();
        }
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("intent.action.smart_mode_change");
        getContext().registerReceiver(this.mReceiver, intentFilter);
    }

    @Override // android.view.View
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        getContext().unregisterReceiver(this.mReceiver);
        MediaPlayer mediaPlayer = this.mMediaPlayer;
        if (mediaPlayer != null) {
            mediaPlayer.release();
            this.mMediaPlayer = null;
        }
        VibrateHelper vibrateHelper = this.mHelper;
        if (vibrateHelper != null) {
            vibrateHelper.release();
        }
        this.mMaxValue = 0;
        this.mMinValue = 0;
        this.mHandlerThread.quit();
        if (this.mItemHeight == 0) {
            return;
        }
        if (!this.mScroller.isFinished()) {
            this.mScroller.abortAnimation();
            this.mCurrDrawGlobalY = this.mScroller.getCurrY();
            calculateFirstItemParameterByGlobalY();
            int i = this.mCurrDrawFirstItemY;
            if (i != 0) {
                int i2 = this.mItemHeight;
                if (i < (-i2) / 2) {
                    this.mCurrDrawGlobalY = this.mCurrDrawGlobalY + i2 + i;
                } else {
                    this.mCurrDrawGlobalY += i;
                }
                calculateFirstItemParameterByGlobalY();
            }
            onScrollStateChange(0);
        }
        int willPickIndexByGlobalY = getWillPickIndexByGlobalY(this.mCurrDrawGlobalY);
        int i3 = this.mPrevPickedIndex;
        if (willPickIndexByGlobalY != i3 && this.mRespondChangeOnDetach) {
            try {
                if (this.mOnValueChangeListener != null) {
                    this.mOnValueChangeListener.onValueChange(this, i3 + this.mMinValue, this.mMinValue + willPickIndexByGlobalY);
                }
                if (this.mOnValueChangeListenerRaw != null) {
                    this.mOnValueChangeListenerRaw.onValueChangeRelativeToRaw(this, this.mPrevPickedIndex, willPickIndexByGlobalY, this.mDisplayedValues);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        this.mPrevPickedIndex = willPickIndexByGlobalY;
    }

    public int getOneRecycleSize() {
        return (this.mMaxShowIndex - this.mMinShowIndex) + 1;
    }

    public void setDisplayedValues(String[] strArr) {
        if (strArr == null) {
            throw new IllegalArgumentException("newDisplayedValues should not be null.");
        }
        if ((this.mMaxValue - this.mMinValue) + 1 > strArr.length) {
            throw new IllegalArgumentException("mMaxValue - mMinValue + 1 should not be greater than mDisplayedValues.length, now ((mMaxValue - mMinValue + 1) is " + ((this.mMaxValue - this.mMinValue) + 1) + " newDisplayedValues.length is " + strArr.length + ", you need to set MaxValue and MinValue before setDisplayedValues(String[])");
        }
        updateContent(strArr);
        updateMaxWHOfDisplayedValues(true);
        this.mPrevPickedIndex = this.mMinShowIndex + 0;
        correctPositionByDefaultValue(0, this.mWrapSelectorWheel && this.mWrapSelectorWheelCheck);
        postInvalidate();
        this.mHandlerInMainThread.sendEmptyMessage(3);
    }

    public void smoothScrollToValue(int i) {
        smoothScrollToValue(getValue(), i, true);
    }

    public void smoothScrollToValue(int i, int i2, boolean z) {
        int i3;
        int refineValueByLimit = refineValueByLimit(i, this.mMinValue, this.mMaxValue, this.mWrapSelectorWheel && this.mWrapSelectorWheelCheck);
        int refineValueByLimit2 = refineValueByLimit(i2, this.mMinValue, this.mMaxValue, this.mWrapSelectorWheel && this.mWrapSelectorWheelCheck);
        if (this.mWrapSelectorWheel && this.mWrapSelectorWheelCheck) {
            i3 = refineValueByLimit2 - refineValueByLimit;
            int oneRecycleSize = getOneRecycleSize() / 2;
            if (i3 < (-oneRecycleSize) || oneRecycleSize < i3) {
                int oneRecycleSize2 = getOneRecycleSize();
                i3 = i3 > 0 ? i3 - oneRecycleSize2 : i3 + oneRecycleSize2;
            }
        } else {
            i3 = refineValueByLimit2 - refineValueByLimit;
        }
        setValue(refineValueByLimit);
        if (refineValueByLimit == refineValueByLimit2) {
            return;
        }
        scrollByIndexSmoothly(i3, z);
    }

    public void refreshByNewDisplayedValues(String[] strArr) {
        int minValue = getMinValue();
        int maxValue = (getMaxValue() - minValue) + 1;
        int length = (strArr.length + minValue) - 1;
        if ((length - minValue) + 1 > maxValue) {
            setDisplayedValues(strArr);
            setMaxValue(length);
        } else {
            setMaxValue(length);
            setDisplayedValues(strArr);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void respondPickedValueChanged(int i, int i2, Object obj) {
        onScrollStateChange(0);
        if ((i != i2 || (i == 0 && i2 == 0)) && (obj == null || !(obj instanceof Boolean) || ((Boolean) obj).booleanValue())) {
            OnValueChangeListener onValueChangeListener = this.mOnValueChangeListener;
            if (onValueChangeListener != null) {
                int i3 = this.mMinValue;
                onValueChangeListener.onValueChange(this, i + i3, i3 + i2);
            }
            OnValueChangeListenerRelativeToRaw onValueChangeListenerRelativeToRaw = this.mOnValueChangeListenerRaw;
            if (onValueChangeListenerRelativeToRaw != null) {
                onValueChangeListenerRelativeToRaw.onValueChangeRelativeToRaw(this, i, i2, this.mDisplayedValues);
            }
        }
        this.mPrevPickedIndex = i2;
        if (this.mPendingWrapToLinear) {
            this.mPendingWrapToLinear = false;
            internalSetWrapToLinear();
        }
    }

    private void scrollByIndexSmoothly(int i) {
        scrollByIndexSmoothly(i, true);
    }

    private void scrollByIndexSmoothly(int i, boolean z) {
        int pickedIndexRelativeToRaw;
        int pickedIndexRelativeToRaw2;
        int i2;
        int i3;
        if ((!this.mWrapSelectorWheel || !this.mWrapSelectorWheelCheck) && ((pickedIndexRelativeToRaw2 = (pickedIndexRelativeToRaw = getPickedIndexRelativeToRaw()) + i) > (i2 = this.mMaxShowIndex) || pickedIndexRelativeToRaw2 < (i2 = this.mMinShowIndex))) {
            i = i2 - pickedIndexRelativeToRaw;
        }
        int i4 = this.mCurrDrawFirstItemY;
        int i5 = this.mItemHeight;
        if (i4 < (-i5) / 2) {
            int i6 = i5 + i4;
            int i7 = (int) (((i4 + i5) * 300.0f) / i5);
            i3 = i < 0 ? (-i7) - (i * 300) : i7 + (i * 300);
            i4 = i6;
        } else {
            int i8 = (int) (((-i4) * 300.0f) / i5);
            i3 = i < 0 ? i8 - (i * 300) : i8 + (i * 300);
        }
        int i9 = i4 + (i * this.mItemHeight);
        if (i3 < 300) {
            i3 = 300;
        }
        if (i3 > 600) {
            i3 = 600;
        }
        this.mScroller.startScroll(0, this.mCurrDrawGlobalY, 0, i9, i3);
        if (z) {
            this.mHandlerInNewThread.sendMessageDelayed(getMsg(1), i3 / 4);
        } else {
            this.mHandlerInNewThread.sendMessageDelayed(getMsg(1, 0, 0, new Boolean(z)), i3 / 4);
        }
        postInvalidate();
    }

    public int getMinValue() {
        return this.mMinValue;
    }

    public int getMaxValue() {
        return this.mMaxValue;
    }

    public void setMaxValue(int i) {
        String[] strArr = this.mDisplayedValues;
        if (strArr == null) {
            throw new NullPointerException("mDisplayedValues should not be null");
        }
        int i2 = this.mMinValue;
        if ((i - i2) + 1 > strArr.length) {
            throw new IllegalArgumentException("(maxValue - mMinValue + 1) should not be greater than mDisplayedValues.length now  (maxValue - mMinValue + 1) is " + ((i - this.mMinValue) + 1) + " and mDisplayedValues.length is " + this.mDisplayedValues.length);
        }
        this.mMaxValue = i;
        int i3 = this.mMinShowIndex;
        int i4 = (i - i2) + i3;
        this.mMaxShowIndex = i4;
        setMinAndMaxShowIndex(i3, i4);
        updateNotWrapYLimit();
    }

    public void setValue(int i) {
        String[] strArr = this.mDisplayedValues;
        if (strArr != null && strArr.length > 1) {
            refreshByNewDisplayedValues(strArr);
        }
        int i2 = this.mMinValue;
        if (i < i2) {
            throw new IllegalArgumentException("should not set a value less than mMinValue, value is " + i);
        }
        if (i > this.mMaxValue) {
            throw new IllegalArgumentException("should not set a value greater than mMaxValue, value is " + i);
        }
        setPickedIndexRelativeToRaw(i - i2);
    }

    public int getValue() {
        return getPickedIndexRelativeToRaw() + this.mMinValue;
    }

    public void setPickedIndexRelativeToRaw(int i) {
        int i2 = this.mMinShowIndex;
        if (i2 <= -1 || i2 > i || i > this.mMaxShowIndex) {
            return;
        }
        this.mPrevPickedIndex = i;
        correctPositionByDefaultValue(i - i2, this.mWrapSelectorWheel && this.mWrapSelectorWheelCheck);
        postInvalidate();
    }

    public int getPickedIndexRelativeToRaw() {
        int i = this.mCurrDrawFirstItemY;
        if (i != 0) {
            int i2 = this.mItemHeight;
            if (i < (-i2) / 2) {
                return getWillPickIndexByGlobalY(this.mCurrDrawGlobalY + i2 + i);
            }
            return getWillPickIndexByGlobalY(this.mCurrDrawGlobalY + i);
        }
        return getWillPickIndexByGlobalY(this.mCurrDrawGlobalY);
    }

    public void setMinAndMaxShowIndex(int i, int i2) {
        setMinAndMaxShowIndex(i, i2, true);
    }

    public void setMinAndMaxShowIndex(int i, int i2, boolean z) {
        if (i > i2) {
            throw new IllegalArgumentException("minShowIndex should be less than maxShowIndex, minShowIndex is " + i + ", maxShowIndex is " + i2 + ".");
        }
        String[] strArr = this.mDisplayedValues;
        if (strArr == null) {
            throw new IllegalArgumentException("mDisplayedValues should not be null, you need to set mDisplayedValues first.");
        }
        if (i < 0) {
            throw new IllegalArgumentException("minShowIndex should not be less than 0, now minShowIndex is " + i);
        }
        if (i > strArr.length - 1) {
            throw new IllegalArgumentException("minShowIndex should not be greater than (mDisplayedValues.length - 1), now (mDisplayedValues.length - 1) is " + (this.mDisplayedValues.length - 1) + " minShowIndex is " + i);
        }
        if (i2 < 0) {
            throw new IllegalArgumentException("maxShowIndex should not be less than 0, now maxShowIndex is " + i2);
        }
        if (i2 > strArr.length - 1) {
            throw new IllegalArgumentException("maxShowIndex should not be greater than (mDisplayedValues.length - 1), now (mDisplayedValues.length - 1) is " + (this.mDisplayedValues.length - 1) + " maxShowIndex is " + i2);
        }
        this.mMinShowIndex = i;
        this.mMaxShowIndex = i2;
        if (z) {
            this.mPrevPickedIndex = i + 0;
            correctPositionByDefaultValue(0, this.mWrapSelectorWheel && this.mWrapSelectorWheelCheck);
            postInvalidate();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void onScrollStateChange(int i) {
        if (this.mScrollState == i) {
            return;
        }
        this.mScrollState = i;
        OnScrollListener onScrollListener = this.mOnScrollListener;
        if (onScrollListener != null) {
            onScrollListener.onScrollStateChange(this, i);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public int getWillPickIndexByGlobalY(int i) {
        int i2 = this.mItemHeight;
        if (i2 == 0) {
            return 0;
        }
        int indexByRawIndex = getIndexByRawIndex((i / i2) + (this.mShownCount / 2), getOneRecycleSize(), this.mWrapSelectorWheel && this.mWrapSelectorWheelCheck);
        int i3 = indexByRawIndex >= 0 ? indexByRawIndex : 0;
        if (i3 >= getOneRecycleSize()) {
            i3 = getOneRecycleSize() - 1;
        }
        if (i3 >= 0 && i3 < getOneRecycleSize()) {
            return i3 + this.mMinShowIndex;
        }
        throw new IllegalArgumentException("getWillPickIndexByGlobalY illegal index : " + i3 + " getOneRecycleSize() : " + getOneRecycleSize() + " mWrapSelectorWheel : " + this.mWrapSelectorWheel);
    }

    private int getIndexByRawIndex(int i, int i2, boolean z) {
        if (i2 <= 0) {
            return 0;
        }
        if (!z) {
            return i;
        }
        int i3 = i % i2;
        return i3 < 0 ? i3 + i2 : i3;
    }

    private void internalSetWrapToLinear() {
        correctPositionByDefaultValue(getPickedIndexRelativeToRaw() - this.mMinShowIndex, false);
        this.mWrapSelectorWheel = false;
        postInvalidate();
    }

    private void updateFontAttr() {
        int i = this.mTextSizeNormal;
        int i2 = this.mItemHeight;
        if (i > i2) {
            this.mTextSizeNormal = i2;
        }
        int i3 = this.mTextSizeSelected;
        int i4 = this.mItemHeight;
        if (i3 > i4) {
            this.mTextSizeSelected = i4;
        }
        TextPaint textPaint = this.mPaintText;
        if (textPaint == null) {
            throw new IllegalArgumentException("mPaintText should not be null.");
        }
        textPaint.setTextSize(this.mTextSizeSelected);
        this.mTextSizeSelectedCenterYOffset = getTextCenterYOffset(this.mPaintText.getFontMetrics());
        this.mPaintText.setTextSize(this.mTextSizeNormal);
        this.mTextSizeNormalCenterYOffset = getTextCenterYOffset(this.mPaintText.getFontMetrics());
    }

    private void updateNotWrapYLimit() {
        this.mNotWrapLimitYTop = 0;
        this.mNotWrapLimitYBottom = (-this.mShownCount) * this.mItemHeight;
        if (this.mDisplayedValues != null) {
            int oneRecycleSize = getOneRecycleSize();
            int i = this.mShownCount;
            int i2 = this.mItemHeight;
            this.mNotWrapLimitYTop = ((oneRecycleSize - (i / 2)) - 1) * i2;
            this.mNotWrapLimitYBottom = (-(i / 2)) * i2;
        }
    }

    private int limitY(int i) {
        if (this.mWrapSelectorWheel && this.mWrapSelectorWheelCheck) {
            return i;
        }
        int i2 = this.mNotWrapLimitYBottom;
        if (i < i2) {
            return i2;
        }
        int i3 = this.mNotWrapLimitYTop;
        return i > i3 ? i3 : i;
    }

    /* JADX WARN: Code restructure failed: missing block: B:8:0x000e, code lost:
    
        if (r0 != 3) goto L23;
     */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean dispatchTouchEvent(android.view.MotionEvent r10) {
        /*
            r9 = this;
            int r0 = r10.getAction()
            if (r0 == 0) goto L60
            r1 = 0
            r2 = 1
            if (r0 == r2) goto L57
            r3 = 2
            if (r0 == r3) goto L11
            r3 = 3
            if (r0 == r3) goto L57
            goto L6c
        L11:
            float r0 = r10.getX()
            float r4 = r10.getY()
            float r5 = r9.dispatchLocationX
            float r0 = r0 - r5
            float r0 = java.lang.Math.abs(r0)
            float r5 = r9.dispatchLocationY
            float r4 = r4 - r5
            float r4 = java.lang.Math.abs(r4)
            float r0 = r0 * r0
            float r5 = r4 * r4
            float r0 = r0 + r5
            double r5 = (double) r0
            double r5 = java.lang.Math.sqrt(r5)
            double r7 = (double) r4
            double r7 = r7 / r5
            double r4 = java.lang.Math.asin(r7)
            r6 = 4614256656552045848(0x400921fb54442d18, double:3.141592653589793)
            double r4 = r4 / r6
            r6 = 4640537203540230144(0x4066800000000000, double:180.0)
            double r4 = r4 * r6
            float r0 = (float) r4
            int r0 = java.lang.Math.round(r0)
            r9.angle = r0
            r4 = 45
            if (r0 >= r4) goto L50
            r9.swipeFlag = r2
            goto L52
        L50:
            r9.swipeFlag = r3
        L52:
            int r0 = r9.swipeFlag
            if (r0 != r2) goto L6c
            return r1
        L57:
            int r0 = r9.swipeFlag
            if (r0 != r2) goto L5c
            return r1
        L5c:
            r0 = -1
            r9.swipeFlag = r0
            goto L6c
        L60:
            float r0 = r10.getX()
            r9.dispatchLocationX = r0
            float r0 = r10.getY()
            r9.dispatchLocationY = r0
        L6c:
            boolean r9 = super.dispatchTouchEvent(r10)
            return r9
        */
        throw new UnsupportedOperationException("Method not decompiled: com.heytap.wearable.support.widget.HeyNumberPicker.dispatchTouchEvent(android.view.MotionEvent):boolean");
    }

    /* JADX WARN: Code restructure failed: missing block: B:25:0x0060, code lost:
    
        if (r1 < r4) goto L36;
     */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean onTouchEvent(android.view.MotionEvent r18) {
        /*
            Method dump skipped, instructions count: 276
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: com.heytap.wearable.support.widget.HeyNumberPicker.onTouchEvent(android.view.MotionEvent):boolean");
    }

    @Override // android.view.View
    protected void onFocusChanged(boolean z, int i, Rect rect) {
        super.onFocusChanged(z, i, rect);
        ValueAnimator valueAnimator = this.mTextSelectedColorAnimator;
        if (valueAnimator != null && valueAnimator.isStarted()) {
            this.mTextSelectedColorAnimator.end();
            this.mTextSelectedColorAnimator = null;
        }
        ValueAnimator ofArgb = ValueAnimator.ofArgb(z ? this.mTextColorSelectedUnFocused : this.mTextColorSelectedFocused, z ? this.mTextColorSelectedFocused : this.mTextColorSelectedUnFocused);
        this.mTextSelectedColorAnimator = ofArgb;
        ofArgb.setDuration(300L);
        this.mTextSelectedColorAnimator.setInterpolator(HeyWidgetUtils.getHeyInterpolator("EASE"));
        this.mTextSelectedColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.heytap.wearable.support.widget.HeyNumberPicker.4
            @Override // android.animation.ValueAnimator.AnimatorUpdateListener
            public void onAnimationUpdate(ValueAnimator valueAnimator2) {
                HeyNumberPicker.this.mTextColorSelected = ((Integer) valueAnimator2.getAnimatedValue()).intValue();
                HeyNumberPicker.this.postInvalidate();
            }
        });
        this.mTextSelectedColorAnimator.start();
    }

    private void click(MotionEvent motionEvent) {
        float y = motionEvent.getY();
        for (int i = 0; i < this.mShownCount; i++) {
            int i2 = this.mItemHeight;
            if (i2 * i <= y && y < i2 * (i + 1)) {
                clickItem(i);
                return;
            }
        }
    }

    private void clickItem(int i) {
        int i2;
        if (i < 0 || i >= (i2 = this.mShownCount)) {
            return;
        }
        scrollByIndexSmoothly(i - (i2 / 2));
    }

    private float getTextCenterYOffset(Paint.FontMetrics fontMetrics) {
        if (fontMetrics == null) {
            return 0.0f;
        }
        float f = fontMetrics.bottom;
        return ((f - fontMetrics.top) / 2.0f) - f;
    }

    private void correctPositionByDefaultValue(int i, boolean z) {
        int i2 = i - ((this.mShownCount - 1) / 2);
        this.mCurrDrawFirstItemIndex = i2;
        int indexByRawIndex = getIndexByRawIndex(i2, getOneRecycleSize(), z);
        this.mCurrDrawFirstItemIndex = indexByRawIndex;
        int i3 = this.mItemHeight;
        if (i3 == 0) {
            this.mCurrentItemIndexEffect = true;
            return;
        }
        this.mCurrDrawGlobalY = i3 * indexByRawIndex;
        int i4 = indexByRawIndex + (this.mShownCount / 2);
        this.mInScrollingPickedOldValue = i4;
        int oneRecycleSize = i4 % getOneRecycleSize();
        this.mInScrollingPickedOldValue = oneRecycleSize;
        if (oneRecycleSize < 0) {
            this.mInScrollingPickedOldValue = oneRecycleSize + getOneRecycleSize();
        }
        this.mInScrollingPickedNewValue = this.mInScrollingPickedOldValue;
        calculateFirstItemParameterByGlobalY();
    }

    @Override // android.view.View
    public void computeScroll() {
        if (this.mItemHeight != 0 && this.mScroller.computeScrollOffset()) {
            this.mCurrDrawGlobalY = this.mScroller.getCurrY();
            calculateFirstItemParameterByGlobalY();
            postInvalidate();
        }
    }

    private void calculateFirstItemParameterByGlobalY() {
        int round = Math.round(this.mCurrDrawGlobalY / this.mItemHeight);
        this.mCurrDrawFirstItemIndex = round;
        int i = this.mCurrDrawGlobalY;
        int i2 = this.mItemHeight;
        int i3 = -(i - (round * i2));
        this.mCurrDrawFirstItemY = i3;
        if (this.mOnValueChangeListenerInScrolling != null) {
            if ((-i3) > i2 / 2) {
                this.mInScrollingPickedNewValue = round + 1 + (this.mShownCount / 2);
            } else {
                this.mInScrollingPickedNewValue = round + (this.mShownCount / 2);
            }
            int oneRecycleSize = this.mInScrollingPickedNewValue % getOneRecycleSize();
            this.mInScrollingPickedNewValue = oneRecycleSize;
            if (oneRecycleSize < 0) {
                this.mInScrollingPickedNewValue = oneRecycleSize + getOneRecycleSize();
            }
            int i4 = this.mInScrollingPickedOldValue;
            int i5 = this.mInScrollingPickedNewValue;
            if (i4 != i5) {
                int i6 = this.mMinValue;
                respondPickedValueChangedInScrolling(i4 + i6, i5 + i6);
            }
            this.mInScrollingPickedOldValue = this.mInScrollingPickedNewValue;
        }
    }

    private void releaseVelocityTracker() {
        VelocityTracker velocityTracker = this.mVelocityTracker;
        if (velocityTracker != null) {
            velocityTracker.clear();
            this.mVelocityTracker.recycle();
            this.mVelocityTracker = null;
        }
    }

    private void updateMaxWHOfDisplayedValues(boolean z) {
        updateMaxWidthOfDisplayedValues();
        updateMaxHeightOfDisplayedValues();
        if (z) {
            if (this.mSpecModeW == Integer.MIN_VALUE || this.mSpecModeH == Integer.MIN_VALUE) {
                this.mHandlerInMainThread.sendEmptyMessage(3);
            }
        }
    }

    private int measureWidth(int i) {
        int mode = View.MeasureSpec.getMode(i);
        this.mSpecModeW = mode;
        int size = View.MeasureSpec.getSize(i);
        if (mode == 1073741824) {
            return size;
        }
        int paddingLeft = getPaddingLeft() + getPaddingRight() + Math.max(this.mMaxWidthOfAlterArrayWithMeasureHint, Math.max(this.mMaxWidthOfDisplayedValues, this.mMaxWidthOfAlterArrayWithoutMeasureHint) + (((Math.max(this.mWidthOfHintText, this.mWidthOfAlterHint) != 0 ? this.mMarginStartOfHint : 0) + Math.max(this.mWidthOfHintText, this.mWidthOfAlterHint) + (Math.max(this.mWidthOfHintText, this.mWidthOfAlterHint) == 0 ? 0 : this.mMarginEndOfHint) + (this.mItemPaddingHorizontal * 2)) * 2));
        return mode == Integer.MIN_VALUE ? Math.min(paddingLeft, size) : paddingLeft;
    }

    private int measureHeight(int i) {
        int mode = View.MeasureSpec.getMode(i);
        this.mSpecModeH = mode;
        int size = View.MeasureSpec.getSize(i);
        if (mode == 1073741824) {
            return size;
        }
        int paddingTop = getPaddingTop() + getPaddingBottom() + (this.mShownCount * (this.mMaxHeightOfDisplayedValues + (this.mItemPaddingVertical * 2)));
        return mode == Integer.MIN_VALUE ? Math.min(paddingTop, size) : paddingTop;
    }

    @Override // android.view.View
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        drawContent(canvas);
    }

    private void drawContent(Canvas canvas) {
        float f;
        int evaluateColor;
        float evaluateSize;
        float evaluateSize2;
        int i;
        float f2;
        for (int i2 = 0; i2 < this.mShownCount; i2++) {
            float f3 = this.mCurrDrawFirstItemY + (this.mItemHeight * i2);
            int indexByRawIndex = getIndexByRawIndex(this.mCurrDrawFirstItemIndex + i2, getOneRecycleSize(), this.mWrapSelectorWheel && this.mWrapSelectorWheelCheck);
            int i3 = this.mShownCount;
            if (i2 == i3 / 2) {
                float abs = 1.0f - (Math.abs(this.mCurrDrawFirstItemY) / this.mItemHeight);
                i = getEvaluateColor(abs, this.mTextColorNormal, this.mTextColorSelected);
                evaluateSize = getEvaluateSize(abs, this.mTextSizeNormal, this.mTextSizeSelected);
                f2 = getEvaluateSize(abs, this.mTextSizeNormalCenterYOffset, this.mTextSizeSelectedCenterYOffset);
            } else {
                if (i2 == (i3 / 2) + 1) {
                    int i4 = this.mCurrDrawFirstItemY;
                    f = i4 < 0 ? (-i4) / this.mItemHeight : 0.0f;
                    evaluateColor = getEvaluateColor(f, this.mTextColorNormal, this.mTextColorSelected);
                    evaluateSize = getEvaluateSize(f, this.mTextSizeNormal, this.mTextSizeSelected);
                    evaluateSize2 = getEvaluateSize(f, this.mTextSizeNormalCenterYOffset, this.mTextSizeSelectedCenterYOffset);
                } else {
                    int i5 = this.mCurrDrawFirstItemY;
                    f = i5 > 0 ? i5 / this.mItemHeight : 0.0f;
                    evaluateColor = getEvaluateColor(f, this.mTextColorNormal, this.mTextColorSelected);
                    evaluateSize = getEvaluateSize(f, this.mTextSizeNormal, this.mTextSizeSelected);
                    evaluateSize2 = getEvaluateSize(f, this.mTextSizeNormalCenterYOffset, this.mTextSizeSelectedCenterYOffset);
                }
                float f4 = evaluateSize2;
                i = evaluateColor;
                f2 = f4;
            }
            this.mPaintText.setColor(i);
            this.mPaintText.setTextSize(evaluateSize);
            if (indexByRawIndex >= 0 && indexByRawIndex < getOneRecycleSize()) {
                CharSequence charSequence = this.mDisplayedValues[indexByRawIndex + this.mMinShowIndex];
                if (this.mTextEllipsize != null) {
                    charSequence = TextUtils.ellipsize(charSequence, this.mPaintText, getWidth() - (this.mItemPaddingHorizontal * 2), getEllipsizeType());
                }
                canvas.drawText(charSequence.toString(), this.mViewCenterX, f3 + (this.mItemHeight / 2) + f2, this.mPaintText);
            } else if (!TextUtils.isEmpty(this.mEmptyItemHint)) {
                canvas.drawText(this.mEmptyItemHint, this.mViewCenterX, f3 + (this.mItemHeight / 2) + f2, this.mPaintText);
            }
        }
    }

    private TextUtils.TruncateAt getEllipsizeType() {
        char c;
        String str = this.mTextEllipsize;
        int hashCode = str.hashCode();
        if (hashCode == -1074341483) {
            if (str.equals("middle")) {
                c = 1;
            }
            c = 65535;
        } else if (hashCode != 100571) {
            if (hashCode == 109757538 && str.equals("start")) {
                c = 0;
            }
            c = 65535;
        } else {
            if (str.equals("end")) {
                c = 2;
            }
            c = 65535;
        }
        if (c == 0) {
            return TextUtils.TruncateAt.START;
        }
        if (c == 1) {
            return TextUtils.TruncateAt.MIDDLE;
        }
        if (c == 2) {
            return TextUtils.TruncateAt.END;
        }
        throw new IllegalArgumentException("Illegal text ellipsize type.");
    }

    private void updateMaxWidthOfDisplayedValues() {
        float textSize = this.mPaintText.getTextSize();
        this.mPaintText.setTextSize(this.mTextSizeSelected);
        this.mMaxWidthOfDisplayedValues = getMaxWidthOfTextArray(this.mDisplayedValues, this.mPaintText);
        this.mMaxWidthOfAlterArrayWithMeasureHint = getMaxWidthOfTextArray(this.mAlterTextArrayWithMeasureHint, this.mPaintText);
        this.mMaxWidthOfAlterArrayWithoutMeasureHint = getMaxWidthOfTextArray(this.mAlterTextArrayWithoutMeasureHint, this.mPaintText);
        this.mPaintText.setTextSize(this.mTextSizeHint);
        this.mWidthOfAlterHint = getTextWidth(this.mAlterHint, this.mPaintText);
        this.mPaintText.setTextSize(textSize);
    }

    private int getMaxWidthOfTextArray(CharSequence[] charSequenceArr, Paint paint) {
        if (charSequenceArr == null) {
            return 0;
        }
        int i = 0;
        for (CharSequence charSequence : charSequenceArr) {
            if (charSequence != null) {
                i = Math.max(getTextWidth(charSequence, paint), i);
            }
        }
        return i;
    }

    private int getTextWidth(CharSequence charSequence, Paint paint) {
        Integer num;
        if (TextUtils.isEmpty(charSequence)) {
            return 0;
        }
        String charSequence2 = charSequence.toString();
        if (this.mTextWidthCache.containsKey(charSequence2) && (num = this.mTextWidthCache.get(charSequence2)) != null) {
            return num.intValue();
        }
        int measureText = (int) (paint.measureText(charSequence2) + 0.5f);
        this.mTextWidthCache.put(charSequence2, Integer.valueOf(measureText));
        return measureText;
    }

    private void updateMaxHeightOfDisplayedValues() {
        float textSize = this.mPaintText.getTextSize();
        this.mPaintText.setTextSize(this.mTextSizeSelected);
        this.mMaxHeightOfDisplayedValues = (int) ((this.mPaintText.getFontMetrics().bottom - this.mPaintText.getFontMetrics().top) + 0.5d);
        this.mPaintText.setTextSize(textSize);
    }

    private void updateContent(String[] strArr) {
        this.mDisplayedValues = strArr;
        updateWrapStateByContent();
    }

    private void updateValueForInit() {
        inflateDisplayedValuesIfNull();
        updateWrapStateByContent();
        if (this.mMinShowIndex == -1) {
            this.mMinShowIndex = 0;
        }
        if (this.mMaxShowIndex == -1) {
            this.mMaxShowIndex = this.mDisplayedValues.length - 1;
        }
        setMinAndMaxShowIndex(this.mMinShowIndex, this.mMaxShowIndex, false);
    }

    private void inflateDisplayedValuesIfNull() {
        if (this.mDisplayedValues == null) {
            this.mDisplayedValues = r0;
            String[] strArr = {"0"};
        }
    }

    private void updateWrapStateByContent() {
        this.mWrapSelectorWheelCheck = this.mDisplayedValues.length > this.mShownCount;
    }

    private int refineValueByLimit(int i, int i2, int i3, boolean z) {
        if (!z) {
            return i > i3 ? i3 : i < i2 ? i2 : i;
        }
        if (i > i3) {
            return (((i - i3) % getOneRecycleSize()) + i2) - 1;
        }
        return i < i2 ? ((i - i2) % getOneRecycleSize()) + i3 + 1 : i;
    }

    public void stopScrolling() {
        Scroller scroller = this.mScroller;
        if (scroller == null || scroller.isFinished()) {
            return;
        }
        Scroller scroller2 = this.mScroller;
        scroller2.startScroll(0, scroller2.getCurrY(), 0, 0, 1);
        this.mScroller.abortAnimation();
        postInvalidate();
    }

    /* JADX WARN: Removed duplicated region for block: B:14:0x0094  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x011b  */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean onGenericMotionEvent(android.view.MotionEvent r12) {
        /*
            Method dump skipped, instructions count: 392
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: com.heytap.wearable.support.widget.HeyNumberPicker.onGenericMotionEvent(android.view.MotionEvent):boolean");
    }

    private void crownSmoothScrollToValue(float f) {
        int i = this.mCrownTargetValue;
        if (i < 0) {
            this.mCrownTargetValue = f > 0.0f ? getValue() + 1 : getValue() - 1;
        } else {
            this.mCrownTargetValue = f > 0.0f ? i + 1 : i - 1;
        }
        stopScrolling();
        smoothScrollToValue(this.mCrownTargetValue);
        this.mHandlerInNewThread.sendMessageDelayed(getMsg(3), 100L);
    }

    private Message getMsg(int i) {
        return getMsg(i, 0, 0, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public Message getMsg(int i, int i2, int i3, Object obj) {
        Message obtain = Message.obtain();
        obtain.what = i;
        obtain.arg1 = i2;
        obtain.arg2 = i3;
        obtain.obj = obj;
        return obtain;
    }

    private String[] convertCharSequenceArrayToStringArray(CharSequence[] charSequenceArr) {
        if (charSequenceArr == null) {
            return null;
        }
        String[] strArr = new String[charSequenceArr.length];
        for (int i = 0; i < charSequenceArr.length; i++) {
            strArr[i] = charSequenceArr[i].toString();
        }
        return strArr;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void vibrate() {
        if (this.mHelper == null) {
            this.mHelper = new VibrateHelper(getContext());
        }
        this.mHelper.heytapVibrate(302);
    }

    @Override // android.view.View
    protected void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        if (configuration.getLocales().get(0) == null || configuration.getLocales().get(0).getCountry().equals(this.locale.getCountry())) {
            return;
        }
        this.locale = configuration.getLocales().get(0);
    }
}