A fork of Simple Time Tracker with WearOS support. (Now integrated upstream)
0

Configure Feed

Select the types of activity you want to include in your feed.

add edit mode initialization for pie chart view

razeeman (Jun 6, 2020, 11:09 AM +0300) f32e8455 b3220370

+13 -9
+13 -9
feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/customView/PieChartView.kt
··· 49 49 init { 50 50 initArgs(context, attrs, defStyleAttr) 51 51 initPaint() 52 - if (segmentCount != 0) populateChart() 52 + initEditMode() 53 53 setLayerType(LAYER_TYPE_SOFTWARE, null) 54 54 } 55 55 ··· 256 256 } 257 257 } 258 258 259 - private fun populateChart() { 260 - (segmentCount downTo 1).map { 261 - PiePortion( 262 - value = it.toLong(), 263 - colorInt = Color.BLACK, 264 - iconId = R.drawable.unknown 265 - ) 266 - }.let(::setSegments) 259 + private fun initEditMode() { 260 + val segments = segmentCount.takeIf { it != 0 } ?: 5 261 + if (isInEditMode) { 262 + (segments downTo 1) 263 + .map { 264 + PiePortion( 265 + value = it.toLong(), 266 + colorInt = Color.BLACK, 267 + iconId = R.drawable.unknown 268 + ) 269 + }.let(::setSegments) 270 + } 267 271 } 268 272 269 273 private fun getIconDrawable(iconId: Int): Drawable? {