diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 76a612d..05d648d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -138,10 +138,7 @@ android:launchMode="singleTop" android:screenOrientation="portrait" /> - + diff --git a/app/src/main/java/com/zj365/dc/activity/InfoSimpleAct.kt b/app/src/main/java/com/zj365/dc/activity/InfoSimpleAct.kt deleted file mode 100644 index e0e6013..0000000 --- a/app/src/main/java/com/zj365/dc/activity/InfoSimpleAct.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.zj365.dc.activity - -import android.content.Intent -import android.text.Editable -import android.text.TextWatcher -import android.util.Log -import com.alibaba.android.arouter.facade.annotation.Route -import com.alibaba.android.arouter.launcher.ARouter -import com.luck.picture.lib.PictureSelector -import com.luck.picture.lib.config.PictureConfig -import com.tamsiree.rxkit.RxActivityTool -import com.tamsiree.rxkit.RxKeyboardTool -import com.xty.base.act.BaseVmAct -import com.xty.common.TimeSelect -import com.xty.common.TimeUtils -import com.xty.common.arouter.ARouterUrl -import com.xty.common.arouter.RouteManager -import com.xty.common.event.MyInfoEvent -import com.xty.common.picture.PictureUtils -import com.xty.common.setImage -import com.xty.common.util.CommonToastUtils -import com.zj365.dc.R -import com.zj365.dc.databinding.ActInfoSimpleBinding -import com.zj365.dc.vm.InfoSimpleVm -import org.greenrobot.eventbus.EventBus -import java.util.regex.Pattern - -/** - * 基本信息 - * 简单信息填写 - */ -@Route(path = ARouterUrl.INFO_SIMPLE) -class InfoSimpleAct : BaseVmAct() { - - val binding by lazy { ActInfoSimpleBinding.inflate(layoutInflater) } - override fun setLayout() = binding.root - - private var isBinding: Boolean = false - private var sexType = 1 - private var birthdayType = 1 - - var phone: String = "" - private var pwd: String = "" - - private val timeSelect by lazy { TimeSelect(this) {} } - private val textListener by lazy { - object : TextWatcher { - override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { - } - - override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { - } - - override fun afterTextChanged(s: Editable?) { - binding.mName.removeTextChangedListener(this) - val str = s.toString().trim() - if (str.isNotEmpty()) { - val isNum = Pattern.matches("[0-9]", str.substring(0, 1)) - if (isNum) { - if (str.length > 2) { - binding.mName.setText(str.substring(1, str.length)) - } else { - binding.mName.setText("") - } - CommonToastUtils.showToast(R.string.name_first_num) - } - } - binding.mName.addTextChangedListener(this) - } - } - } - - override fun initData() { - super.initData() - isDarkBar = true - phone = intent.getStringExtra("phone").toString() - pwd = intent.getStringExtra("password").toString() - } - - override fun initView() { - super.initView() - statusBar(binding.title.mView) - binding.title.mTvTitle.text = getString(R.string.base_info) - binding.title.mIvBack.setOnClickListener { finish() } - binding.mImage.setOnClickListener { PictureUtils.openCamera(this) } - timeSelect.startDate.set(1922, 0, 1) - binding.llBirthday.setOnClickListener { - RxKeyboardTool.hideSoftInput(this) - timeSelect.selectTime(binding.mBirthday) - } - sexType = if (binding.checkSex.isChecked) 2 else 1 - birthdayType = if (binding.checkBirthday.isChecked) 2 else 1 - binding.bindingTv.setOnClickListener { - isBinding = true - turnToSaveBaseData() - - - } - binding.mName.addTextChangedListener(textListener) - - binding.mSubmit.setOnClickListener { - isBinding = false - turnToSaveBaseData() - } - } - - /** - * 调用接口保存 - */ - private fun turnToSaveBaseData() { - - val birthDay = binding.mBirthday.text.toString().trim() - val name = binding.mName.text.toString().trim() - if (TimeUtils.getAgeByBirth(birthDay) < 14) { - CommonToastUtils.showToast("需要年满14岁才可使用") - isBinding = false - return - } - val avatar = binding.mImage.tag - val datanal = avatar?.toString() ?: "" - val sexValue = if (binding.checkSex.isChecked) "2" else "1" - birthdayType = if (binding.checkBirthday.isChecked) 2 else 1 - //调用接口 - if (name.trim().isEmpty()) { - mViewModel.submit(datanal, null, sexValue, birthdayType.toString(), birthDay) - } else { - mViewModel.submit(datanal, name, sexValue, birthdayType.toString(), birthDay) - } - } - - override fun liveObserver() { - mViewModel.setBasic.observe(this) { - - //不管点击绑定还是完成都会去登录 - EventBus.getDefault().post(MyInfoEvent()) - mViewModel.login(phone, pwd) - - if (isBinding) { - return@observe - } - CommonToastUtils.showSucceedToast("信息设置成功") - } - - mViewModel.mLogin.observe(this) { - //登录成功请求用户token - mViewModel.getImUserSig("user_${it.data.id}") - } - - mViewModel.getImUserSig.observe(this) { - Log.e("simon", "login" + it.data) - /*TUILogin.login( - applicationContext, - 0, - it.paramsData, - it.data, - object : TUICallback() { - override fun onSuccess() { - Log.e("simon", "onSuccess") - if (!isBinding) { //如果是直接点击完成,跳转到主页面 - ARouter.getInstance().build(ARouterUrl.MAIN_ACT).navigation() - RxActivityTool.finishAllActivity() - } else { //如果是去绑定设备,跳转到设备选择界面,同是给予标记,告诉该界面已经登录 - bundle.clear() - bundle.putBoolean("isLogin", true) - RouteManager.goAct(ARouterUrl.DEVICE_CHOICE, bundle) - } - } - - override fun onError(errorCode: Int, errorMessage: String?) { - Log.e("simon", "onError") - } - })*/ - } - } - - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) - - if (resultCode === RESULT_OK) { - when (requestCode) { - PictureConfig.CHOOSE_REQUEST -> { - var result = PictureSelector.obtainMultipleResult(data) - if (result.size > 0) { - var path = if (result[0].compressPath.isEmpty()) { - result[0].androidQToPath - } else { - result[0].compressPath - } - binding.mImage.setImage(this, path) - binding.mImage.tag = path - } - } - - 1000 -> { - finish() - } - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/zj365/dc/vm/InfoSimpleVm.kt b/app/src/main/java/com/zj365/dc/vm/InfoSimpleVm.kt deleted file mode 100644 index 5a1af46..0000000 --- a/app/src/main/java/com/zj365/dc/vm/InfoSimpleVm.kt +++ /dev/null @@ -1,123 +0,0 @@ -package com.zj365.dc.vm - -import androidx.lifecycle.MutableLiveData -import com.tamsiree.rxkit.RxTool -import com.xty.base.vm.BaseVm -import com.xty.common.Const -import com.xty.common.MMkvHelper -import com.xty.common.util.CommonToastUtils -import com.xty.network.model.ImageUploadBean -import com.xty.network.model.MainBean -import com.xty.network.model.NotAccepted -import com.xty.network.model.RespBody -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.async -import kotlinx.coroutines.withContext -import okhttp3.Headers -import okhttp3.MultipartBody -import org.json.JSONObject -import java.io.File - -class InfoSimpleVm : BaseVm() { - - val setBasic by lazy { MutableLiveData>() } - val mLogin by lazy { MutableLiveData>() } - val getImUserSig by lazy { MutableLiveData>() } - - fun login(account: String, pwd: String) { - startHttp { - val json = JSONObject() - json.put("phone", account) - json.put("userPwd", RxTool.Md5(pwd)) - //json.put("userPwd", pwd) - val login = apiInterface().login(retrofits.getRequestBody(json.toString())) - if (login.body()?.code == 500) { - login.body()?.msg?.let { CommonToastUtils.showToast(it) } - return@startHttp - } - saveToken(login.raw().headers) - val bodys = login.body() as RespBody - - MMkvHelper.put(Const.USER_ID, bodys.data.id) - bodys.getCodeStatus(mLogin, nowData, loading) - } - } - - private fun saveToken(headers: Headers) { - val headerIterator = headers.iterator() - while (headerIterator.hasNext()) { - val next = headerIterator.next() - if (Const.Auth_Token == next.first) MMkvHelper.put(Const.Auth_Token, next.second) - - if (Const.Auth_Id == next.first) MMkvHelper.put(Const.Auth_Id, next.second) - } - } - - fun getImUserSig(identifier: String) { - startHttp { - val imUserSig = apiInterface().getImUserSig(identifier) - imUserSig.body()?.getCodeStatus(getImUserSig, nowData, paramsData = identifier) - } - } - - fun submit(path: String, name: String?, sex: String, birthDaytype: String, birthDay: String) { - startHttp { - withContext(Dispatchers.IO) { - var fileId = "" - if (path.isNullOrEmpty()) { - - } else { - val image = async { uploadImage(path) } - val await = image.await() - fileId = await.fileId - } - val upload = async { uploadInfo(name, sex, fileId, birthDaytype, birthDay) } - val await = upload.await() //个人信息上传 - if (await.code != 0) { - CommonToastUtils.showToast(await.msg) - } - } - } - } - - private suspend fun uploadInfo( - name: String?, - sex: String, - fileId: String = "", - birthdayType: String, - birthDay: String - ): RespBody { - val json = JSONObject() - json.put("name", name) - json.put("sex", sex) - if (sex == "1") { - json.put("height", "170") - json.put("weight", "65") - } else { - json.put("height", "160") - json.put("weight", "49") - } - - json.put("birthday", birthDay) - json.put("birthdayType", birthdayType) - - if (!fileId.isNullOrEmpty()) { - json.put("avatarUrl", fileId) - } - val rb = retrofits.getRequestBody(json.toString()) - val body = apiInterface().setUpdateUser(rb) - body.getCodeStatus(setBasic, nowData) - return body - } - - private suspend fun uploadImage(path: String): ImageUploadBean { - val f = File(path) - val fileRb = MultipartBody.Part.createFormData( - "file", - f.name, - retrofits.getMultiPartFileRb(f) - ) - val body = apiInterface().uploadImage(fileRb) - return body.data - } -} \ No newline at end of file diff --git a/app/src/main/res/layout/act_info_simple.xml b/app/src/main/res/layout/act_info_simple.xml deleted file mode 100644 index ecb2f1a..0000000 --- a/app/src/main/res/layout/act_info_simple.xml +++ /dev/null @@ -1,291 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/common/src/main/java/com/xty/common/arouter/ARouterUrl.kt b/common/src/main/java/com/xty/common/arouter/ARouterUrl.kt index 292f39f..82a6c94 100644 --- a/common/src/main/java/com/xty/common/arouter/ARouterUrl.kt +++ b/common/src/main/java/com/xty/common/arouter/ARouterUrl.kt @@ -12,7 +12,7 @@ class ARouterUrl { const val BIND_WX_PHONE = "/com/zj365/dc/act/BindWxPhone" const val DEVICE_CONNECT = "/com/zj365/dc/activity/DeviceConnectAct" const val DEVICE_CHOICE = "/com/zj365/dc/activity/DeviceChoiceAct" - const val INFO_SIMPLE = "/com/zj365/dc/act/InfoSimpleAct" + // const val INFO_SIMPLE = "/com/zj365/dc/act/InfoSimpleAct" const val DEVICE_SEARCH = "/com/zj365/dc/activity/DeviceSearchBodyFatAct" const val DEVICE_BIND = "/com/zj365/dc/activity/DeviceBindAct" const val SCIENCE_LIST = "/com/zj365/dc/activity/HealthScienceAct" @@ -57,7 +57,6 @@ class ARouterUrl { const val ONLINE_MAKE = "/health/com/zj365/health/act/OnLineMakeAct" const val HEALTH_STATUS = "/health/com/zj365/health/act/HealthStatusAct" const val HEALTH_24HOUR_REPORT = "/health/com/zj365/health/act/Health24HourReportAct" - const val HEALTH_24HOUR_REPORT_OLD = "/health/com/zj365/health/act/Health24HourReportAct" const val HEALTH_REPORT = "/health/com/zj365/health/act/HealthReportAct" const val HEALTH_ESTIMATE = "/health/com/zj365/health/act/HealthEstimateActivity" const val HEALTH_SKY_HOUR_REPORT = "/health/com/zj365/health/act/HealthSkyHourReportAct" diff --git a/health/src/main/java/com/zj365/health/act/healthrecord/HealthRecordMainAct.kt b/health/src/main/java/com/zj365/health/act/healthrecord/HealthRecordMainAct.kt index 87dbf91..8616256 100644 --- a/health/src/main/java/com/zj365/health/act/healthrecord/HealthRecordMainAct.kt +++ b/health/src/main/java/com/zj365/health/act/healthrecord/HealthRecordMainAct.kt @@ -81,6 +81,7 @@ class HealthRecordMainAct : BaseVmAct() { binding.mProgress.progress = it.data.userSchedule * 10 binding.clBody.tvScore.text = "${it.data.surveys.score}" mSurveysList = it.data.surveys.list + binding.tvConfirmTest.visibility = View.GONE mSurveysList.forEach { if (it.status == 0){ binding.tvConfirmTest.visibility = View.VISIBLE diff --git a/health/src/main/res/layout/frag_breath.xml b/health/src/main/res/layout/frag_breath.xml index c32425a..a99b823 100644 --- a/health/src/main/res/layout/frag_breath.xml +++ b/health/src/main/res/layout/frag_breath.xml @@ -105,7 +105,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:text="次/分" + tools:text="次/分" android:textColor="@color/col_6B6" android:textSize="@dimen/sp_12" android:textStyle="bold" /> diff --git a/health/src/main/res/layout/frag_temper.xml b/health/src/main/res/layout/frag_temper.xml index 661f19b..63315c3 100644 --- a/health/src/main/res/layout/frag_temper.xml +++ b/health/src/main/res/layout/frag_temper.xml @@ -105,7 +105,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:text="次/分" + tools:text="次/分" android:textColor="@color/col_6B6" android:textSize="@dimen/sp_12" android:textStyle="bold" /> diff --git a/health/src/main/res/layout/frag_xl.xml b/health/src/main/res/layout/frag_xl.xml index 7cf0ad9..33890d3 100644 --- a/health/src/main/res/layout/frag_xl.xml +++ b/health/src/main/res/layout/frag_xl.xml @@ -106,7 +106,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:text="次/分" + tools:text="次/分" android:textColor="@color/col_6B6" android:textSize="@dimen/sp_12" android:textStyle="bold" />