Skip to content

Commit 4e8c93c

Browse files
authored
Merge pull request #443 from AppDevNext/UtilsRestructure
Utils restructure
2 parents 5e3ac68 + 7aeb89f commit 4e8c93c

File tree

11 files changed

+132
-323
lines changed

11 files changed

+132
-323
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import com.github.mikephil.charting.utils.Transformer;
3737
import com.github.mikephil.charting.utils.Utils;
3838

39+
import androidx.annotation.NonNull;
40+
3941
/**
4042
* Base-class of LineChart, BarChart, ScatterChart and CandleStickChart.
4143
*
@@ -191,7 +193,7 @@ protected void init() {
191193
private long drawCycles = 0;
192194

193195
@Override
194-
protected void onDraw(Canvas canvas) {
196+
protected void onDraw(@NonNull Canvas canvas) {
195197
super.onDraw(canvas);
196198

197199
if (mData == null)
@@ -465,7 +467,7 @@ protected void calculateLegendOffsets(RectF offsets) {
465467
}
466468
}
467469

468-
private RectF mOffsetsBuffer = new RectF();
470+
private final RectF mOffsetsBuffer = new RectF();
469471

470472
@Override
471473
public void calculateOffsets() {
@@ -528,7 +530,7 @@ public void calculateOffsets() {
528530
if (mLogEnabled) {
529531
Log.i(LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop
530532
+ ", offsetRight: " + offsetRight + ", offsetBottom: " + offsetBottom);
531-
Log.i(LOG_TAG, "Content: " + mViewPortHandler.getContentRect().toString());
533+
Log.i(LOG_TAG, "Content: " + mViewPortHandler.getContentRect());
532534
}
533535
}
534536

@@ -1610,10 +1612,8 @@ public float getYChartMin() {
16101612
public boolean isAnyAxisInverted() {
16111613
if (mAxisLeft.isInverted())
16121614
return true;
1613-
if (mAxisRight.isInverted())
1614-
return true;
1615-
return false;
1616-
}
1615+
return mAxisRight.isInverted();
1616+
}
16171617

16181618
/**
16191619
* Flag that indicates if auto scaling on the y axis is enabled. This is

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

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22

33
import android.animation.ValueAnimator;
44
import android.animation.ValueAnimator.AnimatorUpdateListener;
5-
import android.content.ContentValues;
65
import android.content.Context;
76
import android.graphics.Bitmap;
8-
import android.graphics.Bitmap.CompressFormat;
97
import android.graphics.Canvas;
108
import android.graphics.Color;
119
import android.graphics.Paint;
1210
import android.graphics.Paint.Align;
1311
import android.graphics.RectF;
1412
import android.graphics.Typeface;
1513
import android.graphics.drawable.Drawable;
16-
import android.os.Environment;
17-
import android.provider.MediaStore.Images;
1814
import android.text.TextUtils;
1915
import android.util.AttributeSet;
2016
import android.util.Log;
@@ -48,14 +44,12 @@
4844
import com.github.mikephil.charting.utils.Utils;
4945
import com.github.mikephil.charting.utils.ViewPortHandler;
5046

51-
import java.io.File;
52-
import java.io.FileOutputStream;
53-
import java.io.IOException;
54-
import java.io.OutputStream;
5547
import java.util.ArrayList;
5648
import java.util.Collections;
5749
import java.util.List;
5850

51+
import androidx.annotation.NonNull;
52+
5953
/**
6054
* Baseclass of all Chart-Views.
6155
*
@@ -210,13 +204,9 @@ protected void init() {
210204
setWillNotDraw(false);
211205
// setLayerType(View.LAYER_TYPE_HARDWARE, null);
212206

213-
mAnimator = new ChartAnimator(new AnimatorUpdateListener() {
214-
215-
@Override
216-
public void onAnimationUpdate(ValueAnimator animation) {
217-
// ViewCompat.postInvalidateOnAnimation(Chart.this);
218-
postInvalidate();
219-
}
207+
mAnimator = new ChartAnimator(animation -> {
208+
// ViewCompat.postInvalidateOnAnimation(Chart.this);
209+
postInvalidate();
220210
});
221211

222212
// initialize the utils
@@ -387,7 +377,7 @@ protected void setupDefaultFormatter(float min, float max) {
387377
private boolean mOffsetsCalculated = false;
388378

389379
@Override
390-
protected void onDraw(Canvas canvas) {
380+
protected void onDraw(@NonNull Canvas canvas) {
391381
// super.onDraw(canvas);
392382

393383
if (mData == null) {
@@ -404,7 +394,7 @@ protected void onDraw(Canvas canvas) {
404394
break;
405395

406396
case RIGHT:
407-
pt.x *= 2.0;
397+
pt.x *= 2.0F;
408398
canvas.drawText(mNoDataText, pt.x, pt.y, mInfoPaint);
409399
break;
410400

@@ -1289,14 +1279,12 @@ public void setPaint(Paint p, int which) {
12891279
* @param which e.g. Chart.PAINT_LEGEND_LABEL
12901280
*/
12911281
public Paint getPaint(int which) {
1292-
switch (which) {
1293-
case PAINT_INFO:
1294-
return mInfoPaint;
1295-
case PAINT_DESCRIPTION:
1296-
return mDescPaint;
1297-
}
1282+
return switch (which) {
1283+
case PAINT_INFO -> mInfoPaint;
1284+
case PAINT_DESCRIPTION -> mDescPaint;
1285+
default -> null;
1286+
};
12981287

1299-
return null;
13001288
}
13011289

13021290
@Deprecated

0 commit comments

Comments
 (0)