Procházet zdrojové kódy

Tied programme name to songTitleNextText.

yattoz před 4 roky
rodič
revize
8b5ecc7288

+ 1 - 1
app/src/main/java/fr/forum_thalie/tsumugi/RadioService.kt Zobrazit soubor

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

+ 10 - 1
app/src/main/java/fr/forum_thalie/tsumugi/planning/Planning.kt Zobrazit soubor

@@ -1,6 +1,7 @@
1 1
 package fr.forum_thalie.tsumugi.planning
2 2
 
3 3
 import android.content.Context
4
+import androidx.lifecycle.MutableLiveData
4 5
 import fr.forum_thalie.tsumugi.Async
5 6
 import org.json.JSONObject
6 7
 import java.io.IOException
@@ -10,8 +11,9 @@ class Planning {
10 11
 
11 12
     private val programmes: ArrayList<Programme> = ArrayList()
12 13
     private var regularProgramme: String? = null
14
+    val currentProgramme: MutableLiveData<String> = MutableLiveData()
13 15
 
14
-    fun currentProgramme(): String
16
+    private fun findCurrentProgramme(): String
15 17
     {
16 18
         programmes.forEach {
17 19
             if (it.isCurrent())
@@ -20,6 +22,13 @@ class Planning {
20 22
         return regularProgramme ?: "none"
21 23
     }
22 24
 
25
+    fun checkProgramme()
26
+    {
27
+        val newProgramme = findCurrentProgramme()
28
+        if (currentProgramme.value != newProgramme)
29
+            currentProgramme.value = newProgramme
30
+    }
31
+
23 32
     fun parseUrl(url: String? = null, context: Context? = null)
24 33
     {
25 34
         val scrape : (Any?) -> String = {

+ 11 - 4
app/src/main/java/fr/forum_thalie/tsumugi/ui/nowplaying/NowPlayingFragment.kt Zobrazit soubor

@@ -21,8 +21,10 @@ import com.google.android.material.snackbar.BaseTransientBottomBar
21 21
 import com.google.android.material.snackbar.Snackbar
22 22
 import fr.forum_thalie.tsumugi.*
23 23
 import fr.forum_thalie.tsumugi.alarm.RadioSleeper
24
+import fr.forum_thalie.tsumugi.planning.Planning
24 25
 import fr.forum_thalie.tsumugi.playerstore.PlayerStore
25 26
 import fr.forum_thalie.tsumugi.playerstore.Song
27
+import kotlinx.android.synthetic.main.fragment_nowplaying.*
26 28
 
27 29
 
28 30
 class NowPlayingFragment : Fragment() {
@@ -51,10 +53,11 @@ class NowPlayingFragment : Fragment() {
51 53
         val streamerPictureImageView: ImageView = root.findViewById(R.id.streamerPicture)
52 54
 
53 55
         // Note: these values are not used in the generic app, but if you want to, you can use them.
54
-        /*
55
-        val streamerNameText : TextView = root.findViewById(R.id.streamerName)
56 56
         val songTitleNextText: TextView = root.findViewById(R.id.text_song_title_next)
57 57
         val songArtistNextText: TextView = root.findViewById(R.id.text_song_artist_next)
58
+
59
+        /*
60
+        val streamerNameText : TextView = root.findViewById(R.id.streamerName)
58 61
         val listenersText : TextView = root.findViewById(R.id.listenersCount)
59 62
          */
60 63
 
@@ -86,11 +89,15 @@ class NowPlayingFragment : Fragment() {
86 89
 
87 90
 
88 91
         PlayerStore.instance.currentSong.title.observe(viewLifecycleOwner, Observer {
89
-                songTitleText.text = it
92
+            songTitleText.text = it
93
+        })
94
+
95
+        Planning.instance.currentProgramme.observe(viewLifecycleOwner, Observer {
96
+            songTitleNextText.text = it
90 97
         })
91 98
 
92 99
         PlayerStore.instance.currentSong.artist.observe(viewLifecycleOwner, Observer {
93
-                songArtistText.text = it
100
+            songArtistText.text = it
94 101
         })
95 102
 
96 103
         PlayerStore.instance.playbackState.observe(viewLifecycleOwner, Observer {

+ 4 - 3
app/src/main/res/layout/fragment_nowplaying.xml Zobrazit soubor

@@ -173,7 +173,7 @@
173 173
                 android:orientation="vertical"
174 174
                 android:layout_marginEnd="8dp"
175 175
                 android:layout_marginRight="8dp"
176
-                android:visibility="gone"
176
+                android:visibility="visible"
177 177
                 >
178 178
 
179 179
                 <TextView
@@ -183,7 +183,7 @@
183 183
                     android:layout_gravity="top"
184 184
                     android:text="@string/up_next"
185 185
                     android:textAlignment="center"
186
-                    android:textColor="@color/whited"
186
+                    android:textColor="@color/whited3"
187 187
                     android:layout_marginTop="8dp"
188 188
                     app:layout_constraintStart_toStartOf="parent"
189 189
                     app:layout_constraintEnd_toEndOf="parent"
@@ -200,7 +200,8 @@
200 200
                     android:textColor="@color/whited3"
201 201
                     android:textSize="16sp"
202 202
                     app:layout_constraintStart_toStartOf="parent"
203
-                    app:layout_constraintTop_toBottomOf="@id/upNext" />
203
+                    app:layout_constraintTop_toBottomOf="@id/upNext"
204
+                    android:visibility="gone"/>
204 205
 
205 206
                 <TextView
206 207
                     android:id="@+id/text_song_title_next"