Skip to content

Commit 842e50a

Browse files
authored
Merge pull request #73 from AppDevNext/FixLints
Fix lint warnings
2 parents 4427ccb + 5f9750b commit 842e50a

File tree

2 files changed

+19
-39
lines changed
  • MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/notimportant
  • MPChartLib/src/main/java/com/github/mikephil/charting/utils

2 files changed

+19
-39
lines changed

MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/notimportant/MainActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ protected void onCreate(Bundle savedInstanceState) {
5959
WindowManager.LayoutParams.FLAG_FULLSCREEN);
6060
setContentView(R.layout.activity_main);
6161

62-
setTitle("MPAndroidChart Example");
63-
6462
// initialize the utilities
6563
Utils.init(this);
6664

MPChartLib/src/main/java/com/github/mikephil/charting/utils/Utils.java

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@
77
import android.graphics.Canvas;
88
import android.graphics.Paint;
99
import android.graphics.Rect;
10-
import android.graphics.drawable.BitmapDrawable;
1110
import android.graphics.drawable.Drawable;
12-
import android.os.Build;
1311
import android.text.Layout;
1412
import android.text.StaticLayout;
1513
import android.text.TextPaint;
1614
import android.util.DisplayMetrics;
1715
import android.util.Log;
18-
import android.util.SizeF;
1916
import android.view.MotionEvent;
2017
import android.view.VelocityTracker;
2118
import android.view.View;
@@ -34,6 +31,7 @@
3431
*
3532
* @author Philipp Jahoda
3633
*/
34+
@SuppressWarnings("JavaDoc")
3735
public abstract class Utils {
3836

3937
private static DisplayMetrics mMetrics;
@@ -50,8 +48,6 @@ public abstract class Utils {
5048

5149
/**
5250
* initialize method, called inside the Chart.init() method.
53-
*
54-
* @param context
5551
*/
5652
@SuppressWarnings("deprecation")
5753
public static void init(Context context) {
@@ -148,7 +144,7 @@ public static int calcTextWidth(Paint paint, String demoText) {
148144
return (int) paint.measureText(demoText);
149145
}
150146

151-
private static Rect mCalcTextHeightRect = new Rect();
147+
private static final Rect mCalcTextHeightRect = new Rect();
152148
/**
153149
* calculates the approximate height of a text, depending on a demo text
154150
* avoid repeated calls (e.g. inside drawing methods)
@@ -165,7 +161,7 @@ public static int calcTextHeight(Paint paint, String demoText) {
165161
return r.height();
166162
}
167163

168-
private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics();
164+
private static final Paint.FontMetrics mFontMetrics = new Paint.FontMetrics();
169165

170166
public static float getLineHeight(Paint paint) {
171167
return getLineHeight(paint, mFontMetrics);
@@ -201,7 +197,7 @@ public static FSize calcTextSize(Paint paint, String demoText) {
201197
return result;
202198
}
203199

204-
private static Rect mCalcTextSizeRect = new Rect();
200+
private static final Rect mCalcTextSizeRect = new Rect();
205201
/**
206202
* calculates the approximate size of a text, depending on a demo text
207203
* avoid repeated calls (e.g. inside drawing methods)
@@ -225,15 +221,14 @@ public static void calcTextSize(Paint paint, String demoText, FSize outputFSize)
225221
* Math.pow(...) is very expensive, so avoid calling it and create it
226222
* yourself.
227223
*/
228-
private static final int POW_10[] = {
224+
private static final int[] POW_10 = {
229225
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000
230226
};
231227

232-
private static IValueFormatter mDefaultValueFormatter = generateDefaultValueFormatter();
228+
private static final IValueFormatter mDefaultValueFormatter = generateDefaultValueFormatter();
233229

234230
private static IValueFormatter generateDefaultValueFormatter() {
235-
final DefaultValueFormatter formatter = new DefaultValueFormatter(1);
236-
return formatter;
231+
return new DefaultValueFormatter(1);
237232
}
238233

239234
/// - returns: The default value formatter used for all chart components that needs a default
@@ -276,10 +271,7 @@ public static String formatNumber(float number, int digitCount, boolean separate
276271
return "0";
277272
}
278273

279-
boolean zero = false;
280-
if (number < 1 && number > -1) {
281-
zero = true;
282-
}
274+
boolean zero = number < 1 && number > -1;
283275

284276
if (number < 0) {
285277
neg = true;
@@ -353,11 +345,11 @@ public static String formatNumber(float number, int digitCount, boolean separate
353345
* @return
354346
*/
355347
public static float roundToNextSignificant(double number) {
356-
if (Double.isInfinite(number) ||
357-
Double.isNaN(number) ||
348+
if (Double.isInfinite(number) ||
349+
Double.isNaN(number) ||
358350
number == 0.0)
359351
return 0;
360-
352+
361353
final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));
362354
final int pw = 1 - (int) d;
363355
final float magnitude = (float) Math.pow(10, pw);
@@ -375,10 +367,10 @@ public static float roundToNextSignificant(double number) {
375367
public static int getDecimals(float number) {
376368

377369
float i = roundToNextSignificant(number);
378-
370+
379371
if (Float.isInfinite(i))
380372
return 0;
381-
373+
382374
return (int) Math.ceil(-Math.log10(i)) + 2;
383375
}
384376

@@ -398,7 +390,7 @@ public static int[] convertIntegers(List<Integer> integers) {
398390
}
399391

400392
public static void copyIntegers(List<Integer> from, int[] to){
401-
int count = to.length < from.size() ? to.length : from.size();
393+
int count = Math.min(to.length, from.size());
402394
for(int i = 0 ; i < count ; i++){
403395
to[i] = from.get(i);
404396
}
@@ -421,13 +413,6 @@ public static String[] convertStrings(List<String> strings) {
421413
return ret;
422414
}
423415

424-
public static void copyStrings(List<String> from, String[] to){
425-
int count = to.length < from.size() ? to.length : from.size();
426-
for(int i = 0 ; i < count ; i++){
427-
to[i] = from.get(i);
428-
}
429-
}
430-
431416
/**
432417
* Replacement for the Math.nextUp(...) method that is only available in
433418
* HONEYCOMB and higher. Dat's some seeeeek sheeet.
@@ -501,10 +486,7 @@ public static void velocityTrackerPointerUpCleanUpIfNecessary(MotionEvent ev,
501486
*/
502487
@SuppressLint("NewApi")
503488
public static void postInvalidateOnAnimation(View view) {
504-
if (Build.VERSION.SDK_INT >= 16)
505-
view.postInvalidateOnAnimation();
506-
else
507-
view.postInvalidateDelayed(10);
489+
view.postInvalidateOnAnimation();
508490
}
509491

510492
public static int getMinimumFlingVelocity() {
@@ -525,7 +507,7 @@ public static float getNormalizedAngle(float angle) {
525507
return angle % 360.f;
526508
}
527509

528-
private static Rect mDrawableBoundsCache = new Rect();
510+
private static final Rect mDrawableBoundsCache = new Rect();
529511

530512
public static void drawImage(Canvas canvas,
531513
Drawable drawable,
@@ -550,8 +532,8 @@ public static void drawImage(Canvas canvas,
550532
canvas.restoreToCount(saveId);
551533
}
552534

553-
private static Rect mDrawTextRectBuffer = new Rect();
554-
private static Paint.FontMetrics mFontMetricsBuffer = new Paint.FontMetrics();
535+
private static final Rect mDrawTextRectBuffer = new Rect();
536+
private static final Paint.FontMetrics mFontMetricsBuffer = new Paint.FontMetrics();
555537

556538
public static void drawXAxisValue(Canvas c, String text, float x, float y,
557539
Paint paint,
@@ -569,7 +551,7 @@ public static void drawXAxisValue(Canvas c, String text, float x, float y,
569551
// Android does not snap the bounds to line boundaries,
570552
// and draws from bottom to top.
571553
// And we want to normalize it.
572-
drawOffsetY += -mFontMetricsBuffer.ascent;
554+
drawOffsetY -= mFontMetricsBuffer.ascent;
573555

574556
// To have a consistent point of reference, we always draw left-aligned
575557
Paint.Align originalTextAlign = paint.getTextAlign();

0 commit comments

Comments
 (0)