@@ -388,7 +388,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
388
388
* array of Highlight objects that reference the highlighted slices in the
389
389
* chart
390
390
*/
391
- protected var mIndicesToHighlight: Array <Highlight ? >? = null
391
+ protected var mIndicesToHighlight: Array <Highlight >? = null
392
392
393
393
/* *
394
394
* 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
415
415
*
416
416
* @return
417
417
*/
418
- open fun getHighlighted (): Array <Highlight ? >? {
418
+ open fun getHighlighted (): Array <Highlight >? {
419
419
return mIndicesToHighlight
420
420
}
421
421
@@ -446,16 +446,16 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
446
446
* @return
447
447
*/
448
448
open fun valuesToHighlight (): Boolean {
449
- return ! (mIndicesToHighlight == null || mIndicesToHighlight!! .isEmpty() || mIndicesToHighlight !! [ 0 ] == null )
449
+ return ! (mIndicesToHighlight == null || mIndicesToHighlight!! .isEmpty())
450
450
}
451
451
452
452
/* *
453
453
* Sets the last highlighted value for the touchlistener.
454
454
*
455
455
* @param highs
456
456
*/
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()) {
459
459
mChartTouchListener!! .setLastHighlighted(null )
460
460
} else {
461
461
mChartTouchListener!! .setLastHighlighted(highs[0 ])
@@ -470,7 +470,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
470
470
*
471
471
* @param highs
472
472
*/
473
- open fun highlightValues (highs : Array <Highlight ? >? ) {
473
+ open fun highlightValues (highs : Array <Highlight >? ) {
474
474
475
475
// set the indices to highlight
476
476
mIndicesToHighlight = highs
@@ -605,27 +605,27 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
605
605
* @param callListener - call the listener
606
606
*/
607
607
open fun highlightValue (high : Highlight ? , callListener : Boolean ) {
608
- var high = high
608
+ var mHigh = high
609
609
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 )
613
613
if (e == null ) {
614
614
mIndicesToHighlight = null
615
- high = null
615
+ mHigh = null
616
616
} else {
617
617
618
618
// set the indices to highlight
619
619
mIndicesToHighlight = arrayOf(
620
- high
620
+ mHigh
621
621
)
622
622
}
623
623
}
624
624
setLastHighlighted(mIndicesToHighlight)
625
625
if (callListener && mSelectionListener != null ) {
626
626
if (! valuesToHighlight()) mSelectionListener!! .onNothingSelected() else {
627
627
// notify the listener
628
- mSelectionListener!! .onValueSelected(e!! , high !! )
628
+ mSelectionListener!! .onValueSelected(e!! , mHigh !! )
629
629
}
630
630
}
631
631
@@ -696,9 +696,9 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
696
696
if (mMarker == null || ! isDrawMarkersEnabled() || ! valuesToHighlight()) return
697
697
for (i in mIndicesToHighlight!! .indices) {
698
698
val highlight = mIndicesToHighlight!! [i]
699
- val set = mData!! .getDataSetByIndex(highlight!! .getDataSetIndex())!!
699
+ val set = mData!! .getDataSetByIndex(highlight.getDataSetIndex())!!
700
700
val e = mData!! .getEntryForHighlight(
701
- mIndicesToHighlight!! [i]!!
701
+ mIndicesToHighlight!! [i]
702
702
)
703
703
val entryIndex = set.getEntryIndex(e)
704
704
@@ -782,10 +782,10 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
782
782
* @param newValue
783
783
*/
784
784
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
789
789
}
790
790
791
791
/* *
@@ -1450,7 +1450,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
1450
1450
*/
1451
1451
open fun saveToPath (title : String , pathOnSD : String ): Boolean {
1452
1452
val b = getChartBitmap()
1453
- var stream: OutputStream ? = null
1453
+ val stream: OutputStream ?
1454
1454
try {
1455
1455
stream = FileOutputStream (
1456
1456
Environment .getExternalStorageDirectory().path
@@ -1490,9 +1490,9 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
1490
1490
quality : Int
1491
1491
): Boolean {
1492
1492
// 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
1496
1496
val currentTime = System .currentTimeMillis()
1497
1497
val extBaseDir = Environment .getExternalStorageDirectory()
1498
1498
val file = File (extBaseDir.absolutePath + " /DCIM/" + subFolderPath)
@@ -1501,31 +1501,31 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
1501
1501
return false
1502
1502
}
1503
1503
}
1504
- var mimeType: String = " "
1504
+ val mimeType: String
1505
1505
when (format) {
1506
1506
CompressFormat .PNG -> {
1507
1507
mimeType = " image/png"
1508
- if (! fileName .endsWith(" .png" )) fileName + = " .png"
1508
+ if (! mFileName .endsWith(" .png" )) mFileName + = " .png"
1509
1509
}
1510
1510
CompressFormat .WEBP -> {
1511
1511
mimeType = " image/webp"
1512
- if (! fileName .endsWith(" .webp" )) fileName + = " .webp"
1512
+ if (! mFileName .endsWith(" .webp" )) mFileName + = " .webp"
1513
1513
}
1514
1514
CompressFormat .JPEG -> {
1515
1515
mimeType = " image/jpeg"
1516
- if (! (fileName .endsWith(" .jpg" ) || fileName .endsWith(" .jpeg" ))) fileName + = " .jpg"
1516
+ if (! (mFileName .endsWith(" .jpg" ) || mFileName .endsWith(" .jpeg" ))) mFileName + = " .jpg"
1517
1517
}
1518
1518
else -> {
1519
1519
mimeType = " image/jpeg"
1520
- if (! (fileName .endsWith(" .jpg" ) || fileName .endsWith(" .jpeg" ))) fileName + = " .jpg"
1520
+ if (! (mFileName .endsWith(" .jpg" ) || mFileName .endsWith(" .jpeg" ))) mFileName + = " .jpg"
1521
1521
}
1522
1522
}
1523
- val filePath = file.absolutePath + " /" + fileName
1524
- var out : FileOutputStream ? = null
1523
+ val filePath = file.absolutePath + " /" + mFileName
1524
+ val out : FileOutputStream ?
1525
1525
try {
1526
1526
out = FileOutputStream (filePath)
1527
1527
val b = getChartBitmap()
1528
- b.compress(format, quality , out )
1528
+ b.compress(format, mQuality , out )
1529
1529
out .flush()
1530
1530
out .close()
1531
1531
} catch (e: IOException ) {
@@ -1536,8 +1536,8 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry?>?>?> : ViewGroup, Cha
1536
1536
val values = ContentValues (8 )
1537
1537
1538
1538
// 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 )
1541
1541
values.put(Images .Media .DATE_ADDED , currentTime)
1542
1542
values.put(Images .Media .MIME_TYPE , mimeType)
1543
1543
values.put(Images .Media .DESCRIPTION , fileDescription)
0 commit comments