looking good coach

This commit is contained in:
Rukasu committed 2026-08-30 17:36:42 -04:00
1 parent 1ceea4afbd
commit 28b78ba430
3 files changed
+38 -4

No files matched your search

@@ -111,6 +111,8 @@ class MistTitleView(context: Context) : FrameLayout(context), TitleViewAdapter.P
class BrowseFragment : BrowseSupportFragment() {
private lateinit var rowsAdapter: ArrayObjectAdapter
private var hasLoadedOnce = false
private var returningFromPlayback = false
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@@ -136,7 +138,14 @@ class BrowseFragment : BrowseSupportFragment() {
override fun onResume() {
super.onResume()
loadChannels()
// Only refresh channels on the very first load (app start) or right after
// returning from a stream — not on every resume (e.g. sidebar toggling,
// app backgrounding/foregrounding without leaving the guide).
if (!hasLoadedOnce || returningFromPlayback) {
hasLoadedOnce = true
returningFromPlayback = false
loadChannels()
}
}
private fun setupTransitionListener() {
@@ -161,7 +170,7 @@ class BrowseFragment : BrowseSupportFragment() {
lifecycleScope.launch {
ChannelRepository.refreshChannels()
rowsAdapter = ArrayObjectAdapter(ListRowPresenter())
rowsAdapter = ArrayObjectAdapter(ListRowPresenter().apply { shadowEnabled = false })
// Pass long click listener to presenter
val cardPresenter = ChannelCardPresenter { channel ->
@@ -227,6 +236,7 @@ class BrowseFragment : BrowseSupportFragment() {
onItemViewClickedListener = OnItemViewClickedListener { _, item, _, _ ->
if (item is Channel) {
RecentChannelsManager.addRecentChannel(requireContext(), item.id)
returningFromPlayback = true
val intent = Intent(requireContext(), PlaybackActivity::class.java).apply {
putExtra(PlaybackActivity.EXTRA_CHANNEL, item)
}
@@ -65,6 +65,8 @@ class ChannelCardPresenter(private val onLongClickListener: ((Channel) -> Unit)?
val cardView = ImageCardView(context).apply {
isFocusable = true
isFocusableInTouchMode = true
elevation = 0f
stateListAnimator = null
setMainImageDimensions(
dpToPx(context, CARD_WIDTH_DP),
dpToPx(context, CARD_HEIGHT_DP)
@@ -72,6 +74,10 @@ class ChannelCardPresenter(private val onLongClickListener: ((Channel) -> Unit)?
setBackgroundColor(ContextCompat.getColor(context, R.color.mist_card_bg))
setCardType(ImageCardView.CARD_TYPE_MAIN_ONLY)
}
// ImageCardView's internal mainImageView defaults to CENTER_CROP regardless of
// Glide's own transform, which is why non-16:9 thumbnails were still filling/cropping
// the box. Overriding it here to letterbox instead.
cardView.mainImageView.scaleType = ImageView.ScaleType.FIT_CENTER
val viewerCountView = TextView(context).apply {
tag = "viewer_count"
@@ -129,19 +135,25 @@ class ChannelCardPresenter(private val onLongClickListener: ((Channel) -> Unit)?
dpToPx(context, CARD_WIDTH_DP),
LinearLayout.LayoutParams.WRAP_CONTENT
)
background = ContextCompat.getDrawable(context, R.drawable.info_row_outline)
setPadding(dpToPx(context, 8), dpToPx(context, 8), dpToPx(context, 8), dpToPx(context, 8))
addView(logoView)
addView(textStack)
}
// Root just stacks the original (untouched) cardView above our info row.
// No focus/click changes here — cardView keeps its normal Leanback focus behavior.
val root = LinearLayout(context).apply {
orientation = LinearLayout.VERTICAL
addView(cardView)
addView(infoRow)
}
// Raise the whole root above sibling rows while focused, so the card's
// built-in focus-zoom doesn't get visually underlapped by the row below it.
cardView.setOnFocusChangeListener { _, hasFocus ->
root.z = if (hasFocus) 10f else 0f
}
return ChannelViewHolder(root, cardView, logoView, titleView, descriptionView)
}
@@ -182,7 +194,6 @@ class ChannelCardPresenter(private val onLongClickListener: ((Channel) -> Unit)?
.load(channel.thumbnailUrl)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.centerCrop()
.into(object : CustomTarget<Drawable>() {
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
cancelPlaceholder(cardView)
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="0dp"
android:topRightRadius="0dp"
android:bottomLeftRadius="6dp"
android:bottomRightRadius="6dp" />
<solid android:color="#243952" />
<stroke
android:width="1dp"
android:color="#33FFFFFF" />
</shape>