Browse Source

Show season number in MediaFragment

pull/49/head
Jannik 3 months ago
parent
commit
ab660d0ae7
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
  1. 20
      app/src/main/java/org/mosad/teapod/ui/activity/main/fragments/MediaFragmentEpisodes.kt
  2. 2
      app/src/main/res/values/strings.xml

20
app/src/main/java/org/mosad/teapod/ui/activity/main/fragments/MediaFragmentEpisodes.kt

@ -11,6 +11,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
import org.mosad.teapod.R
import org.mosad.teapod.databinding.FragmentMediaEpisodesBinding
import org.mosad.teapod.ui.activity.main.MainActivity
import org.mosad.teapod.ui.activity.main.viewmodel.MediaFragmentViewModel
@ -47,7 +48,11 @@ class MediaFragmentEpisodes : Fragment() {
if (model.seasonsCrunchy.total < 2) {
binding.buttonSeasonSelection.visibility = View.GONE
} else {
binding.buttonSeasonSelection.text = model.currentSeasonCrunchy.title
binding.buttonSeasonSelection.text = getString(
R.string.season_number_title,
model.currentSeasonCrunchy.seasonNumber,
model.currentSeasonCrunchy.title
)
binding.buttonSeasonSelection.setOnClickListener { v ->
showSeasonSelection(v)
}
@ -64,7 +69,12 @@ class MediaFragmentEpisodes : Fragment() {
// TODO replace with Exposed dropdown menu: https://material.io/components/menus/android#exposed-dropdown-menus
val popup = PopupMenu(requireContext(), v)
model.seasonsCrunchy.items.forEach { season ->
popup.menu.add(season.title).also {
popup.menu.add(getString(
R.string.season_number_title,
season.seasonNumber,
season.title
)
).also {
it.setOnMenuItemClickListener {
onSeasonSelected(season.id)
false
@ -86,7 +96,11 @@ class MediaFragmentEpisodes : Fragment() {
// load the new season
lifecycleScope.launch {
model.setCurrentSeason(seasonId)
binding.buttonSeasonSelection.text = model.currentSeasonCrunchy.title
binding.buttonSeasonSelection.text = getString(
R.string.season_number_title,
model.currentSeasonCrunchy.seasonNumber,
model.currentSeasonCrunchy.title
)
adapterRecEpisodes.notifyDataSetChanged()
}
}

2
app/src/main/res/values/strings.xml

@ -34,6 +34,7 @@
<item quantity="one">%d Minute</item>
<item quantity="other">%d Minutes</item>
</plurals>
<string name="season_number_title" translatable="false">S%1$d - %2$s</string>
<string name="similar_titles">Similar titles</string>
<string name="component_episode_title">Ep. %1$s %2$s</string>
<string name="component_episode_title_sub">Ep. %1$s %2$s (Sub)</string>
@ -67,7 +68,6 @@
<string name="info_about" translatable="false">Teapod by @Seil0</string>
<string name="info_about_desc">Version %1$s (%2$s)</string>
<!-- about fragment -->
<string name="version">Version</string>
<string name="version_desc" translatable="false">%1$s (%2$s)</string>

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close