daimajia / daimajia/AndroidSwipeLayout
Multiple onStartOpen after onOpen if continue dragging
- Dominant language
- Java
- Stars
- 12.3k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
When I open SwipeLayout and continue drag, the new "cycle" start - SurfaceView moved to the start , called onStartOpen, than when I dragged to the end and onOpen called all repeat again.
Video:
https://youtu.be/ocXpQQqad6Q
Code:
//Commented lined is my temp solution, but this solution contains other bugs
``` Java
public Holder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown);
swipeLayout.addDrag(SwipeLayout.DragEdge.Right, bottomViewReserve);
if (mode == WishListFragment.GIFT_LIST_MODE) swipeLayout.addDrag(SwipeLayout.DragEdge.Left, bottomViewRemove);
swipeLayout.addSwipeListener(new SimpleSwipeListener() {
@Override
public void onOpen(SwipeLayout layout) {
Log.d("swipe", "onOpen");
if (layout.getDragEdge() == SwipeLayout.DragEdge.Left) {
removeWish(getAdapterPosition());
} else {
// swipeLayout.setSwipeEnabled(false);
// swipeLayout.setOnTouchListener(new View.OnTouchListener() {
// @Override
// public boolean onTouch(View v, MotionEvent event) {
// if (event.getAction() == MotionEvent.ACTION_UP) {
// swipeLayout.setSwipeEnabled(true);
// swipeLayout.setOnTouchListener(null);
// Log.d("swipe", "unlocked");
// }
// return true;
// }
// });
}
}
@Override
public void onUpdate(SwipeLayout layout, int leftOffset, int topOffset) {
//Log.d("swipe", "onUpdate");
float alpha = Math.abs((float) leftOffset / (float) bottomViewReserve.getWidth());//TODO:
layout.getCurrentBottomView().setAlpha(alpha);
}
@Override
public void onStartOpen(SwipeLayout layout) {
Log.e("swipe", "onStartOpen");
if (swipedItem != null && !swipeLayout.equals(swipedItem)) swipedItem.close();
swipedItem = swipeLayout;
if (layout.getDragEdge() == SwipeLayout.DragEdge.Right)
textViewReserve.setText(wishes.get(getAdapterPosition()).isReserved() ? R.string.action_unreserve : R.string.action_reserve);
}
@Override
public void onClose(SwipeLayout layout) {
Log.d("swipe", "onClose");
if (swipeLayout.equals(swipedItem)) swipedItem = null;
}
});
}
```
wish_list_item.xml
``` xml
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.