EnhancedListView icon indicating copy to clipboard operation
EnhancedListView copied to clipboard

Problem with SwipeRefreshLayout

Open dostalleos opened this issue 10 years ago • 5 comments

Hi, I'm using your EnhancedListView and it's great, but I have problem with it in combination with SwipeRefreshLayout from support library. If you swipe verticaly during swiping horizontaly it stops the item at the place and doesn't put it to right place. I'm cliping the image. 2014-08-04 15 54 44

dostalleos avatar Aug 04 '14 15:08 dostalleos

Based on my testing, this only happens when the EnhancedListView is scrolled all the way to the top. A downward dragging motion causes the SwipeRefreshLayout to start its swipe animation.

One possible solution I could imagine would be exposing mSwiping via getter, and using that value in a custom SwipeRefreshLayout to override SwipeRefreshLayout.canChildScrollUp:

public boolean canChildScrollUp(){
    if(mEnhancedListView.isSwiping || !super.canChildScrollUp())
          return false;
    else
          return true;
}

jcogilvie avatar Aug 26 '14 02:08 jcogilvie

Confirmed using my fork (goldenspiral):

package com.my.package;

import de.timroes.android.listview.EnhancedListView;
import de.timroes.android.listview.EnhancedListView.OnSwipeCallback;
import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;

public class EnhancedSwipeRefreshLayout extends SwipeRefreshLayout {

    private EnhancedListView lv;
    private boolean disableSwipeToRefresh;

    public EnhancedSwipeRefreshLayout(Context context) {
        super(context);
    }

    public EnhancedSwipeRefreshLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setEnhancedListViewChild(EnhancedListView v){
        this.lv = v;
        lv.setSwipeCallback(new OnSwipeCallback(){
            @Override
            public void onSwipeBegin(){
                disableSwipeToRefresh = true;
            }

            @Override
            public void onSwipeEnd(){
                disableSwipeToRefresh = false;
            }
        });
    }

    @Override
    public boolean canChildScrollUp(){

        // If we return TRUE from here, swipe to refresh is disabled.
        // If it's not disabled, we fall back to whatever super has to say.
        return disableSwipeToRefresh || super.canChildScrollUp();
    }
}

You might be also able to write the callbacks in a different way and just disable the SwipeRefreshLayout where I'm setting the boolean flag here.

jcogilvie avatar Aug 26 '14 04:08 jcogilvie

Yes, you are right, that it happens only when EnhancedListView is scrolled all the way to the top.

Your solution looking good, but there is no method setSwipeCallback and no OnSwipeCallback in EnhancedListView class.

dostalleos avatar Aug 26 '14 07:08 dostalleos

I added it in my fork. Goldenspiral/EnhancedListView. On Aug 26, 2014 3:47 AM, "Leoš Dostál" [email protected] wrote:

Yes, you are right, that it happens only when EnhancedListView is scrolled all the way to the top.

Your solution looking good, but there is no method setSwipeCallback and no OnSwipeCallback in EnhancedListView class.

— Reply to this email directly or view it on GitHub https://github.com/timroes/EnhancedListView/issues/54#issuecomment-53386372 .

jcogilvie avatar Aug 26 '14 13:08 jcogilvie

Oh, I see, Thank you

dostalleos avatar Aug 26 '14 13:08 dostalleos