|
@@ -1,22 +1,30 @@
|
|
|
package com.yingyangfly.home.evaluation
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
+import android.os.Bundle
|
|
|
import android.text.TextUtils
|
|
|
import android.view.MotionEvent
|
|
|
import android.view.View
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
+import com.tencent.imsdk.v2.V2TIMCallback
|
|
|
+import com.tencent.imsdk.v2.V2TIMManager
|
|
|
import com.yingyang.home.R
|
|
|
import com.yingyang.home.databinding.ActivityEvaluationBinding
|
|
|
import com.yingyangfly.baselib.bean.Evaluation
|
|
|
import com.yingyangfly.baselib.db.QuestionsBean
|
|
|
+import com.yingyangfly.baselib.db.VoicePlayerBean
|
|
|
import com.yingyangfly.baselib.ext.getEndAnimation
|
|
|
import com.yingyangfly.baselib.ext.getScaleAnimation
|
|
|
import com.yingyangfly.baselib.ext.toast
|
|
|
import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
|
|
|
+import com.yingyangfly.baselib.player.VoicePlayer
|
|
|
import com.yingyangfly.baselib.router.RouterUrlCommon
|
|
|
import com.yingyangfly.baselib.utils.JumpUtil
|
|
|
+import com.yingyangfly.baselib.utils.LiveEventBusUtil
|
|
|
+import com.yingyangfly.baselib.utils.RxBusCodes
|
|
|
+import com.yingyangfly.baselib.utils.User
|
|
|
import com.yingyangfly.home.adapter.EvaluationListAdapter
|
|
|
|
|
|
/**
|
|
@@ -32,7 +40,17 @@ class EvaluationActivity : BaseMVVMActivity<ActivityEvaluationBinding, Evaluatio
|
|
|
private var exclusiveList = mutableListOf<Evaluation>()
|
|
|
private val exclusiveGameAdapter by lazy {EvaluationListAdapter()}
|
|
|
|
|
|
+ private var myBoolean: Boolean = true
|
|
|
+
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ myBoolean = intent.getBooleanExtra("ck",true)
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
+ }
|
|
|
+
|
|
|
override fun initViews() {
|
|
|
+ if (!myBoolean) {
|
|
|
+ voicePlayer = VoicePlayer.getInstance(mContext)
|
|
|
+ }
|
|
|
binding {
|
|
|
rvEvaluation.layoutManager = LinearLayoutManager(this@EvaluationActivity, RecyclerView.HORIZONTAL, false)
|
|
|
rvEvaluation.adapter = exclusiveGameAdapter
|
|
@@ -48,6 +66,9 @@ class EvaluationActivity : BaseMVVMActivity<ActivityEvaluationBinding, Evaluatio
|
|
|
@SuppressLint("SetTextI18n")
|
|
|
override fun onResume() {
|
|
|
super.onResume()
|
|
|
+ if (!myBoolean) {
|
|
|
+ binding.rollback.setBackgroundResource(R.mipmap.icon_back_1)
|
|
|
+ }
|
|
|
exclusiveList.clear()
|
|
|
exclusiveList.add(Evaluation("MMSE","https://yaorongoss.yaorongmedical.com/appraisal/evaluation/pingce_icon_mmse.png","MMSE"))
|
|
|
exclusiveList.add(Evaluation("MOCA","https://yaorongoss.yaorongmedical.com/appraisal/evaluation/pingce_icon_moca.png","MOCA"))
|
|
@@ -69,7 +90,30 @@ class EvaluationActivity : BaseMVVMActivity<ActivityEvaluationBinding, Evaluatio
|
|
|
}
|
|
|
|
|
|
override fun initData() {
|
|
|
+ if (!myBoolean) {
|
|
|
+ //语音合成
|
|
|
+ LiveEventBusUtil.observer<String>(this, RxBusCodes.SPEECHSYNTHESIS) {
|
|
|
+ if (TextUtils.isEmpty(it).not()) {
|
|
|
+ speak(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //结束语音播放
|
|
|
+ LiveEventBusUtil.observer<String>(this, RxBusCodes.STOPVOICE) {
|
|
|
+ if (voicePlayer != null) {
|
|
|
+ if (voicePlayer!!.isPlaying) {
|
|
|
+ voicePlayer?.stop()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ //退出登录
|
|
|
+ LiveEventBusUtil.observer<String>(this, RxBusCodes.LOGINOUT) {
|
|
|
+ runOnUiThread {
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private fun loadData(type: String) {
|
|
@@ -101,6 +145,54 @@ class EvaluationActivity : BaseMVVMActivity<ActivityEvaluationBinding, Evaluatio
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 语音合成
|
|
|
+ */
|
|
|
+ private var voicePlayer: VoicePlayer? = null
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 语音合成
|
|
|
+ */
|
|
|
+ private fun speak(desn: String) {
|
|
|
+ if (voicePlayerDao != null) {
|
|
|
+ val voicePlayerBean = voicePlayerDao?.getVoicePlayerBean(desn)
|
|
|
+ if (voicePlayerBean != null) {
|
|
|
+ if (voicePlayer != null) {
|
|
|
+ voicePlayer?.play(voicePlayerBean.url) {
|
|
|
+ LiveEventBusUtil.send(RxBusCodes.STARTMUSIC, "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ getVoiceUrl(desn)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ getVoiceUrl(desn)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取声音url
|
|
|
+ */
|
|
|
+ private fun getVoiceUrl(taskDesn: String) {
|
|
|
+ viewModel.getVoiceUrl(taskDesn, fail = {}, success = {
|
|
|
+ if (TextUtils.isEmpty(it).not()) {
|
|
|
+ if (voicePlayerDao != null) {
|
|
|
+ val voicePlayerBean = VoicePlayerBean().apply {
|
|
|
+ url = it
|
|
|
+ words = taskDesn
|
|
|
+ }
|
|
|
+ voicePlayerDao?.insert(voicePlayerBean)
|
|
|
+ }
|
|
|
+ if (voicePlayer != null) {
|
|
|
+ voicePlayer?.play(it) {
|
|
|
+ LiveEventBusUtil.send(RxBusCodes.STARTMUSIC, "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
override fun onTouch(v: View, event: MotionEvent): Boolean {
|
|
|
when (event.action) {
|
|
@@ -122,7 +214,12 @@ class EvaluationActivity : BaseMVVMActivity<ActivityEvaluationBinding, Evaluatio
|
|
|
// }
|
|
|
|
|
|
R.id.layoutHome -> {
|
|
|
- finish()
|
|
|
+ if (myBoolean) {
|
|
|
+ finish()
|
|
|
+ }else {
|
|
|
+ loginOut()
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
R.id.tvEvaluationHistory -> {
|
|
@@ -140,6 +237,41 @@ class EvaluationActivity : BaseMVVMActivity<ActivityEvaluationBinding, Evaluatio
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 退出登录
|
|
|
+ */
|
|
|
+ private fun loginOut() {
|
|
|
+ viewModel.logout(fail = {
|
|
|
+ "退出失败,请重试".toast()
|
|
|
+ }, success = {
|
|
|
+ runOnUiThread {
|
|
|
+ User.saveSaveGameSoundDate("")
|
|
|
+ User.saveUserId("")
|
|
|
+ User.saveName("")
|
|
|
+ User.saveAvatar("")
|
|
|
+ User.saveUserAge("")
|
|
|
+ User.saveUserSex("")
|
|
|
+ User.saveToken("")
|
|
|
+ User.saveMobile("")
|
|
|
+ User.saveIdCard("")
|
|
|
+ User.saveOrgCode("")
|
|
|
+ User.savePadNo("")
|
|
|
+ V2TIMManager.getInstance().logout(object : V2TIMCallback {
|
|
|
+ override fun onSuccess() {
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onError(p0: Int, p1: String?) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ LiveEventBusUtil.send(RxBusCodes.LOGINOUT, "")
|
|
|
+ LiveEventBusUtil.send(RxBusCodes.IMLoginOut, "")
|
|
|
+ JumpUtil.jumpActivity(RouterUrlCommon.login, mContext)
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取测评任务
|
|
|
*/
|