mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-23 16:21:52 +01:00
Fix ControllerPreference
's index
not being passed to Activity
A bug caused by not passing the index argument to `ControllerActivity` led to all preferences opening the activity that pertained to Controller #1. This was fixed by passing the `index` argument in the activity launch intent.
This commit is contained in:
parent
270ee4a7a6
commit
2c46709064
@ -25,6 +25,10 @@ class ControllerPreference @JvmOverloads constructor(context : Context, attrs :
|
||||
notifyChanged()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val INDEX_ARG = "index"
|
||||
}
|
||||
|
||||
/**
|
||||
* The index of the controller this preference manages
|
||||
*/
|
||||
@ -36,7 +40,7 @@ class ControllerPreference @JvmOverloads constructor(context : Context, attrs :
|
||||
for (i in 0 until attrs!!.attributeCount) {
|
||||
val attr = attrs.getAttributeName(i)
|
||||
|
||||
if (attr.equals("index", ignoreCase = true)) {
|
||||
if (attr.equals(INDEX_ARG)) {
|
||||
index = attrs.getAttributeValue(i).toInt()
|
||||
break
|
||||
}
|
||||
@ -55,5 +59,5 @@ class ControllerPreference @JvmOverloads constructor(context : Context, attrs :
|
||||
/**
|
||||
* This launches [ControllerActivity] on click to configure the controller
|
||||
*/
|
||||
override fun onClick() = controllerCallback.launch(Intent(context, ControllerActivity::class.java))
|
||||
override fun onClick() = controllerCallback.launch(Intent(context, ControllerActivity::class.java).putExtra(INDEX_ARG, index))
|
||||
}
|
||||
|
@ -28,4 +28,8 @@
|
||||
<!-- A URL to the library -->
|
||||
<attr format="string" name="libraryUrl"/>
|
||||
</declare-styleable>
|
||||
<declare-styleable name="ControllerPreference">
|
||||
<!-- Index of the controller the preference corresponds to -->
|
||||
<attr name="index" format="integer" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user