EnhancedListView
EnhancedListView copied to clipboard
Problem with SwipeRefreshLayout
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.
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;
}
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.
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.
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 .
Oh, I see, Thank you