中建365-二期开发

develop
wlh 1 year ago
parent 010088fb65
commit b3a6aebe50

@ -40,9 +40,12 @@ import com.xty.common.aMapUtils.AmapInit
import com.xty.common.arouter.ARouterUrl
import com.xty.common.arouter.RouteManager
import com.xty.common.bracelet.checkBlueConnectPermission
import com.xty.common.event.AddSuccessEvent
import com.xty.common.event.BindDevEvent
import com.xty.common.event.LoginOrRegisterEvent
import com.xty.common.event.MeasureWeightEvent
import com.xty.common.event.MqttReceive
import com.xty.common.event.MyInfoEvent
import com.xty.common.util.CommonToastUtils
import com.xty.common.util.CommonUtils
import com.xty.common.util.ViewScreenshotUtils
@ -158,6 +161,8 @@ class MainActivity : BaseVmAct<MainVm>(), Consumer<AbstractMeasureData> {
}
if(!TextUtils.isEmpty(userId)){
mViewModel.getIsDemonstate()
mViewModel.getMySetting()
// if (BuildConfig.isRelease) {//设置极光推送别名
JPushInterface.setAlias(
this,
@ -169,7 +174,8 @@ class MainActivity : BaseVmAct<MainVm>(), Consumer<AbstractMeasureData> {
mViewModel.getUserEquipmentInformationizationRequest(userId)
mViewModel.getBanners(userId,3)
mViewModel.getIsDemonstate()
/* if(EasyPermissions.hasPermissions(this, Manifest.permission.ACCESS_COARSE_LOCATION,
@ -290,6 +296,24 @@ class MainActivity : BaseVmAct<MainVm>(), Consumer<AbstractMeasureData> {
override fun liveObserver() {
mViewModel.saveSuccess.observe(this) {
}
//个人设置信息获取
mViewModel.settingLive.observe(this) {
if (null == it.data) return@observe
it.data.let { settingBean ->
if (BuildConfig.isRelease) {//设置极光推送别名
JPushInterface.setAlias(
this,
settingBean.user.id.toInt(),
"user_release_${settingBean.user.id}"
)
}
Const.mainLiveData.value = settingBean
// binding.mNoNetwork.root.visibility = View.GONE
}
}
/* mViewModel.boundDevices.observe(this) {
if (it.code != 0) return@observe
val data = it.data
@ -462,4 +486,22 @@ class MainActivity : BaseVmAct<MainVm>(), Consumer<AbstractMeasureData> {
// BlueUtil.getBlueManage().releaseResource()
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun bindDevSuccess(event: BindDevEvent){
mViewModel.getMySetting()
mViewModel.getIsDemonstate()
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun refreshUI(event: MyInfoEvent){
mViewModel.getMySetting()
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onLoginOrRegisterSuccess(event: LoginOrRegisterEvent){
mViewModel.getMySetting()
mViewModel.getIsDemonstate()
}
}

@ -51,6 +51,7 @@ class RecognizeResultAct : BaseVmAct<DietManagementVm>() {
it.data[0].isCheck = true
adapter.setNewInstance(it.data)
refreshCalorieUI(it.data[0])
foodRecoginzeInfo = it.data[0]
}
}
@ -78,7 +79,7 @@ class RecognizeResultAct : BaseVmAct<DietManagementVm>() {
binding.tvDetail.setOnClickListener {
foodRecoginzeInfo?.let {
bundle.clear()
bundle.putString("web_site_url","${BuildConfig.h5url}pages/index/index?pageId=mealsDetail&id=${it.id}")
bundle.putString("web_site_url","${BuildConfig.h5url}pages/index/index?pageId=mealsDetail&id=${it.recipe_id}")
RouteManager.goAct(ARouterUrl.H5_ACT,bundle)
}

@ -271,9 +271,10 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>(){
R.id.mMsg, R.id.mMsgLayout -> {
RouteManager.goAct(ARouterUrl.WARNING_MSG)
}
//设备连接
//健康档案
R.id.mHealthRecords -> {
// RouteManager.goAct(ARouterUrl.FAMILY_RECORD_ACT)
CommonToastUtils.showToast("敬请期待")
return@OnClickListener
@ -738,6 +739,8 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>(){
dialogInfoUn.show()
}
isDemonstrate = bean.demonstrate == 1 //1 演示模式0 普通模式
Const.isDemonstrate = bean.demonstrate == 1
// (requireActivity() as MainActivity).isDemonstrate = isDemonstrate
if (isDemonstrate) {
binding.mHeader.mWearInfo.visibility = View.INVISIBLE
@ -748,6 +751,7 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>(){
if (showIdInfo ==MMkvHelper.getLong(Const.USER_ID).toString()) { //自己
Const.otherLiveData.value = bean
binding.mHeader.mHealthRecords.visibility = View.VISIBLE
}
Const.battery = bean.power
Const.watchType = bean.watchType

@ -6,6 +6,7 @@ import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.arouter.facade.annotation.Route
import com.lifesense.android.ble.core.application.ApplicationContext
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram
@ -248,9 +249,22 @@ HealthHomeFrag : BaseVmFrag<HomeVm>() {
when(contentData.jumpType){
1 ->{
when(contentData.jumpUrl){
"health_data" ->{
// RouteManager.goAct(ARouterUrl.FAMILY_RECORD_ACT)
CommonToastUtils.showToast("敬请期待")
}
"health_dic" ->{
CommonToastUtils.showToast("敬请期待")
}
else ->{
CommonToastUtils.showToast("敬请期待")
}
}
}
2->{
if (contentData.name == "视频问诊"){
@ -344,6 +358,7 @@ HealthHomeFrag : BaseVmFrag<HomeVm>() {
}
"PSYCHOLOGY" ->{
// RouteManager.goAct(ARouterUrl.PSYCHOLOGICAL_TEST_LIST_ACT)
CommonToastUtils.showToast("敬请期待")
}

@ -494,7 +494,7 @@ class MineFrag : BaseVmFrag<SettingVm>() {
} else {
MMkvHelper.getLong(Const.USER_ID).toString()
}
mViewModel.getMySetting()
// mViewModel.getMySetting()
// mViewModel.getScore(1)
mViewModel.searchInviteInfo()
}
@ -506,7 +506,7 @@ class MineFrag : BaseVmFrag<SettingVm>() {
@Subscribe(threadMode = ThreadMode.MAIN)
fun addSuccess(event: AddSuccessEvent){
mViewModel.getMySetting()
// mViewModel.getMySetting()
mViewModel.getAllInfo(showIdInfo,false)
// mViewModel.getScore(1)
@ -514,13 +514,13 @@ class MineFrag : BaseVmFrag<SettingVm>() {
@Subscribe(threadMode = ThreadMode.MAIN)
fun bindDevSuccess(event:BindDevEvent){
mViewModel.getMySetting()
// mViewModel.getMySetting()
mViewModel.getAllInfo(showIdInfo,false)
// mViewModel.getScore(1)
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun refreshUI(event: MyInfoEvent){
mViewModel.getMySetting()
// mViewModel.getMySetting()
mViewModel.getAllInfo(showIdInfo,false)
// mViewModel.getScore(1)
mViewModel.searchInviteInfo()

@ -12,6 +12,7 @@ import com.xty.network.model.BannerBean
import com.xty.network.model.BindDeviceListBean
import com.xty.network.model.InviteCustodyBean
import com.xty.network.model.RespBody
import com.xty.network.model.SettingBean
import com.xty.network.model.UnReadMessageBean
import com.xty.network.model.Update
import com.xty.network.model.UserEquipmentInformationizationBean
@ -41,6 +42,9 @@ class MainVm : BaseVm() {
val confirmInviteLiveData by lazy { MutableLiveData<RespBody<Any>>() }
val settingLive by lazy { MutableLiveData<RespBody<SettingBean>>() }
/**
* 设备类型1血压计2血糖仪.3体脂秤
*/
@ -183,4 +187,14 @@ class MainVm : BaseVm() {
}
}
}
/**
* 个人设置接口
*/
fun getMySetting() {
startHttp {
val body = apiInterface().getMySetting()
body.getCodeStatus(settingLive, nowData)
}
}
}

