Merge pull request #624 from Bnyro/master

fix fab
This commit is contained in:
Bnyro 2022-06-26 17:22:29 +02:00 committed by GitHub
commit 4dc71ae588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -28,6 +28,8 @@ class Library : Fragment() {
lateinit var token: String lateinit var token: String
private lateinit var playlistRecyclerView: RecyclerView private lateinit var playlistRecyclerView: RecyclerView
private lateinit var refreshLayout: SwipeRefreshLayout private lateinit var refreshLayout: SwipeRefreshLayout
private lateinit var createPlaylistButton: FloatingActionButton
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
arguments?.let { arguments?.let {
@ -58,7 +60,8 @@ class Library : Fragment() {
Log.d(TAG, "hmm") Log.d(TAG, "hmm")
fetchPlaylists(view) fetchPlaylists(view)
} }
view.findViewById<FloatingActionButton>(R.id.create_playlist).setOnClickListener { createPlaylistButton = view.findViewById<FloatingActionButton>(R.id.create_playlist)
createPlaylistButton.setOnClickListener {
val newFragment = CreatePlaylistDialog() val newFragment = CreatePlaylistDialog()
newFragment.show(childFragmentManager, "Create Playlist") 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) { private fun fetchPlaylists(view: View) {
fun run() { fun run() {
refreshLayout.isRefreshing = true refreshLayout.isRefreshing = true

View File

@ -92,6 +92,7 @@ import java.util.concurrent.Executors
import kotlin.math.abs import kotlin.math.abs
var isFullScreen = false var isFullScreen = false
var isMiniPlayerVisible = false
class PlayerFragment : Fragment() { class PlayerFragment : Fragment() {
@ -197,9 +198,11 @@ class PlayerFragment : Fragment() {
val mainMotionLayout = val mainMotionLayout =
mainActivity.findViewById<MotionLayout>(R.id.mainMotionLayout) mainActivity.findViewById<MotionLayout>(R.id.mainMotionLayout)
if (currentId == eId) { if (currentId == eId) {
isMiniPlayerVisible = true
exoPlayerView.useController = false exoPlayerView.useController = false
mainMotionLayout.progress = 1F mainMotionLayout.progress = 1F
} else if (currentId == sId) { } else if (currentId == sId) {
isMiniPlayerVisible = false
exoPlayerView.useController = true exoPlayerView.useController = true
mainMotionLayout.progress = 0F mainMotionLayout.progress = 0F
} }
@ -218,6 +221,7 @@ class PlayerFragment : Fragment() {
playerMotionLayout.transitionToStart() playerMotionLayout.transitionToStart()
view.findViewById<ImageView>(R.id.close_imageView).setOnClickListener { view.findViewById<ImageView>(R.id.close_imageView).setOnClickListener {
isMiniPlayerVisible = false
motionLayout.transitionToEnd() motionLayout.transitionToEnd()
val mainActivity = activity as MainActivity val mainActivity = activity as MainActivity
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
@ -226,6 +230,7 @@ class PlayerFragment : Fragment() {
.commit() .commit()
} }
view.findViewById<ImageButton>(R.id.close_imageButton).setOnClickListener { view.findViewById<ImageButton>(R.id.close_imageButton).setOnClickListener {
isMiniPlayerVisible = false
motionLayout.transitionToEnd() motionLayout.transitionToEnd()
val mainActivity = activity as MainActivity val mainActivity = activity as MainActivity
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT