pull/743/head
gedoor 4 years ago
parent b7cd5bd176
commit 00ebad810d
  1. 2
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  4. 4
      app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt
  6. 2
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt
  7. 2
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt
  8. 2
      app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubAdapter.kt
  9. 15
      app/src/main/java/io/legado/app/ui/widget/recycler/ItemTouchCallback.kt

@ -144,7 +144,7 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) :
private var isMoved = false private var isMoved = false
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { override fun swap(srcPosition: Int, targetPosition: Int): Boolean {
val srcItem = getItem(srcPosition) val srcItem = getItem(srcPosition)
val targetItem = getItem(targetPosition) val targetItem = getItem(targetPosition)
if (srcItem != null && targetItem != null) { if (srcItem != null && targetItem != null) {

@ -192,7 +192,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
} }
} }
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { override fun swap(srcPosition: Int, targetPosition: Int): Boolean {
swapItem(srcPosition, targetPosition) swapItem(srcPosition, targetPosition)
isMoved = true isMoved = true
return true return true

@ -191,7 +191,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
} }
} }
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { override fun swap(srcPosition: Int, targetPosition: Int): Boolean {
swapItem(srcPosition, targetPosition) swapItem(srcPosition, targetPosition)
isMoved = true isMoved = true
return true return true

@ -247,10 +247,10 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
private var isMoved = false private var isMoved = false
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { override fun swap(srcPosition: Int, targetPosition: Int): Boolean {
swapItem(srcPosition, targetPosition) swapItem(srcPosition, targetPosition)
isMoved = true isMoved = true
return super.onMove(srcPosition, targetPosition) return super.swap(srcPosition, targetPosition)
} }
override fun onClearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) { override fun onClearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {

@ -229,7 +229,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
return selection.sortedBy { it.customOrder } return selection.sortedBy { it.customOrder }
} }
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { override fun swap(srcPosition: Int, targetPosition: Int): Boolean {
val srcItem = getItem(srcPosition) val srcItem = getItem(srcPosition)
val targetItem = getItem(targetPosition) val targetItem = getItem(targetPosition)
if (srcItem != null && targetItem != null) { if (srcItem != null && targetItem != null) {

@ -145,7 +145,7 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) :
popupMenu.show() popupMenu.show()
} }
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { override fun swap(srcPosition: Int, targetPosition: Int): Boolean {
val srcItem = getItem(srcPosition) val srcItem = getItem(srcPosition)
val targetItem = getItem(targetPosition) val targetItem = getItem(targetPosition)
if (srcItem != null && targetItem != null) { if (srcItem != null && targetItem != null) {

@ -181,7 +181,7 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) :
popupMenu.show() popupMenu.show()
} }
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { override fun swap(srcPosition: Int, targetPosition: Int): Boolean {
val srcItem = getItem(srcPosition) val srcItem = getItem(srcPosition)
val targetItem = getItem(targetPosition) val targetItem = getItem(targetPosition)
if (srcItem != null && targetItem != null) { if (srcItem != null && targetItem != null) {

@ -59,7 +59,7 @@ class RuleSubAdapter(context: Context, val callBack: Callback) :
return ItemRuleSubBinding.inflate(inflater, parent, false) return ItemRuleSubBinding.inflate(inflater, parent, false)
} }
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { override fun swap(srcPosition: Int, targetPosition: Int): Boolean {
val srcItem = getItem(srcPosition) val srcItem = getItem(srcPosition)
val targetItem = getItem(targetPosition) val targetItem = getItem(targetPosition)
if (srcItem != null && targetItem != null) { if (srcItem != null && targetItem != null) {

@ -85,7 +85,18 @@ class ItemTouchCallback(private val callback: Callback) : ItemTouchHelper.Callba
srcViewHolder: RecyclerView.ViewHolder, srcViewHolder: RecyclerView.ViewHolder,
targetViewHolder: RecyclerView.ViewHolder targetViewHolder: RecyclerView.ViewHolder
): Boolean { ): Boolean {
return callback.onMove(srcViewHolder.adapterPosition, targetViewHolder.adapterPosition) val fromPosition: Int = srcViewHolder.adapterPosition
val toPosition: Int = targetViewHolder.adapterPosition
if (fromPosition < toPosition) {
for (i in fromPosition until toPosition) {
callback.swap(i, i + 1)
}
} else {
for (i in fromPosition downTo toPosition + 1) {
callback.swap(i, i - 1)
}
}
return true
} }
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
@ -122,7 +133,7 @@ class ItemTouchCallback(private val callback: Callback) : ItemTouchHelper.Callba
* @param targetPosition 目的地的Item的position * @param targetPosition 目的地的Item的position
* @return 开发者处理了操作应该返回true开发者没有处理就返回false * @return 开发者处理了操作应该返回true开发者没有处理就返回false
*/ */
fun onMove(srcPosition: Int, targetPosition: Int): Boolean { fun swap(srcPosition: Int, targetPosition: Int): Boolean {
return true return true
} }

Loading…
Cancel
Save