im::floo::floolib::BMXImageAttachment

Message picture attachment

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)
Constructor, to build the message attachment of sent picture
BMXImageAttachment(String path, BMXMessageAttachment.Size size)
BMXImageAttachment(String ratelUrl, BMXMessageAttachment.Size size, String displayName, long fileLength)
Constructor, to build the message attachment of received picture
BMXMessageAttachment.Type type()
Return the type of picture attachment
BMXMessageAttachment clone()
Cloning function
BMXMessageAttachment.Size size()
Picture size
String thumbnailUrl()
void setThumbnail(String path)
Set a thumbnail for sent picture
String thumbnailPath()
Local path of thumbnail
BMXMessageAttachment.DownloadStatus thumbnailDownloadStatus()
Thumbnail downloading state
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)
Constructor to build the message attachment of sent file
BMXFileAttachment(String path)
BMXFileAttachment(String ratelUrl, String displayName, long fileLength)
Constructor to build the message attachment of received file
String path()
Local path
String displayName()
Display name
String ratelUrl()
String url()
Remote URL
long fileLength()
File length
BMXMessageAttachment.DownloadStatus downloadStatus()
Attachment download state

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
)

Constructor, to build the message attachment of sent picture

Parameters:

  • path Local path
  • size Size, width, and height of image
  • displayName Display name

Example:

function BMXImageAttachment

inline BMXImageAttachment(
    String path,
    BMXMessageAttachment.Size size
)

Example:

function BMXImageAttachment

inline BMXImageAttachment(
    String ratelUrl,
    BMXMessageAttachment.Size size,
    String displayName,
    long fileLength
)

Constructor, to build the message attachment of received picture

Parameters:

  • ratelUrl ratel server address
  • size Size, width, and height of image
  • displayName Display name
  • fileLength File size

Example:

function type

inline BMXMessageAttachment.Type type()

Return the type of picture attachment

Return: Type

Reimplements: im::floo::floolib::BMXFileAttachment::type

Example:

function clone

inline BMXMessageAttachment clone()

Cloning function

Return: BMXMessageAttachmentPtr

Reimplements: im::floo::floolib::BMXFileAttachment::clone

Example:

function size

inline BMXMessageAttachment.Size size()

Picture 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());
photoViewBeans.add(photoViewBean);
PhotoViewListBean listBean = new PhotoViewListBean();
listBean.setPhotoViewBeans(photoViewBeans);
PhotoDetailActivity.openPhotoDetail(mView.getContext(), listBean);

function setThumbnail

inline void setThumbnail(
    String path
)

Set a thumbnail for sent picture

Parameters:

  • path Local path

Example:

function thumbnailPath

inline String thumbnailPath()

Local path of thumbnail

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());
photoViewBeans.add(photoViewBean);
PhotoViewListBean listBean = new PhotoViewListBean();
listBean.setPhotoViewBeans(photoViewBeans);
PhotoDetailActivity.openPhotoDetail(mView.getContext(), listBean);

function thumbnailDownloadStatus

inline BMXMessageAttachment.DownloadStatus thumbnailDownloadStatus()

Thumbnail downloading state

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

© 2019-2023 MaximTop | Homepage Last modified time: 2023-08-09 14:48:15

results matching ""

    No results matching ""