refactor(YouTube - Add more double tap to seek length options): Use more idiomatic code
This commit is contained in:
parent
3c46a2d2e8
commit
f10f5e2910
1 changed files with 4 additions and 10 deletions
|
|
@ -28,12 +28,7 @@ val addMoreDoubleTapToSeekLengthOptionsPatch = resourcePatch(
|
|||
|
||||
execute {
|
||||
// Values are hard coded to keep patching simple.
|
||||
val doubleTapLengthOptionsString = "3, 5, 10, 15, 20, 30, 60, 120, 180, 240"
|
||||
|
||||
val doubleTapLengths = doubleTapLengthOptionsString
|
||||
.replace(" ", "")
|
||||
.split(",")
|
||||
if (doubleTapLengths.isEmpty()) throw PatchException("Invalid double-tap length elements")
|
||||
val doubleTapLengths = listOf(3, 5, 10, 15, 20, 30, 60, 120, 180, 240)
|
||||
|
||||
document("res/values/arrays.xml").use { document ->
|
||||
fun Element.removeAllChildren() {
|
||||
|
|
@ -56,10 +51,9 @@ val addMoreDoubleTapToSeekLengthOptionsPatch = resourcePatch(
|
|||
entries.removeAllChildren()
|
||||
|
||||
doubleTapLengths.forEach { length ->
|
||||
val item = document.createElement("item")
|
||||
item.textContent = length
|
||||
entries.appendChild(item)
|
||||
values.appendChild(item.cloneNode(true))
|
||||
document.createElement("item").apply { textContent = length.toString() }
|
||||
.also(entries::appendChild)
|
||||
.cloneNode(true).let(values::appendChild)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue