@@ -142,7 +142,9 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
142142 var alreadyShowedFeedOnce = false
143143 viewModel.videoFeed.observe(viewLifecycleOwner) {
144144 if (! viewModel.isCurrentTabSubChannels && it != null ) {
145- showFeed(! alreadyShowedFeedOnce)
145+ lifecycleScope.launch {
146+ showFeed(! alreadyShowedFeedOnce)
147+ }
146148 alreadyShowedFeedOnce = true
147149 }
148150 }
@@ -179,7 +181,9 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
179181 binding.subRefresh.isRefreshing = true
180182 viewModel.isCurrentTabSubChannels = ! viewModel.isCurrentTabSubChannels
181183
182- if (viewModel.isCurrentTabSubChannels) showSubscriptions() else showFeed()
184+ lifecycleScope.launch {
185+ if (viewModel.isCurrentTabSubChannels) showSubscriptions() else showFeed()
186+ }
183187
184188 binding.subChannels.isVisible = viewModel.isCurrentTabSubChannels
185189 binding.subFeed.isGone = viewModel.isCurrentTabSubChannels
@@ -204,7 +208,10 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
204208
205209 binding.channelGroups.setOnCheckedStateChangeListener { group, _ ->
206210 selectedFilterGroup = group.children.indexOfFirst { it.id == group.checkedChipId }
207- if (viewModel.isCurrentTabSubChannels) showSubscriptions() else showFeed()
211+
212+ lifecycleScope.launch {
213+ if (viewModel.isCurrentTabSubChannels) showSubscriptions() else showFeed()
214+ }
208215 }
209216
210217 channelGroupsModel.groups.observe(viewLifecycleOwner) {
@@ -256,7 +263,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
256263 selectedSortOrder = resultBundle.getInt(IntentData .sortOptions)
257264 hideWatched = resultBundle.getBoolean(IntentData .hideWatched)
258265 showUpcoming = resultBundle.getBoolean(IntentData .showUpcoming)
259- showFeed()
266+ lifecycleScope.launch { showFeed() }
260267 }
261268
262269 FilterSortBottomSheet ()
@@ -283,7 +290,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
283290 _binding = null
284291 }
285292
286- private fun playByGroup (groupIndex : Int ) {
293+ private suspend fun playByGroup (groupIndex : Int ) {
287294 val streams = viewModel.videoFeed.value.orEmpty()
288295 .filterByGroup(groupIndex)
289296 .let { DatabaseHelper .filterByStatusAndWatchPosition(it, hideWatched) }
@@ -306,7 +313,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
306313
307314 binding.chipAll.isChecked = selectedFilterGroup == 0
308315 binding.chipAll.setOnLongClickListener {
309- playByGroup(0 )
316+ lifecycleScope.launch { playByGroup(0 ) }
310317 true
311318 }
312319
@@ -321,7 +328,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
321328 text = group.name
322329 setOnLongClickListener {
323330 // the index must be increased by one to skip the "all channels" group button
324- playByGroup(index + 1 )
331+ lifecycleScope.launch { playByGroup(index + 1 ) }
325332 true
326333 }
327334 }
@@ -360,7 +367,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
360367 else -> this
361368 }
362369
363- private fun showFeed (restoreScrollState : Boolean = true) {
370+ private suspend fun showFeed (restoreScrollState : Boolean = true) {
364371 val binding = _binding ? : return
365372 val videoFeed = viewModel.videoFeed.value ? : return
366373
0 commit comments