SwipeListView.java 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package de.tudarmstadt.informatik.hostage.ui2.swipelist;
  2. import android.content.Context;
  3. import android.util.AttributeSet;
  4. /**
  5. * Extends the SwipeListView with an mechanism to allow to open only one item at the same time.
  6. *
  7. * @author Alexander Brakowski
  8. * @created 28.02.14 22:05
  9. */
  10. public class SwipeListView extends com.fortysevendeg.android.swipelistview.SwipeListView {
  11. /**
  12. * {@inheritDoc}
  13. */
  14. public SwipeListView(Context context, int swipeBackView, int swipeFrontView) {
  15. super(context, swipeBackView, swipeFrontView);
  16. }
  17. /**
  18. * {@inheritDoc}
  19. */
  20. public SwipeListView(Context context, AttributeSet attrs) {
  21. super(context, attrs);
  22. }
  23. /**
  24. * {@inheritDoc}
  25. */
  26. public SwipeListView(Context context, AttributeSet attrs, int defStyle) {
  27. super(context, attrs, defStyle);
  28. }
  29. /**
  30. * {@inheritDoc}
  31. */
  32. @Override
  33. protected void onOpened(int position, boolean toRight) {
  34. super.onOpened(position, toRight);
  35. int start = getFirstVisiblePosition();
  36. int end = getLastVisiblePosition();
  37. // close all visible items other then the current one
  38. for(int i=start; i<=end; i++){
  39. if(i != position){
  40. closeAnimate(i);
  41. }
  42. }
  43. }
  44. }