mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 13:31:51 +01:00
changing dragging behavior of bottom sheets to be like iOS
ie: if at the top of the scrollview it can be dragged down, even if you scroll a bit down then up without letting go
This commit is contained in:
parent
b0948cf0a7
commit
eb88d4e94f
@ -7,7 +7,6 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.kanade.tachiyomi.databinding.RecyclerWithScrollerBinding
|
import eu.kanade.tachiyomi.databinding.RecyclerWithScrollerBinding
|
||||||
import eu.kanade.tachiyomi.util.view.isExpanded
|
|
||||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||||
|
|
||||||
class RecyclerWithScrollerView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class RecyclerWithScrollerView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
@ -22,24 +21,12 @@ class RecyclerWithScrollerView @JvmOverloads constructor(context: Context, attrs
|
|||||||
binding.recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
binding.recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||||
super.onScrollStateChanged(recyclerView, newState)
|
super.onScrollStateChanged(recyclerView, newState)
|
||||||
if (sheet.isOnView(this@RecyclerWithScrollerView) &&
|
if (newState == RecyclerView.SCROLL_STATE_IDLE ||
|
||||||
(
|
|
||||||
newState == RecyclerView.SCROLL_STATE_IDLE ||
|
|
||||||
newState == RecyclerView.SCROLL_STATE_SETTLING
|
newState == RecyclerView.SCROLL_STATE_SETTLING
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
sheet.sheetBehavior?.isDraggable = true
|
sheet.sheetBehavior?.isDraggable = true
|
||||||
}
|
} else {
|
||||||
}
|
sheet.sheetBehavior?.isDraggable = !recyclerView.canScrollVertically(-1)
|
||||||
|
|
||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
|
||||||
super.onScrolled(recyclerView, dx, dy)
|
|
||||||
if (sheet.isOnView(this@RecyclerWithScrollerView) &&
|
|
||||||
sheet.sheetBehavior.isExpanded() &&
|
|
||||||
recyclerView.canScrollVertically(-1) &&
|
|
||||||
recyclerView.scrollState != RecyclerView.SCROLL_STATE_SETTLING
|
|
||||||
) {
|
|
||||||
sheet.sheetBehavior?.isDraggable = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -67,15 +67,8 @@ abstract class E2EBottomSheetDialog<VB : ViewBinding>(activity: Activity) :
|
|||||||
newState == RecyclerView.SCROLL_STATE_SETTLING
|
newState == RecyclerView.SCROLL_STATE_SETTLING
|
||||||
) {
|
) {
|
||||||
sheetBehavior.isDraggable = true
|
sheetBehavior.isDraggable = true
|
||||||
}
|
} else {
|
||||||
}
|
sheetBehavior.isDraggable = !recyclerView.canScrollVertically(-1)
|
||||||
|
|
||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
|
||||||
super.onScrolled(recyclerView, dx, dy)
|
|
||||||
if (recyclerView.canScrollVertically(-1) &&
|
|
||||||
recyclerView.scrollState != RecyclerView.SCROLL_STATE_SETTLING
|
|
||||||
) {
|
|
||||||
sheetBehavior.isDraggable = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user