This commit is contained in:
Bnyro 2022-06-26 17:20:53 +02:00
parent b477e1a202
commit fcd012184e
2 changed files with 16 additions and 1 deletions

View File

@ -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<FloatingActionButton>(R.id.create_playlist).setOnClickListener {
createPlaylistButton = view.findViewById<FloatingActionButton>(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

View File

@ -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<MotionLayout>(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<ImageView>(R.id.close_imageView).setOnClickListener {
isMiniPlayerVisible = false
motionLayout.transitionToEnd()
val mainActivity = activity as MainActivity
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT