Skip to content

Commit

Permalink
TIMOB-9955: Android: ScrollView with a wrap view becomes unscrollable…
Browse files Browse the repository at this point in the history
… on android Ti 2.1
  • Loading branch information
Allen Yeung committed Jul 25, 2012
1 parent dc02154 commit 533f6d1
Showing 1 changed file with 14 additions and 3 deletions.
Expand Up @@ -22,6 +22,8 @@

import android.content.Context;
import android.graphics.Canvas;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -47,10 +49,20 @@ private class TiScrollViewLayout extends TiCompositeLayout
private int parentWidth = 0;
private int parentHeight = 0;
private boolean canCancelEvents = true;
private GestureDetector gestureDetector;

public TiScrollViewLayout(Context context, LayoutArrangement arrangement)
{
super(context, arrangement, proxy);
gestureDetector = new GestureDetector(new SimpleOnGestureListener()
{
@Override
public void onLongPress(MotionEvent e)
{
// Only do this for long presses to match iOS behavior
requestDisallowInterceptTouchEvent(true);
}
});
}

public void setParentWidth(int width)
Expand All @@ -72,11 +84,10 @@ public void setCanCancelEvents(boolean value)
public boolean dispatchTouchEvent(MotionEvent ev)
{
// If canCancelEvents is false, then we want to prevent the scroll view from canceling the touch
// events of the child view
// events of the child view by calling requestDisallowInterceptTouchEvent(true)
if (!canCancelEvents) {
requestDisallowInterceptTouchEvent(true);
gestureDetector.onTouchEvent(ev);
}

return super.dispatchTouchEvent(ev);
}

Expand Down

0 comments on commit 533f6d1

Please sign in to comment.