[Android] TV: ensure media list has focus
Geoffrey Métais
git at videolan.org
Tue Jun 11 15:23:55 CEST 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jun 11 15:21:21 2019 +0200| [90f89efc3a9d35a2dd9599ade5b1c899d4f4d529] | committer: Geoffrey Métais
TV: ensure media list has focus
Menu button were taking focus while recyclerview was being populated
> https://code.videolan.org/videolan/vlc-android/commit/90f89efc3a9d35a2dd9599ade5b1c899d4f4d529
---
.../vlc/gui/tv/browser/BaseBrowserTvFragment.kt | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt
index a3ff7400c..9b9822a59 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt
@@ -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)
+
}
}
More information about the Android
mailing list