监测模块修改

This commit is contained in:
zhanglei
2025-07-02 14:26:20 +08:00
parent 48e13ea271
commit 1f204f2476
11 changed files with 76 additions and 621 deletions
Binary file not shown.
@@ -1,268 +0,0 @@
package com.xjjk.healthyclients.base
import android.app.Activity
import android.app.ActivityManager
import android.app.ActivityManager.RunningAppProcessInfo
import android.app.ProgressDialog
import android.content.Context
import android.content.Intent
import android.graphics.drawable.Drawable
import android.os.Build
import android.os.Bundle
import android.text.InputType
import android.util.AttributeSet
import android.view.View
import android.view.Window
import android.widget.EditText
import android.widget.Toast
import androidx.annotation.IdRes
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity
import com.sw.healthyclients.view.CustomToast
import com.sw.healthyclients.view.LoadingDialog
import com.xjjk.healthyclients.MyApplication
import com.xjjk.healthyclients.event.GlobalEvent
import com.xjjk.healthyclients.retrofit.NetApi
import com.xjjk.healthyclients.retrofit.RetrofitManager
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import java.lang.reflect.Method
/**
* 可以再基类中
*/
abstract class BaseActivity : AppCompatActivity(), View.OnClickListener, CoroutineScope by MainScope() {
protected var app: MyApplication? = null
public var mContext: Context? = null
protected set
var newsApi = RetrofitManager.getRetrofits().create(NetApi::class.java)
protected set
public var mActivity: Activity? = null
var dialog: LoadingDialog? = null
protected set
protected var screenWidth = 0
protected var screenHeight = 0
var moveTime: Long = 0
var currentMS: Long = 0
override fun onClick(view: View) {
processClick(view)
}
override fun onCreate(paramBundle: Bundle?) {
super.onCreate(paramBundle)
EventBus.getDefault().register(this)
screenWidth = this.resources.displayMetrics.widthPixels
screenHeight = this.resources.displayMetrics.heightPixels
mContext = this
mActivity = this
createDialog()
}
override fun onCreateView(name: String, context: Context, attrs: AttributeSet): View? {
return super.onCreateView(name, context, attrs)
}
/**
* 创建加载弹窗
*/
private fun createDialog() {
dialog = LoadingDialog(
mActivity,
ProgressDialog.STYLE_SPINNER, "数据加载中"
)
dialog!!.requestWindowFeature(Window.FEATURE_NO_TITLE)
dialog!!.setCanceledOnTouchOutside(false)
dialog!!.setCancelable(false)
dialog!!.setMessage("请稍后")
}
override fun setContentView(@LayoutRes layoutResID: Int) {
super.setContentView(layoutResID)
initView()
initData()
bindEvent()
tryToAddBackClick()
}
override fun setContentView(view: View) {
super.setContentView(view)
initView()
bindEvent()
initData()
tryToAddBackClick()
}
override fun onStart() {
super.onStart()
}
override fun onStop() {
super.onStop()
}
override fun onDestroy() {
super.onDestroy()
cancel()
EventBus.getDefault().unregister(this)
}
override fun onBackPressed() {
super.onBackPressed()
finish()
}
/**
* 初始化View
*/
abstract fun initView()
/**
* 初始化数据
*/
abstract fun initData()
/**
* 事件监听
*/
protected abstract fun bindEvent()
/**
* 点击事件处理
*
* @param paramView
*/
abstract fun processClick(paramView: View?)
/**
* 返回键的默认点击销毁当前activity
*/
fun tryToAddBackClick() {}
fun showLongToast(message: String?) {
CustomToast.makeText(mContext, message, Toast.LENGTH_LONG).show()
}
fun showToast(message: String?, drawable: Drawable?) {
CustomToast.makeText(mContext, message, Toast.LENGTH_SHORT, drawable).show()
}
fun showToast(message: String?) {
if (message != null&&message.isNotEmpty()) {
CustomToast.makeText(mContext, message, Toast.LENGTH_SHORT).show()
}
}
fun toActivity(clazz: Class<*>?) {
val intent = Intent(mActivity, clazz)
mActivity?.startActivity(intent)
}
fun toActivityForResult(clazz: Class<*>?,code:Int) {
val intent = Intent(mActivity, clazz)
mActivity?.startActivityForResult(intent, code)
}
fun toActivityForResult(clazz: Class<*>?,bundle: Bundle?,code:Int) {
val intent = Intent(mActivity, clazz)
if (bundle != null) {
intent.putExtras(bundle)
}
mActivity?.startActivityForResult(intent, code)
}
fun toActivity(clazz: Class<*>?, bundle: Bundle?) {
val intent = Intent(mActivity, clazz)
if (bundle != null) {
intent.putExtras(bundle)
}
mActivity?.startActivity(intent)
}
protected fun toLoginActivity(clazz: Class<*>?) {
val intent = Intent(mActivity, clazz)
mActivity?.startActivity(intent)
}
override fun onRestart() {
super.onRestart()
}
override fun finish() {
super.finish()
}
protected fun <E : View?> F(@IdRes viewId: Int): E {
return super.findViewById<View>(viewId) as E
}
protected fun <E : View?> F(view: View, @IdRes viewId: Int): E {
return view.findViewById<View>(viewId) as E
}
protected fun <E : View?> C(view: E) {
view!!.setOnClickListener(this)
}// The name of the process that this object is associated with.// Returns a list of application processes that are running on the
// device
/**
* 程序是否在前台运行
*
* @return
*/
val isAppOnForeground: Boolean
get() {
// Returns a list of application processes that are running on the
// device
val activityManager = applicationContext
.getSystemService(ACTIVITY_SERVICE) as ActivityManager
val packageName = applicationContext.packageName
val appProcesses = activityManager
.runningAppProcesses ?: return false
for (appProcess in appProcesses) {
// The name of the process that this object is associated with.
if (appProcess.processName == packageName && appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
return true
}
}
return false
}
fun disableShowInput(view: EditText) {
if (Build.VERSION.SDK_INT <= 10) {
view.inputType = InputType.TYPE_NULL
} else {
val cls = EditText::class.java
var method: Method
try {
method = cls.getMethod("setShowSoftInputOnFocus", Boolean::class.javaPrimitiveType)
method.isAccessible = true
method.invoke(view, false)
} catch (e: Exception) { //TODO: handle exception
}
try {
method = cls.getMethod("setSoftInputShownOnFocus", Boolean::class.javaPrimitiveType)
method.isAccessible = true
method.invoke(view, false)
} catch (e: Exception) { //TODO: handle exception
}
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
open fun onMessageEvent(event: GlobalEvent?) {
try {
event?.let{ event->
if (event is GlobalEvent) {
}
}
} catch (e: Exception) {
}
}
}
@@ -1,81 +0,0 @@
package com.xjjk.healthyclients.base
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.fragment.app.Fragment
import com.sw.healthyclients.utils.StatusbarUtil
import com.sw.healthyclients.view.CustomToast
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
/**
* 可以再基类中
*/
abstract class BaseFragment : Fragment(), View.OnClickListener, CoroutineScope by MainScope() {
var mContext:Context?=null
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
mContext=context
return inflater.inflate(getContentLayoutId(), container, false);
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initViews(view);
initData();
bindEvent()
}
fun fitTransparentStatusBar(view: View?){
view?.let {
var statusHeight = StatusbarUtil.getStatusBarHeight(requireContext())
it.setPadding(0, statusHeight,
0, 0)
var height: Int = it.layoutParams?.height ?: 0
it.layoutParams.height = height + statusHeight
}
}
protected abstract fun getContentLayoutId(): Int
protected abstract fun getStatusbarStyle(): Int // 0 主题色+白字 1白底黑字
protected abstract fun initViews(root: View?)
protected open fun initData() {}
protected abstract fun bindEvent()
@RequiresApi(Build.VERSION_CODES.M)
@SuppressLint("ResourceAsColor")
override fun onResume() {
super.onResume()
// try {
// if (getStatusbarStyle()==0) {
// activity?.let { StatusbarUtil.customColorMode(it, "#54eccb",false) }
// }else if (getStatusbarStyle()==1){
// activity?.let { StatusbarUtil.customColorMode(it, "#FFFFFFFF",true) }
// }
// } catch (e: Exception) {
// }
}
fun showToast(message: String?) {
if (message != null&&message.isNotEmpty()) {
CustomToast.makeText(mContext, message, Toast.LENGTH_SHORT).show()
}
}
fun toActivity(clazz: Class<*>?) {
val intent = Intent(activity, clazz)
activity?.startActivity(intent)
}
}
@@ -33,10 +33,10 @@ public class CvdWarningHistoryBean {
}
public String getAddress() {
if (TextUtils.isEmpty(gpsErrorMsg)) {
return TextUtils.isEmpty(addressGd) ? address : addressGd;
if (TextUtils.isEmpty(address)) {
return TextUtils.isEmpty(addressGd) ? gpsErrorMsg : addressGd;
} else {
return gpsErrorMsg;
return address;
}
}
@@ -205,16 +205,16 @@ interface HealthCheckNetApi {
*/
@GET("health-watch/watchH5Api/indexDataNew")
fun getCvdHomeData(@Query("userId") userId: String): Call<CustomInterventionResponseResult<CvdMainBean>>
/**
* 防范心梗 查询是否填写问卷
*/
@GET("health-intervene/api/risk/riskMyocardialSuddenDeath/selectTfFillQuestion")
fun selectTfFillQuestion(@Query("type") type: String): Call<CustomInterventionResponseResult<Boolean>>
/**
* 防范心梗 查询危险因素
*/
@GET("health-intervene/api/risk/angiocarpyPreventionWarning/selectAngiocarpyPreventionWarningDOByUserId")
fun selectAngiocarpyPreventionWarningDOByUserId(@Query("type") type: String): Call<CustomInterventionResponseResult<CvdRiskInfoBean>>
// /**
// * 防范心梗 查询是否填写问卷
// */
// @GET("health-intervene/api/risk/riskMyocardialSuddenDeath/selectTfFillQuestion")
// fun selectTfFillQuestion(@Query("type") type: String): Call<CustomInterventionResponseResult<Boolean>>
// /**
// * 防范心梗 查询危险因素
// */
// @GET("health-intervene/api/risk/angiocarpyPreventionWarning/selectAngiocarpyPreventionWarningDOByUserId")
// fun selectAngiocarpyPreventionWarningDOByUserId(@Query("type") type: String): Call<CustomInterventionResponseResult<CvdRiskInfoBean>>
/**
* 查询预警历史数据
@@ -13,14 +13,12 @@ import com.xjjk.healthyclients.adapter.CvdMainAdapter
import com.xjjk.healthyclients.base.BaseVMBFragment
import com.xjjk.healthyclients.base.viewmodel.TestViewModel
import com.xjjk.healthyclients.bean.CvdMainBean
import com.xjjk.healthyclients.bean.CvdRiskInfoBean
import com.xjjk.healthyclients.bean.TitleTagBean
import com.xjjk.healthyclients.chart.DoubleWheelBPicker
import com.xjjk.healthyclients.chart.HeartRateProvider
import com.xjjk.healthyclients.chart.TemperatureProvider
import com.xjjk.healthyclients.data.api.HealthCheckNetApi
import com.xjjk.healthyclients.databinding.FragmentMonitorBinding
import com.xjjk.healthyclients.event.WebReloadEvent
import com.xjjk.healthyclients.retrofit.getHealthCheckRetrofit
import com.xjjk.healthyclients.retrofit.intervention.CallbackInterventionManager
import com.xjjk.healthyclients.ui.activity.CvdWarningHistoryActivity
@@ -47,9 +45,8 @@ class MonitorFragment: BaseVMBFragment<TestViewModel, FragmentMonitorBinding>(R.
private var mUserId: String = ""
private var mToken: String = ""
var mType=2
override fun initView(root: View?, savedInstanceState: Bundle?) {
mBinding.ccdwvAnswer.initView(mType)
}
override fun initData() {
@@ -70,7 +67,7 @@ class MonitorFragment: BaseVMBFragment<TestViewModel, FragmentMonitorBinding>(R.
override fun lazyLoadData() {
super.lazyLoadData()
getHomePageUserInfo()
answer()
// answer()
}
private fun initListData() {
@@ -203,7 +200,6 @@ class MonitorFragment: BaseVMBFragment<TestViewModel, FragmentMonitorBinding>(R.
dialog?.dismiss()
result?.let {
mBinding.wearTimeTv.text = "佩戴${result.days}"
mBinding.sleepValue2Tv.text =
"平均睡眠${result.aveSleep.toInt() / 60}小时${result.aveSleep.toInt() % 60}分钟"
@@ -267,57 +263,57 @@ class MonitorFragment: BaseVMBFragment<TestViewModel, FragmentMonitorBinding>(R.
}
fun answer(){
dialog?.show()
var getCvdHomeData = mApi.selectTfFillQuestion(mType.toString())
getCvdHomeData.enqueue(object : CallbackInterventionManager<Boolean>() {
override fun onSuccess(
code: Int,
result: Boolean?,
message: String,
ok: Boolean
) {
dialog?.dismiss()
result?.let {
if (it) {
//已填写问卷
mBinding?.ccdwvAnswer?.answerState(true)
getRiskInfo()
}else{
mBinding?.ccdwvAnswer?.answerState(false)
}
}
}
override fun onFail(code: Int, errMsg: String?) {
dialog?.dismiss()
showToast(errMsg)
}
})
}
fun getRiskInfo(){
var getCvdHomeData = mApi.selectAngiocarpyPreventionWarningDOByUserId(mType.toString())
getCvdHomeData.enqueue(object : CallbackInterventionManager<CvdRiskInfoBean>() {
override fun onSuccess(
code: Int,
result: CvdRiskInfoBean?,
message: String,
ok: Boolean
) {
dialog?.dismiss()
mBinding?.ccdwvAnswer?.setRiskInfo(result)
}
override fun onFail(code: Int, errMsg: String?) {
showToast(errMsg)
}
})
}
// fun answer(){
// dialog?.show()
// var getCvdHomeData = mApi.selectTfFillQuestion(mType.toString())
// getCvdHomeData.enqueue(object : CallbackInterventionManager<Boolean>() {
//
// override fun onSuccess(
// code: Int,
// result: Boolean?,
// message: String,
// ok: Boolean
// ) {
// dialog?.dismiss()
// result?.let {
// if (it) {
// //已填写问卷
// mBinding?.ccdwvAnswer?.answerState(true)
// getRiskInfo()
// }else{
// mBinding?.ccdwvAnswer?.answerState(false)
// }
// }
// }
//
// override fun onFail(code: Int, errMsg: String?) {
// dialog?.dismiss()
// showToast(errMsg)
// }
//
// })
// }
//
// fun getRiskInfo(){
// var getCvdHomeData = mApi.selectAngiocarpyPreventionWarningDOByUserId(mType.toString())
// getCvdHomeData.enqueue(object : CallbackInterventionManager<CvdRiskInfoBean>() {
//
// override fun onSuccess(
// code: Int,
// result: CvdRiskInfoBean?,
// message: String,
// ok: Boolean
// ) {
// dialog?.dismiss()
// mBinding?.ccdwvAnswer?.setRiskInfo(result)
// }
//
// override fun onFail(code: Int, errMsg: String?) {
// showToast(errMsg)
// }
//
// })
// }
private fun showHeartPicker() {
@@ -464,10 +460,10 @@ class MonitorFragment: BaseVMBFragment<TestViewModel, FragmentMonitorBinding>(R.
}
override fun onMessageEvent(event: Any?) {
super.onMessageEvent(event)
if (event is WebReloadEvent) {
answer()
}
}
// override fun onMessageEvent(event: Any?) {
// super.onMessageEvent(event)
// if (event is WebReloadEvent) {
// answer()
// }
// }
}
@@ -192,7 +192,7 @@ class InterventionWebActivity() :
}
}
fun getToken(idcard: String) {
// fun getToken(idcard: String) {
// dialog?.show()
// var getToken = mApi.getTokenByIdCard(idcard)
// getToken.enqueue(object : CallbackInterventionManager<String>() {
@@ -207,7 +207,7 @@ class InterventionWebActivity() :
// }
// })
}
// }
fun hasNext(dateString: String): Boolean {
val date = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(dateString)
@@ -37,7 +37,7 @@ class UserSettingActivity :
override fun bindEvent() {
mBinding?.apply {
addClickViews(settingEditPassword,settingUserAgreement,settingUserPrivacyPolicy,settingUserVersion)
addClickViews(settingEditPassword,settingUserAgreement,settingUserPrivacyPolicy)
}
}
@@ -43,27 +43,6 @@
android:layout_marginLeft="@dimen/dp_12"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dp_5"
android:background="#EFEFEF"
/>
<com.xjjk.healthyclients.view.CustomUserInfoMenu
android:id="@+id/setting_user_advocate"
android:layout_marginLeft="@dimen/dp_12"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.xjjk.healthyclients.view.CustomUserInfoMenu
android:id="@+id/setting_user_version"
android:layout_marginLeft="@dimen/dp_12"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.xjjk.healthyclients.view.CustomUserInfoMenu
android:id="@+id/record_number"
android:layout_marginLeft="@dimen/dp_12"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</layout>
@@ -129,7 +129,7 @@
android:layout_marginLeft="@dimen/dp_14"
android:layout_marginTop="@dimen/dp_8"
android:ellipsize="end"
android:maxLines="1"
android:maxLines="2"
android:textColor="#999999"
android:textSize="@dimen/txt13"
tools:text="--" />
@@ -263,179 +263,8 @@
android:layout_marginRight="@dimen/dp_14"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_14"
android:layout_marginTop="@dimen/dp_14"
android:layout_marginRight="@dimen/dp_14"
android:background="@drawable/bg_food_white_background"
android:orientation="horizontal"
android:padding="@dimen/dp_14">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/bg_cvd_main_blue"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_12"
android:paddingTop="@dimen/dp_14"
android:paddingRight="@dimen/dp_12"
android:paddingBottom="@dimen/dp_14">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="华为穿戴"
android:textColor="#ff0789c0"
android:textSize="@dimen/txt16" />
<TextView
android:id="@+id/wear_time_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_12"
android:text="佩戴90天"
android:textColor="#ff77849e"
android:textSize="12sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_12"
android:textColor="#ff77849e"
android:textSize="12sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_12"
android:textColor="#ff77849e"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_14"
android:layout_weight="1"
android:background="@drawable/bg_cvd_main_yellow"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_12"
android:paddingTop="@dimen/dp_14"
android:paddingRight="@dimen/dp_12"
android:paddingBottom="@dimen/dp_14">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="预警研究"
android:textColor="#ffe7ae84"
android:textSize="@dimen/txt16" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_12"
android:text="心率失常权重"
android:textColor="#ff77849e"
android:textSize="@dimen/txt12" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_12"
android:text="血氧下降权重"
android:textColor="#ff77849e"
android:textSize="@dimen/txt12" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_12"
android:text="体温下降权重"
android:textColor="#ff77849e"
android:textSize="@dimen/txt12" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_14"
android:layout_weight="1"
android:background="@drawable/bg_cvd_main_red"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_12"
android:paddingTop="@dimen/dp_14"
android:paddingRight="@dimen/dp_12"
android:paddingBottom="@dimen/dp_14">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="心脏体检"
android:textColor="#ffd16685"
android:textSize="@dimen/txt16" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_12"
android:text="心电图正常"
android:textColor="#ff77849e"
android:textSize="@dimen/txt12" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_12"
android:text="心脏CTA正常"
android:textColor="#ff77849e"
android:textSize="@dimen/txt12" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_12"
android:text="检验指标正常"
android:textColor="#ff77849e"
android:textSize="@dimen/txt12" />
</LinearLayout>
</LinearLayout>
<com.xjjk.healthyclients.view.CustomCvdMainDiseaseWarningView
android:id="@+id/ccdwv_answer"
android:layout_margin="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_46"
android:paddingTop="@dimen/dp_6"
android:paddingRight="@dimen/dp_46"
android:paddingBottom="@dimen/dp_6"
android:visibility="gone">
<TextView
android:id="@+id/fast_help_tv"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_44"
android:background="@drawable/bg_red_button"
android:gravity="center"
android:text="一键帮助"
android:textColor="#ffffffff"
android:textSize="@dimen/txt18" />
</LinearLayout>
</LinearLayout>
</LinearLayout>