Skip to content

Commit 7138bc1

Browse files
committed
Use foreach
1 parent 6ecfb54 commit 7138bc1

25 files changed

+48
-55
lines changed

app/src/main/kotlin/info/appdev/chartexample/AnotherBarActivity.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ class AnotherBarActivity : DemoBase(), OnSeekBarChangeListener {
124124
}
125125

126126
R.id.actionToggleValues -> {
127-
for (set in chart!!.data!!.dataSets) set.setDrawValues(!set.isDrawValues())
128-
127+
chart!!.data!!.dataSets.forEach { set ->
128+
set.setDrawValues(!set.isDrawValues())
129+
}
129130
chart!!.invalidate()
130131
}
131132

app/src/main/kotlin/info/appdev/chartexample/BarChartActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ class BarChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelect
202202
}
203203

204204
R.id.actionToggleValues -> {
205-
for (set in chart!!.data!!.dataSets)
205+
chart!!.data!!.dataSets.forEach { set ->
206206
set.setDrawValues(!set.isDrawValues())
207-
207+
}
208208
chart!!.invalidate()
209209
}
210210

app/src/main/kotlin/info/appdev/chartexample/BarChartActivityMultiDataset.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ class BarChartActivityMultiDataset : DemoBase(), OnSeekBarChangeListener, OnChar
193193
}
194194

195195
R.id.actionToggleValues -> {
196-
for (set in chart!!.data!!.dataSets) set.setDrawValues(!set.isDrawValues())
197-
196+
chart!!.data!!.dataSets.forEach { set ->
197+
set.setDrawValues(!set.isDrawValues())
198+
}
198199
chart!!.invalidate()
199200
}
200201

app/src/main/kotlin/info/appdev/chartexample/BarChartActivitySinus.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ class BarChartActivitySinus : DemoBase(), OnSeekBarChangeListener {
131131
}
132132

133133
R.id.actionToggleValues -> {
134-
for (set in binding.chart1.data!!.dataSets) set.setDrawValues(!set.isDrawValues())
135-
134+
binding.chart1.data!!.dataSets.forEach { set ->
135+
set.setDrawValues(!set.isDrawValues())
136+
}
136137
binding.chart1.invalidate()
137138
}
138139

app/src/main/kotlin/info/appdev/chartexample/BubbleChartActivity.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ class BubbleChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSel
167167
}
168168

169169
R.id.actionToggleValues -> {
170-
for (set in chart!!.data!!.dataSets) set.setDrawValues(!set.isDrawValues())
171-
170+
chart!!.data!!.dataSets.forEach { set ->
171+
set.setDrawValues(!set.isDrawValues())
172+
}
172173
chart!!.invalidate()
173174
}
174175

app/src/main/kotlin/info/appdev/chartexample/CandleStickChartActivity.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ class CandleStickChartActivity : DemoBase(), OnSeekBarChangeListener {
148148
}
149149

150150
R.id.actionToggleValues -> {
151-
for (set in chart!!.data!!.dataSets) set.setDrawValues(!set.isDrawValues())
152-
151+
chart!!.data!!.dataSets.forEach { set ->
152+
set.setDrawValues(!set.isDrawValues())
153+
}
153154
chart!!.invalidate()
154155
}
155156

app/src/main/kotlin/info/appdev/chartexample/CombinedChartActivity.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class CombinedChartActivity : DemoBase() {
110110
set.circleRadius = 5f
111111
set.setFillColor(Color.rgb(240, 238, 70))
112112
set.lineMode = LineDataSet.Mode.CUBIC_BEZIER
113-
set.setDrawValues(true)
113+
set.isDrawValues = true
114114
set.valueTextSize = 10f
115115
set.setValueTextColor(Color.rgb(240, 238, 70))
116116

@@ -172,7 +172,7 @@ class CombinedChartActivity : DemoBase() {
172172
val set = ScatterDataSet(entries, "Scatter DataSet")
173173
set.setColors(*ColorTemplate.MATERIAL_COLORS)
174174
set.scatterShapeSize = 7.5f
175-
set.setDrawValues(false)
175+
set.isDrawValues = false
176176
set.valueTextSize = 10f
177177
d.addDataSet(set)
178178

@@ -195,7 +195,7 @@ class CombinedChartActivity : DemoBase() {
195195
set.shadowColor = Color.DKGRAY
196196
set.setBarSpace(0.3f)
197197
set.valueTextSize = 10f
198-
set.setDrawValues(false)
198+
set.isDrawValues = false
199199
d.addDataSet(set)
200200

201201
return d
@@ -217,7 +217,7 @@ class CombinedChartActivity : DemoBase() {
217217
set.valueTextSize = 10f
218218
set.setValueTextColor(Color.WHITE)
219219
set.highlightCircleWidth = 1.5f
220-
set.setDrawValues(true)
220+
set.isDrawValues = true
221221
bd.addDataSet(set)
222222

223223
return bd
@@ -239,15 +239,15 @@ class CombinedChartActivity : DemoBase() {
239239

240240
R.id.actionToggleLineValues -> {
241241
for (set in chart!!.data!!.dataSets) {
242-
if (set is LineDataSet) set.setDrawValues(!set.isDrawValues)
242+
if (set is LineDataSet) set.isDrawValues = !set.isDrawValues
243243
}
244244

245245
chart!!.invalidate()
246246
}
247247

248248
R.id.actionToggleBarValues -> {
249249
for (set in chart!!.data!!.dataSets) {
250-
if (set is BarDataSet) set.setDrawValues(!set.isDrawValues)
250+
if (set is BarDataSet) set.isDrawValues = !set.isDrawValues
251251
}
252252
chart!!.invalidate()
253253
}

app/src/main/kotlin/info/appdev/chartexample/CubicLineChartActivity.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ class CubicLineChartActivity : DemoBase(), OnSeekBarChangeListener {
154154
}
155155

156156
R.id.actionToggleValues -> {
157-
for (set in binding.chart1.data!!.dataSets) set.setDrawValues(!set.isDrawValues)
158-
157+
binding.chart1.data!!.dataSets.forEach { set ->
158+
set.setDrawValues(!set.isDrawValues())
159+
}
159160
binding.chart1.invalidate()
160161
}
161162

app/src/main/kotlin/info/appdev/chartexample/DrawChartActivity.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,9 @@ class DrawChartActivity : DemoBase(), OnChartValueSelectedListener, OnDrawListen
7979
override fun onOptionsItemSelected(item: MenuItem): Boolean {
8080
when (item.itemId) {
8181
R.id.actionToggleValues -> {
82-
val sets = binding.chart1.data!!.dataSets
83-
84-
for (set in sets) {
85-
set.setDrawValues(!set.isDrawValues)
82+
binding.chart1.data!!.dataSets.forEach { set ->
83+
set.setDrawValues(!set.isDrawValues())
8684
}
87-
8885
binding.chart1.invalidate()
8986
}
9087

app/src/main/kotlin/info/appdev/chartexample/HorizontalBarChartActivity.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,9 @@ class HorizontalBarChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartV
153153
}
154154

155155
R.id.actionToggleValues -> {
156-
val sets = binding.chart1.data!!
157-
.dataSets
158-
159-
for (iSet in sets) {
160-
iSet.setDrawValues(!iSet.isDrawValues())
156+
binding.chart1.data!!.dataSets.forEach { set ->
157+
set.setDrawValues(!set.isDrawValues())
161158
}
162-
163159
binding.chart1.invalidate()
164160
}
165161

0 commit comments

Comments
 (0)