|
@@ -7,6 +7,12 @@ import android.view.ViewGroup
|
|
|
import android.widget.TextView
|
|
|
import androidx.fragment.app.Fragment
|
|
|
import androidx.lifecycle.ViewModelProvider
|
|
|
+import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
+import com.khmer9.boxingapplication.R
|
|
|
+import com.khmer9.boxingapplication.adapter.CardItem
|
|
|
+import com.khmer9.boxingapplication.adapter.NewsFeedCardAdapter
|
|
|
+import com.khmer9.boxingapplication.adapter.SubTopNewsCardAdapter
|
|
|
+import com.khmer9.boxingapplication.adapter.TopNewsCardAdapter
|
|
|
import com.khmer9.boxingapplication.databinding.FragmentGalleryBinding
|
|
|
|
|
|
class BoxingFragment : Fragment() {
|
|
@@ -22,16 +28,13 @@ class BoxingFragment : Fragment() {
|
|
|
container: ViewGroup?,
|
|
|
savedInstanceState: Bundle?
|
|
|
): View {
|
|
|
- val galleryViewModel =
|
|
|
- ViewModelProvider(this).get(BoxingViewModel::class.java)
|
|
|
-
|
|
|
_binding = FragmentGalleryBinding.inflate(inflater, container, false)
|
|
|
val root: View = binding.root
|
|
|
|
|
|
- val textView: TextView = binding.textGallery
|
|
|
- galleryViewModel.text.observe(viewLifecycleOwner) {
|
|
|
- textView.text = it
|
|
|
- }
|
|
|
+ setTopNews()
|
|
|
+ setSubTopNews()
|
|
|
+ setNewsFeed()
|
|
|
+
|
|
|
return root
|
|
|
}
|
|
|
|
|
@@ -39,4 +42,46 @@ class BoxingFragment : Fragment() {
|
|
|
super.onDestroyView()
|
|
|
_binding = null
|
|
|
}
|
|
|
+
|
|
|
+ private fun setTopNews() {
|
|
|
+ val recyclerView = binding.recyclerViewTopNews
|
|
|
+ val cardList = createCardList() // Create your card data list here
|
|
|
+ val cardAdapter = TopNewsCardAdapter(cardList)
|
|
|
+
|
|
|
+ recyclerView.layoutManager =
|
|
|
+ LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
|
|
+ recyclerView.adapter = cardAdapter
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun setSubTopNews() {
|
|
|
+ val recyclerView = binding.recyclerViewSecondTopNews
|
|
|
+ val cardList = createCardList() // Create your card data list here
|
|
|
+ val cardAdapter = TopNewsCardAdapter(cardList)
|
|
|
+
|
|
|
+ recyclerView.layoutManager =
|
|
|
+ LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
|
|
+ recyclerView.adapter = cardAdapter
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun setNewsFeed() {
|
|
|
+ val recyclerView = binding.recyclerViewNewsFeed
|
|
|
+ val cardList = createCardList() // Create your card data list here
|
|
|
+ val cardAdapter = NewsFeedCardAdapter(cardList)
|
|
|
+
|
|
|
+ recyclerView.layoutManager =
|
|
|
+ LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
|
|
|
+ recyclerView.adapter = cardAdapter
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun createCardList(): List<CardItem> {
|
|
|
+ // Create and return your list of CardItems
|
|
|
+ return listOf(
|
|
|
+ CardItem(R.drawable.ic_launcher_background, "Date 1", "Title 1"),
|
|
|
+ CardItem(R.drawable.ic_launcher_background, "Date 2", "Title 2"),
|
|
|
+ CardItem(R.drawable.ic_launcher_background, "Date 3", "Title 3"),
|
|
|
+ CardItem(R.drawable.ic_launcher_background, "Date 4", "Title 4"),
|
|
|
+ CardItem(R.drawable.ic_launcher_background, "Date 5", "Title 5"),
|
|
|
+ // Add more card items as needed
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|