Skip to content

Commit

Permalink
update shuffle visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mebarbosa committed Oct 30, 2024
1 parent 668426d commit 78d0047
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class UpNextAdapter(
}

private var isSignedInAsPaidUser: Boolean = false
private var isUpNextNotEmpty: Boolean = false

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val inflater = LayoutInflater.from(parent.context)
Expand Down Expand Up @@ -163,6 +164,10 @@ class UpNextAdapter(
this.isSignedInAsPaidUser = isSignedInAsPaidUser
}

fun updateUpNextEmptyState(isUpNextNotEmpty: Boolean) {
this.isUpNextNotEmpty = isUpNextNotEmpty
}

inner class HeaderViewHolder(val binding: AdapterUpNextFooterBinding) : RecyclerView.ViewHolder(binding.root) {

fun bind(header: PlayerViewModel.UpNextSummary) {
Expand All @@ -176,7 +181,7 @@ class UpNextAdapter(
root.resources.getQuantityString(LR.plurals.player_up_next_header_title, header.episodeCount, header.episodeCount, time)
}

shuffle.isVisible = hasEpisodeInProgress() && FeatureFlag.isEnabled(Feature.UP_NEXT_SHUFFLE)
shuffle.isVisible = isUpNextNotEmpty && FeatureFlag.isEnabled(Feature.UP_NEXT_SHUFFLE)
shuffle.updateShuffleButton()

shuffle.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ class UpNextFragment : BaseFragment(), UpNextListener, UpNextTouchCallback.ItemT

playerViewModel.listDataLive.observe(viewLifecycleOwner) {
adapter.isPlaying = it.podcastHeader.isPlaying
adapter.updateUpNextEmptyState(it.upNextEpisodes.isNotEmpty())
toolbar.menu.findItem(R.id.menu_select)?.isVisible = it.upNextEpisodes.isNotEmpty()
toolbar.menu.findItem(R.id.clear_up_next)?.isVisible = it.upNextEpisodes.isNotEmpty()
}
Expand Down

0 comments on commit 78d0047

Please sign in to comment.