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-13610] correctly handle scrollableView inside tableview/listview and scrollview AGAIN #4748

Merged
merged 6 commits into from
Oct 10, 2013
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -16,12 +16,14 @@
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiEventHelper;
import org.appcelerator.titanium.util.TiUIHelper;
import org.appcelerator.titanium.view.TiCompositeLayout;
import org.appcelerator.titanium.view.TiCompositeLayout.LayoutParams;
import org.appcelerator.titanium.view.TiUIView;

import ti.modules.titanium.ui.ScrollableViewProxy;
import ti.modules.titanium.ui.widget.TiUIScrollView.TiScrollViewLayout;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
Expand All @@ -33,8 +35,11 @@
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary import in line 19, 38 and 40.


@SuppressLint("NewApi")
public class TiUIScrollableView extends TiUIView
{
private static final String TAG = "TiUIScrollableView";
Expand Down Expand Up @@ -100,6 +105,8 @@ public boolean onInterceptTouchEvent(MotionEvent event) {
@Override
public void onPageScrollStateChanged(int scrollState)
{
mPager.requestDisallowInterceptTouchEvent(state != ViewPager.SCROLL_STATE_IDLE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean "scrollState" here?


if ((scrollState == ViewPager.SCROLL_STATE_IDLE) && isValidScroll) {
int oldIndex = mCurIndex;

Expand Down Expand Up @@ -550,27 +557,6 @@ public boolean onTrackballEvent(MotionEvent event)
return super.onTrackballEvent(event);
}

@Override
public boolean dispatchTouchEvent(MotionEvent ev)
{
// If the parent is a scroll view, then we prevent the scroll view from intercepting touch events
if (getParent() instanceof TiScrollViewLayout) {
int action = ev.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
requestDisallowInterceptTouchEvent(true);
break;

case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
requestDisallowInterceptTouchEvent(false);
break;

}
}
return super.dispatchTouchEvent(ev);
}

@Override
public boolean dispatchKeyEvent(KeyEvent event)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import android.view.Gravity;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewParent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary import.

import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;

Expand Down Expand Up @@ -1005,4 +1006,17 @@ public static void firePostLayoutEvent(TiViewProxy proxy)
proxy.fireEvent(TiC.EVENT_POST_LAYOUT, null, false);
}
}

public static boolean isViewInsideViewOfClass(View view, Class<?>[] testClass) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems you don't need this function at all.

ViewParent parent = view.getParent();
if (parent != null) {
for (int i = 0; i < testClass.length; i++) {
if (testClass[i].isAssignableFrom(parent.getClass()))
return true;
}
if (parent instanceof View)
return isViewInsideViewOfClass((View)parent, testClass);
}
return false;
}
}