Tied programme name to songTitleNextText.

remotes/origin/devel
yattoz 2019-12-16 23:58:58 +01:00
parent 0218dfab75
commit 8b5ecc7288
4 changed files with 26 additions and 9 deletions

View File

@ -130,7 +130,7 @@ class RadioService : MediaBrowserServiceCompat() {
PlayerStore.instance.updateLp() PlayerStore.instance.updateLp()
} }
nowPlayingNotification.update(this) nowPlayingNotification.update(this)
Log.d(tag, Planning.instance.currentProgramme()) Planning.instance.checkProgramme()
} }
private val streamerPictureObserver = Observer<Bitmap> { private val streamerPictureObserver = Observer<Bitmap> {

View File

@ -1,6 +1,7 @@
package fr.forum_thalie.tsumugi.planning package fr.forum_thalie.tsumugi.planning
import android.content.Context import android.content.Context
import androidx.lifecycle.MutableLiveData
import fr.forum_thalie.tsumugi.Async import fr.forum_thalie.tsumugi.Async
import org.json.JSONObject import org.json.JSONObject
import java.io.IOException import java.io.IOException
@ -10,8 +11,9 @@ class Planning {
private val programmes: ArrayList<Programme> = ArrayList() private val programmes: ArrayList<Programme> = ArrayList()
private var regularProgramme: String? = null private var regularProgramme: String? = null
val currentProgramme: MutableLiveData<String> = MutableLiveData()
fun currentProgramme(): String private fun findCurrentProgramme(): String
{ {
programmes.forEach { programmes.forEach {
if (it.isCurrent()) if (it.isCurrent())
@ -20,6 +22,13 @@ class Planning {
return regularProgramme ?: "none" return regularProgramme ?: "none"
} }
fun checkProgramme()
{
val newProgramme = findCurrentProgramme()
if (currentProgramme.value != newProgramme)
currentProgramme.value = newProgramme
}
fun parseUrl(url: String? = null, context: Context? = null) fun parseUrl(url: String? = null, context: Context? = null)
{ {
val scrape : (Any?) -> String = { val scrape : (Any?) -> String = {

View File

@ -21,8 +21,10 @@ import com.google.android.material.snackbar.BaseTransientBottomBar
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import fr.forum_thalie.tsumugi.* import fr.forum_thalie.tsumugi.*
import fr.forum_thalie.tsumugi.alarm.RadioSleeper import fr.forum_thalie.tsumugi.alarm.RadioSleeper
import fr.forum_thalie.tsumugi.planning.Planning
import fr.forum_thalie.tsumugi.playerstore.PlayerStore import fr.forum_thalie.tsumugi.playerstore.PlayerStore
import fr.forum_thalie.tsumugi.playerstore.Song import fr.forum_thalie.tsumugi.playerstore.Song
import kotlinx.android.synthetic.main.fragment_nowplaying.*
class NowPlayingFragment : Fragment() { class NowPlayingFragment : Fragment() {
@ -51,10 +53,11 @@ class NowPlayingFragment : Fragment() {
val streamerPictureImageView: ImageView = root.findViewById(R.id.streamerPicture) val streamerPictureImageView: ImageView = root.findViewById(R.id.streamerPicture)
// Note: these values are not used in the generic app, but if you want to, you can use them. // Note: these values are not used in the generic app, but if you want to, you can use them.
/*
val streamerNameText : TextView = root.findViewById(R.id.streamerName)
val songTitleNextText: TextView = root.findViewById(R.id.text_song_title_next) val songTitleNextText: TextView = root.findViewById(R.id.text_song_title_next)
val songArtistNextText: TextView = root.findViewById(R.id.text_song_artist_next) val songArtistNextText: TextView = root.findViewById(R.id.text_song_artist_next)
/*
val streamerNameText : TextView = root.findViewById(R.id.streamerName)
val listenersText : TextView = root.findViewById(R.id.listenersCount) val listenersText : TextView = root.findViewById(R.id.listenersCount)
*/ */
@ -86,11 +89,15 @@ class NowPlayingFragment : Fragment() {
PlayerStore.instance.currentSong.title.observe(viewLifecycleOwner, Observer { PlayerStore.instance.currentSong.title.observe(viewLifecycleOwner, Observer {
songTitleText.text = it songTitleText.text = it
})
Planning.instance.currentProgramme.observe(viewLifecycleOwner, Observer {
songTitleNextText.text = it
}) })
PlayerStore.instance.currentSong.artist.observe(viewLifecycleOwner, Observer { PlayerStore.instance.currentSong.artist.observe(viewLifecycleOwner, Observer {
songArtistText.text = it songArtistText.text = it
}) })
PlayerStore.instance.playbackState.observe(viewLifecycleOwner, Observer { PlayerStore.instance.playbackState.observe(viewLifecycleOwner, Observer {

View File

@ -173,7 +173,7 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:visibility="gone" android:visibility="visible"
> >
<TextView <TextView
@ -183,7 +183,7 @@
android:layout_gravity="top" android:layout_gravity="top"
android:text="@string/up_next" android:text="@string/up_next"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/whited" android:textColor="@color/whited3"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
@ -200,7 +200,8 @@
android:textColor="@color/whited3" android:textColor="@color/whited3"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/upNext" /> app:layout_constraintTop_toBottomOf="@id/upNext"
android:visibility="gone"/>
<TextView <TextView
android:id="@+id/text_song_title_next" android:id="@+id/text_song_title_next"