消息功能对接,为测试
This commit is contained in:
parent
61864990b6
commit
fcc2f166ce
@ -5,6 +5,7 @@ import android.view.ViewGroup
|
|||||||
import com.chad.library.adapter4.BaseQuickAdapter
|
import com.chad.library.adapter4.BaseQuickAdapter
|
||||||
import com.chad.library.adapter4.viewholder.QuickViewHolder
|
import com.chad.library.adapter4.viewholder.QuickViewHolder
|
||||||
import com.dahe.gldriver.R
|
import com.dahe.gldriver.R
|
||||||
|
import com.dahe.gldriver.bean.MessageBean
|
||||||
import com.dahe.glex.bean.WayBillBean
|
import com.dahe.glex.bean.WayBillBean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,11 +14,16 @@ import com.dahe.glex.bean.WayBillBean
|
|||||||
* @Date 2024/1/24 14:40
|
* @Date 2024/1/24 14:40
|
||||||
* @Description TODO
|
* @Description TODO
|
||||||
*/
|
*/
|
||||||
class MessageAdapter: BaseQuickAdapter<WayBillBean, QuickViewHolder>() {
|
class MessageAdapter : BaseQuickAdapter<MessageBean, QuickViewHolder>() {
|
||||||
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: WayBillBean?) {
|
override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: MessageBean?) {
|
||||||
|
holder.run {
|
||||||
|
setText(R.id.tvTitle, item?.messageTypeLable)
|
||||||
|
setText(R.id.tvData, item?.createTime)
|
||||||
|
setText(R.id.tvProduct, item?.messageTitle)
|
||||||
|
setGone(R.id.tvBadge,item?.isRead=="1")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(
|
override fun onCreateViewHolder(
|
||||||
|
24
app/src/main/java/com/dahe/gldriver/bean/MessageBean.kt
Normal file
24
app/src/main/java/com/dahe/gldriver/bean/MessageBean.kt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package com.dahe.gldriver.bean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName MessageBean
|
||||||
|
* @Author john
|
||||||
|
* @Date 2024/4/18 08:44
|
||||||
|
* @Description TODO
|
||||||
|
*/
|
||||||
|
data class MessageBean(
|
||||||
|
val createBy: String,
|
||||||
|
val createTime: String,
|
||||||
|
val driverId: String,
|
||||||
|
val isRead: String,
|
||||||
|
val messageContent: String,
|
||||||
|
val messageId: String,
|
||||||
|
val messageTitle: String,
|
||||||
|
val messageType: String,
|
||||||
|
val messageTypeLable: String,
|
||||||
|
val phone: String,
|
||||||
|
val remark: String,
|
||||||
|
val status: String,
|
||||||
|
val updateBy: String,
|
||||||
|
val updateTime: String
|
||||||
|
)
|
@ -11,6 +11,7 @@ import com.dahe.gldriver.bean.DiCarColor
|
|||||||
import com.dahe.gldriver.bean.DriverBean
|
import com.dahe.gldriver.bean.DriverBean
|
||||||
import com.dahe.gldriver.bean.FaceBean
|
import com.dahe.gldriver.bean.FaceBean
|
||||||
import com.dahe.gldriver.bean.InviteRecord
|
import com.dahe.gldriver.bean.InviteRecord
|
||||||
|
import com.dahe.gldriver.bean.MessageBean
|
||||||
import com.dahe.gldriver.bean.OcrPersonBean
|
import com.dahe.gldriver.bean.OcrPersonBean
|
||||||
import com.dahe.gldriver.bean.OrderChild
|
import com.dahe.gldriver.bean.OrderChild
|
||||||
import com.dahe.gldriver.bean.OrderDetailBean
|
import com.dahe.gldriver.bean.OrderDetailBean
|
||||||
@ -564,6 +565,16 @@ interface Api {
|
|||||||
@GET(BASE_URL + "driver/driver/getESignPsnAuthUrl")
|
@GET(BASE_URL + "driver/driver/getESignPsnAuthUrl")
|
||||||
fun getESignPsnAuthUrl(): Observable<CommonResponseBean<FaceBean>>
|
fun getESignPsnAuthUrl(): Observable<CommonResponseBean<FaceBean>>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询司机消息通知列表
|
||||||
|
* @return Observable<CommonResponseBean<MutableList<MessageBean>>>
|
||||||
|
*/
|
||||||
|
@GET(BASE_URL+"driver/message/list")
|
||||||
|
fun messageList():Observable<CommonResponseBean<MutableList<MessageBean>>>
|
||||||
|
|
||||||
|
@GET(BASE_URL+"driver/message/read")
|
||||||
|
fun messageRead(@Query("messageId") messageId :String):Observable<CommonResponseBean<Any>>
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// String BASE_URL = "https://tmstest.dahehuoyun.com/";
|
// String BASE_URL = "https://tmstest.dahehuoyun.com/";
|
||||||
const val BASE_URL = BuildConfig.BASE_URL
|
const val BASE_URL = BuildConfig.BASE_URL
|
||||||
|
@ -6,14 +6,22 @@ import android.widget.LinearLayout
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.dahe.gldriver.R
|
import com.dahe.gldriver.R
|
||||||
|
import com.dahe.gldriver.adapter.BusinessListAdapter
|
||||||
import com.dahe.gldriver.adapter.MessageAdapter
|
import com.dahe.gldriver.adapter.MessageAdapter
|
||||||
|
import com.dahe.gldriver.bean.MessageBean
|
||||||
import com.dahe.gldriver.databinding.FragmentMessageBinding
|
import com.dahe.gldriver.databinding.FragmentMessageBinding
|
||||||
import com.dahe.gldriver.databinding.FragmentWaybillBinding
|
import com.dahe.gldriver.databinding.FragmentWaybillBinding
|
||||||
|
import com.dahe.gldriver.net.BaseObserver
|
||||||
|
import com.dahe.gldriver.net.DataManager
|
||||||
|
import com.dahe.gldriver.net.RxHttpCallBack
|
||||||
import com.dahe.glex.bean.WayBillBean
|
import com.dahe.glex.bean.WayBillBean
|
||||||
import com.dahe.mylibrary.base.BaseFragment
|
import com.dahe.mylibrary.base.BaseFragment
|
||||||
import com.dahe.mylibrary.callback.RefreshCallBack
|
import com.dahe.mylibrary.callback.RefreshCallBack
|
||||||
|
import com.dahe.mylibrary.net.CommonResponseBean
|
||||||
import com.dahe.mylibrary.recycleviewswipe.RecycleViewDivider
|
import com.dahe.mylibrary.recycleviewswipe.RecycleViewDivider
|
||||||
import com.dahe.mylibrary.utils.ConvertUtils
|
import com.dahe.mylibrary.utils.ConvertUtils
|
||||||
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||||
|
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||||
import net.lucode.hackware.magicindicator.ViewPagerHelper
|
import net.lucode.hackware.magicindicator.ViewPagerHelper
|
||||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator
|
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter
|
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter
|
||||||
@ -31,7 +39,7 @@ import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorT
|
|||||||
*/
|
*/
|
||||||
class MessageFragment : BaseFragment<FragmentMessageBinding>(), RefreshCallBack {
|
class MessageFragment : BaseFragment<FragmentMessageBinding>(), RefreshCallBack {
|
||||||
|
|
||||||
|
lateinit var adapter: MessageAdapter
|
||||||
override fun onFragmentVisibleChange(isVisible: Boolean) {
|
override fun onFragmentVisibleChange(isVisible: Boolean) {
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
}
|
}
|
||||||
@ -39,30 +47,41 @@ class MessageFragment : BaseFragment<FragmentMessageBinding>(), RefreshCallBack
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFragmentFirstVisible() {
|
override fun onFragmentFirstVisible() {
|
||||||
setRefresh(binding.refresh,this)
|
setRefresh(binding.refresh, this)
|
||||||
initRecy()
|
initRecy()
|
||||||
|
getData()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun getRefreshDate(stat: Int, page: Int, count: Int) {
|
override fun getRefreshDate(stat: Int, page: Int, count: Int) {
|
||||||
|
getData()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getData() {
|
||||||
|
DataManager.getInstance().messageList()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(BaseObserver(mContext, object : RxHttpCallBack<MutableList<MessageBean>>() {
|
||||||
|
override fun onSuccess(t: CommonResponseBean<MutableList<MessageBean>>) {
|
||||||
|
super.onSuccess(t)
|
||||||
|
if (t.data == null || t.data.size == 0) {
|
||||||
|
adapter.submitList(null)
|
||||||
|
adapter.setStateViewLayout(mContext, R.layout.empty_view)
|
||||||
|
} else {
|
||||||
|
adapter.submitList(t.data)
|
||||||
|
}
|
||||||
|
setFinishRefresh(
|
||||||
|
binding.refresh,
|
||||||
|
t.total > mRefreshPage * mRefreshCount
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initRecy() {
|
private fun initRecy() {
|
||||||
var datas = mutableListOf<WayBillBean>(
|
adapter = binding.recyclerView.run {
|
||||||
WayBillBean(),
|
layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false)
|
||||||
WayBillBean(),
|
|
||||||
WayBillBean(),
|
|
||||||
WayBillBean(),
|
|
||||||
WayBillBean(),
|
|
||||||
WayBillBean(),
|
|
||||||
WayBillBean(),
|
|
||||||
WayBillBean()
|
|
||||||
)
|
|
||||||
|
|
||||||
var adapter = binding.recyclerView.run {
|
|
||||||
layoutManager = LinearLayoutManager(mContext,RecyclerView.VERTICAL,false)
|
|
||||||
addItemDecoration(
|
addItemDecoration(
|
||||||
RecycleViewDivider(
|
RecycleViewDivider(
|
||||||
LinearLayout.VERTICAL,
|
LinearLayout.VERTICAL,
|
||||||
@ -70,14 +89,24 @@ class MessageFragment : BaseFragment<FragmentMessageBinding>(), RefreshCallBack
|
|||||||
Color.TRANSPARENT
|
Color.TRANSPARENT
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
setHasFixedSize(true)
|
|
||||||
adapter = MessageAdapter()
|
adapter = MessageAdapter()
|
||||||
adapter as MessageAdapter
|
adapter as MessageAdapter
|
||||||
}.apply {
|
}.apply {
|
||||||
isStateViewEnable = true
|
isStateViewEnable = true
|
||||||
|
setOnItemClickListener { _, _, position ->
|
||||||
|
DataManager.getInstance().messageRead(items[position].messageId)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(BaseObserver(mContext, object : RxHttpCallBack<Any>() {
|
||||||
|
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||||
|
super.onSuccess(t)
|
||||||
|
|
||||||
|
getData()
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter.submitList(datas)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
8
app/src/main/res/drawable/simple_count_badge_bg.xml
Normal file
8
app/src/main/res/drawable/simple_count_badge_bg.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="#ffcc0000" />
|
||||||
|
<size
|
||||||
|
android:width="12dp"
|
||||||
|
android:height="12dp" />
|
||||||
|
<corners android:radius="6dp" />
|
||||||
|
</shape>
|
@ -2,10 +2,11 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/shape_message_item_bg"
|
|
||||||
android:padding="@dimen/dp_11"
|
|
||||||
android:layout_marginLeft="@dimen/dp_18"
|
android:layout_marginLeft="@dimen/dp_18"
|
||||||
android:layout_marginRight="@dimen/dp_18">
|
android:layout_marginRight="@dimen/dp_18"
|
||||||
|
android:background="@drawable/shape_message_item_bg"
|
||||||
|
android:padding="@dimen/dp_11">
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
@ -27,6 +28,7 @@
|
|||||||
android:textStyle="bold"></TextView>
|
android:textStyle="bold"></TextView>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/tvData"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBottom="@+id/tvTitle"
|
android:layout_alignBottom="@+id/tvTitle"
|
||||||
@ -75,4 +77,12 @@
|
|||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:background="@drawable/right_gray"></ImageView>
|
android:background="@drawable/right_gray"></ImageView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvBadge"
|
||||||
|
android:layout_width="@dimen/dp_8"
|
||||||
|
android:layout_height="@dimen/dp_8"
|
||||||
|
android:background="@drawable/simple_count_badge_bg"
|
||||||
|
|
||||||
|
android:visibility="gone" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
Loading…
Reference in New Issue
Block a user