中建365-消息模块

develop
wlh 2 years ago
parent 7dca4b772c
commit dbd6eccb2e

@ -32,9 +32,15 @@ android {
//.
JPUSH_CHANNEL : "developer-default",
OPPO_APPKEY : "OP-", // OPPOappkey
OPPO_APPID : "OP-", // OPPOappid
OPPO_APPSECRET: "OP-",//OPPOappsecret
XIAOMI_APPKEY : "MI-5992028541716",// appkey
XIAOMI_APPID : "MI-2882303761520285716", // appid
VIVO_APPKEY:"",
VIVO_APPID:"",
HONOR_APPID:"109849297"
]
// APK

@ -165,6 +165,14 @@
android:launchMode="singleTop"
android:screenOrientation="portrait" />
<activity android:name="com.zj365.mime.act.MessageAct"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
<activity android:name="com.zj365.mime.act.MessageTypeListAct"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
<activity
android:name="com.zj365.mime.act.SettingNewAct"
android:launchMode="singleTop"

@ -23,6 +23,7 @@ import com.lifesense.android.ble.core.serializer.AbstractMeasureData
import com.lifesense.android.ble.device.fatscale.model.WeightMeasureData
import com.tamsiree.rxkit.RxActivityTool
import com.tamsiree.rxkit.RxSPTool
import com.tencent.qcloud.tuicore.TUIConstants
import com.xty.base.act.BaseVmAct
import com.xty.base.dialog.AppUpdateDialog
import com.xty.base.vp2.VpAdapter
@ -75,7 +76,7 @@ class MainActivity : BaseVmAct<MainVm>(), Consumer<AbstractMeasureData> {
}
private fun initUnreadCountReceiver() {
/* unreadCountReceiver = object : BroadcastReceiver() {
unreadCountReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val unreadCount = intent.getLongExtra(TUIConstants.UNREAD_COUNT_EXTRA, 0)
// if (unreadCount > 0) {
@ -91,7 +92,7 @@ class MainActivity : BaseVmAct<MainVm>(), Consumer<AbstractMeasureData> {
val unreadCountFilter = IntentFilter()
unreadCountFilter.addAction(TUIConstants.CONVERSATION_UNREAD_COUNT_ACTION)
LocalBroadcastManager.getInstance(this)
.registerReceiver(unreadCountReceiver as BroadcastReceiver, unreadCountFilter)*/
.registerReceiver(unreadCountReceiver as BroadcastReceiver, unreadCountFilter)
}
private val listFragment by lazy {
@ -128,7 +129,7 @@ class MainActivity : BaseVmAct<MainVm>(), Consumer<AbstractMeasureData> {
Log.e("yansu", "请求 ${MMkvHelper.getString(Const.USER_ID)}")
mViewModel.getImUserSig("user_" + MMkvHelper.getLong(Const.USER_ID))
}*/
// initUnreadCountReceiver()
initUnreadCountReceiver()
JPushInterface.setBadgeNumber(this, 0)
// //前台空服务
// val service = RouteManager.getAny(ARouterUrl.NONE_SERVICE) as Service
@ -374,7 +375,7 @@ class MainActivity : BaseVmAct<MainVm>(), Consumer<AbstractMeasureData> {
private fun addNv() {
val menuView = binding.mBottom.getChildAt(0) as BottomNavigationMenuView
//这里就是获取所添加的每一个Tab(或者叫menu)
val tab = menuView.getChildAt(3) as BottomNavigationItemView
val tab = menuView.getChildAt(2) as BottomNavigationItemView
//加载我们的角标View新创建的一个布局
badegView = LayoutInflater.from(this).inflate(R.layout.item_msg_count, tab, true)

@ -4,13 +4,18 @@ import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.xty.base.act.BaseVmAct
import com.xty.base.vm.BaseVm
import com.xty.common.Dateutils
import com.xty.common.arouter.ARouterUrl
import com.xty.network.model.MessageBean
import com.xty.network.model.MessageTypeDataBean
import com.zj365.dc.databinding.ActMessageDetailNewBinding
@Route(path = ARouterUrl.MESSAGE_DETAIL_NEW)
class MessageDetailNewAct: BaseVmAct<BaseVm>() {
val binding by lazy { ActMessageDetailNewBinding.inflate(layoutInflater) }
var msgBean : MessageTypeDataBean.MessageTypeBean? = null
override fun liveObserver() {
}
@ -25,4 +30,21 @@ class MessageDetailNewAct: BaseVmAct<BaseVm>() {
finish()
}
}
override fun initData() {
super.initData()
intent.extras?.let {
if(it.containsKey("bean")){
msgBean=it.getSerializable("bean") as MessageTypeDataBean.MessageTypeBean
msgBean?.let {
binding.tvMsgTitle.text = it.notifyTitle
binding.tvMsgTime.text = Dateutils.formatTime(it.notifyCreateTime,Dateutils.YYYY_MM_DD_HH_MM)
binding.tvMsgContent.text = it.notifyContent
}
}
}
}
}

@ -1,17 +1,55 @@
package com.zj365.dc.adapter
import android.text.TextUtils
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.cardview.widget.CardView
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.xty.common.Dateutils
import com.xty.network.model.ScienceBean
import com.xty.network.model.SystemMsgBean
import com.zj365.dc.R
class HomeMessageAdapter : BaseAdapter<SystemMsgBean>(R.layout.item_home_message) {
override fun convert(holder: BaseViewHolder, item: SystemMsgBean) {
holder.setText(R.id.tv_msg_title,item.title)
holder.setText(R.id.tv_msg_content,item.content)
holder.setText(R.id.tv_msg_time,Dateutils.formatTime(item.time,Dateutils.YYYY_MM_DD_HH_MM))
if (item.type == 1){
holder.getView<ImageView>(R.id.img_msg).setImageDrawable(context.resources.getDrawable(R.mipmap.icon_msg_system))
}else if (item.type == 2){
holder.getView<ImageView>(R.id.img_msg).setImageDrawable(context.resources.getDrawable(R.mipmap.icon_msg_assistant))
}else{
holder.getView<ImageView>(R.id.img_msg).setImageDrawable(context.resources.getDrawable(R.mipmap.icon_msg_welfare))
}
holder.setText(R.id.tv_msg_title,item.name)
holder.setText(R.id.tv_msg_content,item.msg)
if(!TextUtils.isEmpty(item.time)){
holder.setText(R.id.tv_msg_time,Dateutils.formatTime(item.time.toLong(),Dateutils.YYYY_MM_DD_HH_MM))
}
var num = holder.getView<TextView>(R.id.mBadge)
var card = holder.getView<CardView>(R.id.mCard)
if(item.unReadCount > 0){
card.visibility = View.VISIBLE
num.text = if (item.unReadCount > 99) "99+" else "${item.unReadCount}"
num.post{
var layoutParams = num.layoutParams as ViewGroup.LayoutParams
var numTxt = num.text.toString()
card.radius = num.height / 2f
var textWidth = num.paint.measureText(numTxt)
if (num.height >= textWidth) { //等宽高的圆形
layoutParams.width = num.height
} else { //宽高不等 将宽度两边加10
layoutParams.width = textWidth.toInt() + 20
}
num.layoutParams = layoutParams
}
}else{
card.visibility = View.GONE
}
}
}

@ -1,14 +1,18 @@
package com.zj365.dc.fragment
import android.content.Intent
import android.graphics.Color
import android.view.View
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.tencent.qcloud.tuicore.TUIConstants
import com.xty.base.fragment.BaseFragList
import com.xty.common.arouter.ARouterUrl
import com.xty.common.arouter.RouteManager
import com.xty.common.event.LoginOrRegisterEvent
import com.xty.common.event.LoginOutEvent
import com.xty.common.event.MessageReadEvent
import com.xty.network.model.SystemMsgBean
import com.zj365.dc.adapter.HomeMessageAdapter
import com.zj365.dc.databinding.FragMessageBinding
import com.zj365.dc.vm.MessageVm
@ -20,12 +24,22 @@ class MessageFragment : BaseFragList<MessageVm>() {
val binding by lazy { FragMessageBinding.inflate(layoutInflater) }
val adapter by lazy { HomeMessageAdapter() }
var msgList = ArrayList<SystemMsgBean>()
override fun initAdapter() {
binding.mRecycle.layoutManager= LinearLayoutManager(requireContext())
binding.mRecycle.adapter=adapter
adapter.setOnItemClickListener { adapter, view, position ->
RouteManager.goAct(ARouterUrl.MESSAGE_DETAIL_NEW)
var bean = adapter.getItem(position) as SystemMsgBean
bundle.clear()
bundle.putInt("msgType",bean.type)
RouteManager.goAct(ARouterUrl.MESSAGE_TYPE,bundle)
}
}
override fun initData() {
super.initData()
}
override fun initView() {
@ -37,7 +51,7 @@ class MessageFragment : BaseFragList<MessageVm>() {
binding.title.mTvRight.visibility = View.VISIBLE
binding.title.mIvBack.visibility = View.INVISIBLE
binding.title.mTvRight.setOnClickListener {
mViewModel.setAllRead()
}
initAdapter()
setRecycleRefresh(binding.mRecycle,binding.mRefresh)
@ -50,6 +64,17 @@ class MessageFragment : BaseFragList<MessageVm>() {
override fun setViewModel()= MessageVm()
override fun observer() {
mViewModel.msgData.observe(this){
adapter.setNewInstance(it.data.list)
val intent = Intent()
intent.action = TUIConstants.CONVERSATION_UNREAD_COUNT_ACTION
intent.putExtra(TUIConstants.UNREAD_COUNT_EXTRA, it.data.unReadCount)
LocalBroadcastManager.getInstance(requireContext())
.sendBroadcast(intent)
}
mViewModel.msgAllRead.observe(this){
refresh()
}
}
@ -65,4 +90,9 @@ class MessageFragment : BaseFragList<MessageVm>() {
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun readMsg(event:MessageReadEvent){
refresh()
}
}

@ -188,14 +188,14 @@ class MineFrag : BaseVmFrag<SettingVm>(),EasyPermissions.PermissionCallbacks {
override fun onResume() {
super.onResume()
if (!checkNetworkAvailable(requireContext())) {
/* if (!checkNetworkAvailable(requireContext())) {
binding.mNoNetwork.root.visibility = View.VISIBLE
} else {
if (binding.mNoNetwork.root.visibility == View.VISIBLE) {
if (binding.mNoNetwork.root.visibility == View.VISIBLE) {*/
mViewModel.getMySetting()
}
// }
mViewModel.getScore(1)
}
// }
}
override fun observer() {
@ -265,7 +265,7 @@ class MineFrag : BaseVmFrag<SettingVm>(),EasyPermissions.PermissionCallbacks {
if (null == it.data) return@observe
it.data.let { settingBean ->
Const.mainLiveData.value = settingBean
binding.mNoNetwork.root.visibility = View.GONE
// binding.mNoNetwork.root.visibility = View.GONE
}
}

@ -1,10 +1,26 @@
package com.zj365.dc.vm
import androidx.lifecycle.MutableLiveData
import com.xty.base.vm.BaseVm
import com.xty.network.model.RespBody
import com.xty.network.model.SystemMsgDataResp
class MessageVm(): BaseVm() {
val msgData by lazy { MutableLiveData<RespBody<SystemMsgDataResp>> ()}
val msgAllRead by lazy { MutableLiveData<RespBody<Any>>() }
fun getSystemMsg(){
startHttp {
var response = apiInterface().getSystemMsg()
response.getCodeStatus(msgData, nowData)
}
}
fun setAllRead(){
startHttp(true) {
var response = apiInterface().setMessageReadAll()
response.getCodeStatus(msgAllRead, nowData)
}
}
}

@ -4,7 +4,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:background="@color/col_6F7"
tools:ignore="MissingDefaultResource">
<include android:id="@+id/title"
@ -24,7 +24,8 @@
android:id="@+id/mRecycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10" />
android:background="@color/white"
/>
<com.scwang.smart.refresh.footer.ClassicsFooter
android:layout_width="match_parent"

@ -3,28 +3,60 @@
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_76"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/dp_16"
android:paddingRight="@dimen/dp_15"
android:paddingTop="@dimen/dp_14"
android:paddingBottom="@dimen/dp_14"
tools:ignore="MissingDefaultResource">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fm_img"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/img_msg"
android:layout_width="@dimen/dp_49"
android:layout_height="@dimen/dp_49"
android:background="@mipmap/icon_msg_system"
tools:background="@mipmap/icon_msg_system"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
/>
<androidx.cardview.widget.CardView
android:id="@+id/mCard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/col_f23"
app:cardCornerRadius="@dimen/dp_10"
app:cardElevation="0dp"
android:layout_gravity="end"
android:visibility="gone"
>
<TextView
android:id="@+id/mBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="1"
android:textColor="@color/white"
android:textSize="@dimen/dp_12"
/>
</androidx.cardview.widget.CardView>
</FrameLayout>
<TextView
android:id="@+id/tv_msg_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="系统消息"
app:layout_constraintLeft_toRightOf="@+id/img_msg"
app:layout_constraintLeft_toRightOf="@+id/fm_img"
android:layout_marginLeft="@dimen/dp_12"
app:layout_constraintTop_toTopOf="parent"
android:textStyle="bold"
@ -33,17 +65,18 @@
<TextView
android:id="@+id/tv_msg_content"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_12"
app:layout_constraintLeft_toRightOf="@+id/img_msg"
app:layout_constraintLeft_toRightOf="@+id/fm_img"
app:layout_constraintTop_toBottomOf="@+id/tv_msg_title"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:textColor="@color/col_7c7"
android:textSize="@dimen/sp_13"
android:maxLines="1"
android:ellipsize="end"
tools:text="预约消息提醒您于2023-05-17已经预约成功..."/>
tools:text="17已经预约成功17已经预约成功17已经预约成功17已经预约成功17已经预约成功17已经预约成功"/>
<TextView
android:id="@+id/tv_msg_time"

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

@ -154,6 +154,7 @@ class ARouterUrl {
//我的
const val MESSAGE = "/mine/com/zj365/dc/mime/act/MessageAct"
const val MESSAGE_TYPE = "/mine/com/zj365/dc/mime/act/MessageTypeListAct"
const val MESSAGE_DETAIL = "/mine/com/zj365/dc/mime/act/MessageDetailAct"
const val SCORE = "/mine/com/zj365/dc/mime/act/ScoreAct"
const val MY_INTEGRAL = "/mine/com/zj365/dc/mime/act/MyIntegralAct"

@ -0,0 +1,4 @@
package com.xty.common.event
class MessageReadEvent {
}

@ -91,7 +91,7 @@ class MessageAct : BaseListAct<MessageVm>() {
} else {
bundle.clear()
bundle.putSerializable("bean", data)
RouteManager.goAct(ARouterUrl.MESSAGE_DETAIL, bundle)
RouteManager.goAct(ARouterUrl.MESSAGE_DETAIL_NEW, bundle)
}
}
}
@ -110,10 +110,10 @@ class MessageAct : BaseListAct<MessageVm>() {
adapter.notifyItemChanged(clickPosition)
bundle.clear()
bundle.putSerializable("bean", clickBean)
RouteManager.goAct(ARouterUrl.MESSAGE_DETAIL, bundle)
RouteManager.goAct(ARouterUrl.MESSAGE_DETAIL_NEW, bundle)
}
mViewModel.messageLive.observe(this) {
when (nowPosition) {
/* when (nowPosition) {
3 -> {
val list = mutableListOf<Any>()
list.add(it.data.message)
@ -130,7 +130,7 @@ class MessageAct : BaseListAct<MessageVm>() {
else -> {
setDate(adapter, it.data.systemMessage as MutableList<Any>)
}
}
}*/
}
mViewModel.deleteLive.observe(this) {
mViewModel.getMessageList(page, 0)

@ -31,7 +31,7 @@ class MessageDetailAct: IBaseAct() {
}
binding.mMsg.text=content
onEventObject(baseContext, UmengEventId.WarningMsg, "查看预警消息详情$content")
// onEventObject(baseContext, UmengEventId.WarningMsg, "查看预警消息详情$content")
}
override fun initView() {

@ -8,6 +8,7 @@ import com.alibaba.android.arouter.facade.annotation.Route
import com.xty.base.act.BaseListAct
import com.xty.common.arouter.ARouterUrl
import com.xty.common.arouter.RouteManager
import com.xty.common.event.MessageReadEvent
import com.xty.common.getImageUrl
import com.xty.common.util.CommonToastUtils
import com.zj365.mime.R
@ -16,20 +17,24 @@ import com.zj365.mime.databinding.ActMessageBinding
import com.zj365.mime.vm.MessageVm
import com.zj365.mime.weight.MessagePop
import com.xty.network.model.MessageBean
import com.xty.network.model.MessageTypeDataBean
import org.greenrobot.eventbus.EventBus
import java.lang.StringBuilder
/**
* 我的消息
*/
@Route(path = ARouterUrl.MESSAGE)
@Route(path = ARouterUrl.MESSAGE_TYPE)
class MessageTypeListAct : BaseListAct<MessageVm>() {
var choiceMode:Boolean = false
val binding by lazy { ActMessageBinding.inflate(layoutInflater) }
val adapter by lazy { MessageAdapter() }
var clickBean: MessageBean.SysMsg? = null
var clickBean: MessageTypeDataBean.MessageTypeBean? = null
var clickPosition = 0
val array by lazy { resources.getStringArray(R.array.msg_array) }
var nowPosition = 1
var msgType:Int = 1 //根据type消息获取消息列表 消息类型1消息消息2福利官3小助手
val popWindow by lazy {
MessagePop(this) {
if (it != nowPosition) {
@ -46,6 +51,8 @@ class MessageTypeListAct : BaseListAct<MessageVm>() {
override fun initData() {
super.initData()
isDarkBar = true
msgType = intent.getIntExtra("msgType",0)
}
override fun initView() {
@ -56,7 +63,7 @@ class MessageTypeListAct : BaseListAct<MessageVm>() {
mTvTitle.text = getString(R.string.sys_message)
mTvRight.visibility = View.VISIBLE
mTvRight.text = getString(R.string.message_manager)
mTvRight.setTextColor(ContextCompat.getColor(this@MessageTypeListAct,R.color.col_25C))
mTvRight.setTextColor(ContextCompat.getColor(this@MessageTypeListAct,R.color.col_02c))
titleBg.setBackgroundColor(ContextCompat.getColor(this@MessageTypeListAct,R.color.white))
mTvRight.setOnClickListener {
@ -76,7 +83,7 @@ class MessageTypeListAct : BaseListAct<MessageVm>() {
binding.llDelete.setOnClickListener{
val ids = StringBuilder()
adapter.data.forEachIndexed{ pos, any ->
var msg = any as MessageBean.SysMsg
var msg = any as MessageTypeDataBean.MessageTypeBean
if(msg.isChoice){
ids.append("${msg.id},")
}
@ -88,11 +95,6 @@ class MessageTypeListAct : BaseListAct<MessageVm>() {
binding.title.mIvBack.setOnClickListener {
finish()
}
// binding.mSpinner.setOnClickListener {
// popWindow.showAction(it)
// }
// binding.mSpinner.text = array[nowPosition]
}
private fun choiceMode(mode:Boolean){
@ -132,7 +134,7 @@ class MessageTypeListAct : BaseListAct<MessageVm>() {
bundle.putString("chatImage", getImageUrl(bean.avatar))
RouteManager.goAct(ARouterUrl.CHAT_MSG, bundle)
} else {
val data = bean as MessageBean.SysMsg
val data = bean as MessageTypeDataBean.MessageTypeBean
if (data.notifyStatus == 0) {
clickBean = data
mViewModel.readMsg(data.id, data.notifyId)
@ -140,17 +142,17 @@ class MessageTypeListAct : BaseListAct<MessageVm>() {
} else {
bundle.clear()
bundle.putSerializable("bean", data)
RouteManager.goAct(ARouterUrl.MESSAGE_DETAIL, bundle)
RouteManager.goAct(ARouterUrl.MESSAGE_DETAIL_NEW, bundle)
}
}
}
R.id.mDelete -> {
val sysBean = bean as MessageBean.SysMsg
val sysBean = bean as MessageTypeDataBean.MessageTypeBean
mViewModel.deleteMsg(sysBean.notifyId)
}
R.id.cbChoice->{
val sysBean = bean as MessageBean.SysMsg
val sysBean = bean as MessageTypeDataBean.MessageTypeBean
val choiceView = view as CheckBox
sysBean.isChoice = choiceView.isChecked
if(choiceView.isChecked){
@ -165,58 +167,61 @@ class MessageTypeListAct : BaseListAct<MessageVm>() {
override fun liveObserver() {
mViewModel.readLive.observe(this) {
(adapter.data[clickPosition] as MessageBean.SysMsg).notifyStatus = 1
(adapter.data[clickPosition] as MessageTypeDataBean.MessageTypeBean).notifyStatus = 1
adapter.notifyItemChanged(clickPosition)
bundle.clear()
bundle.putSerializable("bean", clickBean)
RouteManager.goAct(ARouterUrl.MESSAGE_DETAIL, bundle)
RouteManager.goAct(ARouterUrl.MESSAGE_DETAIL_NEW, bundle)
EventBus.getDefault().post(MessageReadEvent())
}
mViewModel.messageLive.observe(this) {
when (nowPosition) {
3 -> {
val list = mutableListOf<Any>()
list.add(it.data.message)
list.add(it.data.records)
setDate(adapter, list)
}
0 -> {
val list = mutableListOf<Any>()
list.add(it.data.message)
list.add(it.data.records)
it?.data?.let {
it.systemMessage.let { it1 -> list.addAll(it1) }
it.records.let { it1 -> list.addAll(it1) }
}
setDate(adapter, list)
}
else -> {
it?.data?.let {
setDate(adapter, it?.systemMessage as MutableList<Any>)
setDate(adapter, it?.records as MutableList<Any>)
}
}
}
}
mViewModel.deleteLive.observe(this) {
mViewModel.getMessageList(page, 0)
mViewModel.getMessageList(page, msgType)
}
mViewModel.deletesLive.observe(this){
adapter.getDeletePos().forEachIndexed{_, any ->
if (adapter.data.size > any){
adapter.data.removeAt(any)
EventBus.getDefault().post(MessageReadEvent())
}else{
CommonToastUtils.showLoserToast("删除失败")
}
}
adapter.data.forEachIndexed{_, any ->
val msg = any as MessageBean.SysMsg
val msg = any as MessageTypeDataBean.MessageTypeBean
msg.isChoice = false
}
adapter.getDeletePos().clear()
choiceMode(false)
CommonToastUtils.showSucceedToast("删除成功")
EventBus.getDefault().post(MessageReadEvent())
}
}
override fun loadData() {
adapter.getDeletePos().clear()
mViewModel.getMessageList(page, 0)
mViewModel.getMessageList(page, msgType)
}
}

@ -15,6 +15,7 @@ import com.xty.base.adapter.BaseAdapter
import com.xty.common.setImageUser
import com.zj365.mime.R
import com.xty.network.model.MessageBean
import com.xty.network.model.MessageTypeDataBean
import de.hdodenhof.circleimageview.CircleImageView
import okhttp3.internal.filterList
@ -36,7 +37,7 @@ class MessageAdapter():BaseAdapter<Any>(R.layout.item_message) {
// holder.setGone(R.id.mDelete,true)
// setBadge(item.count,holder.getView(R.id.msgCard),holder.getView(R.id.mBadge))
// }else
if(item is MessageBean.SysMsg){
if(item is MessageTypeDataBean.MessageTypeBean){
holder.setGone(R.id.mRelMsg,false).setGone(R.id.mChat,true)
holder.setText(R.id.mContent,item.notifyContent)
.setText(R.id.mTvTime,RxTimeTool.milliseconds2String(item.notifyCreateTime))

@ -4,23 +4,23 @@ import androidx.lifecycle.MutableLiveData
import com.xty.base.vm.BaseVm
import com.xty.common.util.CommonUtils
import com.xty.network.model.MessageBean
import com.xty.network.model.MessageTypeDataBean
import com.xty.network.model.RespBody
import org.json.JSONObject
class MessageVm : BaseVm(){
val messageLive by lazy{MutableLiveData<RespBody<MessageBean>>()}
val messageLive by lazy{MutableLiveData<RespBody<MessageTypeDataBean>>()}
val readLive by lazy{MutableLiveData<RespBody<Any>>()}
val deleteLive by lazy{MutableLiveData<RespBody<Any>>()}
val deletesLive by lazy { MutableLiveData<RespBody<Any>>() }
fun getMessageList(page:Int,type:Int){
startHttp {
var json=JSONObject()
// json.put("pageNum",page)
//json.put("pageSize",Const.PAGE_SIZE)
json.put("type",type)
json.put("userId", CommonUtils.getMyUserId())
json.put("pageNum", page)
json.put("pageSize",20)
var respnse=apiInterface().getMessageList(retrofits.getRequestBody(json.toString()))
var respnse=apiInterface().getMessageListForType(retrofits.getRequestBody(json.toString()))
respnse.getCodeStatus(messageLive,nowData)
}
}
@ -29,11 +29,8 @@ class MessageVm : BaseVm(){
startHttp {
var json=JSONObject()
json.put("id", id)
json.put("notifyId", notifyId)
json.put("notifyStatus",1)
json.put("notifyHandStatus",2)
var respnse=apiInterface().readMsg(retrofits.getRequestBody(json.toString()))
var respnse=apiInterface().setMessageRead(retrofits.getRequestBody(json.toString()))
respnse.getCodeStatus(readLive,nowData)
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 884 B

After

Width:  |  Height:  |  Size: 714 B

@ -1017,6 +1017,9 @@ interface ApiInterface {
@POST("customer/message")
suspend fun getMessageList(@Body rb: RequestBody): RespBody<MessageBean>
@POST("customer/message/messageList")
suspend fun getMessageListForType(@Body rb: RequestBody):RespBody<MessageTypeDataBean>
/**
* 我的预警消息
*/
@ -1032,7 +1035,7 @@ interface ApiInterface {
/**
* 批量删除消息
*/
@POST("butler/message/deleteMsg")
@POST("customer/message/deleteMsg")
suspend fun deleteMsgs(@Body ids: RequestBody): RespBody<Any>
/**
@ -1326,6 +1329,21 @@ interface ApiInterface {
@GET("customer/device/findUserBaseInfo")
suspend fun getUserInfo(@Query("userId") userId: String): RespBody<BodyFatUserBean>
/**
* 获取首页系统消息
*/
@POST("customer/message/index")
suspend fun getSystemMsg():RespBody<SystemMsgDataResp>
/**
* 设置消息已读
*/
@POST("customer/message/setMessageRead")
suspend fun setMessageRead(@Body rb: RequestBody): RespBody<Any>
@POST("customer/message/setAllMessageRead")
suspend fun setMessageReadAll(): RespBody<Any>
/**
* 解绑设备SN号
*/

@ -0,0 +1,34 @@
package com.xty.network.model
import com.google.gson.annotations.SerializedName
import java.io.Serializable
data class MessageTypeDataBean (
var records:ArrayList<MessageTypeBean>,
var total:Int,
var size:Int,
var current:Int
):Serializable{
data class MessageTypeBean(
val notifyContent: String,
val notifyCreateTime: Long,
val notifyHandStatus: Int,
val notifyId: String,
var notifyStatus: Int,
val notifyTitle: String,
val notifyType: Int,
val notifyUserType: Int,
val remark: Any,
val type: Int,
val userId: String,
val id: String,
val reportPresetId:String,
val titleStatus:String,
val time:String,
var isChoice:Boolean = false
):Serializable{
}
}

@ -2,4 +2,6 @@ package com.xty.network.model
import android.content.ContentResolver
data class SystemMsgBean(var id:Long,var title:String,var time:Long,var content:String)
data class SystemMsgBean(var unReadCount:Long,var name:String,var time:String,var msg:String,var type:Int)
data class SystemMsgDataResp(var unReadCount:Long,var list:ArrayList<SystemMsgBean>)

Loading…
Cancel
Save