Commit 8b5dd9be authored by jyx's avatar jyx

福袋计时器监听优化

parent 4e345302
...@@ -295,6 +295,7 @@ class HorizonChannelFragment : BaseFragment(), HorizChannelView, View.OnClickLis ...@@ -295,6 +295,7 @@ class HorizonChannelFragment : BaseFragment(), HorizChannelView, View.OnClickLis
fun stopRedbox() { fun stopRedbox() {
if (rope != null && rope!!.isRunning) { if (rope != null && rope!!.isRunning) {
rope?.stop() rope?.stop()
rope = null
} }
} }
...@@ -317,6 +318,7 @@ class HorizonChannelFragment : BaseFragment(), HorizChannelView, View.OnClickLis ...@@ -317,6 +318,7 @@ class HorizonChannelFragment : BaseFragment(), HorizChannelView, View.OnClickLis
mRedBoxTimer?.setOnCountDownTimerListener(object : OnCountDownTimerListener { mRedBoxTimer?.setOnCountDownTimerListener(object : OnCountDownTimerListener {
override fun onTick(millisUntilFinished: Long) { override fun onTick(millisUntilFinished: Long) {
if (!requireActivity().isFinishing) { if (!requireActivity().isFinishing) {
stopRedbox()
tv_fragment_main_redbox.text = TimeRender.ms2MS(millisUntilFinished.toInt()) tv_fragment_main_redbox.text = TimeRender.ms2MS(millisUntilFinished.toInt())
} }
} }
...@@ -383,7 +385,7 @@ class HorizonChannelFragment : BaseFragment(), HorizChannelView, View.OnClickLis ...@@ -383,7 +385,7 @@ class HorizonChannelFragment : BaseFragment(), HorizChannelView, View.OnClickLis
}) })
} }
private fun destoryTimerRedbox(){ private fun destoryTimerRedbox() {
mRedBoxTimer?.stop() mRedBoxTimer?.stop()
mRedBoxTimer = null mRedBoxTimer = null
} }
......
...@@ -364,7 +364,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener { ...@@ -364,7 +364,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
cdvvYilanTime.layoutParams = params cdvvYilanTime.layoutParams = params
val paramsRedBox = FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT) val paramsRedBox = FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT)
paramsRedBox.setMargins(0, BubbleUtils.dp2px(60), 0, 0) paramsRedBox.setMargins(0, BubbleUtils.dp2px(40), 0, 0)
paramsRedBox.gravity = Gravity.END paramsRedBox.gravity = Gravity.END
rl_fragment_main_redbox.layoutParams = paramsRedBox rl_fragment_main_redbox.layoutParams = paramsRedBox
cdvvYilanTime.setOnClickListener(this) cdvvYilanTime.setOnClickListener(this)
...@@ -589,6 +589,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener { ...@@ -589,6 +589,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
fun stopRedbox() { fun stopRedbox() {
if (rope != null && rope!!.isRunning) { if (rope != null && rope!!.isRunning) {
rope?.stop() rope?.stop()
rope = null
} }
} }
...@@ -609,6 +610,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener { ...@@ -609,6 +610,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
mRedBoxTimer?.setOnCountDownTimerListener(object : OnCountDownTimerListener { mRedBoxTimer?.setOnCountDownTimerListener(object : OnCountDownTimerListener {
override fun onTick(millisUntilFinished: Long) { override fun onTick(millisUntilFinished: Long) {
if (!requireActivity().isFinishing) { if (!requireActivity().isFinishing) {
stopRedbox()
tv_fragment_main_redbox.text = TimeRender.ms2MS(millisUntilFinished.toInt()) tv_fragment_main_redbox.text = TimeRender.ms2MS(millisUntilFinished.toInt())
} }
} }
...@@ -629,7 +631,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener { ...@@ -629,7 +631,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
} }
} }
private fun destoryTimerRedbox(){ private fun destoryTimerRedbox() {
mRedBoxTimer?.stop() mRedBoxTimer?.stop()
mRedBoxTimer = null mRedBoxTimer = null
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment