mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-28 10:15:28 +03:00
Collapse appBarLayout
on appList
focus
We collapse the app bar when the focus is on the app list which only occurs while using a controller, this is required as the app bar will never be collapsed otherwise. It also removes the older code to work around the limitation on `View.FOCUS_DOWN` by collapsing only when the end of the list was reached.
This commit is contained in:
parent
3e4ec7323b
commit
3ae62c7fcc
@ -202,23 +202,16 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestChildFocus(parent : RecyclerView, state : RecyclerView.State, child : View, focused : View?) : Boolean {
|
||||
binding.appBarLayout.setExpanded(false)
|
||||
return super.onRequestChildFocus(parent, state, child, focused)
|
||||
}
|
||||
|
||||
override fun onFocusSearchFailed(focused : View, focusDirection : Int, recycler : RecyclerView.Recycler, state : RecyclerView.State) : View? {
|
||||
val nextFocus = super.onFocusSearchFailed(focused, focusDirection, recycler, state)
|
||||
when (focusDirection) {
|
||||
View.FOCUS_DOWN -> {
|
||||
findContainingItemView(focused)?.let { focusedChild ->
|
||||
val current = binding.appList.indexOfChild(focusedChild)
|
||||
val currentSpanIndex = (focusedChild.layoutParams as LayoutParams).spanIndex
|
||||
for (i in current + 1 until binding.appList.size) {
|
||||
val candidate = getChildAt(i)!!
|
||||
// Return candidate when span index matches
|
||||
if (currentSpanIndex == (candidate.layoutParams as LayoutParams).spanIndex) return candidate
|
||||
}
|
||||
nextFocus?.let { if ((it.layoutParams as LayoutParams).spanIndex == currentSpanIndex) return nextFocus }
|
||||
|
||||
binding.appBarLayout.setExpanded(false) // End of list, hide app bar, so bottom row is fully visible
|
||||
binding.appList.smoothScrollToPosition(adapter.itemCount)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
View.FOCUS_UP -> {
|
||||
|
Loading…
Reference in New Issue
Block a user