Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMOB-9955: Android: ScrollView with a wrap view becomes unscrollable on... #2634

Merged
merged 1 commit into from
Jul 25, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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