|
@@ -5,16 +5,20 @@ import androidx.fragment.app.Fragment
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
|
+import android.widget.Toast
|
|
|
+import androidx.appcompat.app.AppCompatActivity
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
+import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.sambath.kunkhmer.R
|
|
|
import com.sambath.kunkhmer.adapter.LivesAdapter
|
|
|
import com.sambath.kunkhmer.adapter.LivesCardItem
|
|
|
import kotlinx.android.synthetic.main.fragment_event.view.recyclerViewEvent
|
|
|
import kotlinx.android.synthetic.main.fragment_lives.view.recyclerViewLives
|
|
|
|
|
|
-class LivesFragment : Fragment() {
|
|
|
+class LivesFragment : Fragment(), LivesAdapter.OnItemClickListener {
|
|
|
private var _root: View? = null
|
|
|
private val binding get() = _root!!
|
|
|
+ private var cardList: List<LivesCardItem>? = null
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
@@ -34,8 +38,8 @@ class LivesFragment : Fragment() {
|
|
|
|
|
|
private fun setEvent() {
|
|
|
val recyclerView = binding.recyclerViewLives
|
|
|
- val cardList = createCardList() // Create your card data list here
|
|
|
- val cardAdapter = LivesAdapter(cardList)
|
|
|
+ cardList = createCardList() // Create your card data list here
|
|
|
+ val cardAdapter = LivesAdapter(cardList!!, this)
|
|
|
|
|
|
recyclerView.layoutManager =
|
|
|
LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
|
|
@@ -58,4 +62,22 @@ class LivesFragment : Fragment() {
|
|
|
// Add more card items as needed
|
|
|
)
|
|
|
}
|
|
|
+
|
|
|
+ override fun onItemClick(position: Int) {
|
|
|
+ val clickedItem = cardList!![position]
|
|
|
+ val liveDetailFragment = LiveDetailFragment()
|
|
|
+
|
|
|
+ // You can pass data to the LiveDetailFragment using arguments if needed
|
|
|
+ val bundle = Bundle()
|
|
|
+ bundle.putString("image_url", clickedItem.imageResource)
|
|
|
+ bundle.putString("title", clickedItem.title)
|
|
|
+ bundle.putString("description", clickedItem.title)
|
|
|
+ liveDetailFragment.arguments = bundle
|
|
|
+
|
|
|
+ // Replace the current fragment with the LiveDetailFragment
|
|
|
+ parentFragmentManager.beginTransaction()
|
|
|
+ .replace(R.id.nav_host_fragment_activity_main, liveDetailFragment)
|
|
|
+ .addToBackStack(null) // Add to back stack to handle the back navigation
|
|
|
+ .commit()
|
|
|
+ }
|
|
|
}
|