5

I use a SlidingDrawer as my main layout. Inside the content area I have a Fragment (which contains a ListView) When the activity first loads everything is great, the listview scrolls correctly.

When I start a different activity and then come back, the first scroll motion I try is intercepted by the SlidindDrawer, and either opens or closes it. As soon as you stop the scroll and pick up your finger, the ListView is again able to scroll.

I would like the ListView to be able to scroll when the activity resumes. And just generally be able to control whether the SlidingDrawer is the one getting focus.

UPDATE:

I have narrowed the issue down a little bit. I have extended the SLidingDrawer to allow for click on buttons in the handle with the following code.

Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    super.onInterceptTouchEvent(event);

    if (mHandleLayout != null) {
        int clickX = (int) (event.getX() - mHandleLayout.getLeft());
        int clickY = (int) (event.getY() - mHandleLayout.getTop());

        if (isAnyClickableChildHit(mHandleLayout, clickX, clickY))
            return false;
    }
    return super.onInterceptTouchEvent(event);
}

private boolean isAnyClickableChildHit(ViewGroup viewGroup, int clickX, int clickY) {
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        View childView = viewGroup.getChildAt(i);

        if (TAG_CLICK_INTERCEPTED.equals(childView.getTag())) {
            childView.getHitRect(mHitRect);

            if (mHitRect.contains(clickX, clickY))
                return true;
        }

        if (childView instanceof ViewGroup && isAnyClickableChildHit((ViewGroup) childView, clickX, clickY))
            return true;
    }
    return false;
}

If I comment out the onInterceptTouchEvent function, everything seems to work normally.

Leo
  • 4,652
  • 6
  • 32
  • 42

1 Answers1

0

I noticed that you are calling super.onInterceptTouchEvent(event) twice. Why? That could be the reason for the issue.

Ron
  • 24,175
  • 8
  • 56
  • 97
  • Well yes that is the cause for the issue. However, the reason it is called in the first line is to enable dragging action even when the clickable buttons are being dragged on. I have mitigated the issue by disabling the first super.onInterceptTouchEvent for a couple events after the activity has resumed. – Leo Sep 13 '12 at 19:13