2020-10-06 08:46:04 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 Hemanth Savarla.
|
|
|
|
*
|
|
|
|
* Licensed under the GNU General Public License v3
|
|
|
|
*
|
|
|
|
* This is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
2019-04-20 05:29:45 +00:00
|
|
|
package code.name.monkey.retromusic.fragments.base
|
2018-11-30 01:06:16 +00:00
|
|
|
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.view.View
|
|
|
|
import android.view.animation.AccelerateInterpolator
|
|
|
|
import android.view.animation.DecelerateInterpolator
|
2020-07-30 14:11:19 +00:00
|
|
|
import androidx.annotation.LayoutRes
|
2019-04-04 06:07:55 +00:00
|
|
|
import code.name.monkey.retromusic.R
|
2021-09-27 16:11:27 +00:00
|
|
|
import code.name.monkey.retromusic.fragments.other.VolumeFragment
|
2019-10-04 10:58:28 +00:00
|
|
|
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
2020-06-06 18:57:28 +00:00
|
|
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
2020-05-18 07:22:18 +00:00
|
|
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
2019-04-04 06:07:55 +00:00
|
|
|
|
2018-11-30 01:06:16 +00:00
|
|
|
/**
|
|
|
|
* Created by hemanths on 24/09/17.
|
|
|
|
*/
|
|
|
|
|
2020-07-30 14:11:19 +00:00
|
|
|
abstract class AbsPlayerControlsFragment(@LayoutRes layout: Int) : AbsMusicServiceFragment(layout),
|
2020-02-26 16:49:24 +00:00
|
|
|
MusicProgressViewUpdateHelper.Callback {
|
2018-11-30 01:06:16 +00:00
|
|
|
|
|
|
|
protected abstract fun show()
|
|
|
|
|
|
|
|
protected abstract fun hide()
|
|
|
|
|
|
|
|
protected abstract fun updateShuffleState()
|
|
|
|
|
|
|
|
protected abstract fun updateRepeatState()
|
|
|
|
|
|
|
|
protected abstract fun setUpProgressSlider()
|
|
|
|
|
2020-05-18 07:22:18 +00:00
|
|
|
abstract fun setColor(color: MediaNotificationProcessor)
|
2018-11-30 01:06:16 +00:00
|
|
|
|
2021-09-08 18:30:20 +00:00
|
|
|
fun showBounceAnimation(view: View) {
|
2018-12-05 12:13:50 +00:00
|
|
|
view.apply {
|
|
|
|
clearAnimation()
|
|
|
|
scaleX = 0.9f
|
|
|
|
scaleY = 0.9f
|
|
|
|
visibility = View.VISIBLE
|
|
|
|
pivotX = (view.width / 2).toFloat()
|
|
|
|
pivotY = (view.height / 2).toFloat()
|
|
|
|
|
|
|
|
animate().setDuration(200)
|
2020-01-06 03:12:32 +00:00
|
|
|
.setInterpolator(DecelerateInterpolator())
|
|
|
|
.scaleX(1.1f)
|
|
|
|
.scaleY(1.1f)
|
|
|
|
.withEndAction {
|
|
|
|
animate().setDuration(200)
|
|
|
|
.setInterpolator(AccelerateInterpolator())
|
|
|
|
.scaleX(1f)
|
|
|
|
.scaleY(1f)
|
|
|
|
.alpha(1f)
|
|
|
|
.start()
|
|
|
|
}
|
|
|
|
.start()
|
2018-12-05 12:13:50 +00:00
|
|
|
}
|
2018-11-30 01:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
2018-12-05 12:13:50 +00:00
|
|
|
hideVolumeIfAvailable()
|
|
|
|
}
|
2018-12-05 04:29:55 +00:00
|
|
|
|
2019-04-04 06:07:55 +00:00
|
|
|
protected var volumeFragment: VolumeFragment? = null
|
|
|
|
|
2018-12-05 12:13:50 +00:00
|
|
|
private fun hideVolumeIfAvailable() {
|
2020-06-06 18:57:28 +00:00
|
|
|
if (PreferenceUtil.isVolumeVisibilityMode) {
|
2020-05-23 13:53:10 +00:00
|
|
|
childFragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.volumeFragmentContainer, VolumeFragment()).commit()
|
2019-10-04 10:58:28 +00:00
|
|
|
childFragmentManager.executePendingTransactions()
|
2020-05-23 13:53:10 +00:00
|
|
|
volumeFragment =
|
|
|
|
childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?
|
2019-04-04 06:07:55 +00:00
|
|
|
}
|
2019-02-23 17:39:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
const val SLIDER_ANIMATION_TIME: Long = 400
|
2018-11-30 01:06:16 +00:00
|
|
|
}
|
|
|
|
}
|