czfyzy / android-wheel

Automatically exported from code.google.com/p/android-wheel
0 stars 0 forks source link

Issue #5 is not fixed #48

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Issue #5 is marked as fixed but as of Android 4.0 the behavior is back.

I have the latest version of the Wheel but running on a real device (Samsung 
Galaxy SII) with Android 4.0.4 the Wheel scrolls inside a ScrollView but it is 
VERY unresponsive. I need to make sure to click precisely in the center of the 
wheel hold my position for a moment and slowly scroll. With the same wheel 
outside of the ScrollView it functions flawlessly.

My layout:

--------------main layout
LinearLayout
 ScrollView
  LinearLayout
-----------------compound control layout
   LinearLayout
    WheelView
    WheelView
    WheelView

Not sure if it matters but the direct parent of the wheel is not the ScrollView 
so the call to getParent().requestDisallowInterceptTouchEvent(true) might not 
be working properly. The WheelView is inside a compound control and I believe 
the parent LinearLayout is being merged into the next parent so the end result 
overall is only 2 LinearLayouts not 3 (I could be mistaken about that). 

I tried to put a while loop in its place that recursively went through all 
parent checking for ScrollViews and making the appropriate call as needed but 
this didn't work either.

Original issue reported on code.google.com by akuse...@gmail.com on 4 Feb 2013 at 6:31

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I found a solution to this. In WheelView.java on line 611 change the switch 
statement to the following:

switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN: //added to fix problem
    case MotionEvent.ACTION_MOVE:
        if (getParent() != null) {
            getParent().requestDisallowInterceptTouchEvent(true);
    }
    break;

    case MotionEvent.ACTION_UP:
        if (getParent() != null) { //added to fix problem, this may be uneeded
            getParent().requestDisallowInterceptTouchEvent(false);
        }

    if (!isScrollingPerformed) {
        int distance = (int) event.getY() - getHeight() / 2;
        if (distance > 0) {
            distance += getItemHeight() / 2;
        } else {
                distance -= getItemHeight() / 2;
        }
        int items = distance / getItemHeight();
        if (items != 0 && isValidItemIndex(currentItem + items)) {
                notifyClickListenersAboutClick(currentItem + items);
            }
    }
    break;
}

Original comment by akuse...@gmail.com on 4 Feb 2013 at 6:54