Skip to content

Commit 6c60d2f

Browse files
authored
Merge pull request #483 from AppDevNext/Utils2Kotlin
Utils to Kotlin
2 parents f9f2335 + 8c48095 commit 6c60d2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+578
-694
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.github.mikephil.charting.utils.MPPointF;
3434
import com.github.mikephil.charting.utils.Transformer;
3535
import com.github.mikephil.charting.utils.Utils;
36+
import com.github.mikephil.charting.utils.UtilsKtKt;
3637

3738
import androidx.annotation.NonNull;
3839

@@ -181,7 +182,7 @@ protected void init() {
181182
mBorderPaint = new Paint();
182183
mBorderPaint.setStyle(Style.STROKE);
183184
mBorderPaint.setColor(Color.BLACK);
184-
mBorderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
185+
mBorderPaint.setStrokeWidth(UtilsKtKt.convertDpToPixel(1f));
185186
}
186187

187188
// for performance tracking
@@ -515,7 +516,7 @@ public void calculateOffsets() {
515516
offsetBottom += getExtraBottomOffset();
516517
offsetLeft += getExtraLeftOffset();
517518

518-
float minOffset = Utils.convertDpToPixel(mMinOffset);
519+
float minOffset = UtilsKtKt.convertDpToPixel(mMinOffset);
519520

520521
mViewPortHandler.restrainViewPort(Math.max(minOffset, offsetLeft), Math.max(minOffset, offsetTop), Math.max(minOffset, offsetRight), Math.max(minOffset, offsetBottom));
521522

@@ -549,8 +550,6 @@ protected void drawGridBackground(Canvas c) {
549550
* Returns the Transformer class that contains all matrices and is
550551
* responsible for transforming values into pixels on the screen and
551552
* backwards.
552-
*
553-
* @return
554553
*/
555554
public Transformer getTransformer(AxisDependency which) {
556555
if (which == AxisDependency.LEFT) {
@@ -1165,7 +1164,7 @@ public boolean isClipDataToContentEnabled() {
11651164
* Sets the width of the border lines in dp.
11661165
*/
11671166
public void setBorderWidth(float width) {
1168-
mBorderPaint.setStrokeWidth(Utils.convertDpToPixel(width));
1167+
mBorderPaint.setStrokeWidth(UtilsKtKt.convertDpToPixel(width));
11691168
}
11701169

11711170
/**

MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.github.mikephil.charting.utils.MPPointF;
4141
import com.github.mikephil.charting.utils.SaveUtils;
4242
import com.github.mikephil.charting.utils.Utils;
43+
import com.github.mikephil.charting.utils.UtilsKtKt;
4344
import com.github.mikephil.charting.utils.ViewPortHandler;
4445

4546
import java.util.ArrayList;
@@ -209,7 +210,8 @@ protected void init() {
209210

210211
// initialize the utils
211212
Utils.init(getContext());
212-
mMaxHighlightDistance = Utils.convertDpToPixel(500f);
213+
UtilsKtKt.initUtils(getContext());
214+
mMaxHighlightDistance = UtilsKtKt.convertDpToPixel(500f);
213215

214216
mDescription = new Description();
215217
mLegend = new Legend();
@@ -223,7 +225,7 @@ protected void init() {
223225
mInfoPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
224226
mInfoPaint.setColor(Color.rgb(247, 189, 51)); // orange
225227
mInfoPaint.setTextAlign(Align.CENTER);
226-
mInfoPaint.setTextSize(Utils.convertDpToPixel(12f));
228+
mInfoPaint.setTextSize(UtilsKtKt.convertDpToPixel(12f));
227229

228230
if (mLogEnabled) {
229231
Log.i("", "Chart.init()");
@@ -364,7 +366,7 @@ protected void setupDefaultFormatter(float min, float max) {
364366
reference = Math.abs(max - min);
365367
}
366368

367-
int digits = Utils.getDecimals(reference);
369+
int digits = UtilsKtKt.getDecimals(reference);
368370

369371
// setup the formatter with a new number of digits
370372
mDefaultValueFormatter.setup(digits);
@@ -464,7 +466,7 @@ public float getMaxHighlightDistance() {
464466
* Default: 500dp
465467
*/
466468
public void setMaxHighlightDistance(float distDp) {
467-
mMaxHighlightDistance = Utils.convertDpToPixel(distDp);
469+
mMaxHighlightDistance = UtilsKtKt.convertDpToPixel(distDp);
468470
}
469471

470472
/**
@@ -1031,7 +1033,7 @@ public void setExtraOffsets(float left, float top, float right, float bottom) {
10311033
* Set an extra offset to be appended to the viewport's top
10321034
*/
10331035
public void setExtraTopOffset(float offset) {
1034-
mExtraTopOffset = Utils.convertDpToPixel(offset);
1036+
mExtraTopOffset = UtilsKtKt.convertDpToPixel(offset);
10351037
}
10361038

10371039
/**
@@ -1045,7 +1047,7 @@ public float getExtraTopOffset() {
10451047
* Set an extra offset to be appended to the viewport's right
10461048
*/
10471049
public void setExtraRightOffset(float offset) {
1048-
mExtraRightOffset = Utils.convertDpToPixel(offset);
1050+
mExtraRightOffset = UtilsKtKt.convertDpToPixel(offset);
10491051
}
10501052

10511053
/**
@@ -1059,7 +1061,7 @@ public float getExtraRightOffset() {
10591061
* Set an extra offset to be appended to the viewport's bottom
10601062
*/
10611063
public void setExtraBottomOffset(float offset) {
1062-
mExtraBottomOffset = Utils.convertDpToPixel(offset);
1064+
mExtraBottomOffset = UtilsKtKt.convertDpToPixel(offset);
10631065
}
10641066

10651067
/**
@@ -1073,7 +1075,7 @@ public float getExtraBottomOffset() {
10731075
* Set an extra offset to be appended to the viewport's left
10741076
*/
10751077
public void setExtraLeftOffset(float offset) {
1076-
mExtraLeftOffset = Utils.convertDpToPixel(offset);
1078+
mExtraLeftOffset = UtilsKtKt.convertDpToPixel(offset);
10771079
}
10781080

10791081
/**
@@ -1492,7 +1494,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
14921494
@Override
14931495
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
14941496
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
1495-
int size = (int) Utils.convertDpToPixel(50f);
1497+
int size = (int) UtilsKtKt.convertDpToPixel(50f);
14961498
setMeasuredDimension(Math.max(getSuggestedMinimumWidth(), resolveSize(size, widthMeasureSpec)), Math.max(getSuggestedMinimumHeight(), resolveSize(size, heightMeasureSpec)));
14971499
}
14981500

0 commit comments

Comments
 (0)