|
@@ -1,5 +1,6 @@
|
|
|
package com.sambath.sbc.adapter
|
|
|
|
|
|
+import android.graphics.drawable.Drawable
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
@@ -26,13 +27,26 @@ class FighterAdapter (private val cardList: List<FighterCardItem>) : RecyclerVie
|
|
|
holder.imageRightTitle.text = currentItem.imageRightTitle
|
|
|
holder.date.text = currentItem.date
|
|
|
holder.title.text = currentItem.title
|
|
|
- holder.favorite.setOnCheckedChangeListener { buttonView, isChecked ->
|
|
|
- if (currentItem.favorite) {
|
|
|
+
|
|
|
+ if(currentItem.favorite) {
|
|
|
+ val drawable: Drawable? = holder.itemView.context.getDrawable(R.drawable.ic_star_filled_50)
|
|
|
+ holder.favorite.setImageDrawable(drawable)
|
|
|
+ } else {
|
|
|
+ val drawable: Drawable? = holder.itemView.context.getDrawable(R.drawable.ic_star_50)
|
|
|
+ holder.favorite.setImageDrawable(drawable)
|
|
|
+ }
|
|
|
+
|
|
|
+ holder.favorite.setOnClickListener{
|
|
|
+ if (!currentItem.favorite) {
|
|
|
// Perform bookmarking action
|
|
|
- buttonView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_user, 0, 0)
|
|
|
+ val drawable: Drawable? = holder.itemView.context.getDrawable(R.drawable.ic_star_filled_50)
|
|
|
+ holder.favorite.setImageDrawable(drawable)
|
|
|
+ currentItem.favorite = true
|
|
|
} else {
|
|
|
// Perform unbookmarking action
|
|
|
- buttonView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_user, 0, 0)
|
|
|
+ val drawable: Drawable? = holder.itemView.context.getDrawable(R.drawable.ic_star_50)
|
|
|
+ holder.favorite.setImageDrawable(drawable)
|
|
|
+ currentItem.favorite = false
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -48,6 +62,6 @@ class FighterAdapter (private val cardList: List<FighterCardItem>) : RecyclerVie
|
|
|
val imageRightTitle: TextView = itemView.findViewById(R.id.titleRight)
|
|
|
val date: TextView = itemView.findViewById(R.id.tvDate)
|
|
|
val title: TextView = itemView.findViewById(R.id.titleMatch)
|
|
|
- val favorite: ToggleButton = itemView.findViewById(R.id.bookmarkToggleButton)
|
|
|
+ val favorite: ImageView = itemView.findViewById(R.id.bookmarkToggleButton)
|
|
|
}
|
|
|
}
|