| 
					
				 | 
			
			
				@@ -8,17 +8,18 @@ import androidx.recyclerview.widget.GridLayoutManager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.alibaba.android.arouter.facade.annotation.Route 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyang.home.R 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyang.home.databinding.ActivityHomeBinding 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yingyangfly.baselib.db.VoicePlayerBean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.baselib.dialog.TaskFragment 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.baselib.dialog.TipsDialog 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.baselib.ext.* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.baselib.guideview.Guide 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.baselib.guideview.GuideBuilder 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.baselib.mvvm.BaseMVVMActivity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yingyangfly.baselib.player.VoicePlayer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.baselib.router.RouterUrlCommon 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.baselib.utils.AppUtil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.baselib.utils.JumpUtil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.baselib.utils.User 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.yingyangfly.baselib.voice.PlayVoice 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.home.adapter.GameAdapter 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.home.component.ShowFunTimeViewComponent 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yingyangfly.home.component.ShowHealthCounselingViewComponent 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -50,11 +51,16 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private var pageList = mutableListOf<Record>() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private val gameAdapter by lazy { GameAdapter() } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private var playVoice: PlayVoice? = null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //    private var playVoice: PlayVoice? = null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 语音合成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private var voicePlayer: VoicePlayer? = null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     override fun initViews() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        playVoice = PlayVoice() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        playVoice?.setContext(mContext) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        voicePlayer = VoicePlayer.getInstance(mContext) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        playVoice = PlayVoice() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        playVoice?.setContext(mContext) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         binding { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             rvGame.layoutManager = GridLayoutManager(this@HomeActivity, 2) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             rvGame.adapter = gameAdapter 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -239,7 +245,8 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     .not() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 User.saveTaskDialogStatus(User.getNowDay()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                playVoice?.speak(it.taskDesn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                speak(it.taskDesn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                playVoice?.speak(it.taskDesn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -250,7 +257,8 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         if (TextUtils.equals(User.getNowDay(), User.getTaskDialogStatus()).not()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             User.saveTaskDialogStatus(User.getNowDay()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            playVoice?.speak(it.taskDesn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            speak(it.taskDesn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            playVoice?.speak(it.taskDesn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -261,6 +269,58 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 语音合成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private fun speak(taskDesn: String) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (db != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            val voicePlayerDao = db?.getVoicePlayerDao() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (voicePlayerDao != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                val voicePlayerBean = voicePlayerDao.getVoicePlayerBean(taskDesn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (voicePlayerBean != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (voicePlayer != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        voicePlayer?.play(voicePlayerBean.url) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    getVoiceUrl(taskDesn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                getVoiceUrl(taskDesn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            getVoiceUrl(taskDesn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 获取声音url 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private fun getVoiceUrl(taskDesn: String) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        viewModel.getVoiceUrl(taskDesn, fail = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            it.toast() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, success = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (TextUtils.isEmpty(it).not()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (db != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    val voicePlayerDao = db?.getVoicePlayerDao() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (voicePlayerDao != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        val voicePlayerBean = VoicePlayerBean().apply { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            url = it 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            words = taskDesn 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        voicePlayerDao.insert(voicePlayerBean) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (voicePlayer != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    voicePlayer?.play(it) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 训练完成弹窗页面 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -453,8 +513,10 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     override fun onDestroy() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (playVoice != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            playVoice?.stop() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (voicePlayer != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (voicePlayer!!.isPlaying) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                voicePlayer?.stop() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         super.onDestroy() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |