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);
}
public void dismiss(int position)
{
cache.dismiss(position);
}
@Override
public void refresh()
{

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

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

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

Loading…
Cancel
Save