Browse Source

Tied programme name to songTitleNextText.

yattoz 4 years ago
parent
commit
8b5ecc7288

+ 1 - 1
app/src/main/java/fr/forum_thalie/tsumugi/RadioService.kt View File

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

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

1
 package fr.forum_thalie.tsumugi.planning
1
 package fr.forum_thalie.tsumugi.planning
2
 
2
 
3
 import android.content.Context
3
 import android.content.Context
4
+import androidx.lifecycle.MutableLiveData
4
 import fr.forum_thalie.tsumugi.Async
5
 import fr.forum_thalie.tsumugi.Async
5
 import org.json.JSONObject
6
 import org.json.JSONObject
6
 import java.io.IOException
7
 import java.io.IOException
10
 
11
 
11
     private val programmes: ArrayList<Programme> = ArrayList()
12
     private val programmes: ArrayList<Programme> = ArrayList()
12
     private var regularProgramme: String? = null
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
         programmes.forEach {
18
         programmes.forEach {
17
             if (it.isCurrent())
19
             if (it.isCurrent())
20
         return regularProgramme ?: "none"
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
     fun parseUrl(url: String? = null, context: Context? = null)
32
     fun parseUrl(url: String? = null, context: Context? = null)
24
     {
33
     {
25
         val scrape : (Any?) -> String = {
34
         val scrape : (Any?) -> String = {

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

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

+ 4 - 3
app/src/main/res/layout/fragment_nowplaying.xml View File

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