swipeLayout.addSwipeListener methods called multiple times
See original GitHub issueWhen i swipe, the onOpen methods is called multiple times. It varies every time. Sometimes, it’s called once, sometimes twice, most times thrice or more. Could you please help?
public class ItemListAdapter extends ArrayAdapter<ItemDetails> {
Context cContext;
/ * //return the SwipeLayout resource id in the layout.
public int getSwipeLayoutResourceId(int position) {
}*/
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
viewHolder.swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
@Override
public void onClose(SwipeLayout layout) {
//when the SurfaceView totally cover the BottomView.
// Log.i("swipelayout", "onClose");
}
@Override
public void onUpdate(SwipeLayout layout, int leftOffset, int topOffset) {
//you are swiping.
Log.i("swipelayout", "onUpdate " + " " + leftOffset + " " + topOffset);
}
@Override
public void onStartOpen(SwipeLayout layout) {
// Log.i("swipelayout", "onStartOpen");
}
@Override
public void onOpen(final SwipeLayout layout) {
if (layout.getOpenStatus() == SwipeLayout.Status.Open && layout.isSwipeEnabled()) {
layout.postDelayed(new Runnable() {
@Override
public void run() {
layout.close();
if (layout.getDragEdge() == SwipeLayout.DragEdge.Left) {
Log.i("swipelayout", "DELETE Item");
} else if (layout.getDragEdge() == SwipeLayout.DragEdge.Right) {
Log.i("swipelayout", "Item PAID");
paidItem(ItemObject);
}
}
}, 500);
}
}
@Override
public void onStartClose(SwipeLayout layout) {
Log.i("swipelayout", "onStartClose");
}
@Override
public void onHandRelease(final SwipeLayout layout, final float xvel, final float yvel) {
//when user's hand released.
Log.i("swipelayout", "onHandRelease " + " " + xvel + " " + yvel);
}
});
}
public class ViewHolder {
...
}
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:5
Top Results From Across the Web
daimajia AndroidSwipeLayout Button click issue in Activity
When I set default fragment in onClose method of swipeLayout's addSwipeListener, it does not listen to button click.
Read more >com.daimajia.swipe.SwipeLayout.addSwipeListener java ...
Popular methods of SwipeLayout · addDrag · findViewById · addRevealListener. bind multiple views with an com.daimajia.swipe.SwipeLayout. · close. close surface.
Read more >Swipeable ListView in Android - Apna Java
Open build.gradle > add this line compile "com.daimajia.swipelayout:library:1.2.0@aar". > Sync the gradle file . Like this. dependencies {.
Read more >Making Swipeable ListView in Android
This design is helpful in quickly actions with each ListView element (edit, delete, archive,...). By searching on Internet, we found that there ...
Read more >SwipeLayout.java example - Javatips.net
This class describes the usage of SwipeLayout.java. ... float xvel, float yvel); } public void addSwipeListener(SwipeListener l) { mSwipeListeners.add(l); } ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the same issue, it seems it’s called multiple times until we release the finger ad the view is open. Here is a fix I’ve used :
@tsakmalis I’ve a solution for you… I’ve created a simple derived SwipeLayout class that you can use for handle listener events direct from SwipeLayout:
Now, you can use it like that: