Skip to content

Commit 2e8bbf7

Browse files
committed
Add SpecialChartListActivity with chart list UI
Introduces SpecialChartListActivity to display a list of special chart types using a RecyclerView. Adds SpecialChartAdapter, supporting layouts, and updates MainActivity and AndroidManifest.xml to integrate the new activity.
1 parent 0965bbf commit 2e8bbf7

File tree

6 files changed

+159
-1
lines changed

6 files changed

+159
-1
lines changed

sample/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<activity android:name=".additionalcontent.DoubleChartsLinkedWorkActivity" />
4242
<activity android:name=".additionalcontent.ScrollableChartActivity" />
4343
<activity android:name=".additionalcontent.AdvancedUpdatingFeatureActivity" />
44+
<activity android:name=".basiccontent.SpecialChartListActivity" />
4445
</application>
4546

4647
</manifest>

sample/src/main/java/com/github/aachartmodel/aainfographics/demo/basiccontent/MainActivity.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,10 @@ class MainActivity : AppCompatActivity() {
537537
val chartType = chartTypeArr[groupPosition][childPosition] as String
538538
when (groupPosition) {
539539
0 -> goToCommonChartActivity(chartType, childPosition)
540-
1 -> goToSpecialChartActivity(chartType)
540+
1 -> {
541+
val intent = Intent(this, SpecialChartListActivity::class.java)
542+
startActivity(intent)
543+
}
541544
2 -> goToMixedChartActivity(chartType)
542545
3 -> goToCustomStyleChartActivity(chartType)
543546
4 -> goToDrawChartWithAAOptionsActivity(chartType)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.github.aachartmodel.aainfographics.demo.basiccontent
2+
3+
import android.content.Context
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import android.widget.TextView
8+
import androidx.recyclerview.widget.RecyclerView
9+
import com.github.aachartmodel.aainfographics.aachartcreator.AAChartModel
10+
import com.github.aachartmodel.aainfographics.aachartcreator.AAChartView
11+
import com.github.aachartmodel.aainfographics.demo.R
12+
import com.github.aachartmodel.aainfographics.demo.chartcomposer.SpecialChartComposer
13+
14+
data class ChartItem(val name: String, val chartType: String)
15+
16+
class SpecialChartAdapter(
17+
private val context: Context,
18+
private val chartItems: List<ChartItem>
19+
) : RecyclerView.Adapter<SpecialChartAdapter.ViewHolder>() {
20+
21+
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
22+
val nameTextView: TextView = view.findViewById(R.id.tv_chart_name)
23+
val aaChartView: AAChartView = view.findViewById(R.id.aa_chart_view)
24+
}
25+
26+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
27+
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_special_chart, parent, false)
28+
return ViewHolder(view)
29+
}
30+
31+
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
32+
val item = chartItems[position]
33+
holder.nameTextView.text = item.name
34+
val aaChartModel = getChartModel(item.chartType)
35+
holder.aaChartView.aa_drawChartWithChartModel(aaChartModel)
36+
}
37+
38+
override fun getItemCount(): Int = chartItems.size
39+
40+
private fun getChartModel(chartType: String): AAChartModel {
41+
return when (chartType) {
42+
"Column" -> SpecialChartComposer.configurePolarColumnChart()
43+
"Bar" -> SpecialChartComposer.configurePolarBarChart()
44+
"Line" -> SpecialChartComposer.configurePolarLineChart()
45+
"Area" -> SpecialChartComposer.configurePolarAreaChart()
46+
"Pie" -> SpecialChartComposer.configurePieChart()
47+
"Bubble" -> SpecialChartComposer.configureBubbleChart()
48+
"Scatter" -> SpecialChartComposer.configureScatterChart()
49+
"Arearange" -> SpecialChartComposer.configureArearangeChart()
50+
"Areasplinerange" -> SpecialChartComposer.configureAreasplinerangeChart()
51+
"Columnrange" -> SpecialChartComposer.configureColumnrangeChart()
52+
"Spline" -> SpecialChartComposer.configureStepLineChart()
53+
"Areaspline" -> SpecialChartComposer.configureStepAreaChart()
54+
"Boxplot" -> SpecialChartComposer.configureBoxplotChart()
55+
"Waterfall" -> SpecialChartComposer.configureWaterfallChart()
56+
"Pyramid" -> SpecialChartComposer.configurePyramidChart()
57+
"Funnel" -> SpecialChartComposer.configureFunnelChart()
58+
"Errorbar" -> SpecialChartComposer.configureErrorbarChart()
59+
"Gauge" -> SpecialChartComposer.configureGaugeChart()
60+
"Polygon" -> SpecialChartComposer.configurePolygonChart()
61+
else -> SpecialChartComposer.configurePolarColumnChart()
62+
}
63+
}
64+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.github.aachartmodel.aainfographics.demo.basiccontent
2+
3+
import android.os.Bundle
4+
import androidx.appcompat.app.AppCompatActivity
5+
import androidx.recyclerview.widget.LinearLayoutManager
6+
import androidx.recyclerview.widget.RecyclerView
7+
import com.github.aachartmodel.aainfographics.demo.R
8+
9+
class SpecialChartListActivity : AppCompatActivity() {
10+
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
13+
setContentView(R.layout.activity_special_chart_list)
14+
15+
val recyclerView = findViewById<RecyclerView>(R.id.recycler_view)
16+
val chartItems = getChartItems()
17+
recyclerView.layoutManager = LinearLayoutManager(this)
18+
recyclerView.adapter = SpecialChartAdapter(this, chartItems)
19+
}
20+
21+
private fun getChartItems(): List<ChartItem> {
22+
return listOf(
23+
ChartItem("Polar Column Chart", "Column"),
24+
ChartItem("Polar Bar Chart", "Bar"),
25+
ChartItem("Polar Line Chart", "Line"),
26+
ChartItem("Polar Area Chart", "Area"),
27+
ChartItem("Pie Chart", "Pie"),
28+
ChartItem("Bubble Chart", "Bubble"),
29+
ChartItem("Scatter Chart", "Scatter"),
30+
ChartItem("Arearange Chart", "Arearange"),
31+
ChartItem("Areasplinerange Chart", "Areasplinerange"),
32+
ChartItem("Columnrange Chart", "Columnrange"),
33+
ChartItem("Step Line Chart", "Spline"),
34+
ChartItem("Step Area Chart", "Areaspline"),
35+
ChartItem("Boxplot Chart", "Boxplot"),
36+
ChartItem("Waterfall Chart", "Waterfall"),
37+
ChartItem("Pyramid Chart", "Pyramid"),
38+
ChartItem("Funnel Chart", "Funnel"),
39+
ChartItem("Errorbar Chart", "Errorbar"),
40+
ChartItem("Gauge Chart", "Gauge"),
41+
ChartItem("Polygon Chart", "Polygon")
42+
)
43+
}
44+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context=".basiccontent.SpecialChartListActivity">
8+
9+
<androidx.recyclerview.widget.RecyclerView
10+
android:id="@+id/recycler_view"
11+
android:layout_width="0dp"
12+
android:layout_height="0dp"
13+
app:layout_constraintBottom_toBottomOf="parent"
14+
app:layout_constraintEnd_toEndOf="parent"
15+
app:layout_constraintStart_toStartOf="parent"
16+
app:layout_constraintTop_toTopOf="parent" />
17+
18+
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:padding="8dp">
7+
8+
<TextView
9+
android:id="@+id/tv_chart_name"
10+
android:layout_width="0dp"
11+
android:layout_height="wrap_content"
12+
android:layout_marginBottom="8dp"
13+
android:textSize="16sp"
14+
android:textStyle="bold"
15+
app:layout_constraintEnd_toEndOf="parent"
16+
app:layout_constraintStart_toStartOf="parent"
17+
app:layout_constraintTop_toTopOf="parent" />
18+
19+
<com.github.aachartmodel.aainfographics.aachartcreator.AAChartView
20+
android:id="@+id/aa_chart_view"
21+
android:layout_width="0dp"
22+
android:layout_height="300dp"
23+
app:layout_constraintBottom_toBottomOf="parent"
24+
app:layout_constraintEnd_toEndOf="parent"
25+
app:layout_constraintStart_toStartOf="parent"
26+
app:layout_constraintTop_toBottomOf="@id/tv_chart_name" />
27+
28+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)