From 7bed3f6090b14391d7dad4ca4bd632fb28d847c0 Mon Sep 17 00:00:00 2001
From: 罗明文 <125975490@qq.com>
Date: 星期三, 21 五月 2025 15:34:19 +0800
Subject: [PATCH] save

---
 app/src/main/java/com/dollearn/student/ui/home/IncludeFragment.kt |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/app/src/main/java/com/dollearn/student/ui/home/IncludeFragment.kt b/app/src/main/java/com/dollearn/student/ui/home/IncludeFragment.kt
index d2c726c..744ab92 100644
--- a/app/src/main/java/com/dollearn/student/ui/home/IncludeFragment.kt
+++ b/app/src/main/java/com/dollearn/student/ui/home/IncludeFragment.kt
@@ -16,8 +16,11 @@
 import com.dollearn.student.R
 import com.dollearn.student.utils.AudioUtils
 import com.dollearn.student.utils.Const
+import com.dollearn.student.utils.event.EmptyEvent
 import com.dollearn.student.utils.extention.clickDelay
 import kotlinx.android.synthetic.main.fragment_include.*
+import org.greenrobot.eventbus.EventBus
+import org.greenrobot.eventbus.Subscribe
 import org.jetbrains.anko.support.v4.dip
 import org.jetbrains.anko.support.v4.startActivity
 
@@ -63,6 +66,7 @@
     override fun onFirstVisibleToUser() {
         player.setOnAudioStatusUpdateListener(this)
         player.stopPlayMusic()
+        EventBus.getDefault().register(this)
         handler = object : Handler(Looper.getMainLooper()){
             override fun handleMessage(msg: Message) {
                 super.handleMessage(msg)
@@ -121,8 +125,6 @@
         }
         initClick()
         showVoiceEnable()
-        isAutoPlaying = true
-        voiceViews[0].callOnClick()
     }
 
     private fun initClick() {
@@ -367,6 +369,16 @@
         })
     }
 
+    @Subscribe
+    fun onEvent(e: EmptyEvent){
+        if (e.code == Const.EventCode.RECOVERD){
+            if (act.fragments[act.vp.currentItem] == this){ //自动播放
+                isAutoPlaying = true
+                voiceViews[0].callOnClick()
+            }
+        }
+    }
+
     /**
      * 回到上一题,恢复状态
      */
@@ -382,6 +394,10 @@
             it.listend = false
         }
         showVoiceEnable()
+        if (act.fragments[act.vp.currentItem] == this&&act.recoverd) { //自动播放
+            isAutoPlaying = true
+            voiceViews[0].callOnClick()
+        }
     }
 
     companion object{
@@ -535,5 +551,6 @@
     override fun onDestroy() {
         super.onDestroy()
         handler?.removeCallbacksAndMessages(null)
+        EventBus.getDefault().unregister(this)
     }
 }
\ No newline at end of file

--
Gitblit v1.7.1