|
|
@@ -46,25 +46,44 @@ class NowPlayingFragment : Fragment() {
|
|
46
|
46
|
val seekBarVolume: SeekBar = root.findViewById(R.id.seek_bar_volume)
|
|
47
|
47
|
val volumeText: TextView = root.findViewById(R.id.volume_text)
|
|
48
|
48
|
val progressBar: ProgressBar = root.findViewById(R.id.progressBar)
|
|
|
49
|
+ val volumeIconImage : ImageView = root.findViewById(R.id.volume_icon)
|
|
|
50
|
+
|
|
|
51
|
+ // Note: these values are not used in the generic app
|
|
49
|
52
|
val streamerPictureImageView: ImageView = root.findViewById(R.id.streamerPicture)
|
|
|
53
|
+ /*
|
|
50
|
54
|
val streamerNameText : TextView = root.findViewById(R.id.streamerName)
|
|
51
|
55
|
val songTitleNextText: TextView = root.findViewById(R.id.text_song_title_next)
|
|
52
|
56
|
val songArtistNextText: TextView = root.findViewById(R.id.text_song_artist_next)
|
|
53
|
|
- val volumeIconImage : ImageView = root.findViewById(R.id.volume_icon)
|
|
54
|
57
|
val listenersText : TextView = root.findViewById(R.id.listenersCount)
|
|
|
58
|
+ */
|
|
55
|
59
|
|
|
56
|
60
|
|
|
|
61
|
+ /*
|
|
57
|
62
|
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(
|
|
58
|
63
|
streamerNameText,8, 20, 2, TypedValue.COMPLEX_UNIT_SP)
|
|
59
|
64
|
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(
|
|
60
|
65
|
listenersText,8, 16, 2, TypedValue.COMPLEX_UNIT_SP)
|
|
|
66
|
+ */
|
|
|
67
|
+
|
|
61
|
68
|
/*
|
|
62
|
|
- TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(
|
|
63
|
|
- songTitleText,4, 24, 2, TypedValue.COMPLEX_UNIT_SP)
|
|
64
|
|
- TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(
|
|
65
|
|
- songArtistText,4, 24, 2, TypedValue.COMPLEX_UNIT_SP)
|
|
|
69
|
+ // trick : I can't observe the queue because it's an ArrayDeque that doesn't trigger any change...
|
|
|
70
|
+ // so I observe a dedicated Mutable that gets set when the queue is updated.
|
|
|
71
|
+ PlayerStore.instance.isQueueUpdated.observe(viewLifecycleOwner, Observer {
|
|
|
72
|
+ val t = if (PlayerStore.instance.queue.size > 0) PlayerStore.instance.queue[0] else Song("No queue - ") // (it.peekFirst != null ? it.peekFirst : Song() )
|
|
|
73
|
+ songTitleNextText.text = t.title.value
|
|
|
74
|
+ songArtistNextText.text = t.artist.value
|
|
|
75
|
+ })
|
|
|
76
|
+
|
|
|
77
|
+ PlayerStore.instance.streamerName.observe(viewLifecycleOwner, Observer {
|
|
|
78
|
+ streamerNameText.text = it
|
|
|
79
|
+ })
|
|
|
80
|
+
|
|
|
81
|
+ PlayerStore.instance.listenersCount.observe(viewLifecycleOwner, Observer {
|
|
|
82
|
+ listenersText.text = "${getString(R.string.listeners)}: $it"
|
|
|
83
|
+ })
|
|
66
|
84
|
*/
|
|
67
|
85
|
|
|
|
86
|
+
|
|
68
|
87
|
PlayerStore.instance.currentSong.title.observe(viewLifecycleOwner, Observer {
|
|
69
|
88
|
songTitleText.text = it
|
|
70
|
89
|
})
|
|
|
@@ -77,13 +96,6 @@ class NowPlayingFragment : Fragment() {
|
|
77
|
96
|
syncPlayPauseButtonImage(root)
|
|
78
|
97
|
})
|
|
79
|
98
|
|
|
80
|
|
- // trick : I can't observe the queue because it's an ArrayDeque that doesn't trigger any change...
|
|
81
|
|
- // so I observe a dedicated Mutable that gets set when the queue is updated.
|
|
82
|
|
- PlayerStore.instance.isQueueUpdated.observe(viewLifecycleOwner, Observer {
|
|
83
|
|
- val t = if (PlayerStore.instance.queue.size > 0) PlayerStore.instance.queue[0] else Song("No queue - ") // (it.peekFirst != null ? it.peekFirst : Song() )
|
|
84
|
|
- songTitleNextText.text = t.title.value
|
|
85
|
|
- songArtistNextText.text = t.artist.value
|
|
86
|
|
- })
|
|
87
|
99
|
|
|
88
|
100
|
fun volumeIcon(it: Int)
|
|
89
|
101
|
{
|
|
|
@@ -113,14 +125,6 @@ class NowPlayingFragment : Fragment() {
|
|
113
|
125
|
streamerPictureImageView.setImageBitmap(pic)
|
|
114
|
126
|
})
|
|
115
|
127
|
|
|
116
|
|
- PlayerStore.instance.streamerName.observe(viewLifecycleOwner, Observer {
|
|
117
|
|
- streamerNameText.text = it
|
|
118
|
|
- })
|
|
119
|
|
-
|
|
120
|
|
- PlayerStore.instance.listenersCount.observe(viewLifecycleOwner, Observer {
|
|
121
|
|
- listenersText.text = "${getString(R.string.listeners)}: $it"
|
|
122
|
|
- })
|
|
123
|
|
-
|
|
124
|
128
|
// fuck it, do it on main thread
|
|
125
|
129
|
PlayerStore.instance.currentTime.observe(viewLifecycleOwner, Observer {
|
|
126
|
130
|
val dd = (PlayerStore.instance.currentTime.value!! - PlayerStore.instance.currentSong.startTime.value!!).toInt()
|
|
|
@@ -173,18 +177,6 @@ class NowPlayingFragment : Fragment() {
|
|
173
|
177
|
PlayerStore.instance.isPlaying.value = PlayerStore.instance.playbackState.value == PlaybackStateCompat.STATE_STOPPED
|
|
174
|
178
|
}
|
|
175
|
179
|
|
|
176
|
|
- /*
|
|
177
|
|
- /* TODO : disabled volumeIconImage click listener, it creates weird behaviors when switching fragments.
|
|
178
|
|
- in particular, the mute state isn't retained when switching fragments, and it creates visual error
|
|
179
|
|
- (displaying the mute icon when it's not muted).
|
|
180
|
|
- So for the moment it's safer to disable it altogether.
|
|
181
|
|
- */
|
|
182
|
|
- volumeIconImage.setOnClickListener{
|
|
183
|
|
- PlayerStore.instance.isMuted.value = !PlayerStore.instance.isMuted.value!!
|
|
184
|
|
- }
|
|
185
|
|
-
|
|
186
|
|
- */
|
|
187
|
|
-
|
|
188
|
180
|
val setClipboardListener: View.OnLongClickListener = View.OnLongClickListener {
|
|
189
|
181
|
val text = PlayerStore.instance.currentSong.artist.value + " - " + PlayerStore.instance.currentSong.title.value
|
|
190
|
182
|
val clipboard = context!!.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|