更新时间:2024-12-26 07:54:57下载pdf
本文介绍如何管理消息内容。
更新消息时,获取指定类型的消息列表。
fun requestMessageListByType(
offset: Int,
limit: Int,
msgType: MessageType,
callback: IThingDataCallback<MessageListBean>?
)
参数说明
参数 | 类型 | 说明 |
---|---|---|
offset | Int | 开始获取消息位置 |
limit | Int | 每页获取的消息数量 |
msgType | MessageType | 获取的消息类型 |
callback | IThingDataCallback<MessageListBean> |
查询结果的回调 |
调用示例
PersonalMessageCore.newThingSmartMessageCore().requestMessageListByType(10, 20, MSG_REPORT, new IThingDataCallback<MessageListBean>() {
@Override
public void onSuccess(MessageListBean result) {
mBeanResult.t.postValue(change(msgType, result, null));
mBeanResult.networkState.postValue(NetworkState.SUCCESS);
}
@Override
public void onError(String errorCode, String errorMessage) {
mBeanResult.networkState.postValue(NetworkState.falied(errorCode,
errorMessage));
}
})
fun getMsgListBySrcIdSplitEncryptImageKey(
offset: Int,
limit: Int,
msgType: Int,
msgSrcId: String?,
encryptImage: Boolean,
splitImageKey: Boolean,
callback: IThingDataCallback<MessageListBean>?
)
参数说明
参数 | 类型 | 说明 |
---|---|---|
offset | Int | 开始获取消息位置 |
limit | Int | 每页获取的消息数量 |
msgType | Int | 获取的消息类型 |
msgSrcId | String | 消息组的唯一标识符 |
encryptImage | Boolean | 是否加密图片 |
splitImageKey | Boolean | 是否需要调用解密接口 |
callback | IThingDataCallback<MessageListBean> |
查询结果的回调 |
调用示例
PersonalMessageCore.newThingSmartMessageCore().getMsgListBySrcIdSplitEncryptImageKey(0, 0, 0, "id", true, true,
mMessageCore.requestMessageListByType(offset, limit, type, new IThingDataCallback<MessageListBean>() {
@Override
public void onSuccess(MessageListBean result) {
mBeanResult.t.postValue(change(msgType, result, null));
mBeanResult.networkState.postValue(NetworkState.SUCCESS);
}
@Override
public void onError(String errorCode, String errorMessage) {
mBeanResult.networkState.postValue(NetworkState.failed(errorCode, errorMessage));
}
});
)
fun requestMessageNew(callback: IThingDataCallback<MessageHasNew?>?)
参数说明
参数 | 类型 | 说明 |
---|---|---|
callback | IThingDataCallback<MessageListBean> |
查询结果的回调 |
调用示例
PersonalMessageCore.newThingSmartMessageCore().requestMessageNew(object : IThingDataCallback<MessageHasNew?> {
override fun onSuccess(messageHasNew: MessageHasNew?) {
if (messageHasNew != null) {
val hasNew = (messageHasNew.isAlarm || messageHasNew.isFamily || messageHasNew.isNotification)
ThingSecurityPreferenceGlobalUtil.set(
PreferencesContants.MESSAGE_ALARM_HAS_NEW,
messageHasNew.isAlarm
)
ThingSecurityPreferenceGlobalUtil.set(
PreferencesContants.MESSAGE_FAMILY_HAS_NEW,
messageHasNew.isFamily
)
ThingSecurityPreferenceGlobalUtil.set(
PreferencesContants.MESSAGE_NOTIFICATION_HAS_NEW,
messageHasNew.isNotification
)
resultSuccess(WHAT_REFRESH, hasNew)
}
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
fun readMessageByIds(
msgType: Int,
msgSrcId: String?,
callback: IThingDataCallback<Boolean>?
)
参数说明
参数 | 类型 | 说明 |
---|---|---|
msgType | Int | 获取的消息类型 |
msgSrcId | String | 消息组的唯一标识符 |
callback | IThingDataCallback<MessageListBean> |
查询结果的回调 |
调用示例
PersonalMessageCore.newThingSmartMessageCore().readMessageByIds(0, "msgSrcId", object : IThingDataCallback<Boolean> {
override fun onSuccess(result: Boolean?) {
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
fun deleteMessageByIds(
msgType: Int,
idList: List<String>?,
msgSrcIdList: List<String>?,
callback: IBooleanCallback?
)
参数说明
参数 | 类型 | 说明 |
---|---|---|
msgType | Int | 获取的消息类型 |
idList | List<String> |
要删除的消息 ID |
msgSrcIdList | List<String> |
要删除的消息来源 ID |
callback | IThingDataCallback<MessageListBean> |
查询结果的回调 |
调用示例
PersonalMessageCore.newThingSmartMessageCore().deleteMessageByIds(0, "id1,id2,id3", "srcId1,srcId2,srcId3", new IBooleanCallback() {
@Override
public void onSuccess() {
mDeleteBeanLiveData.networkState.postValue(NetworkState.SUCCESS);
mDeleteBeanLiveData.t.postValue(true);
}
@Override
public void onError(String code, String error) {
mDeleteBeanLiveData.networkState.postValue(NetworkState.failed(code, error));
}
})
fun getMessageEncryptImageKeyList(
requestList: List<MessageEncryptImageKeyRequest>,
callback: IThingDataCallback<List<MessageEncryptImageKeyBean>>
)
参数说明
参数 | 类型 | 说明 |
---|---|---|
requestList | List<MessageEncryptImageKeyRequest> |
消息加密图像密钥的请求列表 |
callback | IThingDataCallback<List<MessageEncryptImageKeyBean>> |
查询结果的回调 |
调用示例
PersonalMessageCore.newThingSmartMessageCore().getMessageEncryptImageKeyList(requestList,
new IThingDataCallback<List<MessageEncryptImageKeyBean>>() {
@Override
public void onSuccess(List<MessageEncryptImageKeyBean> keyBeans) {
mBeanResult.t.postValue(change(0, result, keyBeans));
mBeanResult.networkState.postValue(NetworkState.SUCCESS);
}
@Override
public void onError(String errorCode, String errorMessage) {
mBeanResult.t.postValue(change(0, result, null));
mBeanResult.networkState.postValue(NetworkState.SUCCESS);
}
})
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