删除消息本地数据库,改为从服务器获取
This commit is contained in:
@@ -1 +1 @@
|
||||
#Thu Mar 12 15:15:30 CST 2026
|
||||
#Thu Mar 19 17:33:53 CST 2026
|
||||
|
||||
@@ -30,7 +30,7 @@ android {
|
||||
targetSdkVersion 35
|
||||
versionCode 2110
|
||||
// versionName "2.1.10"
|
||||
versionName "2.1.10-Beta9"
|
||||
versionName "2.1.10-Beta10"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -228,7 +228,7 @@ dependencies {
|
||||
implementation 'androidx.recyclerview:recyclerview:1.3.1'
|
||||
|
||||
//谷歌地图
|
||||
implementation 'com.google.android.gms:play-services-maps:19.2.0'
|
||||
implementation 'com.google.android.gms:play-services-maps:20.0.0'
|
||||
//地图操作工具类,添加标记等https://github.com/googlemaps/android-maps-utils
|
||||
// implementation 'com.google.maps.android:android-maps-utils:2.3.0'
|
||||
// implementation 'com.google.maps.android:maps-utils-ktx:3.2.1'
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.abbidot.baselibrary.list.RecyclerViewHolder
|
||||
import com.abbidot.baselibrary.util.Utils
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.bean.MessageBean
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.widget.TypefaceRoundButton
|
||||
|
||||
/**
|
||||
@@ -28,7 +29,7 @@ class NotificationV2Adapter(
|
||||
override fun bindData(holder: RecyclerViewHolder?, position: Int, item: MessageBean) {
|
||||
val roundButton =
|
||||
holder!!.getView(R.id.iv_home_route_notification_state) as TypefaceRoundButton
|
||||
val textColor = if (item.isRead) {
|
||||
val textColor = if (item.isRead == ConstantInt.Type1) {
|
||||
roundButton.visibility = View.GONE
|
||||
R.color.black70
|
||||
} else {
|
||||
@@ -51,26 +52,30 @@ class NotificationV2Adapter(
|
||||
setTextColor(ContextCompat.getColor(mContext, textColor))
|
||||
}
|
||||
holder.getTextView(R.id.tv_home_route_notification_date).apply {
|
||||
text = getRelativeTimeString(item.sendTime)
|
||||
text = getRelativeTimeString(item.timeStamp)
|
||||
setTextColor(ContextCompat.getColor(mContext, textColor))
|
||||
}
|
||||
}
|
||||
|
||||
private fun getRelativeTimeString(sendTime: String): String {
|
||||
private fun getRelativeTimeString(timeStamp: Long): String {
|
||||
var formatDateStr = ""
|
||||
val time = Utils.stringToTimestamp(sendTime, isUtc = true)
|
||||
val now = System.currentTimeMillis()
|
||||
formatDateStr = if (DateUtils.isToday(time)) {
|
||||
mContext.getString(R.string.txt_today) + " " + Utils.formatTime(
|
||||
time, Utils.DATE_FORMAT_PATTERN_EN8
|
||||
val cTimeStamp = Utils.stringToTimestamp(
|
||||
Utils.formatTime(
|
||||
timeStamp, Utils.DATE_FORMAT_PATTERN_CN2
|
||||
)
|
||||
} else if (now - time < (48 * 60 * 60 * 1000)) {
|
||||
)
|
||||
val now = System.currentTimeMillis()
|
||||
formatDateStr = if (DateUtils.isToday(cTimeStamp)) {
|
||||
mContext.getString(R.string.txt_today) + " " + Utils.formatTime(
|
||||
timeStamp, Utils.DATE_FORMAT_PATTERN_EN8
|
||||
)
|
||||
} else if (now - cTimeStamp < (48 * 60 * 60 * 1000)) {
|
||||
mContext.getString(R.string.txt_yesterday) + " " + Utils.formatTime(
|
||||
time, Utils.DATE_FORMAT_PATTERN_EN8
|
||||
timeStamp, Utils.DATE_FORMAT_PATTERN_EN8
|
||||
)
|
||||
} else {
|
||||
Utils.formatTime(
|
||||
Utils.stringToTimestamp(sendTime), Utils.DATE_FORMAT_PATTERN_EN9
|
||||
timeStamp, Utils.DATE_FORMAT_PATTERN_EN9
|
||||
)
|
||||
}
|
||||
return formatDateStr
|
||||
|
||||
@@ -8,6 +8,7 @@ package com.abbidot.tracker.bean
|
||||
data class CommonDataBean(
|
||||
var taxRate: Double,
|
||||
var surplusSafeValidMonths: Int,
|
||||
var unReadCount: Long,
|
||||
var reactivationFee: Double,
|
||||
var surplusSafeValidFee: Double
|
||||
)
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlinx.parcelize.Parcelize
|
||||
* @description:保存用户输入信用卡
|
||||
*/
|
||||
@Parcelize
|
||||
@Entity(tableName = MyDatabase.CreditCardTableName)
|
||||
@Entity(tableName = MyDatabase.CREDIT_CARD_TABLE)
|
||||
data class CreditCardBean(
|
||||
@PrimaryKey @ColumnInfo var cardNumber: String,
|
||||
@ColumnInfo var firstName: String,
|
||||
|
||||
@@ -16,7 +16,7 @@ import kotlinx.parcelize.Parcelize
|
||||
* @description:连接保存的设备表
|
||||
*/
|
||||
// 定义表名称,SQLite 中的表名称不区分大小写,2个主键
|
||||
@Entity(tableName = MyDatabase.DeviceTableName, primaryKeys = ["deviceOutId", "deviceId"])
|
||||
@Entity(tableName = MyDatabase.DEVICE_TABLE, primaryKeys = ["deviceOutId", "deviceId"])
|
||||
@Parcelize
|
||||
data class DeviceBean(//@PrimaryKey(autoGenerate = true) var id: Long,//autoGenerate = true 自动增长分配ID
|
||||
@ColumnInfo @DeviceType var type: Int,//设备类型
|
||||
|
||||
@@ -1,28 +1,25 @@
|
||||
package com.abbidot.tracker.bean
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Ignore
|
||||
import com.abbidot.tracker.constant.MultipleEntity
|
||||
import com.abbidot.tracker.database.MyDatabase
|
||||
|
||||
/**
|
||||
*Created by .yzq on 2022/2/24/024.
|
||||
* @link
|
||||
* @description:消息列表
|
||||
*/
|
||||
@Entity(tableName = MyDatabase.MessageTableName, primaryKeys = ["messageId"])
|
||||
data class MessageBean(
|
||||
@ColumnInfo var messageId: String,
|
||||
@ColumnInfo var title: String,
|
||||
@ColumnInfo var message: String,
|
||||
@ColumnInfo var sendTime: String,
|
||||
@ColumnInfo var messageType: Int,
|
||||
@ColumnInfo var imgUrl: String,
|
||||
@ColumnInfo var isRead: Boolean,
|
||||
@Ignore @MultipleEntity var isContainImg: Int,
|
||||
@Ignore var isSelect: Boolean
|
||||
var messageId: String,
|
||||
var title: String,
|
||||
var message: String,
|
||||
var sendTime: String,
|
||||
var messageType: Int,
|
||||
var imgUrl: String,
|
||||
var isRead: Int,
|
||||
var deviceMessageType: Int,
|
||||
var timeStamp: Long,
|
||||
@MultipleEntity var isContainImg: Int,
|
||||
var isSelect: Boolean
|
||||
) {
|
||||
constructor() : this("", "", "", "", 1, "", false, MultipleEntity.TEXT, false)
|
||||
constructor() : this("", "", "", "", 1, "", 0, 0, 0L, MultipleEntity.TEXT, false)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,8 @@ import androidx.room.RoomDatabase
|
||||
import com.abbidot.tracker.MyApplication
|
||||
import com.abbidot.tracker.bean.CreditCardBean
|
||||
import com.abbidot.tracker.bean.DeviceBean
|
||||
import com.abbidot.tracker.bean.MessageBean
|
||||
import com.abbidot.tracker.database.dao.CreditCardDao
|
||||
import com.abbidot.tracker.database.dao.DeviceDao
|
||||
import com.abbidot.tracker.database.dao.MessageDao
|
||||
|
||||
/**
|
||||
*Created by .yzq on 2021/11/6/006.
|
||||
@@ -18,15 +16,14 @@ import com.abbidot.tracker.database.dao.MessageDao
|
||||
*/
|
||||
//exportSchema = false,防止改数据库内容版本自动增加
|
||||
@Database(
|
||||
entities = [DeviceBean::class, CreditCardBean::class, MessageBean::class],
|
||||
version = 4,
|
||||
entities = [DeviceBean::class, CreditCardBean::class],
|
||||
version = 5,
|
||||
// autoMigrations = [AutoMigration(from = 1, to = 2)],
|
||||
exportSchema = false,
|
||||
)
|
||||
abstract class MyDatabase : RoomDatabase() {
|
||||
abstract fun deviceDao(): DeviceDao
|
||||
abstract fun creditCardDao(): CreditCardDao
|
||||
abstract fun messageDao(): MessageDao
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -49,9 +46,8 @@ abstract class MyDatabase : RoomDatabase() {
|
||||
}
|
||||
|
||||
//表名
|
||||
const val CreditCardTableName = "creditCard"
|
||||
const val DeviceTableName = "device"
|
||||
const val MessageTableName = "message"
|
||||
const val CREDIT_CARD_TABLE = "creditCard"
|
||||
const val DEVICE_TABLE = "device"
|
||||
|
||||
fun deviceDao(): DeviceDao {
|
||||
return db.deviceDao()
|
||||
@@ -60,9 +56,5 @@ abstract class MyDatabase : RoomDatabase() {
|
||||
fun creditCardDao(): CreditCardDao {
|
||||
return db.creditCardDao()
|
||||
}
|
||||
|
||||
fun messageDao(): MessageDao {
|
||||
return db.messageDao()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,6 @@ import com.abbidot.tracker.database.MyDatabase
|
||||
@Dao
|
||||
interface DeviceDao : BaseDao<DeviceBean> {
|
||||
|
||||
@Query("SELECT * FROM ${MyDatabase.DeviceTableName} WHERE macId LIKE :mac LIMIT 1")
|
||||
@Query("SELECT * FROM ${MyDatabase.DEVICE_TABLE} WHERE macId LIKE :mac LIMIT 1")
|
||||
fun findByMac(mac: String): DeviceBean?
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.abbidot.tracker.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import com.abbidot.tracker.bean.MessageBean
|
||||
|
||||
/**
|
||||
*Created by .yzq on 2024/7/19/019.
|
||||
* @link
|
||||
* @description:
|
||||
*/
|
||||
@Dao
|
||||
interface MessageDao : BaseDao<MessageBean>
|
||||
@@ -99,7 +99,7 @@ class PaymentMethodPayPalActivity :
|
||||
withContext(Dispatchers.IO) {
|
||||
ViewUtil.instance.addMenuBean(paymentMethodList, "", "", R.drawable.ico_lay_paypal)
|
||||
|
||||
val list = MyDatabase.creditCardDao().findAll(MyDatabase.CreditCardTableName)
|
||||
val list = MyDatabase.creditCardDao().findAll(MyDatabase.CREDIT_CARD_TABLE)
|
||||
list?.forEach {
|
||||
val imageId = Util.getCreditCardType(it.cardNumber)
|
||||
ViewUtil.instance.addMenuBean(
|
||||
|
||||
@@ -113,7 +113,7 @@ class PaymentMethodStripeActivity :
|
||||
withContext(Dispatchers.IO) {
|
||||
// ViewUtil.instance.addMenuBean(paymentMethodList, "", "", R.drawable.ico_lay_paypal)
|
||||
|
||||
val list = MyDatabase.creditCardDao().findAll(MyDatabase.CreditCardTableName)
|
||||
val list = MyDatabase.creditCardDao().findAll(MyDatabase.CREDIT_CARD_TABLE)
|
||||
list?.forEach {
|
||||
val imageId = Util.getCreditCardType(it.cardNumber)
|
||||
ViewUtil.instance.addMenuBean(
|
||||
|
||||
@@ -220,7 +220,7 @@ class BraintreePalViewModel : ViewModel() {
|
||||
// setMealBean.cost.toString(), nonce, deviceId)
|
||||
var list: List<CreditCardBean>?
|
||||
withContext(Dispatchers.IO) {
|
||||
list = MyDatabase.creditCardDao().findAll(MyDatabase.CreditCardTableName)
|
||||
list = MyDatabase.creditCardDao().findAll(MyDatabase.CREDIT_CARD_TABLE)
|
||||
}
|
||||
if (null != list) {
|
||||
val userId = MMKVUtil.getString(MMKVKey.UserId)
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.lifecycle.viewModelScope
|
||||
import com.abbidot.baselibrary.constant.MMKVKey
|
||||
import com.abbidot.baselibrary.util.MMKVUtil
|
||||
import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.bean.CommonDataBean
|
||||
import com.abbidot.tracker.bean.MessageBean
|
||||
import com.abbidot.tracker.retrofit2.NetworkApi
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -19,6 +20,9 @@ class NotificationsViewModel : ViewModel() {
|
||||
|
||||
val mNotificationsLiveData = MutableLiveData<Result<MutableList<MessageBean>>>()
|
||||
val mDeleteMessageLiveData = MutableLiveData<Result<String>>()
|
||||
val mReadMessageLiveData = MutableLiveData<Result<String>>()
|
||||
val mReadAllMessageLiveData = MutableLiveData<Result<String>>()
|
||||
val mMessageCountLiveData = MutableLiveData<Result<CommonDataBean>>()
|
||||
|
||||
fun getMessageList() {
|
||||
// activity.showLoading(true)
|
||||
@@ -29,6 +33,37 @@ class NotificationsViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun getMessageUnReadCount() {
|
||||
viewModelScope.launch {
|
||||
val userId = MMKVUtil.getString(MMKVKey.UserId)
|
||||
val result = NetworkApi.getMessageUnReadCount(userId)
|
||||
mMessageCountLiveData.value = result
|
||||
}
|
||||
}
|
||||
|
||||
fun messageListByPage(page: Int) {
|
||||
viewModelScope.launch {
|
||||
val userId = MMKVUtil.getString(MMKVKey.UserId)
|
||||
val result = NetworkApi.messageListByPage(userId, page)
|
||||
mNotificationsLiveData.value = result
|
||||
}
|
||||
}
|
||||
|
||||
fun setMessageIsRead(messageId: String) {
|
||||
viewModelScope.launch {
|
||||
val result = NetworkApi.setMessageIsRead(messageId)
|
||||
mReadMessageLiveData.value = result
|
||||
}
|
||||
}
|
||||
|
||||
fun setMessageAllIsRead() {
|
||||
viewModelScope.launch {
|
||||
val userId = MMKVUtil.getString(MMKVKey.UserId)
|
||||
val result = NetworkApi.setMessageAllIsRead(userId)
|
||||
mReadAllMessageLiveData.value = result
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteMessage(activity: BaseActivity<*>, messageIds: String) {
|
||||
activity.showLoading(true)
|
||||
viewModelScope.launch {
|
||||
|
||||
@@ -60,7 +60,7 @@ class StripePalViewModel : ViewModel() {
|
||||
fun startCheckout(activity: BaseActivity<*>, card: MenuTxtBean) {
|
||||
activity.showLoading(true)
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val list = MyDatabase.creditCardDao().findAll(MyDatabase.CreditCardTableName)
|
||||
val list = MyDatabase.creditCardDao().findAll(MyDatabase.CREDIT_CARD_TABLE)
|
||||
if (null != list) {
|
||||
for (it in list) {
|
||||
if (card.menuName == it.cardNumber) {
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.abbidot.tracker.diff
|
||||
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import com.abbidot.tracker.bean.MessageBean
|
||||
|
||||
/**
|
||||
*Created by .yzq on 2021/12/31/031.
|
||||
* @link
|
||||
* @description:通知消息diffutil,多布局的没有写继承封装
|
||||
*/
|
||||
class NotificationsDiffUtil : DiffUtil.ItemCallback<MessageBean>() {
|
||||
override fun areItemsTheSame(oldItem: MessageBean, newItem: MessageBean): Boolean {
|
||||
return oldItem.messageId == newItem.messageId
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: MessageBean, newItem: MessageBean): Boolean {
|
||||
return oldItem.title == newItem.title && oldItem.message == newItem.message && oldItem.isContainImg == newItem.isContainImg && oldItem.isSelect == newItem.isSelect
|
||||
}
|
||||
}
|
||||
@@ -182,6 +182,36 @@ interface INetworkService {
|
||||
@Query("userId") userId: String
|
||||
): BaseResponse<MutableList<MessageBean>>
|
||||
|
||||
/**
|
||||
* 获取未读消息数量
|
||||
*/
|
||||
@GET("user/getMessageUnReadCount")
|
||||
suspend fun getMessageUnReadCount(
|
||||
@Query("userId") userId: String
|
||||
): BaseResponse<CommonDataBean>
|
||||
|
||||
/**
|
||||
* 获取消息列表(分页显示)
|
||||
*/
|
||||
@GET("user/messageListByPage")
|
||||
suspend fun messageListByPage(
|
||||
@Query("userId") userId: String, @Query("page") page: Int, @Query("size") size: Int
|
||||
): BaseResponse<MutableList<MessageBean>>
|
||||
|
||||
/**
|
||||
*设置单条消息已读
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("user/setMessageIsRead")
|
||||
suspend fun setMessageIsRead(@Field("messageId") messageId: String): BaseResponse<String>
|
||||
|
||||
/**
|
||||
*设置全部消息已读
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("user/setMessageAllIsRead")
|
||||
suspend fun setMessageAllIsRead(@Field("userId") userId: String): BaseResponse<String>
|
||||
|
||||
/**
|
||||
*删除消息
|
||||
*/
|
||||
|
||||
@@ -127,6 +127,34 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
service.getMessageList(userId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未读消息数量
|
||||
*/
|
||||
suspend fun getMessageUnReadCount(userId: String) = getResult {
|
||||
service.getMessageUnReadCount(userId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息列表
|
||||
*/
|
||||
suspend fun messageListByPage(userId: String, page: Int) = getResult {
|
||||
service.messageListByPage(userId, page, 20)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置全部消息已读
|
||||
*/
|
||||
suspend fun setMessageAllIsRead(userId: String) = getResult {
|
||||
service.setMessageAllIsRead(userId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置单条消息已读
|
||||
*/
|
||||
suspend fun setMessageIsRead(messageId: String) = getResult {
|
||||
service.setMessageIsRead(messageId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取蓝牙设备Mac
|
||||
*/
|
||||
|
||||
@@ -490,7 +490,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
*/
|
||||
private fun showDeleteInviteDialog(deleteArray: MutableList<FamilyBean>) {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
val myDeviceDb = MyDatabase.deviceDao().findAll(MyDatabase.DeviceTableName)
|
||||
val myDeviceDb = MyDatabase.deviceDao().findAll(MyDatabase.DEVICE_TABLE)
|
||||
myDeviceDb?.apply {
|
||||
for (deviceDb in myDeviceDb) {
|
||||
for (item in deleteArray) {
|
||||
@@ -501,7 +501,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
}
|
||||
}
|
||||
}
|
||||
val newDeviceDb = MyDatabase.deviceDao().findAll(MyDatabase.DeviceTableName)
|
||||
val newDeviceDb = MyDatabase.deviceDao().findAll(MyDatabase.DEVICE_TABLE)
|
||||
newDeviceDb?.apply {
|
||||
LogUtil.e("删去了邀请,还剩${newDeviceDb.size}下个设备")
|
||||
}
|
||||
|
||||
@@ -2,20 +2,17 @@ package com.abbidot.tracker.ui.activity.account
|
||||
|
||||
import android.view.View
|
||||
import androidx.activity.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
|
||||
import com.abbidot.baselibrary.util.LogUtil
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.adapter.NotificationV2Adapter
|
||||
import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.bean.MessageBean
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.GetResultCallback
|
||||
import com.abbidot.tracker.database.MyDatabase
|
||||
import com.abbidot.tracker.databinding.ActivityNotificationV2Binding
|
||||
import com.abbidot.tracker.deprecated.ui.activity.vm.NotificationsViewModel
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.util.ViewUtil
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import com.qmuiteam.qmui.widget.pullLayout.QMUIPullLayout
|
||||
|
||||
/**
|
||||
* 消息列表
|
||||
@@ -27,100 +24,142 @@ class NotificationV2Activity :
|
||||
|
||||
private lateinit var mMessageAdapter: NotificationV2Adapter
|
||||
|
||||
private var mPage = 1
|
||||
private var mPullAction: QMUIPullLayout.PullAction? = null
|
||||
private var mReadMessageId = ""
|
||||
|
||||
override fun getTopBar() = mViewBinding.notificationV2DetailBar.titleTopBar
|
||||
|
||||
override fun initData() {
|
||||
super.initData()
|
||||
setTopBarTitle(R.string.txt_notifications)
|
||||
|
||||
mMessageAdapter = NotificationV2Adapter(mContext, null).apply {
|
||||
mMessageAdapter = NotificationV2Adapter(mContext, mutableListOf()).apply {
|
||||
setOnItemClickListener(object : BaseRecyclerAdapter.OnItemClickListener {
|
||||
override fun onItemClick(itemView: View?, pos: Int) {
|
||||
val message = getItem(pos)
|
||||
message.isSelect = !message.isSelect
|
||||
if (!message.isRead) {
|
||||
message.isRead = true
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
MyDatabase.messageDao().insert(message)
|
||||
// XEventBus.post(EventName.RefreshMessage)
|
||||
}
|
||||
}
|
||||
notifyItemChanged(pos)
|
||||
mReadMessageId = message.messageId
|
||||
mNotificationsViewModel.setMessageIsRead(mReadMessageId)
|
||||
}
|
||||
})
|
||||
}
|
||||
ViewUtil.instance.setRecyclerViewDecorationLinearLayoutManager(
|
||||
mContext, mViewBinding.rvNotificationV2Detail, mMessageAdapter
|
||||
)
|
||||
setOnClickListenerViews(mViewBinding.btnNotificationV2ReadAll)
|
||||
mViewBinding.apply {
|
||||
ViewUtil.instance.setRecyclerViewDecorationLinearLayoutManager(
|
||||
mContext, ilNotificationV2MessageLayout.pullRefreshAndLoadMoreRv, mMessageAdapter
|
||||
)
|
||||
ilNotificationV2MessageLayout.pullRefreshAndLoadMoreLayout.let {
|
||||
it.setActionListener { pullAction ->
|
||||
mPullAction = pullAction
|
||||
if (pullAction.pullEdge == QMUIPullLayout.PULL_EDGE_TOP) {
|
||||
mPage = 1
|
||||
mNotificationsViewModel.messageListByPage(mPage)
|
||||
} else if (pullAction.pullEdge == QMUIPullLayout.PULL_EDGE_BOTTOM) {
|
||||
mPage++
|
||||
mNotificationsViewModel.messageListByPage(mPage)
|
||||
}
|
||||
}
|
||||
}
|
||||
setOnClickListenerViews(btnNotificationV2ReadAll)
|
||||
}
|
||||
|
||||
mNotificationsViewModel.getMessageList()
|
||||
mNotificationsViewModel.messageListByPage(mPage)
|
||||
}
|
||||
|
||||
override fun liveDataObserve() {
|
||||
mNotificationsViewModel.mNotificationsLiveData.observe(this) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
it.getOrNull()?.apply {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
Util.dealMessage(this@apply)
|
||||
setMessageData()
|
||||
mNotificationsViewModel.apply {
|
||||
mNotificationsLiveData.observe(this@NotificationV2Activity) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
mPullAction?.let { p ->
|
||||
mViewBinding.ilNotificationV2MessageLayout.pullRefreshAndLoadMoreLayout.finishActionRun(
|
||||
p
|
||||
)
|
||||
}
|
||||
it.getOrNull()?.apply {
|
||||
setMessageData(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
setMessageData()
|
||||
}
|
||||
}, isShowRequestErrorTip = false)
|
||||
}
|
||||
}
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
mPullAction?.let { p ->
|
||||
mViewBinding.ilNotificationV2MessageLayout.pullRefreshAndLoadMoreLayout.finishActionRun(
|
||||
p
|
||||
)
|
||||
if (p.pullEdge == QMUIPullLayout.PULL_EDGE_BOTTOM) mPage--
|
||||
}
|
||||
}
|
||||
|
||||
private fun setMessageData() {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
MyDatabase.messageDao().findAll(MyDatabase.MessageTableName)?.apply {
|
||||
LogUtil.e("消息列表个数:${size}")
|
||||
//按最新时间排序
|
||||
val sortedByList = this.sortedByDescending { it.sendTime }
|
||||
runOnUiThread {
|
||||
mMessageAdapter.setData(sortedByList.toMutableList(), true)
|
||||
}
|
||||
// for (i in sortedByList){
|
||||
// LogUtil.e(i.messageId+":"+i.message)
|
||||
// }
|
||||
override fun onErrorCode() {
|
||||
mPullAction?.let { p ->
|
||||
mViewBinding.ilNotificationV2MessageLayout.pullRefreshAndLoadMoreLayout.finishActionRun(
|
||||
p
|
||||
)
|
||||
if (p.pullEdge == QMUIPullLayout.PULL_EDGE_BOTTOM) mPage--
|
||||
}
|
||||
}
|
||||
}, isShowRequestErrorTip = false)
|
||||
}
|
||||
mReadMessageLiveData.observe(this@NotificationV2Activity) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
val list = mMessageAdapter.getData()
|
||||
for (i in 0 until list.size) {
|
||||
val l = list[i]
|
||||
if (mReadMessageId == l.messageId) {
|
||||
l.isRead = ConstantInt.Type1
|
||||
mMessageAdapter.notifyItemChanged(i)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
mReadAllMessageLiveData.observe(this@NotificationV2Activity) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
val list = mMessageAdapter.getData()
|
||||
var isRefresh = false
|
||||
for (l in list) {
|
||||
if (l.isRead == ConstantInt.Type0) {
|
||||
l.isRead = ConstantInt.Type1
|
||||
isRefresh = true
|
||||
}
|
||||
}
|
||||
if (isRefresh) mMessageAdapter.notifyItemChanged(0, list.size)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun readAllMessage() {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
MyDatabase.messageDao().findAll(MyDatabase.MessageTableName)?.apply {
|
||||
var isUpdate = false
|
||||
for (message in this) {
|
||||
if (!message.isRead) {
|
||||
message.isRead = true
|
||||
isUpdate = true
|
||||
MyDatabase.messageDao().insert(message)
|
||||
}
|
||||
}
|
||||
runOnUiThread {
|
||||
val list = mMessageAdapter.getData()
|
||||
for (m in list) {
|
||||
if (!m.isRead) {
|
||||
m.isRead = true
|
||||
}
|
||||
}
|
||||
mMessageAdapter.notifyItemRangeChanged(0, list.size)
|
||||
}
|
||||
// if (isUpdate) XEventBus.post(EventName.RefreshMessage)
|
||||
private fun setMessageData(list: MutableList<MessageBean>) {
|
||||
val messageList = mMessageAdapter.getData()
|
||||
if (null == mPullAction) {
|
||||
messageList.addAll(list)
|
||||
mMessageAdapter.notifyItemRangeInserted(
|
||||
messageList.size - list.size, messageList.size
|
||||
)
|
||||
}
|
||||
mPullAction?.apply {
|
||||
if (pullEdge == QMUIPullLayout.PULL_EDGE_TOP) {
|
||||
mMessageAdapter.notifyItemRangeRemoved(0, messageList.size)
|
||||
messageList.clear()
|
||||
messageList.addAll(list)
|
||||
mMessageAdapter.notifyItemRangeInserted(0, messageList.size)
|
||||
} else {
|
||||
messageList.addAll(list)
|
||||
mMessageAdapter.notifyItemRangeInserted(
|
||||
messageList.size - list.size, messageList.size
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
if (isLimitClick()) return
|
||||
mViewBinding.apply {
|
||||
when (v!!) {
|
||||
btnNotificationV2ReadAll -> readAllMessage()
|
||||
btnNotificationV2ReadAll -> mNotificationsViewModel.setMessageAllIsRead()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ class AddNewTracker3Activity :
|
||||
mScanDeviceAdapter = ScanDeviceAdapter(mContext, mutableListOf()).apply {
|
||||
setOnItemClickListener(object : BaseRecyclerAdapter.OnItemClickListener {
|
||||
override fun onItemClick(itemView: View?, pos: Int) {
|
||||
mViewBinding.ivAddNewTracker3RefreshBtn.isEnabled = false
|
||||
if (isConnect) return
|
||||
SRBleUtil.instance.cancelBleScan("AddNewTracker2Activity,开始连接蓝牙,取消蓝牙扫描")
|
||||
disconnectBle()
|
||||
@@ -106,6 +107,10 @@ class AddNewTracker3Activity :
|
||||
startActivity(intent)
|
||||
} else if (ble.conState == ConState.CONNECTION_FAIL) {
|
||||
setNoConnectState()
|
||||
mViewBinding.ivAddNewTracker3RefreshBtn.isEnabled = true
|
||||
}
|
||||
else{
|
||||
mViewBinding.ivAddNewTracker3RefreshBtn.isEnabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,12 +140,14 @@ class AddNewTracker3Activity :
|
||||
|
||||
override fun onErrorCode() {
|
||||
super.onErrorCode()
|
||||
mViewBinding.ivAddNewTracker3RefreshBtn.isEnabled = true
|
||||
setNoConnectState()
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
super.onRequestError(exceptionCode)
|
||||
setNoConnectState()
|
||||
mViewBinding.ivAddNewTracker3RefreshBtn.isEnabled = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class DeleteTracker1Activity :
|
||||
MyDatabase.deviceDao().deleteByParams(
|
||||
ConstantString.DeviceId,
|
||||
device.deviceId,
|
||||
MyDatabase.DeviceTableName
|
||||
MyDatabase.DEVICE_TABLE
|
||||
)
|
||||
runOnUiThread {
|
||||
showDeleteDialog()
|
||||
|
||||
@@ -166,7 +166,7 @@ class DeleteTracker2Activity :
|
||||
MyDatabase.deviceDao().deleteByParams(
|
||||
ConstantString.DeviceId,
|
||||
device.deviceId,
|
||||
MyDatabase.DeviceTableName
|
||||
MyDatabase.DEVICE_TABLE
|
||||
)
|
||||
runOnUiThread {
|
||||
showDeleteDialog()
|
||||
|
||||
@@ -172,7 +172,7 @@ class MyTrackerV2Activity :
|
||||
MyDatabase.deviceDao().deleteByParams(
|
||||
ConstantString.DeviceId,
|
||||
device.deviceId,
|
||||
MyDatabase.DeviceTableName
|
||||
MyDatabase.DEVICE_TABLE
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -275,7 +275,7 @@ class MyTrackerV2Activity :
|
||||
MyDatabase.deviceDao().deleteByParams(
|
||||
ConstantString.DeviceId,
|
||||
device.deviceId,
|
||||
MyDatabase.DeviceTableName
|
||||
MyDatabase.DEVICE_TABLE
|
||||
)
|
||||
}
|
||||
mUnAssignDeviceList.clear()
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.abbidot.tracker.ui.activity.device.wifi
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Intent
|
||||
import android.text.TextUtils
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.animation.LinearInterpolator
|
||||
@@ -21,7 +22,6 @@ import com.abbidot.tracker.databinding.ActivityAddWifiPowerZone1Binding
|
||||
import com.abbidot.tracker.ui.activity.HomeV2Activity
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.util.ViewUtil
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
||||
import com.abbidot.tracker.vm.ConnectionDeviceViewModel
|
||||
import com.clj.fastble.BleManager
|
||||
|
||||
@@ -85,19 +85,25 @@ class AddWifiPowerZone1Activity :
|
||||
//接收蓝牙连接状态
|
||||
XEventBus.observe(this, EventName.ConnectDeviceState) { ble: BleTrackDeviceBean ->
|
||||
showLoading(false)
|
||||
mViewBinding.ilAddWifiZone1BluetoothTips.trbBleConnectState.let { view ->
|
||||
val bgColor = if (ble.conState == ConState.CONNECTED) {
|
||||
mPetBean?.macID = ble.mac
|
||||
ViewUtil.instance.viewShowFadeInAnimation(mViewBinding.btnAddWifiZone1Next)
|
||||
view.text = getString(R.string.tracker_manage_set_ble_connect)
|
||||
ContextCompat.getColor(mContext, R.color.cyan_color1)
|
||||
} else {
|
||||
ViewUtil.instance.viewHideFadeInAnimation(mViewBinding.btnAddWifiZone1Next)
|
||||
view.text = getString(R.string.tracker_manage_set_ble_unconnect)
|
||||
ContextCompat.getColor(mContext, R.color.red_color4)
|
||||
mPetBean?.apply {
|
||||
if (TextUtils.isEmpty(macID)) macID = ble.mac
|
||||
if (macID == ble.mac) {
|
||||
mViewBinding.ilAddWifiZone1BluetoothTips.trbBleConnectState.let { view ->
|
||||
val bgColor = if (ble.conState == ConState.CONNECTED) {
|
||||
ViewUtil.instance.viewShowFadeInAnimation(mViewBinding.btnAddWifiZone1Next)
|
||||
view.text = getString(R.string.tracker_manage_set_ble_connect)
|
||||
ContextCompat.getColor(mContext, R.color.cyan_color1)
|
||||
} else {
|
||||
ViewUtil.instance.viewHideFadeInAnimation(mViewBinding.btnAddWifiZone1Next)
|
||||
view.text = getString(R.string.tracker_manage_set_ble_unconnect)
|
||||
ContextCompat.getColor(mContext, R.color.red_color4)
|
||||
}
|
||||
view.setBackgroundColor(bgColor)
|
||||
ViewUtil.instance.bleConStateToast(
|
||||
this@AddWifiPowerZone1Activity, ble.conState, Gravity.CENTER
|
||||
)
|
||||
}
|
||||
}
|
||||
view.setBackgroundColor(bgColor)
|
||||
ViewUtil.instance.bleConStateToast(this, ble.conState, Gravity.CENTER)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -710,25 +710,25 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
|
||||
mViewBinding.let {
|
||||
if (deviceType == ConstantInt.Type2) {
|
||||
it.ilLiveV2BluetoothFindDevice.ilLiveV2RadarLightSwitch.tvDeviceLightSwitchTitle.text =
|
||||
getString(R.string.txt_light)
|
||||
getString(R.string.txt_tone)
|
||||
it.ilLiveV2BluetoothFindDevice.ilLiveV2RadarLightSwitch.tvDeviceLightSwitchTitle.setCompoundDrawablesWithIntrinsicBounds(
|
||||
R.drawable.icon_light_svg, 0, 0, 0
|
||||
R.drawable.icon_sound_image, 0, 0, 0
|
||||
)
|
||||
it.ilLiveV2OperateLayout.ilLiveV2DataLightSwitch.tvDeviceLightSwitchTitle.text =
|
||||
getString(R.string.txt_light)
|
||||
getString(R.string.txt_tone)
|
||||
it.ilLiveV2OperateLayout.ilLiveV2DataLightSwitch.tvDeviceLightSwitchTitle.setCompoundDrawablesWithIntrinsicBounds(
|
||||
R.drawable.icon_light_svg, 0, 0, 0
|
||||
R.drawable.icon_sound_image, 0, 0, 0
|
||||
)
|
||||
} else {
|
||||
it.ilLiveV2BluetoothFindDevice.ilLiveV2RadarLightSwitch.tvDeviceLightSwitchTitle.text =
|
||||
getString(R.string.txt_tone)
|
||||
getString(R.string.txt_light)
|
||||
it.ilLiveV2BluetoothFindDevice.ilLiveV2RadarLightSwitch.tvDeviceLightSwitchTitle.setCompoundDrawablesWithIntrinsicBounds(
|
||||
R.drawable.icon_sound_image, 0, 0, 0
|
||||
R.drawable.icon_light_svg, 0, 0, 0
|
||||
)
|
||||
it.ilLiveV2OperateLayout.ilLiveV2DataLightSwitch.tvDeviceLightSwitchTitle.text =
|
||||
getString(R.string.txt_tone)
|
||||
getString(R.string.txt_light)
|
||||
it.ilLiveV2OperateLayout.ilLiveV2DataLightSwitch.tvDeviceLightSwitchTitle.setCompoundDrawablesWithIntrinsicBounds(
|
||||
R.drawable.icon_sound_image, 0, 0, 0
|
||||
R.drawable.icon_light_svg, 0, 0, 0
|
||||
)
|
||||
}
|
||||
isLedOpen = ledSwitch == ConstantInt.Open
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.abbidot.tracker.ui.activity.subscribe
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.text.InputFilter
|
||||
import android.text.InputFilter.LengthFilter
|
||||
import android.text.InputType
|
||||
@@ -24,7 +22,6 @@ import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.util.ViewUtil
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
||||
class AddCreditCardPaymentActivity :
|
||||
@@ -218,7 +215,7 @@ class AddCreditCardPaymentActivity :
|
||||
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
|
||||
val list = MyDatabase.creditCardDao().findAll(MyDatabase.CreditCardTableName)
|
||||
val list = MyDatabase.creditCardDao().findAll(MyDatabase.CREDIT_CARD_TABLE)
|
||||
var existCard: CreditCardBean? = null
|
||||
list?.apply {
|
||||
if (isNotEmpty()) {
|
||||
|
||||
@@ -481,7 +481,11 @@ class HomeTrackFragment :
|
||||
ViewUtil.instance.addMenuBean(
|
||||
mTrackMenuList, getString(R.string.tracker_manage_set_duration)
|
||||
)
|
||||
ViewUtil.instance.addMenuBean(mTrackMenuList, getString(R.string.txt_live_duration))
|
||||
if (deviceType == ConstantInt.Type2) {
|
||||
ViewUtil.instance.addMenuBean(
|
||||
mTrackMenuList, getString(R.string.txt_live_duration)
|
||||
)
|
||||
}
|
||||
ViewUtil.instance.addMenuBean(
|
||||
mTrackMenuList,
|
||||
getString(R.string.txt_firmware_version),
|
||||
|
||||
@@ -586,9 +586,9 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
//隐藏蓝牙nearby
|
||||
mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE
|
||||
mViewBinding.homeMapLiveBtn.visibility = View.GONE
|
||||
mViewBinding.ivHomeMapBleConState.setImageResource(R.drawable.icon_map_offline)
|
||||
mViewBinding.llHomeMapDeviceBatteryLayout.visibility = View.INVISIBLE
|
||||
mViewBinding.ilHomeMapPetLocation.root.visibility = View.INVISIBLE
|
||||
mViewBinding.ivHomeMapBleConState.setImageResource(R.drawable.icon_map_offline)
|
||||
isCanLive = false
|
||||
setRefreshLocationBtnState()
|
||||
|
||||
@@ -625,6 +625,15 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
*/
|
||||
private fun setMapData(mapDeviceBean: MapDeviceBean) {
|
||||
mapDeviceBean.apply {
|
||||
|
||||
getHomeV2Activity()?.let {
|
||||
it.getPet(false)?.let { pet ->
|
||||
if (SRBleUtil.instance.isMacConnect(pet.macID)) {
|
||||
mViewBinding.ivHomeMapBleConState.setImageResource(R.drawable.icon_map_online)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setMapDeviceBean(this)
|
||||
//设置循环查询时间间隔 30秒
|
||||
// mMapViewModel.updateMillisInFuture(0.5f)
|
||||
|
||||
@@ -6,7 +6,6 @@ import android.view.View
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.abbidot.baselibrary.util.AppUtils
|
||||
import com.abbidot.baselibrary.util.LogUtil
|
||||
@@ -14,16 +13,12 @@ import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.adapter.ViewPagerAdapter
|
||||
import com.abbidot.tracker.base.BaseFragment
|
||||
import com.abbidot.tracker.constant.GetResultCallback
|
||||
import com.abbidot.tracker.database.MyDatabase
|
||||
import com.abbidot.tracker.databinding.FragmentPetV2Binding
|
||||
import com.abbidot.tracker.deprecated.ui.activity.vm.NotificationsViewModel
|
||||
import com.abbidot.tracker.ui.activity.HomeV2Activity
|
||||
import com.abbidot.tracker.ui.activity.account.NotificationV2Activity
|
||||
import com.abbidot.tracker.ui.fragment.device.HomeTrackFragment
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.util.ViewUtil
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
/**
|
||||
@@ -101,23 +96,13 @@ class PetV2Fragment : BaseFragment<FragmentPetV2Binding>(FragmentPetV2Binding::i
|
||||
}
|
||||
|
||||
override fun liveDataObserve() {
|
||||
// XEventBus.observe(viewLifecycleOwner, EventName.RefreshMessage) {
|
||||
// getMessageCount()
|
||||
// }
|
||||
mNotificationsViewModel.mNotificationsLiveData.observe(viewLifecycleOwner) {
|
||||
mNotificationsViewModel.mMessageCountLiveData.observe(viewLifecycleOwner) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
it.getOrNull()?.apply {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
Util.dealMessage(this@apply)
|
||||
getMessageCount()
|
||||
}
|
||||
getMessageCount(unReadCount)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
getMessageCount()
|
||||
}
|
||||
}, isRequestErrorTip = false, isShowNoDataTip = false)
|
||||
}
|
||||
}
|
||||
@@ -133,7 +118,7 @@ class PetV2Fragment : BaseFragment<FragmentPetV2Binding>(FragmentPetV2Binding::i
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mNotificationsViewModel.getMessageList()
|
||||
mNotificationsViewModel.getMessageUnReadCount()
|
||||
(mFragments[1] as HomeTrackFragment).onResume()
|
||||
getHomeV2Activity()?.apply {
|
||||
//其他页面是否选择了宠物
|
||||
@@ -157,25 +142,14 @@ class PetV2Fragment : BaseFragment<FragmentPetV2Binding>(FragmentPetV2Binding::i
|
||||
(mFragments[1] as HomeTrackFragment).onPause()
|
||||
}
|
||||
|
||||
private fun getMessageCount() {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
MyDatabase.messageDao().findAll(MyDatabase.MessageTableName)?.apply {
|
||||
var noReadNum = size
|
||||
LogUtil.e("消息数量:${size}")
|
||||
for (message in this) {
|
||||
if (message.isRead) noReadNum--
|
||||
}
|
||||
getHomeV2Activity()?.runOnUiThread {
|
||||
mViewBinding.homePetMessageCountText.let {
|
||||
if (noReadNum > 0) {
|
||||
if (noReadNum > 99) noReadNum = 99
|
||||
it.visibility = View.VISIBLE
|
||||
} else it.visibility = View.GONE
|
||||
it.text = "$noReadNum"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private fun getMessageCount(unReadCount: Long) {
|
||||
var noReadNum = unReadCount
|
||||
mViewBinding.homePetMessageCountText.let {
|
||||
if (unReadCount > 0) {
|
||||
if (unReadCount > 99) noReadNum = 99
|
||||
it.visibility = View.VISIBLE
|
||||
} else it.visibility = View.GONE
|
||||
it.text = "$noReadNum"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class CreditCardPaymentFragment : BaseFragment<FragmentCreditCardPaymentBinding>
|
||||
|
||||
private fun getCardData() {
|
||||
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
|
||||
val list = MyDatabase.creditCardDao().findAll(MyDatabase.CreditCardTableName)
|
||||
val list = MyDatabase.creditCardDao().findAll(MyDatabase.CREDIT_CARD_TABLE)
|
||||
list?.let {
|
||||
mActivity?.runOnUiThread {
|
||||
val sortedByList = list.sortedByDescending { l -> l.isPrimary }.toMutableList()
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.base.BaseDialog
|
||||
import com.abbidot.tracker.bean.BleReportDataBean
|
||||
import com.abbidot.tracker.bean.MapDeviceBean
|
||||
import com.abbidot.tracker.bean.MessageBean
|
||||
import com.abbidot.tracker.bean.UserBean
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
@@ -569,9 +568,8 @@ class Util {
|
||||
//保存最后一次登录的邮箱
|
||||
MMKVUtil.putString(MMKVKey.Email, email)
|
||||
withContext(Dispatchers.IO) {
|
||||
MyDatabase.deviceDao().deleteAll(MyDatabase.DeviceTableName)
|
||||
MyDatabase.messageDao().deleteAll(MyDatabase.MessageTableName)
|
||||
MyDatabase.creditCardDao().deleteAll(MyDatabase.CreditCardTableName)
|
||||
MyDatabase.deviceDao().deleteAll(MyDatabase.DEVICE_TABLE)
|
||||
MyDatabase.creditCardDao().deleteAll(MyDatabase.CREDIT_CARD_TABLE)
|
||||
}
|
||||
activity.startActivityFinish(Intent(activity, SayHelloActivity::class.java))
|
||||
}
|
||||
@@ -601,21 +599,6 @@ class Util {
|
||||
return intent
|
||||
}
|
||||
|
||||
fun dealMessage(serverMessageList: MutableList<MessageBean>) {
|
||||
MyDatabase.messageDao().findAll(MyDatabase.MessageTableName)?.let { messageList ->
|
||||
for (message in serverMessageList) {
|
||||
var isAdd = false
|
||||
for (m in messageList) {
|
||||
if (message.messageId == m.messageId) {
|
||||
isAdd = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!isAdd) MyDatabase.messageDao().insert(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测是否有必要权限和开关
|
||||
*/
|
||||
|
||||
@@ -89,6 +89,7 @@ import com.qmuiteam.qmui.util.QMUIDisplayHelper
|
||||
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet.BottomListSheetBuilder
|
||||
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView
|
||||
import java.util.Calendar
|
||||
import androidx.core.view.isVisible
|
||||
|
||||
|
||||
/**
|
||||
@@ -785,7 +786,7 @@ class ViewUtil private constructor() {
|
||||
*/
|
||||
fun viewShowFadeInAnimation(target: View, duration: Long = 350): YoYoString {
|
||||
return YoYo.with(Techniques.FadeIn).duration(duration).onStart {
|
||||
if (target.visibility == View.GONE || target.visibility == View.INVISIBLE) {
|
||||
if (target.isGone || target.isInvisible) {
|
||||
target.post {
|
||||
target.visibility = View.VISIBLE
|
||||
}
|
||||
@@ -798,7 +799,7 @@ class ViewUtil private constructor() {
|
||||
*/
|
||||
fun viewHideFadeInAnimation(target: View, duration: Long = 350, hideType: Int = View.GONE) {
|
||||
YoYo.with(Techniques.FadeOut).duration(duration).onEnd {
|
||||
if (target.visibility == View.VISIBLE) target.visibility = hideType
|
||||
if (target.isVisible) target.visibility = hideType
|
||||
}.playOn(target)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class ConnectionDeviceViewModel : ViewModel() {
|
||||
}
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val localDevices = MyDatabase.deviceDao()
|
||||
.findAll(MyDatabase.DeviceTableName) as MutableList<DeviceBean>
|
||||
.findAll(MyDatabase.DEVICE_TABLE) as MutableList<DeviceBean>
|
||||
LogUtil.e("查找本地ble设备有${localDevices.size}个")
|
||||
if (localDevices.size == 0) {
|
||||
return@launch
|
||||
|
||||
@@ -34,11 +34,10 @@
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_notification_v2_detail"
|
||||
<include
|
||||
android:id="@+id/il_notification_v2_message_layout"
|
||||
layout="@layout/layout_pull_refresh_and_load_more"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginHorizontal="@dimen/dp_18"
|
||||
android:scrollbars="none" />
|
||||
|
||||
android:layout_marginHorizontal="@dimen/dp_16" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
@@ -3,12 +3,13 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/pull_refresh_and_load_more_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@color/qmui_config_color_white"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/transparent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/pull_refresh_and_load_more_rv"
|
||||
style="@style/recycler_view_bg_style"
|
||||
android:background="@color/transparent"
|
||||
app:qmui_is_target="true" />
|
||||
|
||||
<com.qmuiteam.qmui.widget.pullLayout.QMUIPullRefreshView
|
||||
@@ -18,7 +19,7 @@
|
||||
app:qmui_can_over_pull="true"
|
||||
app:qmui_need_receive_fling_from_target_view="false"
|
||||
app:qmui_pull_edge="top"
|
||||
app:qmui_pull_rate="0.45"
|
||||
app:qmui_pull_rate="0.2"
|
||||
app:qmui_target_view_trigger_offset="wrap" />
|
||||
|
||||
<com.qmuiteam.qmui.widget.pullLayout.QMUIPullLoadMoreView
|
||||
@@ -26,8 +27,10 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:qmui_action_view_init_offset="0dp"
|
||||
app:qmui_can_over_pull="true"
|
||||
app:qmui_need_receive_fling_from_target_view="true"
|
||||
app:qmui_pull_load_more_pull_text="@string/txt_load_more_pull_text"
|
||||
app:qmui_pull_load_more_release_text="@string/txt_load_more_release_text"
|
||||
app:qmui_need_receive_fling_from_target_view="false"
|
||||
app:qmui_pull_edge="bottom"
|
||||
app:qmui_pull_rate="0.45"
|
||||
app:qmui_pull_rate="0.2"
|
||||
app:qmui_target_view_trigger_offset="wrap" />
|
||||
</com.qmuiteam.qmui.widget.pullLayout.QMUIPullLayout>
|
||||
@@ -964,7 +964,6 @@
|
||||
<string name="txt_please_enter_email">请输入邮箱。</string>
|
||||
<string name="txt_wifi_password_dec">当LTE信号弱时,Wi-Fi可确保追踪器保持连接</string>
|
||||
<string name="txt_update_time">更新于:%s</string>
|
||||
|
||||
<string name="txt_as_low_as">低至</string>
|
||||
<string name="txt_show_crash">APP出现异常,即将退出!</string>
|
||||
<string name="txt_system_error">系统异常</string>
|
||||
@@ -973,5 +972,7 @@
|
||||
<string name="txt_tracker_offline">Tracker设备未在线</string>
|
||||
<string name="txt_tracker_live">Tracker启动了Live直播</string>
|
||||
<string name="txt_abnormity">其他异常</string>
|
||||
<string name="txt_load_more_pull_text">上拉加载更多</string>
|
||||
<string name="txt_load_more_release_text">松手加载更多</string>
|
||||
|
||||
</resources>
|
||||
@@ -1070,6 +1070,7 @@
|
||||
<string name="txt_tone">Tone</string>
|
||||
<string name="txt_locate_works">Locate works on cellular only</string>
|
||||
<string name="txt_pet_close">Pet is close, try Radar</string>
|
||||
|
||||
<string name="txt_load_more_pull_text">Pull to load more</string>
|
||||
<string name="txt_load_more_release_text">Release to load</string>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user