Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Project] Up Next Shuffle - Update Shuffle Button Visibility #3134

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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