|
|
@@ -6,12 +6,13 @@ import android.view.View
|
|
|
import android.view.ViewGroup
|
|
|
import android.widget.PopupWindow
|
|
|
import android.widget.SeekBar
|
|
|
+import io.legado.app.R
|
|
|
import io.legado.app.databinding.PopupSeekBarBinding
|
|
|
import io.legado.app.model.AudioPlay
|
|
|
import io.legado.app.service.AudioPlayService
|
|
|
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
|
|
|
|
|
|
-class TimerSliderPopup(context: Context) :
|
|
|
+class TimerSliderPopup(private val context: Context) :
|
|
|
PopupWindow(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) {
|
|
|
|
|
|
private val binding = PopupSeekBarBinding.inflate(LayoutInflater.from(context))
|
|
|
@@ -20,14 +21,15 @@ class TimerSliderPopup(context: Context) :
|
|
|
contentView = binding.root
|
|
|
|
|
|
isTouchable = true
|
|
|
- isOutsideTouchable = true
|
|
|
- isFocusable = false
|
|
|
+ isOutsideTouchable = false
|
|
|
+ isFocusable = true
|
|
|
|
|
|
binding.seekBar.max = 180
|
|
|
-
|
|
|
+ setProcessTextValue(binding.seekBar.progress)
|
|
|
binding.seekBar.setOnSeekBarChangeListener(object : SeekBarChangeListener {
|
|
|
|
|
|
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
|
|
+ setProcessTextValue(progress)
|
|
|
if (fromUser) {
|
|
|
AudioPlay.setTimer(progress)
|
|
|
}
|
|
|
@@ -36,9 +38,18 @@ class TimerSliderPopup(context: Context) :
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- override fun showAsDropDown(anchor: View?) {
|
|
|
- super.showAsDropDown(anchor)
|
|
|
+ override fun showAsDropDown(anchor: View?, xoff: Int, yoff: Int, gravity: Int) {
|
|
|
+ super.showAsDropDown(anchor, xoff, yoff, gravity)
|
|
|
+ binding.seekBar.progress = AudioPlayService.timeMinute
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun showAtLocation(parent: View?, gravity: Int, x: Int, y: Int) {
|
|
|
+ super.showAtLocation(parent, gravity, x, y)
|
|
|
binding.seekBar.progress = AudioPlayService.timeMinute
|
|
|
}
|
|
|
|
|
|
+ private fun setProcessTextValue(process: Int) {
|
|
|
+ binding.tvSeekValue.text = context.getString(R.string.timer_m, process)
|
|
|
+ }
|
|
|
+
|
|
|
}
|