优化
This commit is contained in:
@@ -150,6 +150,7 @@ object AudioPlay {
|
||||
appCtx.startService(intent)
|
||||
} else {
|
||||
AudioPlayService.timeMinute = minute
|
||||
postEvent(EventBus.AUDIO_DS, minute)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.app.Activity
|
||||
import android.icu.text.SimpleDateFormat
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.SeekBar
|
||||
@@ -164,7 +165,7 @@ class AudioPlayActivity :
|
||||
AudioPlay.adjustSpeed(this@AudioPlayActivity, -0.1f)
|
||||
}
|
||||
binding.ivTimer.setOnClickListener {
|
||||
timerSliderPopup.showAsDropDown(binding.tvSubTitle)
|
||||
timerSliderPopup.showAsDropDown(it, 0, (-100).dpToPx(), Gravity.TOP)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user