modify numberpicker

This commit is contained in:
houzh 2023-04-25 10:51:58 +00:00
parent f67a974aba
commit e9a6607b26

View File

@ -463,7 +463,6 @@ void NumberPicker::scrollBy(int x, int y){
mCurrentScrollOffset = mInitialScrollOffset; mCurrentScrollOffset = mInitialScrollOffset;
} }
} }
LOGV("%d,%d:(%d->%d)",x,y,startScrollOffset,mCurrentScrollOffset);
if (startScrollOffset != mCurrentScrollOffset) { if (startScrollOffset != mCurrentScrollOffset) {
onScrollChanged(0, mCurrentScrollOffset, 0, startScrollOffset); onScrollChanged(0, mCurrentScrollOffset, 0, startScrollOffset);
} }
@ -854,11 +853,11 @@ int NumberPicker::resolveSizeAndStateRespectingMinSize(int minSize, int measured
} }
void NumberPicker::initializeSelectorWheelIndices(){ void NumberPicker::initializeSelectorWheelIndices(){
const int count= (int)mSelectorIndices.size(); const int valueCount= (mMaxValue-mMinValue+1);
mSelectorIndices.resize(std::min((mMaxValue-mMinValue+1),mMaxSelectorIndices)); mSelectorIndices.resize(std::min(valueCount,mMaxSelectorIndices));
mMiddleItemIndex = mSelectorIndices.size()/2; mMiddleItemIndex = mSelectorIndices.size()/2;
for (int i = 0; i < count; i++) { for (int i = 0; i < mMaxSelectorIndices; i++) {
int selectorIndex = ( count + mValue + (i - mMiddleItemIndex) ) % count; int selectorIndex = ( valueCount + mValue + (i - mMiddleItemIndex) ) % valueCount;
if (mWrapSelectorWheel) { if (mWrapSelectorWheel) {
selectorIndex = getWrappedSelectorIndex(selectorIndex); selectorIndex = getWrappedSelectorIndex(selectorIndex);
} }