diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-02-21 13:32:31 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-02-21 13:35:55 +0100 |
commit | 1aefed336f9ef305f59d3668abc8a39c550e921d (patch) | |
tree | 5eb468ac855b58718a4c15d86bd9915e64769278 /src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt | |
parent | f88c59c04d9f7053a8a97b0c65a282f961913f1b (diff) | |
download | kvision-1aefed336f9ef305f59d3668abc8a39c550e921d.tar.gz kvision-1aefed336f9ef305f59d3668abc8a39c550e921d.tar.bz2 kvision-1aefed336f9ef305f59d3668abc8a39c550e921d.zip |
Small style fixes contributed by tieskedh
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt index dbada3dc..4a82ed5b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt @@ -86,8 +86,8 @@ open class ResponsiveGridPanel( * @return this container */ open fun add(child: Component, col: Int, row: Int, size: Int = 0, offset: Int = 0): ResponsiveGridPanel { - val cRow = if (row < 0) 0 else row - val cCol = if (col < 0) 0 else col + val cRow = maxOf(row, 0) + val cCol = maxOf(col, 0) if (row > rows - 1) rows = cRow + 1 if (col > cols - 1) cols = cCol + 1 map.getOrPut(cRow, { mutableMapOf() })[cCol] = WidgetParam(child, size, offset) @@ -107,16 +107,9 @@ open class ResponsiveGridPanel( @Suppress("NestedBlockDepth") override fun remove(child: Component): ResponsiveGridPanel { - for (i in 0 until rows) { - val row = map[i] - if (row != null) { - for (j in 0 until cols) { - val wp = row[j] - if (wp != null) { - if (wp.widget == child) row.remove(j) - } - } - } + map.values.forEach { row -> + row.filterValues { it.widget == child } + .forEach { (i, _) -> row.remove(i) } } refreshRowContainers() return this @@ -143,8 +136,7 @@ open class ResponsiveGridPanel( val rowContainer = SimplePanel(setOf("row")) val row = map[i] if (row != null) { - for (j in 0 until cols) { - val wp = row[j] + (0 until cols).map { row[it] }.forEach { wp -> if (auto) { val widget = wp?.widget?.let { WidgetWrapper(it, setOf("col-" + gridsize.size + "-" + num)) |