Fix top margin when viewing video in vertical fullscreen

This commit is contained in:
Bnyro 2023-04-27 20:24:15 +02:00
parent 9cd1fd9d58
commit b33ecff67e
3 changed files with 20 additions and 12 deletions

View File

@ -237,13 +237,18 @@ class PlaylistFragment : Fragment() {
} }
private fun showPlaylistVideos(playlist: Playlist) { private fun showPlaylistVideos(playlist: Playlist) {
val videos = if (playlistType == PlaylistType.PUBLIC) playlistFeed val videos = if (playlistType == PlaylistType.PUBLIC) {
else { playlistFeed
} else {
when (selectedSortOrder) { when (selectedSortOrder) {
0, 1 -> { 0, 1 -> {
if (playlistType == PlaylistType.LOCAL) playlistFeed.sortedBy { if (playlistType == PlaylistType.LOCAL) {
playlistFeed.sortedBy {
it.url.orEmpty().toInt() it.url.orEmpty().toInt()
} else playlistFeed }
} else {
playlistFeed
}
} }
2, 3 -> { 2, 3 -> {
playlistFeed.sortedBy { it.duration } playlistFeed.sortedBy { it.duration }

View File

@ -219,6 +219,7 @@ internal class CustomExoPlayerView(
playerViewModel?.isFullscreen?.observe(viewLifecycleOwner!!) { isFullscreen -> playerViewModel?.isFullscreen?.observe(viewLifecycleOwner!!) { isFullscreen ->
WindowHelper.toggleFullscreen(activity, isFullscreen) WindowHelper.toggleFullscreen(activity, isFullscreen)
updateTopBarMargin()
} }
} }
@ -644,11 +645,13 @@ internal class CustomExoPlayerView(
* Add extra margin to the top bar to not overlap the status bar * Add extra margin to the top bar to not overlap the status bar
*/ */
private fun updateTopBarMargin() { private fun updateTopBarMargin() {
val isFullscreen = val margin = when {
resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE -> 10
playerViewModel?.isFullscreen?.value == true playerViewModel?.isFullscreen?.value == true -> 20
else -> 0
}
binding.topBar.updateLayoutParams<MarginLayoutParams> { binding.topBar.updateLayoutParams<MarginLayoutParams> {
topMargin = (if (isFullscreen) 10 else 0).dpToPx().toInt() topMargin = margin.dpToPx().toInt()
} }
} }