mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-29 17:45:28 +03: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()
|
notifyChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val INDEX_ARG = "index"
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The index of the controller this preference manages
|
* 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) {
|
for (i in 0 until attrs!!.attributeCount) {
|
||||||
val attr = attrs.getAttributeName(i)
|
val attr = attrs.getAttributeName(i)
|
||||||
|
|
||||||
if (attr.equals("index", ignoreCase = true)) {
|
if (attr.equals(INDEX_ARG)) {
|
||||||
index = attrs.getAttributeValue(i).toInt()
|
index = attrs.getAttributeValue(i).toInt()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -55,5 +59,5 @@ class ControllerPreference @JvmOverloads constructor(context : Context, attrs :
|
|||||||
/**
|
/**
|
||||||
* This launches [ControllerActivity] on click to configure the controller
|
* 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 -->
|
<!-- A URL to the library -->
|
||||||
<attr format="string" name="libraryUrl"/>
|
<attr format="string" name="libraryUrl"/>
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
<declare-styleable name="ControllerPreference">
|
||||||
|
<!-- Index of the controller the preference corresponds to -->
|
||||||
|
<attr name="index" format="integer" />
|
||||||
|
</declare-styleable>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user