From fcd012184eb8618e1ebc2123d1c77a0f4150c9ae Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 26 Jun 2022 17:20:53 +0200 Subject: [PATCH] fix fab --- .../java/com/github/libretube/fragments/Library.kt | 13 ++++++++++++- .../github/libretube/fragments/PlayerFragment.kt | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/fragments/Library.kt b/app/src/main/java/com/github/libretube/fragments/Library.kt index ead5eceb7..d0dbf7736 100644 --- a/app/src/main/java/com/github/libretube/fragments/Library.kt +++ b/app/src/main/java/com/github/libretube/fragments/Library.kt @@ -28,6 +28,8 @@ class Library : Fragment() { lateinit var token: String private lateinit var playlistRecyclerView: RecyclerView private lateinit var refreshLayout: SwipeRefreshLayout + private lateinit var createPlaylistButton: FloatingActionButton + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) arguments?.let { @@ -58,7 +60,8 @@ class Library : Fragment() { Log.d(TAG, "hmm") fetchPlaylists(view) } - view.findViewById(R.id.create_playlist).setOnClickListener { + createPlaylistButton = view.findViewById(R.id.create_playlist) + createPlaylistButton.setOnClickListener { val newFragment = CreatePlaylistDialog() newFragment.show(childFragmentManager, "Create Playlist") } @@ -71,6 +74,14 @@ class Library : Fragment() { } } + override fun onResume() { + // optimize CreatePlaylistFab bottom margin + val layoutParams = createPlaylistButton.layoutParams as ViewGroup.MarginLayoutParams + layoutParams.bottomMargin = if (isMiniPlayerVisible) 180 else 64 + createPlaylistButton.layoutParams = layoutParams + super.onResume() + } + private fun fetchPlaylists(view: View) { fun run() { refreshLayout.isRefreshing = true diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index 1701158d4..cb6ccca83 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -92,6 +92,7 @@ import java.util.concurrent.Executors import kotlin.math.abs var isFullScreen = false +var isMiniPlayerVisible = false class PlayerFragment : Fragment() { @@ -197,9 +198,11 @@ class PlayerFragment : Fragment() { val mainMotionLayout = mainActivity.findViewById(R.id.mainMotionLayout) if (currentId == eId) { + isMiniPlayerVisible = true exoPlayerView.useController = false mainMotionLayout.progress = 1F } else if (currentId == sId) { + isMiniPlayerVisible = false exoPlayerView.useController = true mainMotionLayout.progress = 0F } @@ -218,6 +221,7 @@ class PlayerFragment : Fragment() { playerMotionLayout.transitionToStart() view.findViewById(R.id.close_imageView).setOnClickListener { + isMiniPlayerVisible = false motionLayout.transitionToEnd() val mainActivity = activity as MainActivity mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT