Question

Recently I was using the Android-SwipeListView library which is a wonderful work. Straight to the point, My request is that when I swipe one item to left, the other items have to be closed. Then After I opened first item to left, again, I started to swipe the second item to left very very slowly at the same time my finger still touch the screen. On the start of Opening(onStartOpen() in BaseSwipeListView), the opened item closed very quickly. At the time of the opened one started to close, I stopped moving my finger. As a result, the second item stopped there. The the result is like below: The first item is open normally

When the second started to move, stop moving finger

When started swiping againwhen the third started to move, stop moving finger

Meanwhile, my layout is :

<com.fortysevendeg.swipelistview.SwipeListView
    android:id="@+id/album_detail_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/album_description_parent"
    android:layout_centerHorizontal="true"
    android:layout_margin="2dp"
    android:background="#ffffff"
    android:cacheColorHint="#000000"
    android:divider="@drawable/divider_bg"
    android:dividerHeight="2dp"
    android:drawingCacheQuality="auto"
    android:footerDividersEnabled="false"
    android:gravity="top|center_horizontal"
    android:headerDividersEnabled="false"
    app:swipeActionLeft="reveal"
    swipe:swipeBackView="@+id/detail_item_back"
    swipe:swipeCloseAllItemsWhenMoveList="true"
    swipe:swipeDrawableChecked="@drawable/choice_selected"
    swipe:swipeDrawableUnchecked="@drawable/choice_unselected"
    swipe:swipeFrontView="@+id/detail_item_front"
    swipe:swipeMode="left"
    swipe:swipeOpenOnLongPress="false" />

And my Java code is:

albumContentSLV
            .setSwipeListViewListener(new BaseSwipeListViewListener() {
                @Override
                public void onStartOpen(int position, int action,
                        boolean right) {
                    // TODO Auto-generated method stub
                    albumContentSLV.closeOpenedItems();
                    super.onStartOpen(position, action, right);
                }
            });

Yes, SwipeListView can close all opened items by closeOpenedItems(). But when there are half-opened item, How does SwipeListView handle this? Is this a bug in SwipeListView?

Was it helpful?

Solution 2

I used this widget library of Android-SwipeListView. And I forked this library on Github. And I had a solution about this problem of this library. Here is my project which I had fixed this bug, check it out, and take a deep look at it.

I modified the implementation of closeAnimate. It was at line 349. The closeAnimate(int) after modification is like this:

protected void closeAnimate(int position) {
    View view = swipeListView.getChildAt(position - swipeListView.getFirstVisiblePosition());
    if (view != null) {
        closeAnimate(view.findViewById(swipeFrontView), position);
    }
}

Then, crashes don't happen again during fast scrolling vertically.

Meanwhile, he same question happens at openAnimate(int), and the openAnimate(int) modified is like this:

protected void openAnimate(int position) {
    final View child = swipeListView.getChildAt(position - swipeListView.getFirstVisiblePosition()).findViewById(swipeFrontView);
    if (child != null) {
        openAnimate(child, position);
    }
}

OTHER TIPS

Yes, it's a bug indeed. And listeners just listen to the Action Open or Close incuding Open started, Open opened, Close started and Close opened. But during the swiping, we can do nothing except the onMove where we can just get x and y. So, what a pity!

Additions:

Eventually, I found a solution to this bug. I modified the implementation of the Function called closeAnimate. It was at line 349. The closeAnimate(int) after modification is here:

protected void closeAnimate(int position) {
    View view = swipeListView.getChildAt(position - swipeListView.getFirstVisiblePosition());
    if (view != null) {
        closeAnimate(view.findViewById(swipeFrontView), position);
    }
}

So, it is resolved at last. Crash won't happen again during fast scrolling vertically.

PS:the same question happens at openAnimate(int), and the openAnimate(int) modified is here:

protected void openAnimate(int position) {
    final View child = swipeListView.getChildAt(position - swipeListView.getFirstVisiblePosition()).findViewById(swipeFrontView);
    if (child != null) {
        openAnimate(child, position);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top