Skip to content

Commit 284be55

Browse files
authored
Merge pull request #435 from AppDevNext/KotlinItems
Kotlin items
2 parents 0063449 + dd6e340 commit 284be55

34 files changed

+812
-920
lines changed

app/src/main/java/info/appdev/chartexample/BarChartActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import com.github.mikephil.charting.listener.OnChartValueSelectedListener
3131
import com.github.mikephil.charting.utils.Fill
3232
import com.github.mikephil.charting.utils.MPPointF
3333
import info.appdev.chartexample.DataTools.Companion.getValues
34-
import info.appdev.chartexample.custom.DayAxisValueFormatter
35-
import info.appdev.chartexample.custom.MyAxisValueFormatter
34+
import info.appdev.chartexample.formatter.DayAxisValueFormatter
35+
import info.appdev.chartexample.formatter.MyAxisValueFormatter
3636
import info.appdev.chartexample.custom.XYMarkerView
3737
import info.appdev.chartexample.notimportant.DemoBase
3838

app/src/main/java/info/appdev/chartexample/ListViewBarChartActivity.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import androidx.core.net.toUri
2727
/**
2828
* Demonstrates the use of charts inside a ListView. IMPORTANT: provide a
2929
* specific height attribute for the chart inside your ListView item
30-
*
31-
* @author Philipp Jahoda
3230
*/
3331
class ListViewBarChartActivity : DemoBase() {
3432
override fun onCreate(savedInstanceState: Bundle?) {

app/src/main/java/info/appdev/chartexample/ListViewMultiChartActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ class ListViewMultiChartActivity : DemoBase() {
6565
}
6666

6767
/** adapter that supports 3 different item types */
68-
private class ChartDataAdapter(context: Context, objects: MutableList<ChartItem?>) : ArrayAdapter<ChartItem?>(context, 0, objects) {
68+
private class ChartDataAdapter(context: Context, objects: MutableList<ChartItem?>) : ArrayAdapter<ChartItem>(context, 0, objects) {
6969
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
70-
return getItem(position)!!.getView(position, convertView, context)
70+
return getItem(position)!!.getView(position, convertView, context)!!
7171
}
7272

7373
override fun getItemViewType(position: Int): Int {
7474
// return the views type
7575
val ci = getItem(position)
76-
return if (ci != null) ci.getItemType() else 0
76+
return if (ci != null) ci.itemType else 0
7777
}
7878

7979
override fun getViewTypeCount(): Int {

app/src/main/java/info/appdev/chartexample/StackedBarActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import com.github.mikephil.charting.interfaces.datasets.IBarDataSet
2626
import com.github.mikephil.charting.listener.OnChartValueSelectedListener
2727
import com.github.mikephil.charting.utils.ColorTemplate
2828
import info.appdev.chartexample.DataTools.Companion.getValues
29-
import info.appdev.chartexample.custom.MyAxisValueFormatter
30-
import info.appdev.chartexample.custom.MyValueFormatter
29+
import info.appdev.chartexample.formatter.MyAxisValueFormatter
30+
import info.appdev.chartexample.formatter.MyValueFormatter
3131
import info.appdev.chartexample.notimportant.DemoBase
3232

3333
class StackedBarActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelectedListener {

app/src/main/java/info/appdev/chartexample/custom/CustomScatterShapeRenderer.java

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package info.appdev.chartexample.custom
2+
3+
import android.graphics.Canvas
4+
import android.graphics.Paint
5+
import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet
6+
import com.github.mikephil.charting.renderer.scatter.IShapeRenderer
7+
import com.github.mikephil.charting.utils.Utils
8+
import com.github.mikephil.charting.utils.ViewPortHandler
9+
10+
/**
11+
* Custom shape renderer that draws a single line.
12+
*/
13+
class CustomScatterShapeRenderer : IShapeRenderer {
14+
override fun renderShape(
15+
canvas: Canvas, dataSet: IScatterDataSet, viewPortHandler: ViewPortHandler?,
16+
posX: Float, posY: Float, renderPaint: Paint
17+
) {
18+
val shapeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeSize()) / 2f
19+
20+
canvas.drawLine(
21+
posX - shapeHalf,
22+
posY - shapeHalf,
23+
posX + shapeHalf,
24+
posY + shapeHalf,
25+
renderPaint
26+
)
27+
}
28+
}

app/src/main/java/info/appdev/chartexample/custom/DayAxisValueFormatter.kt renamed to app/src/main/java/info/appdev/chartexample/formatter/DayAxisValueFormatter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package info.appdev.chartexample.custom
1+
package info.appdev.chartexample.formatter
22

33
import com.github.mikephil.charting.charts.BarLineChartBase
44
import com.github.mikephil.charting.components.AxisBase

app/src/main/java/info/appdev/chartexample/custom/MyAxisValueFormatter.kt renamed to app/src/main/java/info/appdev/chartexample/formatter/MyAxisValueFormatter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package info.appdev.chartexample.custom
1+
package info.appdev.chartexample.formatter
22

33
import com.github.mikephil.charting.components.AxisBase
44
import com.github.mikephil.charting.formatter.IAxisValueFormatter

app/src/main/java/info/appdev/chartexample/custom/MyFillFormatter.kt renamed to app/src/main/java/info/appdev/chartexample/formatter/MyFillFormatter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package info.appdev.chartexample.custom
1+
package info.appdev.chartexample.formatter
22

33
import com.github.mikephil.charting.formatter.IFillFormatter
44
import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider
@@ -10,4 +10,4 @@ class MyFillFormatter(private val fillPos: Float) : IFillFormatter {
1010
// your logic could be here
1111
return fillPos
1212
}
13-
}
13+
}

app/src/main/java/info/appdev/chartexample/custom/MyValueFormatter.kt renamed to app/src/main/java/info/appdev/chartexample/formatter/MyValueFormatter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package info.appdev.chartexample.custom
1+
package info.appdev.chartexample.formatter
22

33
import com.github.mikephil.charting.data.Entry
44
import com.github.mikephil.charting.formatter.IValueFormatter

0 commit comments

Comments
 (0)