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 {
|
execute {
|
||||||
// Values are hard coded to keep patching simple.
|
// Values are hard coded to keep patching simple.
|
||||||
val doubleTapLengthOptionsString = "3, 5, 10, 15, 20, 30, 60, 120, 180, 240"
|
val doubleTapLengths = listOf(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")
|
|
||||||
|
|
||||||
document("res/values/arrays.xml").use { document ->
|
document("res/values/arrays.xml").use { document ->
|
||||||
fun Element.removeAllChildren() {
|
fun Element.removeAllChildren() {
|
||||||
|
|
@ -56,10 +51,9 @@ val addMoreDoubleTapToSeekLengthOptionsPatch = resourcePatch(
|
||||||
entries.removeAllChildren()
|
entries.removeAllChildren()
|
||||||
|
|
||||||
doubleTapLengths.forEach { length ->
|
doubleTapLengths.forEach { length ->
|
||||||
val item = document.createElement("item")
|
document.createElement("item").apply { textContent = length.toString() }
|
||||||
item.textContent = length
|
.also(entries::appendChild)
|
||||||
entries.appendChild(item)
|
.cloneNode(true).let(values::appendChild)
|
||||||
values.appendChild(item.cloneNode(true))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue