@@ -12,7 +12,6 @@ import android.graphics.Color
12
12
import android.graphics.Paint
13
13
import android.graphics.RectF
14
14
import android.util.AttributeSet
15
- import android.util.Log
16
15
import android.view.Gravity
17
16
import android.view.LayoutInflater
18
17
import android.view.MotionEvent
@@ -44,13 +43,29 @@ class ClickablePieChart @JvmOverloads constructor(
44
43
private var clickListener: ((String , Float ) -> Unit )? = null
45
44
private var pointsArray = arrayListOf<Pair <Float , Float >>()
46
45
46
+ // Attributes
47
+ private lateinit var popupText: String
48
+
47
49
init {
48
50
slicePaint.isAntiAlias = true
49
51
slicePaint.isDither = true
50
52
slicePaint.style = Paint .Style .FILL
51
53
52
54
centerPaint.color = Color .WHITE
53
55
centerPaint.style = Paint .Style .FILL
56
+
57
+ initAttributes(attrs)
58
+ }
59
+
60
+ private fun initAttributes (attrs : AttributeSet ? ) {
61
+ val typedArray =
62
+ context.theme.obtainStyledAttributes(attrs, R .styleable.ClickablePieChart , 0 , 0 )
63
+
64
+ try {
65
+ popupText = typedArray.getString(R .styleable.ClickablePieChart_popupText )!!
66
+ } finally {
67
+ typedArray.recycle()
68
+ }
54
69
}
55
70
56
71
private fun scale (): FloatArray {
@@ -138,7 +153,7 @@ class ClickablePieChart @JvmOverloads constructor(
138
153
var center = pointsArray[index].toList().average()
139
154
val halfRadius = rectF!! .centerX()
140
155
141
- popupView.findViewById<TextView >(R .id.textViewPopupText).text = " ${center.toInt()} ziyaret "
156
+ popupView.findViewById<TextView >(R .id.textViewPopupText).text = " ${center.toInt()} $popupText "
142
157
ImageViewCompat .setImageTintList(
143
158
popupView.findViewById<ImageView >(R .id.imageViewPopupCircleIndicator),
144
159
ColorStateList .valueOf(ContextCompat .getColor(context, sliceColors[index]))
0 commit comments