Skip to content

Commit a8f3fbb

Browse files
committed
Highlighter Kotlin
1 parent 83cc6b9 commit a8f3fbb

File tree

8 files changed

+216
-319
lines changed

8 files changed

+216
-319
lines changed

MPChartLib/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ android {
4747

4848
dependencies {
4949
implementation 'androidx.annotation:annotation:1.9.1'
50+
implementation 'androidx.core:core:1.16.0'
5051
testImplementation 'junit:junit:4.13.2'
5152
}
5253

MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.content.Context
44
import android.graphics.Color
55
import android.graphics.DashPathEffect
66
import android.graphics.Typeface
7+
import androidx.core.content.ContextCompat
78
import com.github.mikephil.charting.components.Legend.LegendForm
89
import com.github.mikephil.charting.components.YAxis.AxisDependency
910
import com.github.mikephil.charting.formatter.IValueFormatter
@@ -134,7 +135,7 @@ abstract class BaseDataSet<T : Entry?>() : IDataSet<T> {
134135
* as soon as the number of Entries the DataSet represents is higher than
135136
* the size of the colors array. If you are using colors from the resources,
136137
* make sure that the colors are already prepared (by calling
137-
* getResources().getColor(...)) before adding them to the DataSet.
138+
* ContextCompat.getColor(context,..) before adding them to the DataSet.
138139
*
139140
* @param colors
140141
*/
@@ -147,7 +148,7 @@ abstract class BaseDataSet<T : Entry?>() : IDataSet<T> {
147148
* as soon as the number of Entries the DataSet represents is higher than
148149
* the size of the colors array. If you are using colors from the resources,
149150
* make sure that the colors are already prepared (by calling
150-
* getResources().getColor(...)) before adding them to the DataSet.
151+
* ContextCompat.getColor(context,...)) before adding them to the DataSet.
151152
*
152153
* @param colors
153154
*/
@@ -161,16 +162,15 @@ abstract class BaseDataSet<T : Entry?>() : IDataSet<T> {
161162
* the size of the colors array. You can use
162163
* "new int[] { R.color.red, R.color.green, ... }" to provide colors for
163164
* this method. Internally, the colors are resolved using
164-
* getResources().getColor(...)
165+
* ContextCompat.getColor(context,...)
165166
*
166167
* @param colors
167168
*/
168-
fun setColors(colors: IntArray, c: Context) {
169-
169+
fun setColors(colors: IntArray, context: Context) {
170170
mColors.clear()
171171

172172
for (color in colors) {
173-
mColors.add(c.resources.getColor(color))
173+
mColors.add(ContextCompat.getColor(context, color))
174174
}
175175
}
176176

@@ -318,8 +318,8 @@ abstract class BaseDataSet<T : Entry?>() : IDataSet<T> {
318318
mFormLineDashEffect = dashPathEffect
319319
}
320320

321-
override fun getFormLineDashEffect(): DashPathEffect {
322-
return mFormLineDashEffect!!
321+
override fun getFormLineDashEffect(): DashPathEffect? {
322+
return mFormLineDashEffect
323323
}
324324

325325
override fun setDrawValues(enabled: Boolean) {

MPChartLib/src/main/java/com/github/mikephil/charting/highlight/Highlight.java

Lines changed: 0 additions & 245 deletions
This file was deleted.

0 commit comments

Comments
 (0)