Skip to content

Commit 5421723

Browse files
committed
warning5
1 parent a52ceb1 commit 5421723

32 files changed

+209
-209
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ abstract class BarLineChartBase<T : BarLineScatterCandleBubbleData<out IBarLineS
670670
recycleInstance(origin)
671671
}
672672

673-
protected var mFitScreenMatrixBuffer = Matrix()
673+
private var mFitScreenMatrixBuffer = Matrix()
674674

675675
/**
676676
* Resets all zooming and dragging and makes the chart fit exactly it's

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

+33-33
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
388388
* array of Highlight objects that reference the highlighted slices in the
389389
* chart
390390
*/
391-
protected var mIndicesToHighlight: Array<Highlight?>? = null
391+
protected var mIndicesToHighlight: Array<Highlight>? = null
392392

393393
/**
394394
* The maximum distance in dp away from an entry causing it to highlight.
@@ -415,7 +415,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
415415
*
416416
* @return
417417
*/
418-
open fun getHighlighted(): Array<Highlight?>? {
418+
open fun getHighlighted(): Array<Highlight>? {
419419
return mIndicesToHighlight
420420
}
421421

@@ -446,16 +446,16 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
446446
* @return
447447
*/
448448
open fun valuesToHighlight(): Boolean {
449-
return !(mIndicesToHighlight == null || mIndicesToHighlight!!.isEmpty() || mIndicesToHighlight!![0] == null)
449+
return !(mIndicesToHighlight == null || mIndicesToHighlight!!.isEmpty())
450450
}
451451

452452
/**
453453
* Sets the last highlighted value for the touchlistener.
454454
*
455455
* @param highs
456456
*/
457-
protected open fun setLastHighlighted(highs: Array<Highlight?>?) {
458-
if (highs == null || highs.isEmpty() || highs[0] == null) {
457+
protected open fun setLastHighlighted(highs: Array<Highlight>?) {
458+
if (highs == null || highs.isEmpty()) {
459459
mChartTouchListener!!.setLastHighlighted(null)
460460
} else {
461461
mChartTouchListener!!.setLastHighlighted(highs[0])
@@ -470,7 +470,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
470470
*
471471
* @param highs
472472
*/
473-
open fun highlightValues(highs: Array<Highlight?>?) {
473+
open fun highlightValues(highs: Array<Highlight>?) {
474474

475475
// set the indices to highlight
476476
mIndicesToHighlight = highs
@@ -605,27 +605,27 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
605605
* @param callListener - call the listener
606606
*/
607607
open fun highlightValue(high: Highlight?, callListener: Boolean) {
608-
var high = high
608+
var mHigh = high
609609
var e: Entry? = null
610-
if (high == null) mIndicesToHighlight = null else {
611-
if (mLogEnabled) Log.i(LOG_TAG, "Highlighted: $high")
612-
e = mData!!.getEntryForHighlight(high)
610+
if (mHigh == null) mIndicesToHighlight = null else {
611+
if (mLogEnabled) Log.i(LOG_TAG, "Highlighted: $mHigh")
612+
e = mData!!.getEntryForHighlight(mHigh)
613613
if (e == null) {
614614
mIndicesToHighlight = null
615-
high = null
615+
mHigh = null
616616
} else {
617617

618618
// set the indices to highlight
619619
mIndicesToHighlight = arrayOf(
620-
high
620+
mHigh
621621
)
622622
}
623623
}
624624
setLastHighlighted(mIndicesToHighlight)
625625
if (callListener && mSelectionListener != null) {
626626
if (!valuesToHighlight()) mSelectionListener!!.onNothingSelected() else {
627627
// notify the listener
628-
mSelectionListener!!.onValueSelected(e!!, high!!)
628+
mSelectionListener!!.onValueSelected(e!!, mHigh!!)
629629
}
630630
}
631631

@@ -696,9 +696,9 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
696696
if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight()) return
697697
for (i in mIndicesToHighlight!!.indices) {
698698
val highlight = mIndicesToHighlight!![i]
699-
val set = mData!!.getDataSetByIndex(highlight!!.getDataSetIndex())!!
699+
val set = mData!!.getDataSetByIndex(highlight.getDataSetIndex())!!
700700
val e = mData!!.getEntryForHighlight(
701-
mIndicesToHighlight!![i]!!
701+
mIndicesToHighlight!![i]
702702
)
703703
val entryIndex = set.getEntryIndex(e)
704704

@@ -782,10 +782,10 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
782782
* @param newValue
783783
*/
784784
open fun setDragDecelerationFrictionCoef(newValue: Float) {
785-
var newValue = newValue
786-
if (newValue < 0f) newValue = 0f
787-
if (newValue >= 1f) newValue = 0.999f
788-
mDragDecelerationFrictionCoef = newValue
785+
var mNewValue = newValue
786+
if (mNewValue < 0f) mNewValue = 0f
787+
if (mNewValue >= 1f) mNewValue = 0.999f
788+
mDragDecelerationFrictionCoef = mNewValue
789789
}
790790

791791
/**
@@ -1450,7 +1450,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
14501450
*/
14511451
open fun saveToPath(title: String, pathOnSD: String): Boolean {
14521452
val b = getChartBitmap()
1453-
var stream: OutputStream? = null
1453+
val stream: OutputStream?
14541454
try {
14551455
stream = FileOutputStream(
14561456
Environment.getExternalStorageDirectory().path
@@ -1490,9 +1490,9 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
14901490
quality: Int
14911491
): Boolean {
14921492
// restrain quality
1493-
var fileName = fileName
1494-
var quality = quality
1495-
if (quality < 0 || quality > 100) quality = 50
1493+
var mFileName = fileName
1494+
var mQuality = quality
1495+
if (mQuality < 0 || mQuality > 100) mQuality = 50
14961496
val currentTime = System.currentTimeMillis()
14971497
val extBaseDir = Environment.getExternalStorageDirectory()
14981498
val file = File(extBaseDir.absolutePath + "/DCIM/" + subFolderPath)
@@ -1501,31 +1501,31 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
15011501
return false
15021502
}
15031503
}
1504-
var mimeType: String = ""
1504+
val mimeType: String
15051505
when (format) {
15061506
CompressFormat.PNG -> {
15071507
mimeType = "image/png"
1508-
if (!fileName.endsWith(".png")) fileName += ".png"
1508+
if (!mFileName.endsWith(".png")) mFileName += ".png"
15091509
}
15101510
CompressFormat.WEBP -> {
15111511
mimeType = "image/webp"
1512-
if (!fileName.endsWith(".webp")) fileName += ".webp"
1512+
if (!mFileName.endsWith(".webp")) mFileName += ".webp"
15131513
}
15141514
CompressFormat.JPEG -> {
15151515
mimeType = "image/jpeg"
1516-
if (!(fileName.endsWith(".jpg") || fileName.endsWith(".jpeg"))) fileName += ".jpg"
1516+
if (!(mFileName.endsWith(".jpg") || mFileName.endsWith(".jpeg"))) mFileName += ".jpg"
15171517
}
15181518
else -> {
15191519
mimeType = "image/jpeg"
1520-
if (!(fileName.endsWith(".jpg") || fileName.endsWith(".jpeg"))) fileName += ".jpg"
1520+
if (!(mFileName.endsWith(".jpg") || mFileName.endsWith(".jpeg"))) mFileName += ".jpg"
15211521
}
15221522
}
1523-
val filePath = file.absolutePath + "/" + fileName
1524-
var out: FileOutputStream? = null
1523+
val filePath = file.absolutePath + "/" + mFileName
1524+
val out: FileOutputStream?
15251525
try {
15261526
out = FileOutputStream(filePath)
15271527
val b = getChartBitmap()
1528-
b.compress(format, quality, out)
1528+
b.compress(format, mQuality, out)
15291529
out.flush()
15301530
out.close()
15311531
} catch (e: IOException) {
@@ -1536,8 +1536,8 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
15361536
val values = ContentValues(8)
15371537

15381538
// store the details
1539-
values.put(Images.Media.TITLE, fileName)
1540-
values.put(Images.Media.DISPLAY_NAME, fileName)
1539+
values.put(Images.Media.TITLE, mFileName)
1540+
values.put(Images.Media.DISPLAY_NAME, mFileName)
15411541
values.put(Images.Media.DATE_ADDED, currentTime)
15421542
values.put(Images.Media.MIME_TYPE, mimeType)
15431543
values.put(Images.Media.DESCRIPTION, fileDescription)

MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieChart.kt

+18-13
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import com.github.mikephil.charting.components.XAxis
99
import com.github.mikephil.charting.data.PieData
1010
import com.github.mikephil.charting.highlight.Highlight
1111
import com.github.mikephil.charting.highlight.PieHighlighter
12-
import com.github.mikephil.charting.interfaces.datasets.IPieDataSet
1312
import com.github.mikephil.charting.renderer.PieChartRenderer
1413
import com.github.mikephil.charting.utils.MPPointF
1514
import com.github.mikephil.charting.utils.MPPointF.Companion.getInstance
1615
import com.github.mikephil.charting.utils.MPPointF.Companion.recycleInstance
1716
import com.github.mikephil.charting.utils.Utils.convertDpToPixel
1817
import com.github.mikephil.charting.utils.Utils.getNormalizedAngle
18+
import kotlin.math.min
1919

2020
/**
2121
* View that represents a pie chart. Draws cake like slices.
@@ -143,7 +143,7 @@ open class PieChart : PieRadarChartBase<PieData?> {
143143

144144
// create the circle box that will contain the pie-chart (the bounds of
145145
// the pie-chart)
146-
mCircleBox!![c.x - radius + shift, c.y - radius + shift, c.x + radius - shift] =
146+
mCircleBox[c.x - radius + shift, c.y - radius + shift, c.x + radius - shift] =
147147
c.y + radius - shift
148148
recycleInstance(c)
149149
}
@@ -152,7 +152,7 @@ open class PieChart : PieRadarChartBase<PieData?> {
152152
calcAngles()
153153
}
154154

155-
override fun getMarkerPosition(highlight: Highlight?): FloatArray {
155+
override fun getMarkerPosition(high: Highlight?): FloatArray {
156156
val center = getCenterCircleBox()
157157
var r = getRadius()
158158
var off = r / 10f * 3.6f
@@ -161,7 +161,7 @@ open class PieChart : PieRadarChartBase<PieData?> {
161161
}
162162
r -= off // offset to keep things inside the chart
163163
val rotationAngle = getRotationAngle();
164-
val entryIndex = highlight!!.getX().toInt()
164+
val entryIndex = high!!.getX().toInt()
165165

166166
// offset needed to center the drawn text in the slice
167167
val offset = mDrawAngles[entryIndex] / 2
@@ -432,7 +432,12 @@ open class PieChart : PieRadarChartBase<PieData?> {
432432
}
433433

434434
override fun getRadius(): Float {
435-
return if (mCircleBox == null) 0f else Math.min(
435+
// return if (mCircleBox == null) 0f
436+
// else Math.min(
437+
// mCircleBox.width() / 2f,
438+
// mCircleBox.height() / 2f
439+
// )
440+
return min(
436441
mCircleBox.width() / 2f,
437442
mCircleBox.height() / 2f
438443
)
@@ -453,7 +458,7 @@ open class PieChart : PieRadarChartBase<PieData?> {
453458
* @return
454459
*/
455460
fun getCenterCircleBox(): MPPointF {
456-
return getInstance(mCircleBox!!.centerX(), mCircleBox.centerY())
461+
return getInstance(mCircleBox.centerX(), mCircleBox.centerY())
457462
}
458463

459464
/**
@@ -695,10 +700,10 @@ open class PieChart : PieRadarChartBase<PieData?> {
695700
* @param maxangle min 90, max 360
696701
*/
697702
fun setMaxAngle(maxangle: Float) {
698-
var maxangle = maxangle
699-
if (maxangle > 360) maxangle = 360f
700-
if (maxangle < 90) maxangle = 90f
701-
mMaxAngle = maxangle
703+
var lMaxangle = maxangle
704+
if (lMaxangle > 360) lMaxangle = 360f
705+
if (lMaxangle < 90) lMaxangle = 90f
706+
mMaxAngle = lMaxangle
702707
}
703708

704709
/**
@@ -718,10 +723,10 @@ open class PieChart : PieRadarChartBase<PieData?> {
718723
* @param minAngle minimum 0, maximum is half of [.setMaxAngle]
719724
*/
720725
fun setMinAngleForSlices(minAngle: Float) {
721-
var minAngle = minAngle
722-
if (minAngle > mMaxAngle / 2f) minAngle = mMaxAngle / 2f else if (minAngle < 0) minAngle =
726+
var lMinAngle = minAngle
727+
if (lMinAngle > mMaxAngle / 2f) lMinAngle = mMaxAngle / 2f else if (lMinAngle < 0) lMinAngle =
723728
0f
724-
mMinAngleForSlices = minAngle
729+
mMinAngleForSlices = lMinAngle
725730
}
726731

727732
override fun onDetachedFromWindow() {

MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieRadarChartBase.kt

+5-7
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ abstract class PieRadarChartBase<T : ChartData<out IDataSet<out Entry?>?>?> : Ch
149149
}
150150
}
151151
LegendOrientation.HORIZONTAL -> {
152-
var yLegendOffset = 0f
152+
val yLegendOffset: Float
153153
if (mLegend!!.getVerticalAlignment() === LegendVerticalAlignment.TOP ||
154154
mLegend!!.getVerticalAlignment() === LegendVerticalAlignment.BOTTOM
155155
) {
@@ -209,7 +209,7 @@ abstract class PieRadarChartBase<T : ChartData<out IDataSet<out Entry?>?>?> : Ch
209209
*/
210210
open fun getAngleForPoint(x: Float, y: Float): Float {
211211
val c = getCenterOffsets()
212-
val tx = (x - c!!.x).toDouble()
212+
val tx = (x - c.x).toDouble()
213213
val ty = (y - c.y).toDouble()
214214
val length = Math.sqrt(tx * tx + ty * ty)
215215
val r = Math.acos(ty / length)
@@ -256,15 +256,13 @@ abstract class PieRadarChartBase<T : ChartData<out IDataSet<out Entry?>?>?> : Ch
256256
*/
257257
open fun distanceToCenter(x: Float, y: Float): Float {
258258
val c = getCenterOffsets()
259-
var dist = 0f
260-
var xDist = 0f
261-
var yDist = 0f
262-
xDist = if (x > c!!.x) {
259+
val dist: Float
260+
val xDist: Float = if (x > c.x) {
263261
x - c.x
264262
} else {
265263
c.x - x
266264
}
267-
yDist = if (y > c.y) {
265+
val yDist: Float = if (y > c.y) {
268266
y - c.y
269267
} else {
270268
c.y - y

MPChartLib/src/main/java/com/github/mikephil/charting/charts/RadarChart.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class RadarChart : PieRadarChartBase<RadarData?> {
108108
}
109109

110110
override fun onDraw(canvas: Canvas) {
111-
super.onDraw(canvas!!)
111+
super.onDraw(canvas)
112112
if (mData == null) return
113113

114114
// if (mYAxis.isEnabled())

MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,10 @@ abstract class AxisBase : ComponentBase {
339339
* @param count the number of y-axis labels that should be displayed
340340
*/
341341
open fun setLabelCount(count: Int) {
342-
var count = count
343-
if (count > getAxisMaxLabels()) count = getAxisMaxLabels()
344-
if (count < getAxisMinLabels()) count = getAxisMinLabels()
345-
mLabelCount = count
342+
var lCount = count
343+
if (lCount > getAxisMaxLabels()) lCount = getAxisMaxLabels()
344+
if (lCount < getAxisMinLabels()) lCount = getAxisMinLabels()
345+
mLabelCount = lCount
346346
mForceLabels = false
347347
}
348348

MPChartLib/src/main/java/com/github/mikephil/charting/components/ComponentBase.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ abstract class ComponentBase {
108108
* @param size the text size, in DP
109109
*/
110110
open fun setTextSize(size: Float) {
111-
var size = size
112-
if (size > 24f) size = 24f
113-
if (size < 6f) size = 6f
114-
mTextSize = convertDpToPixel(size)
111+
var lSize = size
112+
if (lSize > 24f) lSize = 24f
113+
if (lSize < 6f) lSize = 6f
114+
mTextSize = convertDpToPixel(lSize)
115115
}
116116

117117
/**

MPChartLib/src/main/java/com/github/mikephil/charting/components/Legend.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ class Legend : ComponentBase {
224224
}
225225

226226
fun setExtra(entries: Array<LegendEntry?>?) {
227-
var entries = entries
228-
if (entries == null) entries = arrayOf()
229-
mExtraEntries = entries
227+
var lEntries = entries
228+
if (lEntries == null) lEntries = arrayOf()
229+
mExtraEntries = lEntries
230230
}
231231

232232
/**

MPChartLib/src/main/java/com/github/mikephil/charting/components/LimitLine.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ class LimitLine : ComponentBase {
7878
* @param width
7979
*/
8080
fun setLineWidth(width: Float) {
81-
var width = width
82-
if (width < 0.2f) width = 0.2f
83-
if (width > 12.0f) width = 12.0f
84-
mLineWidth = convertDpToPixel(width)
81+
var lWidth = width
82+
if (lWidth < 0.2f) lWidth = 0.2f
83+
if (lWidth > 12.0f) lWidth = 12.0f
84+
mLineWidth = convertDpToPixel(lWidth)
8585
}
8686

8787
/**

0 commit comments

Comments
 (0)