2

I am using pullToRefreshLibrary provided by Chris Banes. I have gridView which is containg whole list of data. I tried pullToRefreshGridViewActivity but it was too slow so I am trying to use pullToRefreshScrollViewActivity over my gridView to handle it. The problem is that when I do so, scrollView is handling all touch events and I cannot swipe over gridView. I need to lock it and pass touches to gridView. here is my xml :

<com.handmark.pulltorefresh.library.PullToRefreshScrollView
        xmlns:ptr="http://schemas.android.com/apk/res-auto"
        android:id="@+id/pull_refresh_scrollview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        ptr:ptrAnimationStyle="flip" >

        <com.asd.android.dda.ui.controls.ExpandableGridView
            android:id="@+id/gridview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clipToPadding="false"
            android:drawSelectorOnTop="true"
            android:fadingEdge="none"
            android:gravity="top"
            android:horizontalSpacing="@dimen/image_grid_hspacing"
            android:listSelector="@drawable/selector_shadow"
            android:numColumns="@integer/grid_num_cols"
            android:paddingBottom="50dp"
            android:scrollbarAlwaysDrawVerticalTrack="false"
            android:scrollbars="none"
            android:scrollingCache="true"
            android:smoothScrollbar="false"
            android:stretchMode="columnWidth"
            android:verticalSpacing="@dimen/image_grid_vspacing"
            android:visibility="visible" />
    </com.handmark.pulltorefresh.library.PullToRefreshScrollView>

I tried to lock scrollView with :

mScrollView.requestDisallowInterceptTouchEvent(true);
gridView.requestDisallowInterceptTouchEvent(true);

mScrollView.setOnTouchListener(new OnTouchListener(){ 
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return false; 
    }
});
mScrollView.setOnTouchListener(null);

But none of these work. And I can't use here custom ScrollView to override onInterceptTouchEvent.

filipp.kowalski
  • 5,495
  • 7
  • 27
  • 45
  • define "too slow". that sounds strange as it is pretty much supposed to be made for that kind of use – njzk2 Sep 05 '13 at 15:00
  • It's pretty big library of data with images, two in a row and pretty big list. I've compared it with pull-to-refresh implementation of GridView and it is visibly slower. It's probably of modificiations made in GridView style. That's why I want to use ScrollView which I want to turn on on touch only when user is on top of GridView. – filipp.kowalski Sep 05 '13 at 15:02
  • 1
    this library seems to rely on putting a gridview in a framelayout in a linearlayout for various reasons that i don't quite understand. I'd say a pull to refresh grid view is probably quite simple : detect vertical drag gesture when the top of the grid is already displayed. – njzk2 Sep 05 '13 at 15:10
  • that's weird then, that it slows down the scrolling. We checked this on two same Sgs2, and there was a diffrence unfortunately. – filipp.kowalski Sep 05 '13 at 15:12

2 Answers2

0

One hack you can use is to open the library, go into PullToRefreshBase.java and remove final from methods like onInterceptTouchEvent. You can then use a custom ScrollView.

Muz
  • 5,866
  • 3
  • 47
  • 65
0

I hope this helps :

you have the focus on some Edit text that is up and when the ScrollView scrolls down and hides this EditText that has the focus, if at this moment you scroll in a horizontal recycler view, at the moment the OnCreateViewHolder is called , the ScrollView will scroll to where it has the focus, to solve this problem remove the focus of the EditText when you click outside of it.

Willian
  • 11
  • 1