优化
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)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/shape_card_view"
|
||||
android:padding="8dp">
|
||||
android:padding="8dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_seek_value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/secondaryText" />
|
||||
|
||||
<io.legado.app.lib.theme.view.ThemeSeekBar
|
||||
android:id="@+id/seek_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user