Skip to content

Commit

Permalink
Fixed double vibration in D&D sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Jays2Kings committed Jan 16, 2020
1 parent de66a66 commit 7fda2f9
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import eu.kanade.tachiyomi.util.*
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
import kotlinx.android.synthetic.main.chapters_controller.*
import kotlinx.android.synthetic.main.library_category.view.*
import kotlinx.coroutines.delay
import rx.subscriptions.CompositeSubscription
import uy.kohesive.injekt.injectLazy

Expand Down Expand Up @@ -235,6 +236,9 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
is LibrarySelectionEvent.Selected -> {
if (adapter.mode != SelectableAdapter.Mode.MULTI) {
adapter.mode = SelectableAdapter.Mode.MULTI
}
launchUI {
delay(100)
adapter.isLongPressDragEnabled = false
}
findAndToggleSelection(event.manga)
Expand Down Expand Up @@ -279,13 +283,13 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
override fun onItemClick(view: View?, position: Int): Boolean {
// If the action mode is created and the position is valid, toggle the selection.
val item = adapter.getItem(position) ?: return false
if (adapter.mode == SelectableAdapter.Mode.MULTI) {
return if (adapter.mode == SelectableAdapter.Mode.MULTI) {
lastClickPosition = position
toggleSelection(position)
return true
true
} else {
openManga(item.manga, lastTouchUpY)
return false
false
}
}

Expand All @@ -303,7 +307,6 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
*/
override fun onItemLongClick(position: Int) {
controller.createActionModeIfNeeded()
adapter.isLongPressDragEnabled = false
when {
lastClickPosition == -1 -> setSelection(position)
lastClickPosition > position -> for (i in position until lastClickPosition)
Expand All @@ -320,9 +323,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
}

override fun onItemReleased(position: Int) {
if (adapter.selectedItemCount == 0) {
saveDragSort()
}
if (adapter.selectedItemCount == 0) saveDragSort()
}

private fun saveDragSort() {
Expand All @@ -346,8 +347,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att

override fun onActionStateChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
val position = viewHolder?.adapterPosition ?: return
if (actionState == 2)
onItemLongClick(position)
if (actionState == 2) onItemLongClick(position)
}

/**
Expand Down

0 comments on commit 7fda2f9

Please sign in to comment.