Closed nelsonrc closed 11 years ago
I tried your code and I can't replicate this issue. The scrollListener continues to output degub strings. Can you add some details?
I run into the same issue. Here is my scroll listener. Neither method is ever called.
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
Log.d("test", "" );;
}
});
I believe it has to do with CardArrayAdapter:
if (card.isSwipeable()){
if (mOnTouchListener == null){
mOnTouchListener = new SwipeDismissListViewTouchListener(mCardListView, mCallback);
// Setting this scroll listener is required to ensure that during
// ListView scrolling, we don't look for swipes.
mCardListView.setOnScrollListener(mOnTouchListener.makeScrollListener());
}
cardView.setOnTouchListener(mOnTouchListener);
}else{
//prevent issue with recycle view
cardView.setOnTouchListener(null);
}
Nevermind. Use this:
SwipeDismissListViewTouchListener touchListener =
* new SwipeDismissListViewTouchListener(
* listView,
* new SwipeDismissListViewTouchListener.OnDismissCallback() {
* public void onDismiss(ListView listView, int[] reverseSortedPositions) {
* for (int position : reverseSortedPositions) {
* adapter.remove(adapter.getItem(position));
* }
* adapter.notifyDataSetChanged();
* }
* });
* listView.setOnTouchListener(touchListener);
* listView.setOnScrollListener(touchListener.makeScrollListener());
I need to check it better. I think that "swipeable" cards and own ScrollListeners are incompatible.
Does scrollListener work without swipeable cards (I can't test it now) ?
Yep.
mCardListView.setOnScrollListener(mOnTouchListener.makeScrollListener());
Removing this makes it work if I define my own scrollListener. It seems there is a conflict. I'll take a look sometime this week.
Thanks for all your hard work!
I think storing the scroll listener and then checking for it on registering the touch listener solves it. Works for me. #98
Merged with #98
Sorry for delay. I've pushed a new feature to manage this case.
https://github.com/gabrielemariotti/cardslib/pull/98#issuecomment-37445397
You can also use a snapshot with gradle:
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
dependencies {
compile 'com.github.gabrielemariotti.cards:library:1.4.3-SNAPSHOT'
}
I try to implement infinite scroll. But when setOnScrollListener it fires some tines a stop, not firing any more. I test with standard ListView and work well:
Binding:
listView.setOnScrollListener(
new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) {
/// Adapter: public class NewsCardAdapter extends CardArrayAdapter{ private int lastPosition = -1; private List mcards;