mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fix to color + fixed title on cards
This commit is contained in:
parent
f209c7286e
commit
6bc5d86ff9
3 changed files with 73 additions and 31 deletions
|
@ -4,9 +4,11 @@ import android.view.LayoutInflater
|
|||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.SearchResponse
|
||||
import com.lagradost.cloudstream3.databinding.HomeResultGridBinding
|
||||
import com.lagradost.cloudstream3.databinding.HomeResultGridExpandedBinding
|
||||
import com.lagradost.cloudstream3.ui.search.SearchClickCallback
|
||||
import com.lagradost.cloudstream3.ui.search.SearchResultBuilder
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.IsBottomLayout
|
||||
|
@ -24,10 +26,15 @@ class HomeChildItemAdapter(
|
|||
var hasNext: Boolean = false
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val layout = if (parent.context.IsBottomLayout()) R.layout.home_result_grid_expanded else R.layout.home_result_grid
|
||||
val expanded = parent.context.IsBottomLayout()
|
||||
/* val layout = if (bottom) R.layout.home_result_grid_expanded else R.layout.home_result_grid
|
||||
|
||||
val root = LayoutInflater.from(parent.context).inflate(layout, parent, false)
|
||||
val binding = HomeResultGridBinding.bind(root)
|
||||
val binding = HomeResultGridBinding.bind(root)*/
|
||||
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
val binding = if(expanded) HomeResultGridExpandedBinding.inflate(inflater,parent,false) else HomeResultGridBinding.inflate(inflater,parent,false)
|
||||
|
||||
|
||||
return CardViewHolder(
|
||||
binding,
|
||||
|
@ -69,7 +76,7 @@ class HomeChildItemAdapter(
|
|||
|
||||
class CardViewHolder
|
||||
constructor(
|
||||
val binding: HomeResultGridBinding,
|
||||
val binding: ViewBinding,
|
||||
private val clickCallback: (SearchClickCallback) -> Unit,
|
||||
var itemCount: Int,
|
||||
private val nextFocusUp: Int? = null,
|
||||
|
@ -86,26 +93,56 @@ class HomeChildItemAdapter(
|
|||
itemCount - 1 -> false
|
||||
else -> null
|
||||
}
|
||||
when(binding) {
|
||||
is HomeResultGridBinding -> {
|
||||
binding.backgroundCard.apply {
|
||||
val min = 114.toPx
|
||||
val max = 180.toPx
|
||||
|
||||
binding.backgroundCard.apply {
|
||||
val min = 114.toPx
|
||||
val max = 180.toPx
|
||||
|
||||
layoutParams =
|
||||
layoutParams.apply {
|
||||
width = if (!isHorizontal) {
|
||||
min
|
||||
} else {
|
||||
max
|
||||
}
|
||||
height = if (!isHorizontal) {
|
||||
max
|
||||
} else {
|
||||
min
|
||||
}
|
||||
layoutParams =
|
||||
layoutParams.apply {
|
||||
width = if (!isHorizontal) {
|
||||
min
|
||||
} else {
|
||||
max
|
||||
}
|
||||
height = if (!isHorizontal) {
|
||||
max
|
||||
} else {
|
||||
min
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (position == 0) { // to fix tv
|
||||
binding.backgroundCard.nextFocusLeftId = R.id.nav_rail_view
|
||||
}
|
||||
}
|
||||
is HomeResultGridExpandedBinding -> {
|
||||
binding.backgroundCard.apply {
|
||||
val min = 114.toPx
|
||||
val max = 180.toPx
|
||||
|
||||
layoutParams =
|
||||
layoutParams.apply {
|
||||
width = if (!isHorizontal) {
|
||||
min
|
||||
} else {
|
||||
max
|
||||
}
|
||||
height = if (!isHorizontal) {
|
||||
max
|
||||
} else {
|
||||
min
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (position == 0) { // to fix tv
|
||||
binding.backgroundCard.nextFocusLeftId = R.id.nav_rail_view
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SearchResultBuilder.bind(
|
||||
clickCallback,
|
||||
|
@ -118,9 +155,6 @@ class HomeChildItemAdapter(
|
|||
)
|
||||
itemView.tag = position
|
||||
|
||||
if (position == 0) { // to fix tv
|
||||
binding.backgroundCard.nextFocusLeftId = R.id.nav_rail_view
|
||||
}
|
||||
//val ani = ScaleAnimation(0.9f, 1.0f, 0.9f, 1f)
|
||||
//ani.fillAfter = true
|
||||
//ani.duration = 200
|
||||
|
|
|
@ -40,10 +40,10 @@ class HomeScrollAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
val binding = if(isTvSettings()) {
|
||||
HomeScrollViewBinding.inflate(inflater,parent,false)
|
||||
val binding = if (isTvSettings()) {
|
||||
HomeScrollViewTvBinding.inflate(inflater, parent, false)
|
||||
} else {
|
||||
HomeScrollViewTvBinding.inflate(inflater,parent,false)
|
||||
HomeScrollViewBinding.inflate(inflater, parent, false)
|
||||
}
|
||||
|
||||
return CardViewHolder(
|
||||
|
@ -71,10 +71,11 @@ class HomeScrollAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
val isHorizontal =
|
||||
binding is HomeScrollViewTvBinding || itemView.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||
|
||||
val posterUrl = if (isHorizontal) card.backgroundPosterUrl ?: card.posterUrl else card.posterUrl
|
||||
?: card.backgroundPosterUrl
|
||||
val posterUrl =
|
||||
if (isHorizontal) card.backgroundPosterUrl ?: card.posterUrl else card.posterUrl
|
||||
?: card.backgroundPosterUrl
|
||||
|
||||
when(binding) {
|
||||
when (binding) {
|
||||
is HomeScrollViewBinding -> {
|
||||
binding.homeScrollPreview.setImage(posterUrl)
|
||||
binding.homeScrollPreviewTags.apply {
|
||||
|
@ -83,6 +84,7 @@ class HomeScrollAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
}
|
||||
binding.homeScrollPreviewTitle.text = card.name
|
||||
}
|
||||
|
||||
is HomeScrollViewTvBinding -> {
|
||||
binding.homeScrollPreview.setImage(posterUrl)
|
||||
}
|
||||
|
|
|
@ -30,7 +30,11 @@ class PageAdapter(
|
|||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return LibraryItemViewHolder(
|
||||
SearchResultGridExpandedBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
SearchResultGridExpandedBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -54,7 +58,8 @@ class PageAdapter(
|
|||
}
|
||||
}
|
||||
|
||||
inner class LibraryItemViewHolder(val binding : SearchResultGridExpandedBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
inner class LibraryItemViewHolder(val binding: SearchResultGridExpandedBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
private val compactView = false//itemView.context.getGridIsCompact()
|
||||
private val coverHeight: Int =
|
||||
|
@ -84,6 +89,7 @@ class PageAdapter(
|
|||
binding.textRating.apply {
|
||||
setTextColor(ColorStateList.valueOf(fg))
|
||||
}
|
||||
binding.textRating.compoundDrawables.getOrNull(0)?.setTint(fg)
|
||||
binding.textRating.backgroundTintList = ColorStateList.valueOf(bg)
|
||||
binding.watchProgress.apply {
|
||||
progressTintList = ColorStateList.valueOf(fg)
|
||||
|
|
Loading…
Reference in a new issue