mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
Merge pull request #4744 from Bnyro/master
fix: hide autoplay countdown when miniplayer visible
This commit is contained in:
commit
d45a954d74
@ -8,14 +8,21 @@ import android.view.LayoutInflater
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.os.postDelayed
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.get
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.databinding.AutoplayCountdownBinding
|
||||
import com.github.libretube.ui.activities.MainActivity
|
||||
import com.github.libretube.ui.base.BaseActivity
|
||||
import com.github.libretube.ui.models.PlayerViewModel
|
||||
|
||||
class AutoplayCountdownView(
|
||||
context: Context,
|
||||
attributeSet: AttributeSet?
|
||||
) : FrameLayout(context, attributeSet) {
|
||||
private val layoutInflater = LayoutInflater.from(context)
|
||||
private val playerViewModel: PlayerViewModel get() = ViewModelProvider(context as MainActivity).get()
|
||||
|
||||
val binding = AutoplayCountdownBinding.inflate(layoutInflater, this, true)
|
||||
private var onCountdownEnd: () -> Unit = {}
|
||||
private var hideSelf: () -> Unit = {}
|
||||
@ -34,7 +41,6 @@ class AutoplayCountdownView(
|
||||
}
|
||||
|
||||
fun startCountdown(onEnd: () -> Unit) {
|
||||
this.isVisible = true
|
||||
onCountdownEnd = {
|
||||
hideSelf.invoke()
|
||||
onEnd.invoke()
|
||||
@ -53,6 +59,8 @@ class AutoplayCountdownView(
|
||||
return
|
||||
}
|
||||
|
||||
// only show countdown when mini player not visible
|
||||
this.isVisible = playerViewModel.isMiniPlayerVisible.value == false
|
||||
binding.currentState.text = context.getString(
|
||||
R.string.playing_next,
|
||||
currentTimerState.toString()
|
||||
|
Loading…
Reference in New Issue
Block a user