中建365-消息模块
parent
7dca4b772c
commit
dbd6eccb2e
@ -1,17 +1,55 @@
|
|||||||
package com.zj365.dc.adapter
|
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.chad.library.adapter.base.viewholder.BaseViewHolder
|
||||||
import com.xty.base.adapter.BaseAdapter
|
import com.xty.base.adapter.BaseAdapter
|
||||||
import com.xty.common.Dateutils
|
import com.xty.common.Dateutils
|
||||||
import com.xty.network.model.ScienceBean
|
|
||||||
import com.xty.network.model.SystemMsgBean
|
import com.xty.network.model.SystemMsgBean
|
||||||
import com.zj365.dc.R
|
import com.zj365.dc.R
|
||||||
|
|
||||||
class HomeMessageAdapter : BaseAdapter<SystemMsgBean>(R.layout.item_home_message) {
|
class HomeMessageAdapter : BaseAdapter<SystemMsgBean>(R.layout.item_home_message) {
|
||||||
override fun convert(holder: BaseViewHolder, item: SystemMsgBean) {
|
override fun convert(holder: BaseViewHolder, item: SystemMsgBean) {
|
||||||
holder.setText(R.id.tv_msg_title,item.title)
|
if (item.type == 1){
|
||||||
holder.setText(R.id.tv_msg_content,item.content)
|
holder.getView<ImageView>(R.id.img_msg).setImageDrawable(context.resources.getDrawable(R.mipmap.icon_msg_system))
|
||||||
holder.setText(R.id.tv_msg_time,Dateutils.formatTime(item.time,Dateutils.YYYY_MM_DD_HH_MM))
|
}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,10 +1,26 @@
|
|||||||
package com.zj365.dc.vm
|
package com.zj365.dc.vm
|
||||||
|
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.xty.base.vm.BaseVm
|
import com.xty.base.vm.BaseVm
|
||||||
|
import com.xty.network.model.RespBody
|
||||||
|
import com.xty.network.model.SystemMsgDataResp
|
||||||
|
|
||||||
class MessageVm(): BaseVm() {
|
class MessageVm(): BaseVm() {
|
||||||
|
|
||||||
|
val msgData by lazy { MutableLiveData<RespBody<SystemMsgDataResp>> ()}
|
||||||
|
|
||||||
|
val msgAllRead by lazy { MutableLiveData<RespBody<Any>>() }
|
||||||
fun getSystemMsg(){
|
fun getSystemMsg(){
|
||||||
|
startHttp {
|
||||||
|
var response = apiInterface().getSystemMsg()
|
||||||
|
response.getCodeStatus(msgData, nowData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setAllRead(){
|
||||||
|
startHttp(true) {
|
||||||
|
var response = apiInterface().setMessageReadAll()
|
||||||
|
response.getCodeStatus(msgAllRead, nowData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
After Width: | Height: | Size: 8.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
@ -0,0 +1,4 @@
|
|||||||
|
package com.xty.common.event
|
||||||
|
|
||||||
|
class MessageReadEvent {
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 884 B After Width: | Height: | Size: 714 B |
@ -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{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue