This pull request adds a visualizer.
WARNING: If you try to execute it on your phone, it could not work as the used tactic is hardcoded and comes from my local development.
You can build your own tactic on the web app and then change the value 21 with your desired tactic in the VisualizerPage invokation at MainActivity.App.
We need a pull request for the home page to be able to select the wanted tactic dynamically.
This pull request adds a visualizer.
WARNING: If you try to execute it on your phone, it could not work as the used tactic is hardcoded and comes from my local development.
You can build your own tactic on the web app and then change the value `21` with your desired tactic in the `VisualizerPage` invokation at MainActivity.App.
We need a pull request for the home page to be able to select the wanted tactic dynamically.
The same cost applies here as in the web version. This algorithm may traverse the whole tree and is called for every node. The root node should not be necessary to get the name.
The tree is immutable here, so it relatively simple to a have a separated DTO class:
The same cost applies here as in the web version. This algorithm may traverse the whole tree and is called for every node. The root node should not be necessary to get the name.
The tree is immutable here, so it relatively simple to a have a separated DTO class:
```kt
data class StepNodeInfo(val id: Int, val name: String, val parent: Int?, val children: List<StepNodeInfo>)
data class StepNodeDTO(val id: Int, val children: List<StepNodeDTO>) {
val subTreeSize: Int
get() = children.fold(1) { acc, child -> acc + child.subTreeSize }
}
class StepTreeAdapter {
@FromJson
fun fromJson(dto: StepNodeDTO): StepNodeInfo = fromJson(dto, null, 1)
private fun fromJson(dto: StepNodeDTO, parent: Int?, nextName: Int): StepNodeInfo {
var num = nextName
return StepNodeInfo(dto.id, num.toString(), parent, dto.children.map {
val node = fromJson(it, dto.id, num + 1)
num += it.subTreeSize
node
})
}
}
```
This pull request adds a visualizer.
WARNING: If you try to execute it on your phone, it could not work as the used tactic is hardcoded and comes from my local development.
You can build your own tactic on the web app and then change the value
21
with your desired tactic in theVisualizerPage
invokation at MainActivity.App.We need a pull request for the home page to be able to select the wanted tactic dynamically.
import java.net.URI
for (i in segments.indices) {
val segment = segments[i]
import com.iqball.app.model.tactic.StepContent
/**
* Converts the phantom's [PhantomPositioning] to a XY Position
JsonReader.Token.STRING -> JsonPrimitiveType.String
JsonReader.Token.NUMBER -> JsonPrimitiveType.Number
JsonReader.Token.BOOLEAN -> JsonPrimitiveType.Boolean
JsonReader.Token.NULL -> return null
2e41bd50d9
toa387d4e13f
1 year agoa387d4e13f
to2e41bd50d9
1 year agod35705b8bb
tof035eb854b
1 year agof035eb854b
toe41e3eb8f3
1 year ago11806e0132
to22ed746ce3
1 year agoA bit skeptical with all those
runBlocking
. Using the composablecouroutineScope
would be better.import com.iqball.app.model.tactic.StepNodeInfo
fun getStepName(root: StepNodeInfo, step: Int): String {
The same cost applies here as in the web version. This algorithm may traverse the whole tree and is called for every node. The root node should not be necessary to get the name.
The tree is immutable here, so it relatively simple to a have a separated DTO class:
val parentId = getParent(stepsTree, selectedStepId)?.id
Pair(
getStepContent(selectedStepId),
if (parentId == null) null else getStepContent(parentId)
a913dcc3f5
to5708552b28
1 year ago967552d919
into master 1 year agoReviewers
967552d919
.