|
|
@@ -1,16 +1,29 @@
|
|
|
package com.yingyangfly.home.hospital
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
+import android.text.TextUtils
|
|
|
+import android.view.MotionEvent
|
|
|
+import android.view.View
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
+import com.yingyang.home.R
|
|
|
import com.yingyang.home.databinding.ActivityHospitalBinding
|
|
|
-import com.yingyangfly.baselib.base.BaseTvActivity
|
|
|
+import com.yingyangfly.baselib.dialog.BindingPhoneDialog
|
|
|
+import com.yingyangfly.baselib.ext.getEndAnimation
|
|
|
+import com.yingyangfly.baselib.ext.getScaleAnimation
|
|
|
+import com.yingyangfly.baselib.ext.show
|
|
|
+import com.yingyangfly.baselib.ext.toast
|
|
|
+import com.yingyangfly.baselib.mvvm.BaseTvMVVMActivity
|
|
|
import com.yingyangfly.baselib.router.RouterUrlCommon
|
|
|
+import com.yingyangfly.baselib.utils.JumpUtil
|
|
|
+import com.yingyangfly.baselib.utils.User
|
|
|
import com.youth.banner.indicator.RectangleIndicator
|
|
|
|
|
|
/**
|
|
|
* 医院电视端首页
|
|
|
*/
|
|
|
@Route(path = RouterUrlCommon.hospitalEvaluation)
|
|
|
-class HospitalActivity : BaseTvActivity<ActivityHospitalBinding>() {
|
|
|
+class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalViewModel>(),
|
|
|
+ View.OnTouchListener {
|
|
|
|
|
|
private var str1 = "https://15463311.s21i.faiusr.com/4/ABUIABAEGAAgiOzT0AUo6vfflwQwgA84ggQ.png"
|
|
|
private var str2 =
|
|
|
@@ -27,16 +40,108 @@ class HospitalActivity : BaseTvActivity<ActivityHospitalBinding>() {
|
|
|
imageList.add(str3)
|
|
|
imageList.add(str4)
|
|
|
adapterGuide = GuidePageAdapter(imageList, mContext)
|
|
|
- binding.guide.addBannerLifecycleObserver(this)
|
|
|
- ?.setAdapter(adapterGuide)?.indicator = RectangleIndicator(mContext)
|
|
|
+ binding.guide.addBannerLifecycleObserver(this)?.setAdapter(adapterGuide)?.indicator =
|
|
|
+ RectangleIndicator(mContext)
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @SuppressLint("ClickableViewAccessibility")
|
|
|
override fun initListener() {
|
|
|
-
|
|
|
+ binding {
|
|
|
+ loginOutLayout.setOnTouchListener(this@HospitalActivity)
|
|
|
+ searchLayout.setOnTouchListener(this@HospitalActivity)
|
|
|
+ otherEvaluationsLayout.setOnTouchListener(this@HospitalActivity)
|
|
|
+ mocaLayout.setOnTouchListener(this@HospitalActivity)
|
|
|
+ mmseLayout.setOnTouchListener(this@HospitalActivity)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
override fun initData() {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @SuppressLint("ClickableViewAccessibility")
|
|
|
+ override fun onTouch(v: View, event: MotionEvent): Boolean {
|
|
|
+ when (event.action) {
|
|
|
+ MotionEvent.ACTION_DOWN -> {
|
|
|
+ if (v.id == R.id.loginOutLayout || v.id == R.id.searchLayout || v.id == R.id.otherEvaluationsLayout || v.id == R.id.mocaLayout || v.id == R.id.mmseLayout) {
|
|
|
+ v.startAnimation(getScaleAnimation())
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ MotionEvent.ACTION_UP -> {
|
|
|
+ v.startAnimation(getEndAnimation())
|
|
|
+ when (v.id) {
|
|
|
+ R.id.loginOutLayout -> {
|
|
|
+ loginOut()
|
|
|
+ }
|
|
|
+
|
|
|
+ R.id.searchLayout -> {
|
|
|
+ JumpUtil.jumpActivity(RouterUrlCommon.evaluationHistory)
|
|
|
+ }
|
|
|
+
|
|
|
+ R.id.otherEvaluationsLayout -> {
|
|
|
+ JumpUtil.jumpActivity(RouterUrlCommon.mocaEvaluation)
|
|
|
+ }
|
|
|
+
|
|
|
+ R.id.mocaLayout -> {
|
|
|
+ JumpUtil.jumpActivity(RouterUrlCommon.mocaEvaluation)
|
|
|
+ }
|
|
|
+
|
|
|
+ R.id.mmseLayout -> {
|
|
|
+ JumpUtil.jumpActivity(RouterUrlCommon.mmseEvaluation)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ MotionEvent.ACTION_CANCEL -> {
|
|
|
+ if (v.id == R.id.loginOutLayout || v.id == R.id.searchLayout || v.id == R.id.otherEvaluationsLayout || v.id == R.id.mocaLayout || v.id == R.id.mmseLayout) {
|
|
|
+ v.startAnimation(getEndAnimation())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onResume() {
|
|
|
+ super.onResume()
|
|
|
+ if (TextUtils.isEmpty(User.getToken())) {
|
|
|
+ binding.imageLoginOut.show(false)
|
|
|
+ binding.tvLoginOut.show(false)
|
|
|
+ showBindingPhoneDialog()
|
|
|
+ } else {
|
|
|
+ binding.imageLoginOut.show(true)
|
|
|
+ binding.tvLoginOut.show(true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 退出登录
|
|
|
+ */
|
|
|
+ private fun loginOut() {
|
|
|
+ viewModel.logout(fail = {
|
|
|
+ "解绑失败,请重试".toast()
|
|
|
+ }, success = {
|
|
|
+ runOnUiThread {
|
|
|
+ binding.imageLoginOut.show(false)
|
|
|
+ binding.tvLoginOut.show(false)
|
|
|
+ User.saveToken("")
|
|
|
+ User.savePhone("")
|
|
|
+ showBindingPhoneDialog()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 展示绑定手机号弹窗
|
|
|
+ */
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
+ private fun showBindingPhoneDialog() {
|
|
|
+ val bindingPhoneDialog = BindingPhoneDialog()
|
|
|
+ bindingPhoneDialog.onDialogClickListener = {
|
|
|
+ binding.imageLoginOut.show(true)
|
|
|
+ binding.tvLoginOut.show(true)
|
|
|
+ }
|
|
|
+ bindingPhoneDialog.show(supportFragmentManager, "bindingPhoneDialog")
|
|
|
+ }
|
|
|
}
|