|
|
@ -152,14 +152,14 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV |
|
|
|
binding.recyclerView.addItemDecoration(VerticalDivider(this)) |
|
|
|
binding.recyclerView.addItemDecoration(VerticalDivider(this)) |
|
|
|
adapter = BookSourceAdapter(this, this) |
|
|
|
adapter = BookSourceAdapter(this, this) |
|
|
|
binding.recyclerView.adapter = adapter |
|
|
|
binding.recyclerView.adapter = adapter |
|
|
|
val itemTouchCallback = ItemTouchCallback(adapter) |
|
|
|
// When this page is opened, it is in selection mode |
|
|
|
itemTouchCallback.isCanDrag = true |
|
|
|
|
|
|
|
val dragSelectTouchHelper: DragSelectTouchHelper = |
|
|
|
val dragSelectTouchHelper: DragSelectTouchHelper = |
|
|
|
DragSelectTouchHelper(adapter.initDragSelectTouchHelperCallback()).setSlideArea(16, 50) |
|
|
|
DragSelectTouchHelper(adapter.dragSelectCallback).setSlideArea(16, 50) |
|
|
|
dragSelectTouchHelper.attachToRecyclerView(binding.recyclerView) |
|
|
|
dragSelectTouchHelper.attachToRecyclerView(binding.recyclerView) |
|
|
|
// When this page is opened, it is in selection mode |
|
|
|
|
|
|
|
dragSelectTouchHelper.activeSlideSelect() |
|
|
|
dragSelectTouchHelper.activeSlideSelect() |
|
|
|
// Note: need judge selection first, so add ItemTouchHelper after it. |
|
|
|
// Note: need judge selection first, so add ItemTouchHelper after it. |
|
|
|
|
|
|
|
val itemTouchCallback = ItemTouchCallback(adapter) |
|
|
|
|
|
|
|
itemTouchCallback.isCanDrag = true |
|
|
|
ItemTouchHelper(itemTouchCallback).attachToRecyclerView(binding.recyclerView) |
|
|
|
ItemTouchHelper(itemTouchCallback).attachToRecyclerView(binding.recyclerView) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -339,12 +339,12 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV |
|
|
|
}.show() |
|
|
|
}.show() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun upGroupMenu() { |
|
|
|
private fun upGroupMenu() = groupMenu?.let { menu -> |
|
|
|
groupMenu?.removeGroup(R.id.source_group) |
|
|
|
menu.removeGroup(R.id.source_group) |
|
|
|
groups.sortedWith { o1, o2 -> |
|
|
|
groups.sortedWith { o1, o2 -> |
|
|
|
o1.cnCompare(o2) |
|
|
|
o1.cnCompare(o2) |
|
|
|
}.map { |
|
|
|
}.map { |
|
|
|
groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) |
|
|
|
menu.add(R.id.source_group, Menu.NONE, Menu.NONE, it) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|