You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is more a request for enhancement, with the iPhone equivalent (yes I know
android is not iPhone, but we can always 'steal' some of their usability
ideas), in a number picker (could be any item though), if you click on a number
that is not in the middle, that number is then pushed to the middle (as apposed
to just dragging it to the middle). Its a neat enhancement.
I didnt want to alter the core code to make upgrades possible in the future so
I extended the class with the below, but you could potentially add the
'(getHeight()/2) - event.getY())' bit into your action_up with some invalidates
and it would be done. Its your code so your call, just a sugestion. Anyway,
here is the important bits of the overriding class ...
public class TouchWheelView extends WheelView {
private boolean isScrollingPerformed;
private float clickDownY = 0.0F ;
/**
* Constructor
*/
public TouchWheelView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
/**
* Constructor
*/
public TouchWheelView(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* Constructor
*/
public TouchWheelView(Context context) {
super(context);
this.onFinishInflate();
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
// Add listeners to emulate the isScrollingPerformed behaviour
this.addScrollingListener(new OnWheelScrollListener() {
public void onScrollingStarted(WheelView wheel) {
isScrollingPerformed = true;
}
public void onScrollingFinished(WheelView wheel) {
isScrollingPerformed = false;
}
});
}
@Override
public boolean onTouchEvent(MotionEvent event) {
WheelAdapter adapter = getAdapter();
if (adapter == null) {
return true;
}
// for my event, if an item is click (when button goes up), if click is outside focus region, emulate a move
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
clickDownY = event.getY();
isScrollingPerformed = false ;
break;
}
case MotionEvent.ACTION_MOVE: {
isScrollingPerformed = true ;
break;
}
case MotionEvent.ACTION_UP:
if (!isScrollingPerformed) {
// Pretend to to a move
event.setAction(MotionEvent.ACTION_MOVE);
event.setLocation(event.getX(), clickDownY + ((getHeight()/2) - event.getY()));
super.onTouchEvent(event);
// Now reset back to what it was
event.setAction(MotionEvent.ACTION_UP);
event.setLocation(event.getX(), (getHeight()/2));
}
break;
}
return super.onTouchEvent(event);
}
}
Original issue reported on code.google.com by davidhil...@gmail.com on 5 Dec 2010 at 1:01
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
davidhil...@gmail.com
on 5 Dec 2010 at 1:01The text was updated successfully, but these errors were encountered: