Skip to content
Snippets Groups Projects
Commit 90f89efc authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

TV: ensure media list has focus

Menu button were taking focus while recyclerview was being populated
parent b506c8b9
No related branches found
No related tags found
No related merge requests found
Pipeline #7465 passed with stage
in 3 minutes and 45 seconds
......@@ -45,10 +45,7 @@ import androidx.leanback.app.BackgroundManager
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.song_browser.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.*
import org.videolan.medialibrary.Medialibrary
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.medialibrary.media.MediaWrapper
......@@ -87,6 +84,7 @@ abstract class BaseBrowserTvFragment : Fragment(), BrowserFragmentInterface, IEv
private var currentArt: String? = null
private lateinit var backgroundManager: BackgroundManager
internal lateinit var animationDelegate: MediaBrowserAnimatorDelegate
private var setFocus = true
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = SongBrowserBinding.inflate(inflater, container, false)
......@@ -185,6 +183,11 @@ abstract class BaseBrowserTvFragment : Fragment(), BrowserFragmentInterface, IEv
super.onViewCreated(view, savedInstanceState)
}
override fun onStart() {
super.onStart()
setFocus = true
}
private fun calculateNbColumns() {
viewModel.nbColumns = getColumnNumber()
}
......@@ -343,10 +346,14 @@ abstract class BaseBrowserTvFragment : Fragment(), BrowserFragmentInterface, IEv
fun submitList(pagedList: Any) {
adapter.submitList(pagedList)
if (setFocus) {
setFocus = false
launch { binding.list.requestFocus() }
}
animationDelegate.setVisibility(imageButtonHeader, if (viewModel.provider.headers.isEmpty) View.GONE else View.VISIBLE)
animationDelegate.setVisibility(headerButton, if (viewModel.provider.headers.isEmpty) View.GONE else View.VISIBLE)
animationDelegate.setVisibility(headerDescription, if (viewModel.provider.headers.isEmpty) View.GONE else View.VISIBLE)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment