Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Problem with SwipeRefreshLayout #54

Open
dostalleos opened this issue Aug 4, 2014 · 5 comments
Open

Problem with SwipeRefreshLayout #54

dostalleos opened this issue Aug 4, 2014 · 5 comments

Comments

@dostalleos
Copy link

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

@jcogilvie
Copy link

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
Copy link

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.

@dostalleos
Copy link
Author

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.

@jcogilvie
Copy link

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
#54 (comment)
.

@dostalleos
Copy link
Author

Oh, I see, Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants