aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorClyhtsuriva <aimeric@adjutor.xyz>2021-02-17 22:57:15 +0100
committerClyhtsuriva <aimeric@adjutor.xyz>2021-02-17 22:57:15 +0100
commitc1d5a3e8fb8b3f8ac28d1e7818b5b33c0ab41b49 (patch)
tree8881509b7068b40a064866dff5fe8e27f0c0115c /app/src/main/java
parent7e0e688d4bc59bddfd5e9e69b0da57607c1e56ed (diff)
Recycler view now working in a fragment.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt21
1 files changed, 12 insertions, 9 deletions
diff --git a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt
index 17d124e..ac585c7 100644
--- a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt
@@ -1,13 +1,13 @@
package xyz.adjutor.aniki
import android.os.Bundle
-import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
-import androidx.appcompat.app.AppCompatActivity
+import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
+import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
class TopMangaPage : Fragment() {
@@ -17,7 +17,16 @@ class TopMangaPage : Fragment() {
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
- return inflater.inflate(R.layout.top_manga_page, container, false)
+ val view = inflater.inflate(R.layout.top_manga_page, container, false)
+
+ // Retrieves data from mangasource
+ val mangaList = MangaSource(view.context).getMangaList()
+
+ val recyclerView: RecyclerView = view.findViewById(R.id.recycler_view)
+ recyclerView.setHasFixedSize(true)
+ recyclerView.layoutManager = LinearLayoutManager(view.context)
+ recyclerView.adapter = MangaAdapter(mangaList)
+ return view
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -27,11 +36,5 @@ class TopMangaPage : Fragment() {
findNavController().navigate(R.id.action_TopMangaPage_to_HomePage)
}
- // Retrieves data from mangasource
- val mangaList = MangaSource(requireActivity().applicationContext).getMangaList()
-
- val recyclerView: RecyclerView = view.findViewById(R.id.recycler_view)
- recyclerView.adapter = MangaAdapter(mangaList)
-
}
} \ No newline at end of file