@@ -4,6 +4,7 @@ import android.content.Context
44import android.graphics.Color
55import android.graphics.DashPathEffect
66import android.graphics.Typeface
7+ import androidx.core.content.ContextCompat
78import com.github.mikephil.charting.components.Legend.LegendForm
89import com.github.mikephil.charting.components.YAxis.AxisDependency
910import 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
@@ -266,7 +266,7 @@ abstract class BaseDataSet<T : Entry?>() : IDataSet<T> {
266266 mValueColors = colors
267267 }
268268
269- override fun setValueTypeface (tf : Typeface ) {
269+ override fun setValueTypeface (tf : Typeface ? ) {
270270 mValueTypeface = tf
271271 }
272272
@@ -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 ) {
0 commit comments