am 1caa092f: Allow click listener registration in NumberPicker.
* commit '1caa092f94aaa4b9b7b382263dfd13581d92d2de': Allow click listener registration in NumberPicker.
This commit is contained in:
@@ -427,12 +427,12 @@ public class NumberPicker extends LinearLayout {
|
|||||||
* Flag whether to ignore move events - we ignore such when we show in IME
|
* Flag whether to ignore move events - we ignore such when we show in IME
|
||||||
* to prevent the content from scrolling.
|
* to prevent the content from scrolling.
|
||||||
*/
|
*/
|
||||||
private boolean mIngonreMoveEvents;
|
private boolean mIgnoreMoveEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag whether to show soft input on tap.
|
* Flag whether to perform a click on tap.
|
||||||
*/
|
*/
|
||||||
private boolean mShowSoftInputOnTap;
|
private boolean mPerformClickOnTap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The top of the top selection divider.
|
* The top of the top selection divider.
|
||||||
@@ -808,8 +808,8 @@ public class NumberPicker extends LinearLayout {
|
|||||||
mInputText.setVisibility(View.INVISIBLE);
|
mInputText.setVisibility(View.INVISIBLE);
|
||||||
mLastDownOrMoveEventY = mLastDownEventY = event.getY();
|
mLastDownOrMoveEventY = mLastDownEventY = event.getY();
|
||||||
mLastDownEventTime = event.getEventTime();
|
mLastDownEventTime = event.getEventTime();
|
||||||
mIngonreMoveEvents = false;
|
mIgnoreMoveEvents = false;
|
||||||
mShowSoftInputOnTap = false;
|
mPerformClickOnTap = false;
|
||||||
// Handle pressed state before any state change.
|
// Handle pressed state before any state change.
|
||||||
if (mLastDownEventY < mTopSelectionDividerTop) {
|
if (mLastDownEventY < mTopSelectionDividerTop) {
|
||||||
if (mScrollState == OnScrollListener.SCROLL_STATE_IDLE) {
|
if (mScrollState == OnScrollListener.SCROLL_STATE_IDLE) {
|
||||||
@@ -840,7 +840,7 @@ public class NumberPicker extends LinearLayout {
|
|||||||
postChangeCurrentByOneFromLongPress(
|
postChangeCurrentByOneFromLongPress(
|
||||||
true, ViewConfiguration.getLongPressTimeout());
|
true, ViewConfiguration.getLongPressTimeout());
|
||||||
} else {
|
} else {
|
||||||
mShowSoftInputOnTap = true;
|
mPerformClickOnTap = true;
|
||||||
postBeginSoftInputOnLongPressCommand();
|
postBeginSoftInputOnLongPressCommand();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -861,7 +861,7 @@ public class NumberPicker extends LinearLayout {
|
|||||||
int action = event.getActionMasked();
|
int action = event.getActionMasked();
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case MotionEvent.ACTION_MOVE: {
|
case MotionEvent.ACTION_MOVE: {
|
||||||
if (mIngonreMoveEvents) {
|
if (mIgnoreMoveEvents) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
float currentMoveY = event.getY();
|
float currentMoveY = event.getY();
|
||||||
@@ -893,9 +893,9 @@ public class NumberPicker extends LinearLayout {
|
|||||||
int deltaMoveY = (int) Math.abs(eventY - mLastDownEventY);
|
int deltaMoveY = (int) Math.abs(eventY - mLastDownEventY);
|
||||||
long deltaTime = event.getEventTime() - mLastDownEventTime;
|
long deltaTime = event.getEventTime() - mLastDownEventTime;
|
||||||
if (deltaMoveY <= mTouchSlop && deltaTime < ViewConfiguration.getTapTimeout()) {
|
if (deltaMoveY <= mTouchSlop && deltaTime < ViewConfiguration.getTapTimeout()) {
|
||||||
if (mShowSoftInputOnTap) {
|
if (mPerformClickOnTap) {
|
||||||
mShowSoftInputOnTap = false;
|
mPerformClickOnTap = false;
|
||||||
showSoftInput();
|
performClick();
|
||||||
} else {
|
} else {
|
||||||
int selectorIndexOffset = (eventY / mSelectorElementHeight)
|
int selectorIndexOffset = (eventY / mSelectorElementHeight)
|
||||||
- SELECTOR_MIDDLE_ITEM_INDEX;
|
- SELECTOR_MIDDLE_ITEM_INDEX;
|
||||||
@@ -1188,6 +1188,27 @@ public class NumberPicker extends LinearLayout {
|
|||||||
setValueInternal(value, false);
|
setValueInternal(value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean performClick() {
|
||||||
|
if (!mHasSelectorWheel) {
|
||||||
|
return super.performClick();
|
||||||
|
} else if (!super.performClick()) {
|
||||||
|
showSoftInput();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean performLongClick() {
|
||||||
|
if (!mHasSelectorWheel) {
|
||||||
|
return super.performLongClick();
|
||||||
|
} else if (!super.performLongClick()) {
|
||||||
|
showSoftInput();
|
||||||
|
mIgnoreMoveEvents = true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the soft input for its input text.
|
* Shows the soft input for its input text.
|
||||||
*/
|
*/
|
||||||
@@ -2166,8 +2187,7 @@ public class NumberPicker extends LinearLayout {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
showSoftInput();
|
performLongClick();
|
||||||
mIngonreMoveEvents = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2295,7 +2315,14 @@ public class NumberPicker extends LinearLayout {
|
|||||||
}
|
}
|
||||||
case AccessibilityNodeInfo.ACTION_CLICK: {
|
case AccessibilityNodeInfo.ACTION_CLICK: {
|
||||||
if (NumberPicker.this.isEnabled()) {
|
if (NumberPicker.this.isEnabled()) {
|
||||||
showSoftInput();
|
performClick();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
case AccessibilityNodeInfo.ACTION_LONG_CLICK: {
|
||||||
|
if (NumberPicker.this.isEnabled()) {
|
||||||
|
performLongClick();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user