summaryrefslogtreecommitdiff
path: root/app/src/main/java/xyz
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/xyz')
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/ListAdapter.kt45
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/MainActivity.kt1
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt1
3 files changed, 47 insertions, 0 deletions
diff --git a/app/src/main/java/xyz/adjutor/aniki/ListAdapter.kt b/app/src/main/java/xyz/adjutor/aniki/ListAdapter.kt
new file mode 100644
index 0000000..74ba9c4
--- /dev/null
+++ b/app/src/main/java/xyz/adjutor/aniki/ListAdapter.kt
@@ -0,0 +1,45 @@
+package xyz.adjutor.aniki
+
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+
+class ListAdapter(private val dataSet: Array<String>) :
+ RecyclerView.Adapter<ListAdapter.ViewHolder>() {
+
+ /**
+ * Provide a reference to the type of views that you are using
+ * (custom ViewHolder).
+ */
+ class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ // Define click listener for the ViewHolder's View.
+ val firstLine: TextView = view.findViewById(R.id.firstLine)
+ val secondLine: TextView = view.findViewById(R.id.secondLine)
+
+ }
+
+ // Create new views (invoked by the layout manager)
+ override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
+ // Create a new view, which defines the UI of the list item
+ val view = LayoutInflater.from(viewGroup.context)
+ .inflate(R.layout.row_layout, viewGroup, false)
+
+ return ViewHolder(view)
+ }
+
+ // Replace the contents of a view (invoked by the layout manager)
+ override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
+
+ // Get element from your dataset at this position and replace the
+ // contents of the view with that element
+ viewHolder.firstLine.text = dataSet[position]
+ viewHolder.secondLine.text = dataSet[position]
+ }
+
+ // Return the size of your dataset (invoked by the layout manager)
+ override fun getItemCount() = dataSet.size
+
+}
+
diff --git a/app/src/main/java/xyz/adjutor/aniki/MainActivity.kt b/app/src/main/java/xyz/adjutor/aniki/MainActivity.kt
index 4ccae64..3ae1bf2 100644
--- a/app/src/main/java/xyz/adjutor/aniki/MainActivity.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/MainActivity.kt
@@ -6,6 +6,7 @@ import com.google.android.material.snackbar.Snackbar
import androidx.appcompat.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
+import androidx.recyclerview.widget.RecyclerView
class MainActivity : AppCompatActivity() {
diff --git a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt
index c64b9fe..a59e038 100644
--- a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt
@@ -27,5 +27,6 @@ class TopMangaPage : Fragment() {
view.findViewById<Button>(R.id.home).setOnClickListener {
findNavController().navigate(R.id.action_TopMangaPage_to_HomePage)
}
+
}
} \ No newline at end of file