Enable ItemViewSwipe on the HabitCardListView, plumb it down to Habit.dismiss()

pull/558/head
Scrimbly 6 years ago
parent 23a66e3b6c
commit 2951f85097

@ -288,6 +288,11 @@ public class HabitCardListAdapter
cache.reorder(from, to); cache.reorder(from, to);
} }
public void dismiss(int position)
{
cache.dismiss(position);
}
@Override @Override
public void refresh() public void refresh()
{ {

@ -47,6 +47,10 @@ class HabitCardListController @Inject constructor(
adapter.observable.addListener(this) adapter.observable.addListener(this)
} }
override fun onSwiped(position: Int, direction: Int) {
adapter.dismiss(position)
}
override fun drop(from: Int, to: Int) { override fun drop(from: Int, to: Int) {
if (from == to) return if (from == to) return
cancelSelection() cancelSelection()

@ -129,6 +129,7 @@ class HabitCardListView(
fun drop(from: Int, to: Int) {} fun drop(from: Int, to: Int) {}
fun onItemClick(pos: Int) {} fun onItemClick(pos: Int) {}
fun onItemLongClick(pos: Int) {} fun onItemLongClick(pos: Int) {}
fun onSwiped(position: Int, direction: Int) {}
fun startDrag(position: Int) {} fun startDrag(position: Int) {}
} }
@ -164,9 +165,11 @@ class HabitCardListView(
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, override fun onSwiped(viewHolder: RecyclerView.ViewHolder,
direction: Int) { direction: Int) {
val position = viewHolder.adapterPosition
controller.get().onSwiped(position, direction)
} }
override fun isItemViewSwipeEnabled() = false override fun isItemViewSwipeEnabled() = true
override fun isLongPressDragEnabled() = false override fun isLongPressDragEnabled() = false
} }
} }

@ -179,6 +179,12 @@ public class HabitCardListCache implements CommandRunner.Listener
listener.onItemMoved(from, to); listener.onItemMoved(from, to);
} }
public synchronized void dismiss(int position)
{
Habit habit = data.habits.get(position);
habit.dismiss();
}
public synchronized void setCheckmarkCount(int checkmarkCount) public synchronized void setCheckmarkCount(int checkmarkCount)
{ {
this.checkmarkCount = checkmarkCount; this.checkmarkCount = checkmarkCount;

Loading…
Cancel
Save