@ -97,6 +97,7 @@
android:textColor="@color/white"
android:textSize="@dimen/dp_10"
android:textStyle="bold"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@+id/mHeaderImage"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/mHeaderImage" />

@ -131,12 +131,14 @@
<LinearLayout
android:id="@+id/ll_mine"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingTop="@dimen/dp_25"
android:orientation="horizontal"
android:weightSum="4"
android:background="@color/white"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cl_info">
<LinearLayout
@ -145,6 +147,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:visibility="gone"
android:orientation="vertical">
<TextView

@ -77,6 +77,8 @@ class Const {
var watchType = -1
var isDemonstrate = false
enum class WatchDevice {
/**蓝牙U32**/
BlueU32,

@ -130,6 +130,12 @@ class ARouterUrl {
const val FAMILY_HEALTH_REAL_TIME_ACT = "/health/com/zj365/health/act/familyhealth/FamilyHealthRealTimeAct"
const val FAMILY_GUARDIAN_LIST_ACT = "/health/com/zj365/health/act/familyhealth/FamilyHealthGuardianListAct"
//健康档案
const val FAMILY_RECORD_ACT = "/health/com/zj365/health/act/healthrecord/HealthRecordMainAct"
//心理测试
const val PSYCHOLOGICAL_TEST_LIST_ACT = "/health/com/zj365/health/act/psychological/PsychologicalTestMainAct"
//设备绑定相关
const val XUEYAJI_BIND_LIST = "/health/com/zj365/health/act/XueyaDeviceBindListAct"

@ -50,6 +50,7 @@ class HealthBodyView(context: Context, attrs: AttributeSet?) : ViewGroup(context
if (images != null && texts != null) {
mCount = Math.min(images.size, texts.size)
}
removeAllViews()
//构建菜单项
buildMenuItems()
}

@ -306,6 +306,13 @@
<activity android:name=".act.familyhealth.FamilyHealthGuardianListAct"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
<activity android:name=".act.healthrecord.HealthRecordMainAct"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
<activity android:name=".act.psychological.PsychologicalTestMainAct"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
</application>
</manifest>

@ -1,18 +1,49 @@
package com.zj365.health.act.healthrecord
import android.util.Log
import android.view.View
import androidx.core.view.get
import androidx.core.view.size
import androidx.core.widget.NestedScrollView
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.androidkun.xtablayout.XTabLayout
import com.xty.base.act.BaseVmAct
import com.xty.base.vm.BaseVm
import com.xty.common.Const
import com.xty.common.MMkvHelper
import com.xty.common.R
import com.xty.common.UmengEventId
import com.xty.common.arouter.ARouterUrl
import com.xty.common.arouter.RouteManager
import com.xty.common.onEventObject
import com.xty.common.setImageUser
import com.xty.common.weight.HealthBodyView
import com.zj365.health.adapter.familyhealth.HealthFamilyTargetAdapter
import com.zj365.health.databinding.ActHealthRecordMainBinding
import com.zj365.health.model.MyReportBean
import com.zj365.health.vm.ReportVm
import com.zj365.health.weight.HealthSurveyView
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@Route(path = ARouterUrl.FAMILY_RECORD_ACT)
class HealthRecordMainAct : BaseVmAct<BaseVm>() {
val binding by lazy { ActHealthRecordMainBinding.inflate(layoutInflater) }
val mAdapter by lazy { HealthFamilyTargetAdapter() }
private val mTitles = mutableListOf<String>()
private var isSelectTable = false
private var isScrollTable = false
private var launch: Job? = null
override fun liveObserver() {
}
@ -25,7 +56,182 @@ class HealthRecordMainAct : BaseVmAct<BaseVm>() {
finish()
}
initTab()
initSurvey()
initAdapter()
initClickListener()
Const.mainLiveData.value?.let {
binding.tvName.text = it.user.name
if (it.user.avatarUrl.isNullOrEmpty()) {
binding.imgAvatar.setImageResource(R.mipmap.icon_default_avator)
} else {
binding.imgAvatar.setImageUser(
this,
it.user.avatarUrl,
it.user.sex.toString()
)
}
}
}
fun initClickListener(){
binding.llInquiryRecord.setOnClickListener {
}
binding.llHealthWeekRecord.setOnClickListener {
bundle.clear()
var showIdInfo =if (MMkvHelper.getLong(Const.USER_ID).toString() == "0") {
""
} else {
MMkvHelper.getLong(Const.USER_ID).toString()
}
bundle.putString("id", showIdInfo)
bundle.putSerializable("index", ReportVm.ReportInfoType.Week)
bundle.putBoolean("isDemonstrate", Const.isDemonstrate)
bundle.putString("titleName", "周报")
Const.functionListDate.value?.let {
if(it.size > 0){
bundle.putParcelableArrayList("functionList",it)
}
}
RouteManager.goAct(ARouterUrl.HEALTH_WEEK_MONTH_HOUR_REPORT, bundle)
}
binding.llReportRecord.setOnClickListener {
}
binding.tvCompleteInfo.setOnClickListener {
RouteManager.goAct(ARouterUrl.BASE_INFO_CHANGE)
}
}
fun initSurvey(){
var surveyList = ArrayList<String>()
surveyList.add("免疫系统")
surveyList.add("神经系统")
surveyList.add("内分泌系统")
surveyList.add("泌尿系统")
surveyList.add("生殖系统")
surveyList.add("运动系统")
surveyList.add("心脑血管")
surveyList.add("消化系统")
surveyList.add("呼吸系统")
binding.clBody.surveyView.setMenuItemTexts(surveyList)
binding.clBody.surveyView.setOnClicklisteners(object : HealthSurveyView.onItemClicked{
override fun onPositionClicked(postion: Int) {
}
})
}
fun initTab(){
mTitles.add("自检自测")
mTitles.add("饮食日记")
mTitles.add("健康监测")
mTitles.add("健康记录")
//设置tab
mTitles.forEach { tabData ->
val tab = binding.xTablayout.newTab()
tab.text = tabData
binding.xTablayout.addTab(tab)
}
binding.xTablayout.setOnTabSelectedListener(object : XTabLayout.OnTabSelectedListener{
override fun onTabSelected(tab: XTabLayout.Tab?) {
if (!isScrollTable) {
Log.e("HealthRecordMainAct", "选择的${tab?.position!!}")
isSelectTable = true
if (launch != null) {
launch?.cancel()
}
when (mTitles[tab.position]) {
"自检自测" -> {
binding.scrollView.smoothScrollTo(
0,
binding.clSelfTest.top
)
}
"饮食日记" -> {
binding.scrollView.smoothScrollTo(
0,
binding.clFoodDiary.top
)
}
"健康监测" -> {
binding.scrollView.smoothScrollTo(
0,
binding.clHealthMonitoring.top
)
}
"健康记录" -> {
binding.scrollView.smoothScrollTo(
0,
binding.clHealthRecording.top
)
}
}
launch = GlobalScope.launch {
delay(1000) // 延迟一秒
// 在这里执行你的操作
isSelectTable = false
}
}
}
override fun onTabUnselected(tab: XTabLayout.Tab?) {
}
override fun onTabReselected(tab: XTabLayout.Tab?) {
}
})
binding.scrollView.setOnScrollChangeListener(NestedScrollView.OnScrollChangeListener { _, _, scrollY, _, _ ->
if (mTitles.size > 0) {
if (!isSelectTable) {
Log.e("HealthRecordMainAct", "移动的${scrollY}")
isScrollTable = true
val selectedTabPosition = binding.xTablayout.selectedTabPosition
if (scrollY >= binding.clHealthRecording.top) {
if (selectedTabPosition != mTitles.size - 1) {
binding.xTablayout.getTabAt(mTitles.size - 1)?.select()
}
} else if (scrollY >= binding.clHealthMonitoring.top) {
if (selectedTabPosition != mTitles.size - 2) {
binding.xTablayout.getTabAt(mTitles.size - 2)?.select()
}
} else if (scrollY >= binding.clFoodDiary.top) {
if (selectedTabPosition != mTitles.size - 3) {
binding.xTablayout.getTabAt(mTitles.size - 3)?.select()
}
} else if (scrollY >= binding.clSelfTest.top) {
if (selectedTabPosition != 0) {
binding.xTablayout.getTabAt(0)?.select()
}
} else {
if (selectedTabPosition != 0) {
binding.xTablayout.getTabAt(0)?.select()
binding.xTablayout.setScrollPosition(0, 0F, true)
}
}
isScrollTable = false
}
}
})
}
fun initAdapter (){

@ -1,12 +1,17 @@
package com.zj365.health.act.psychological
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.xty.base.act.BaseListAct
import com.xty.base.act.BaseVmAct
import com.xty.base.vm.BaseVm
import com.xty.common.arouter.ARouterUrl
import com.zj365.health.adapter.psychological.PsychologicalTestMainAdapter
import com.zj365.health.databinding.ActPsychologicalTestMainBinding
import com.zj365.health.vm.PsychologicalTestMainVm
class PsychologicalTestMainAct : BaseVmAct<BaseVm>() {
@Route(path = ARouterUrl.PSYCHOLOGICAL_TEST_LIST_ACT)
class PsychologicalTestMainAct : BaseListAct<PsychologicalTestMainVm>() {
val binding by lazy { ActPsychologicalTestMainBinding.inflate(layoutInflater) }
val mAdapter by lazy { PsychologicalTestMainAdapter() }
@ -19,15 +24,34 @@ class PsychologicalTestMainAct : BaseVmAct<BaseVm>() {
finish()
}
binding.recycler.layoutManager = LinearLayoutManager(this)
binding.recycler.adapter = mAdapter
setRecycleRefresh(binding.mRecycle,binding.mRefresh,true)
}
override fun initAdapter() {
binding.mRecycle.layoutManager = LinearLayoutManager(this)
binding.mRecycle.adapter = mAdapter
mAdapter.setOnItemChildClickListener { adapter, view, position ->
}
}
override fun loadData() {
mViewModel.getPsychologicalList(page)
}
override fun liveObserver() {
mViewModel.psychologicalListData.observe(this){
if (page > 1){
mAdapter.setList(it.data.records)
}else{
mAdapter.setNewInstance(it.data.records)
}
}
}
override fun setLayout() = binding.root

@ -1,11 +1,15 @@
package com.zj365.health.adapter.psychological
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ruffian.library.widget.RImageView
import com.xty.base.adapter.BaseAdapter
import com.xty.common.setImage
import com.xty.network.model.PsychologicalListBean
import com.zj365.health.R
class PsychologicalTestMainAdapter : BaseAdapter<Any>(R.layout.item_psychokogical_test) {
override fun convert(holder: BaseViewHolder, item: Any) {
class PsychologicalTestMainAdapter : BaseAdapter<PsychologicalListBean.PsychologicalBean>(R.layout.item_psychokogical_test) {
override fun convert(holder: BaseViewHolder, item: PsychologicalListBean.PsychologicalBean) {
holder.setText(R.id.tv_psy,item.surveyName)
holder.getView<RImageView>(R.id.img_psy).setImage(context,item.imageUrl)
}
}

@ -0,0 +1,20 @@
package com.zj365.health.vm
import androidx.lifecycle.MutableLiveData
import com.alibaba.fastjson.JSONObject
import com.xty.base.vm.BaseVm
import com.xty.network.model.PsychologicalResultBean
import com.xty.network.model.RespBody
class PsychologicalResultVm : BaseVm() {
val psychologicalResultData by lazy { MutableLiveData<RespBody<PsychologicalResultBean>>() }
fun getPsychologicalResult(answerId:Long){
startHttp {
var request=apiInterface().getPsychologicalResult(answerId.toString())
request.getCodeStatus(psychologicalResultData,nowData)
}
}
}

@ -0,0 +1,24 @@
package com.zj365.health.vm
import androidx.lifecycle.MutableLiveData
import com.alibaba.fastjson.JSONObject
import com.xty.base.vm.BaseVm
import com.xty.network.model.PsychologicalListBean
import com.xty.network.model.RespBody
class PsychologicalTestMainVm: BaseVm() {
val psychologicalListData by lazy { MutableLiveData<RespBody<PsychologicalListBean>>() }
fun getPsychologicalList(pageNum:Int){
startHttp {
var json = JSONObject()
json.put("pageNum",pageNum)
json.put("pageSize",10)
var request=apiInterface().getPsychologicalList(retrofits.getRequestBody(json.toString()))
request.getCodeStatus(psychologicalListData,nowData)
}
}
}

@ -0,0 +1,198 @@
package com.zj365.health.weight
import android.content.Context
import android.graphics.Color
import android.provider.CalendarContract.Colors
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import com.google.android.exoplayer2.util.ColorParser
import com.xty.common.LogUtils
import com.zj365.health.R
import kotlin.math.cos
import kotlin.math.roundToInt
import kotlin.math.sin
class HealthSurveyView(context: Context, attrs: AttributeSet?) : ViewGroup(context, attrs) {
//圆形直径
var mRadius = 0
//该容器内child item 的默认尺寸
val RADIO_DEFAULT_CHILD_DIMESION = 1 /4f
// 该容器的内边距无视padding属性 如需边距请用该变量
val RADIO_PADDING_LAYOUT = 1 / 12f
var mPadding = 0f
// 布局时的开始角度
var mStartAngle = 270.0
//文本
var mSurveyText = ArrayList<String>()
var colors = arrayOf("#20C387","#FD830B","#1ECAFC")
//数
var mCount = 12
var mItemLayoutId: Int = R.layout.layout_health_survey_child
var mOnClicklistener: onItemClicked? = null
fun setMenuItemTexts( texts: ArrayList<String>) {
require(!( texts == null)) { "菜单文本和图标至少设置其一" }
mSurveyText = texts
//初始化mMenucount
mCount = texts.size
//构建菜单项
buildMenuItems()
}
private fun buildMenuItems() {
//根据用户设置的参数初始化menu item
for (i in 0 until mCount) {
val itemView = inflateMenuView(i)
initMenuItem(itemView, i)
addView(itemView)
}
}
private fun inflateMenuView(index: Int): View {
val mInflater = LayoutInflater.from(context)
val itemView: View = mInflater.inflate(mItemLayoutId, this, false)
itemView.setOnClickListener(object : OnClickListener {
override fun onClick(p0: View?) {
mOnClicklistener?.onPositionClicked(index)
}
})
return itemView
}
private fun initMenuItem(itemView: View, index: Int) {
val tv = itemView.findViewById<TextView>(R.id.tv_survey)
tv.text = mSurveyText[index]
when(index){
0,2,4,6 ->{
tv.setTextColor(Color.parseColor(colors[0]))
}
1,5,7->{
tv.setTextColor(Color.parseColor(colors[1]))
}
else ->{
tv.setTextColor(Color.parseColor(colors[2]))
}
}
}
fun setMenuItemLayoutId(mItemLayoutId: Int) {
this.mItemLayoutId = mItemLayoutId
}
fun setOnClicklisteners(mOnClicklistener: onItemClicked) {
this. mOnClicklistener = mOnClicklistener
}
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
// 测量自己
measureSelf(widthMeasureSpec, heightMeasureSpec)
// 测量菜单
measureChildViews()
}
private fun measureSelf(widthMeasureSpec: Int, heightMeasureSpec: Int) {
var resWidth = 0
var resHeight = 0
val width = MeasureSpec.getSize(widthMeasureSpec)
val widthMode = MeasureSpec.getMode(widthMeasureSpec)
val heigh = MeasureSpec.getSize(heightMeasureSpec)
val heightMode = MeasureSpec.getMode(heightMeasureSpec)
//如果宽或者高的测量模式非精确值
/* if (widthMode != MeasureSpec.EXACTLY ||
heightMode != MeasureSpec.EXACTLY
) {
//设置为背景图的宽高
resWidth = suggestedMinimumWidth
//如果未设置背景图,则设置为屏幕宽高的默认值
resWidth = if (resWidth == 0) getDefaultWidth() else resWidth
resHeight = if (resHeight == 0) getDefaultWidth() else resHeight
} else {*/
resHeight = Math.min(width, heigh)
resWidth = resHeight
// }
setMeasuredDimension(resWidth, resHeight)
}
private fun getDefaultWidth(): Int {
return (mRadius * RADIO_DEFAULT_CHILD_DIMESION).toInt()
}
private fun measureChildViews() {
//获得半径
mRadius = Math.max(measuredWidth, measuredWidth)
//menu item 数量
val count = childCount
//menu 尺寸
val childSize = (mRadius * RADIO_DEFAULT_CHILD_DIMESION).toInt()
// menu item 测量模式
val childMode = MeasureSpec.EXACTLY
//迭代测量
for (i in 0 until count) {
val child = getChildAt(i)
if (child.visibility == GONE) {
continue
}
// 计算menu item 的尺寸 以及设置好的模式去对item进行测量
var makeMeasureSpec = -1
makeMeasureSpec = MeasureSpec.makeMeasureSpec(childSize, childMode)
child.measure(makeMeasureSpec, makeMeasureSpec)
}
// mPadding = RADIO_PADDING_LAYOUT * mRadius
}
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
val childCount = childCount
var left: Int
var top: Int
// menu item 的尺寸
val itemWidth = (mRadius * RADIO_DEFAULT_CHILD_DIMESION).toInt()
// 根据menuitem 的个数 计算item的布局占用的角度
if(childCount > 0){
val angleDelay = (360 / childCount).toFloat()
// 遍历所有菜单 设置它们的位置
for (i in 0 until childCount) {
val child = getChildAt(i)
if (child.visibility == GONE) {
continue
}
//菜单的起始角度
mStartAngle %= 360.0
//计算 中心点到menuitem 中心的距离
val distanceFromCenter = mRadius / 2f - itemWidth / 2
left =
mRadius / 2 + (distanceFromCenter * cos(Math.toRadians(mStartAngle)) - 1 / 2f * itemWidth).roundToInt()
top =
mRadius / 2 + (distanceFromCenter * sin(Math.toRadians(mStartAngle)) - 1 / 2f * itemWidth).roundToInt()
LogUtils.e("HealthSurveyView","left:${left},top:${top},itemWidth${itemWidth},mRadius:${mRadius},distanceFromCenter:${distanceFromCenter}")
child.layout(left, top, left + itemWidth, top + itemWidth)
mStartAngle += angleDelay.toDouble()
}
}
}
interface onItemClicked{
fun onPositionClicked(postion:Int)
}
}

@ -54,7 +54,7 @@
android:id="@+id/mProgress"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/dp_9"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_14"
android:layout_below="@+id/tv_name"
@ -269,6 +269,7 @@
android:drawableRight="@mipmap/icon_arrow_right"
android:drawablePadding="@dimen/dp_5"
app:layout_constraintEnd_toEndOf="parent"
android:textSize="@dimen/sp_13"
app:layout_constraintTop_toBottomOf="@+id/mTvFoodDiary"
android:layout_marginTop="@dimen/dp_22"/>
@ -337,7 +338,7 @@
<ProgressBar
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/dp_7"
android:layout_marginTop="@dimen/dp_11"
android:layout_below="@+id/tv_name"
android:layout_toRightOf="@+id/img_avatar"
@ -369,7 +370,7 @@
<ProgressBar
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/dp_7"
android:layout_marginTop="@dimen/dp_11"
android:layout_below="@+id/tv_name"
android:layout_toRightOf="@+id/img_avatar"
@ -401,7 +402,7 @@
<ProgressBar
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/dp_7"
android:layout_marginTop="@dimen/dp_11"
android:layout_below="@+id/tv_name"
android:layout_toRightOf="@+id/img_avatar"
@ -467,6 +468,8 @@
android:layout_marginRight="@dimen/dp_14"
android:layout_marginTop="@dimen/dp_12"
android:background="@drawable/shape_round_white"
android:layout_marginBottom="@dimen/dp_20"
android:paddingBottom="@dimen/dp_27">
<TextView
@ -496,8 +499,9 @@
app:layout_constraintLeft_toLeftOf="parent">
<LinearLayout
android:id="@+id/ll_inquiry_record"
android:layout_width="0dp"
android:layout_height="@dimen/dp_100"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@mipmap/bg_home_item"
android:orientation="vertical"
@ -519,8 +523,9 @@
</LinearLayout>
<LinearLayout
android:id="@+id/ll_report_record"
android:layout_width="0dp"
android:layout_height="@dimen/dp_100"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@mipmap/bg_home_item"
android:layout_marginLeft="@dimen/dp_17"
@ -543,8 +548,9 @@
</LinearLayout>
<LinearLayout
android:id="@+id/ll_health_week_record"
android:layout_width="0dp"
android:layout_height="@dimen/dp_100"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@mipmap/bg_home_item"
android:layout_marginLeft="@dimen/dp_17"

@ -8,9 +8,24 @@
<include layout="@layout/title_white_bar"
android:id="@+id/title"/>
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/mRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.scwang.smart.refresh.header.ClassicsHeader
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/mRecycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recycler"/>
android:layout_margin="@dimen/dp_10" />
<com.scwang.smart.refresh.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</LinearLayout>

@ -14,6 +14,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:is_circle="false"
android:scaleType="fitXY"
android:adjustViewBounds="true"
app:corner_radius="@dimen/dp_8"/>
<TextView

@ -9,6 +9,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center"
android:background="@mipmap/bg_health_record_test">
@ -29,6 +30,12 @@
android:layout_marginTop="@dimen/dp_9"/>
</LinearLayout>
<com.zj365.health.weight.HealthSurveyView
android:id="@+id/survey_view"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="@dimen/dp_320"/>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:gravity="center"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/col_333"
android:textSize="@dimen/sp_13"
android:id="@+id/tv_survey"/>
</LinearLayout>

@ -794,6 +794,17 @@ interface ApiInterface {
@POST("customer/question/reportList")
suspend fun getAnswerList(@Body rb: RequestBody): RespBody<MutableList<AnswerBean>>
/**
* 心理测试问卷列表
*/
@POST("customer/surveys/list")
suspend fun getPsychologicalList(@Body rb: RequestBody):RespBody<PsychologicalListBean>
/**
* 答题详情
*/
@GET("customer/surveys/answerDetail")
suspend fun getPsychologicalResult(@Query("answerId") answerId:String):RespBody<PsychologicalResultBean>
/**
* 设备解绑
*/

@ -37,6 +37,7 @@ data class FoodRecoginzeInfo(
val as_name:String,//别名
val fe:Float,//铁(mg/100g)
val recipe_id:Long,
var isCheck:Boolean = false
) {
}

@ -0,0 +1,14 @@
package com.xty.network.model
data class PsychologicalListBean(
var records:ArrayList<PsychologicalBean>
){
data class PsychologicalBean(
var id:Long,
var surveyName:String,
var surveyDesc:String,
var totalNum:Int,
var imageUrl:String,
var createTime:String
)
}

@ -0,0 +1,10 @@
package com.xty.network.model
data class PsychologicalResultBean(
var surveyName:String,
var surveyDesc:String,
var conclusionText:String,
var answerId:Long,
var score:String
) {
}
Loading…
Cancel
Save