im::floo::floolib::BMXImageAttachment
图片消息附件
Inherits from im.floo.floolib.BMXFileAttachment, im.floo.floolib.BMXMessageAttachment, BMXBaseObject
Public Functions
Name | |
---|---|
synchronized void | delete() |
BMXImageAttachment(String path, BMXMessageAttachment.Size size, String displayName) 构造函数,构建发送图片消息附件 |
|
BMXImageAttachment(String path, BMXMessageAttachment.Size size) | |
BMXImageAttachment(String ratelUrl, BMXMessageAttachment.Size size, String displayName, long fileLength) 构造函数,构建接收图片消息附件 |
|
BMXMessageAttachment.Type | type() 返回图片附件类型 |
BMXMessageAttachment | clone() 克隆函数 |
BMXMessageAttachment.Size | size() 图片大小 |
String | thumbnailUrl() |
void | setThumbnail(String path) 设置发送图片消息缩略图 |
String | thumbnailPath() 缩略图本地路径 |
BMXMessageAttachment.DownloadStatus | thumbnailDownloadStatus() 缩略图下载状态 |
BMXImageAttachment | dynamic_cast(BMXMessageAttachment attachment) |
Protected Functions
Name | |
---|---|
BMXImageAttachment(long cPtr, boolean cMemoryOwn) | |
void | finalize() |
long | getCPtr(BMXImageAttachment obj) |
Additional inherited members
Public Functions inherited from im.floo.floolib.BMXFileAttachment
Name | |
---|---|
BMXFileAttachment(String path, String displayName) 构造函数,构建发送文件消息附件 |
|
BMXFileAttachment(String path) | |
BMXFileAttachment(String ratelUrl, String displayName, long fileLength) 构造函数,构建接收文件消息附件 |
|
String | path() 本地路径 |
String | displayName() 显示名 |
String | ratelUrl() |
String | url() 远程URL |
long | fileLength() 文件长度 |
BMXMessageAttachment.DownloadStatus | downloadStatus() 附件下载状态 |
Protected Functions inherited from im.floo.floolib.BMXFileAttachment
Name | |
---|---|
BMXFileAttachment(long cPtr, boolean cMemoryOwn) |
Protected Functions inherited from im.floo.floolib.BMXMessageAttachment
Name | |
---|---|
BMXMessageAttachment(long cPtr, boolean cMemoryOwn) |
Public Functions Documentation
function delete
inline synchronized void delete()
Reimplements: im::floo::floolib::BMXFileAttachment::delete
Example:
function BMXImageAttachment
inline BMXImageAttachment(
String path,
BMXMessageAttachment.Size size,
String displayName
)
构造函数,构建发送图片消息附件
Parameters:
- path 本地路径
- size 图片的大小,宽度和高度
- displayName 展示名
Example:
function BMXImageAttachment
inline BMXImageAttachment(
String path,
BMXMessageAttachment.Size size
)
Example:
function BMXImageAttachment
inline BMXImageAttachment(
String ratelUrl,
BMXMessageAttachment.Size size,
String displayName,
long fileLength
)
构造函数,构建接收图片消息附件
Parameters:
- ratelUrl ratel服务器地址
- size 图片的大小,宽度和高度
- displayName 展示名
- fileLength 文件大小
Example:
function type
inline BMXMessageAttachment.Type type()
返回图片附件类型
Return: Type
Reimplements: im::floo::floolib::BMXFileAttachment::type
Example:
function clone
inline BMXMessageAttachment clone()
克隆函数
Return: BMXMessageAttachmentPtr
Reimplements: im::floo::floolib::BMXFileAttachment::clone
Example:
function size
inline BMXMessageAttachment.Size size()
图片大小
Return: Size
Example:
BMImageLoader.getInstance().display(mImageView, "");
return;
}
final BMXImageAttachment body = BMXImageAttachment.dynamic_cast(mMaxMessage.attachment());
if (body == null) {
BMImageLoader.getInstance().display(mImageView, "");
return;
}
RelativeLayout.LayoutParams imgLayoutParams = null;
String imgWidth = null, imgHeight = null;
BMXImageAttachment.Size size = body.size();
if (size != null) {
imgWidth = String.valueOf(size.getMWidth());
imgHeight = String.valueOf(size.getMHeight());
}
double maxLength = ScreenUtils.widthPixels * 0.5;
double minLength = ScreenUtils.widthPixels * 0.5 * 0.5;
if (!TextUtils.isEmpty(imgWidth) && !TextUtils.isEmpty(imgHeight)) {
double limitDiff = maxLength / minLength;
double diff = 0;
String text = mBmxMessage.content();
if (!TextUtils.isEmpty(text)) {
messageBean.setContent(text);
return messageBean;
}
return null;
}
if (contentType == BMXMessage.ContentType.Image) {
// 图片
BMXImageAttachment body = BMXImageAttachment.dynamic_cast(mBmxMessage.attachment());
if (body == null || body.size() == null || TextUtils.isEmpty(body.path())) {
return null;
}
int w = (int)body.size().getMWidth();
int h = (int)body.size().getMHeight();
messageBean.setPath(body.path());
messageBean.setW(w);
messageBean.setH(h);
return messageBean;
return messageBean;
}
return null;
}
if (contentType == BMXMessage.ContentType.Image) {
// 图片
BMXImageAttachment body = BMXImageAttachment.dynamic_cast(mBmxMessage.attachment());
if (body == null || body.size() == null || TextUtils.isEmpty(body.path())) {
return null;
}
int w = (int)body.size().getMWidth();
int h = (int)body.size().getMHeight();
messageBean.setPath(body.path());
messageBean.setW(w);
messageBean.setH(h);
return messageBean;
}
if (contentType == BMXMessage.ContentType.Voice) {
// 语音
BMXVoiceAttachment body = BMXVoiceAttachment.dynamic_cast(mBmxMessage.attachment());
}
return null;
}
if (contentType == BMXMessage.ContentType.Image) {
// 图片
BMXImageAttachment body = BMXImageAttachment.dynamic_cast(mBmxMessage.attachment());
if (body == null || body.size() == null || TextUtils.isEmpty(body.path())) {
return null;
}
int w = (int)body.size().getMWidth();
int h = (int)body.size().getMHeight();
messageBean.setPath(body.path());
messageBean.setW(w);
messageBean.setH(h);
return messageBean;
}
if (contentType == BMXMessage.ContentType.Voice) {
// 语音
BMXVoiceAttachment body = BMXVoiceAttachment.dynamic_cast(mBmxMessage.attachment());
if (body == null || TextUtils.isEmpty(body.path())) {
function thumbnailUrl
inline String thumbnailUrl()
Example:
(int)(maxLength * 3 / 4));
}
mImageView.setLayoutParams(imgLayoutParams);
String picUrl = null;
if (!TextUtils.isEmpty(body.thumbnailPath()) && new File(body.thumbnailPath()).exists()) {
picUrl = "file://" + body.thumbnailPath();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
picUrl = "file://" + body.path();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else if (!TextUtils.isEmpty(body.thumbnailUrl())) {
picUrl = body.thumbnailUrl();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else if (!TextUtils.isEmpty(body.url())) {
picUrl = body.url();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else {
BMImageLoader.getInstance().display(mImageView, "", mImageConfig);
ChatManager.getInstance().downloadAttachment(mMaxMessage);
}
mImageView.setLayoutParams(imgLayoutParams);
String picUrl = null;
if (!TextUtils.isEmpty(body.thumbnailPath()) && new File(body.thumbnailPath()).exists()) {
picUrl = "file://" + body.thumbnailPath();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
picUrl = "file://" + body.path();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else if (!TextUtils.isEmpty(body.thumbnailUrl())) {
picUrl = body.thumbnailUrl();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else if (!TextUtils.isEmpty(body.url())) {
picUrl = body.url();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else {
BMImageLoader.getInstance().display(mImageView, "", mImageConfig);
ChatManager.getInstance().downloadAttachment(mMaxMessage);
}
showImageProgress();
private void registerListener() {
if (mMaxMessage == null) {
return;
}
boolean register = false;
BMXImageAttachment body = BMXImageAttachment.dynamic_cast(mMaxMessage.attachment());
boolean notExit = body != null
&& (TextUtils.isEmpty(body.path()) || !new File(body.path()).exists());
if (body != null
&& (!TextUtils.isEmpty(body.thumbnailUrl()) || !TextUtils.isEmpty(body.url()))) {
// 有缩略图 不需要下载
notExit = false;
}
long msgId = mMaxMessage.msgId();
if (mItemPos == ITEM_RIGHT) {
BMXMessage.DeliveryStatus sendStatus = mMaxMessage.deliveryStatus();
register = sendStatus != null && sendStatus != BMXMessage.DeliveryStatus.Deliveried
&& sendStatus != BMXMessage.DeliveryStatus.Failed || notExit;
} else if (mItemPos == ITEM_LEFT) {
register = notExit;
}
BMXImageAttachment body = BMXImageAttachment.dynamic_cast(bean.attachment());
if (body == null) {
return;
}
String picUrl = null;
if (!TextUtils.isEmpty(body.thumbnailPath()) && new File(body.thumbnailPath()).exists()) {
picUrl = body.thumbnailPath();
} else if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
picUrl = body.path();
} else if (!TextUtils.isEmpty(body.thumbnailUrl())) {
picUrl = body.thumbnailUrl();
} else if (!TextUtils.isEmpty(body.url())) {
picUrl = body.url();
}
if (TextUtils.isEmpty(picUrl)) {
// 正在下载
return;
}
List<PhotoViewBean> photoViewBeans = new ArrayList<>();
BMXImageAttachment body = BMXImageAttachment.dynamic_cast(bean.attachment());
if (body == null) {
return;
}
String picUrl = null;
if (!TextUtils.isEmpty(body.thumbnailPath()) && new File(body.thumbnailPath()).exists()) {
picUrl = body.thumbnailPath();
} else if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
picUrl = body.path();
} else if (!TextUtils.isEmpty(body.thumbnailUrl())) {
picUrl = body.thumbnailUrl();
} else if (!TextUtils.isEmpty(body.url())) {
picUrl = body.url();
}
if (TextUtils.isEmpty(picUrl)) {
// 正在下载
return;
}
List<PhotoViewBean> photoViewBeans = new ArrayList<>();
PhotoViewBean photoViewBean = new PhotoViewBean();
picUrl = body.url();
}
if (TextUtils.isEmpty(picUrl)) {
// 正在下载
return;
}
List<PhotoViewBean> photoViewBeans = new ArrayList<>();
PhotoViewBean photoViewBean = new PhotoViewBean();
photoViewBean.setLocalPath(body.path());
photoViewBean.setThumbLocalPath(body.thumbnailPath());
photoViewBean.setThumbHttpUrl(body.thumbnailUrl());
photoViewBean.setHttpUrl(body.url());
photoViewBean.setMsgId(bean.msgId());
photoViewBeans.add(photoViewBean);
PhotoViewListBean listBean = new PhotoViewListBean();
listBean.setPhotoViewBeans(photoViewBeans);
PhotoDetailActivity.openPhotoDetail(mView.getContext(), listBean);
function setThumbnail
inline void setThumbnail(
String path
)
设置发送图片消息缩略图
Parameters:
- path 本地路径
Example:
function thumbnailPath
inline String thumbnailPath()
缩略图本地路径
Return: std::string
Example:
imgLayoutParams = new RelativeLayout.LayoutParams((int)minLength, (int)maxLength);
}
}
} else {
// 宽高比超过标准宽高比 按标准展示
imgLayoutParams = new RelativeLayout.LayoutParams((int)maxLength,
(int)(maxLength * 3 / 4));
}
mImageView.setLayoutParams(imgLayoutParams);
String picUrl = null;
if (!TextUtils.isEmpty(body.thumbnailPath()) && new File(body.thumbnailPath()).exists()) {
picUrl = "file://" + body.thumbnailPath();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
picUrl = "file://" + body.path();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else if (!TextUtils.isEmpty(body.thumbnailUrl())) {
picUrl = body.thumbnailUrl();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else if (!TextUtils.isEmpty(body.url())) {
}
}
} else {
// 宽高比超过标准宽高比 按标准展示
imgLayoutParams = new RelativeLayout.LayoutParams((int)maxLength,
(int)(maxLength * 3 / 4));
}
mImageView.setLayoutParams(imgLayoutParams);
String picUrl = null;
if (!TextUtils.isEmpty(body.thumbnailPath()) && new File(body.thumbnailPath()).exists()) {
picUrl = "file://" + body.thumbnailPath();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
picUrl = "file://" + body.path();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else if (!TextUtils.isEmpty(body.thumbnailUrl())) {
picUrl = body.thumbnailUrl();
BMImageLoader.getInstance().display(mImageView, picUrl, mImageConfig);
} else if (!TextUtils.isEmpty(body.url())) {
picUrl = body.url();
private void onImageItemClick(final BMXMessage bean) {
if (mView == null || bean == null || bean.contentType() != BMXMessage.ContentType.Image) {
return;
}
BMXImageAttachment body = BMXImageAttachment.dynamic_cast(bean.attachment());
if (body == null) {
return;
}
String picUrl = null;
if (!TextUtils.isEmpty(body.thumbnailPath()) && new File(body.thumbnailPath()).exists()) {
picUrl = body.thumbnailPath();
} else if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
picUrl = body.path();
} else if (!TextUtils.isEmpty(body.thumbnailUrl())) {
picUrl = body.thumbnailUrl();
} else if (!TextUtils.isEmpty(body.url())) {
picUrl = body.url();
}
if (TextUtils.isEmpty(picUrl)) {
// 正在下载
private void onImageItemClick(final BMXMessage bean) {
if (mView == null || bean == null || bean.contentType() != BMXMessage.ContentType.Image) {
return;
}
BMXImageAttachment body = BMXImageAttachment.dynamic_cast(bean.attachment());
if (body == null) {
return;
}
String picUrl = null;
if (!TextUtils.isEmpty(body.thumbnailPath()) && new File(body.thumbnailPath()).exists()) {
picUrl = body.thumbnailPath();
} else if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
picUrl = body.path();
} else if (!TextUtils.isEmpty(body.thumbnailUrl())) {
picUrl = body.thumbnailUrl();
} else if (!TextUtils.isEmpty(body.url())) {
picUrl = body.url();
}
if (TextUtils.isEmpty(picUrl)) {
// 正在下载
} else if (!TextUtils.isEmpty(body.url())) {
picUrl = body.url();
}
if (TextUtils.isEmpty(picUrl)) {
// 正在下载
return;
}
List<PhotoViewBean> photoViewBeans = new ArrayList<>();
PhotoViewBean photoViewBean = new PhotoViewBean();
photoViewBean.setLocalPath(body.path());
photoViewBean.setThumbLocalPath(body.thumbnailPath());
photoViewBean.setThumbHttpUrl(body.thumbnailUrl());
photoViewBean.setHttpUrl(body.url());
photoViewBean.setMsgId(bean.msgId());
photoViewBeans.add(photoViewBean);
PhotoViewListBean listBean = new PhotoViewListBean();
listBean.setPhotoViewBeans(photoViewBeans);
PhotoDetailActivity.openPhotoDetail(mView.getContext(), listBean);
function thumbnailDownloadStatus
inline BMXMessageAttachment.DownloadStatus thumbnailDownloadStatus()
缩略图下载状态
Return: DownloadStatus
Example:
function dynamic_cast
static inline BMXImageAttachment dynamic_cast(
BMXMessageAttachment attachment
)
Reimplements: im::floo::floolib::BMXFileAttachment::dynamic_cast
Protected Functions Documentation
Example:
private void showPic() {
registerListener();
if (mMaxMessage == null || mMaxMessage.contentType() != BMXMessage.ContentType.Image) {
BMImageLoader.getInstance().display(mImageView, "");
return;
}
final BMXImageAttachment body = BMXImageAttachment.dynamic_cast(mMaxMessage.attachment());
if (body == null) {
BMImageLoader.getInstance().display(mImageView, "");
return;
}
RelativeLayout.LayoutParams imgLayoutParams = null;
String imgWidth = null, imgHeight = null;
BMXImageAttachment.Size size = body.size();
if (size != null) {
imgWidth = String.valueOf(size.getMWidth());
imgHeight = String.valueOf(size.getMHeight());
}
double maxLength = ScreenUtils.widthPixels * 0.5;
double minLength = ScreenUtils.widthPixels * 0.5 * 0.5;
private void registerListener() {
if (mMaxMessage == null) {
return;
}
boolean register = false;
BMXImageAttachment body = BMXImageAttachment.dynamic_cast(mMaxMessage.attachment());
boolean notExit = body != null
&& (TextUtils.isEmpty(body.path()) || !new File(body.path()).exists());
if (body != null
&& (!TextUtils.isEmpty(body.thumbnailUrl()) || !TextUtils.isEmpty(body.url()))) {
// 有缩略图 不需要下载
notExit = false;
}
long msgId = mMaxMessage.msgId();
if (mItemPos == ITEM_RIGHT) {
BMXMessage.DeliveryStatus sendStatus = mMaxMessage.deliveryStatus();
register = sendStatus != null && sendStatus != BMXMessage.DeliveryStatus.Deliveried
&& sendStatus != BMXMessage.DeliveryStatus.Failed || notExit;
} else if (mItemPos == ITEM_LEFT) {
register = notExit;
private void onImageItemClick(final BMXMessage bean) {
if (mView == null || bean == null || bean.contentType() != BMXMessage.ContentType.Image) {
return;
}
BMXImageAttachment body = BMXImageAttachment.dynamic_cast(bean.attachment());
if (body == null) {
return;
}
String picUrl = null;
if (!TextUtils.isEmpty(body.thumbnailPath()) && new File(body.thumbnailPath()).exists()) {
picUrl = body.thumbnailPath();
} else if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
picUrl = body.path();
} else if (!TextUtils.isEmpty(body.thumbnailUrl())) {
picUrl = body.thumbnailUrl();
} else if (!TextUtils.isEmpty(body.url())) {
picUrl = body.url();
}
if (TextUtils.isEmpty(picUrl)) {
// 正在下载
if (contentType == BMXMessage.ContentType.Text) {
String text = mBmxMessage.content();
if (!TextUtils.isEmpty(text)) {
messageBean.setContent(text);
return messageBean;
}
return null;
}
if (contentType == BMXMessage.ContentType.Image) {
// 图片
BMXImageAttachment body = BMXImageAttachment.dynamic_cast(mBmxMessage.attachment());
if (body == null || body.size() == null || TextUtils.isEmpty(body.path())) {
return null;
}
int w = (int)body.size().getMWidth();
int h = (int)body.size().getMHeight();
messageBean.setPath(body.path());
messageBean.setW(w);
messageBean.setH(h);
return messageBean;
function BMXImageAttachment
inline BMXImageAttachment(
long cPtr,
boolean cMemoryOwn
)
Example:
function finalize
inline void finalize()
Reimplements: im::floo::floolib::BMXFileAttachment::finalize
Example:
function getCPtr
static inline long getCPtr(
BMXImageAttachment obj
)
Example:
Updated on 2022-01-26 at 17:18:31 +0800