mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-28 10:35:29 +03:00
Fix ControllerActivity
Controller Type Change Crash
If the controller type was changed from a type with a larger amount of buttons/axes to one with a fewer amount, a crash would occur due to the transition animation retaining those elements as children yet returning `NO_POSITION` from `getChildAdapterPosition` in `DividerItemDecoration` which was an unhandled case and led to an OOB array access.
This commit is contained in:
parent
2c46709064
commit
8f0db18624
@ -195,7 +195,8 @@ class ControllerActivity : AppCompatActivity() {
|
||||
val divider = drawable!!
|
||||
for (i in 0 until parent.childCount) {
|
||||
val view = parent.getChildAt(i)
|
||||
if (parent.adapter!!.getItemViewType(parent.getChildAdapterPosition(view)) == adapter.getFactoryViewType(ControllerHeaderBindingFactory)) {
|
||||
val position = parent.getChildAdapterPosition(view)
|
||||
if (position != RecyclerView.NO_POSITION && parent.adapter!!.getItemViewType(position) == adapter.getFactoryViewType(ControllerHeaderBindingFactory)) {
|
||||
val bottom = view.top - view.marginTop
|
||||
val top = bottom - divider.intrinsicHeight
|
||||
divider.setBounds(0, top, parent.width, bottom)
|
||||
|
Loading…
Reference in New Issue
Block a user