消息网关
更新时间:2025-04-01 13:24:21
package com.polaris.iot.appsdk.libplayback
object MsgGateway{
/**
* 根据图片ID获取图片存储地址
*
* @param params [GetPictureReq]
* @param listener [OnResultListener]<[GetPictureRsp]>
*/
fun getPictureById(params: GetPictureReq, listener: OnResultListener<GetPictureRsp>)
}
批量根据图片ID获取图片地址
import com.polaris.iot.appsdk.libplayback.MsgGateway
String picId = editText.getText().toString().trim();
if (TextUtils.isEmpty(picId)) {
showToast("请输入图片ID");
return;
}
MsgGateway.getPictureById(new GetPictureReq(
mDeviceInfo.getIotId(),
List.of(picId),
null
), new OnResultListener<GetPictureRsp>() {
@Override
public void onResult(GetPictureRsp result) {
for (GetPictureRspItem item : result.getPictureList()) {
if (Objects.equals(item.getPictureId(), picId)) {
Glide.with(LivePlayActivity.this).load(item.getPictureUrl()).into(imageView);
return;
}
}
IoTLogger.d(TAG, "getPictureById not match result");
showToast("未获取到图片地址");
}
@Override
public void onError(@NonNull IoTSDKError error) {
IoTLogger.d(TAG, "getPictureById error", error);
showToast("获取图片地址异常");
}
});