im::floo::floolib::BMXFileAttachment

消息文件附件

Inherits from im.floo.floolib.BMXMessageAttachment, BMXBaseObject

Inherited by im.floo.floolib.BMXImageAttachment, im.floo.floolib.BMXVideoAttachment, im.floo.floolib.BMXVoiceAttachment

Public Functions

Name
synchronized void delete()
BMXFileAttachment(String path, String displayName)
构造函数,构建发送文件消息附件
BMXFileAttachment(String path)
BMXFileAttachment(String ratelUrl, String displayName, long fileLength)
构造函数,构建接收文件消息附件
BMXMessageAttachment.Type type()
返回文件类型
BMXMessageAttachment clone()
克隆函数
String path()
本地路径
String displayName()
显示名
String ratelUrl()
String url()
远程URL
long fileLength()
文件长度
BMXMessageAttachment.DownloadStatus downloadStatus()
附件下载状态
BMXFileAttachment dynamic_cast(BMXMessageAttachment attachment)

Protected Functions

Name
BMXFileAttachment(long cPtr, boolean cMemoryOwn)
void finalize()
long getCPtr(BMXFileAttachment obj)

Additional inherited members

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::BMXMessageAttachment::delete

Reimplemented by: im::floo::floolib::BMXImageAttachment::delete, im::floo::floolib::BMXVideoAttachment::delete, im::floo::floolib::BMXVoiceAttachment::delete

Example:

function BMXFileAttachment

inline BMXFileAttachment(
    String path,
    String displayName
)

构造函数,构建发送文件消息附件

Parameters:

  • path 文件的本地路径
  • displayName 文件展示名

Example:

function BMXFileAttachment

inline BMXFileAttachment(
    String path
)

Example:

function BMXFileAttachment

inline BMXFileAttachment(
    String ratelUrl,
    String displayName,
    long fileLength
)

构造函数,构建接收文件消息附件

Parameters:

  • ratelUrl ratel服务器地址
  • displayName 文件展示名
  • fileLength 文件大小

Example:

function type

inline BMXMessageAttachment.Type type()

返回文件类型

Return: Type

Reimplements: im::floo::floolib::BMXMessageAttachment::type

Reimplemented by: im::floo::floolib::BMXImageAttachment::type, im::floo::floolib::BMXVideoAttachment::type, im::floo::floolib::BMXVoiceAttachment::type

Example:

function clone

inline BMXMessageAttachment clone()

克隆函数

Return: BMXMessageAttachmentPtr

Reimplements: im::floo::floolib::BMXMessageAttachment::clone

Reimplemented by: im::floo::floolib::BMXImageAttachment::clone, im::floo::floolib::BMXVideoAttachment::clone, im::floo::floolib::BMXVoiceAttachment::clone

Example:

function path

inline String path()

本地路径

Return: std::string

Example:

&& (TextUtils.isEmpty(body.path()) || !new File(body.path()).exists());
private void onFileItemClick(BMXMessage bean) {
    if (mView == null || bean == null || bean.contentType() != BMXMessage.ContentType.File) {
        return;
    }
    final BMXFileAttachment body = BMXFileAttachment.dynamic_cast(bean.attachment());
    if (body == null) {
        return;
    }
    String filePath = null;
    if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
        filePath = body.path();
    } else {
        Log.i(TAG, "local path is null");
    }
    if (!TextUtils.isEmpty(filePath)) {
        openFilePreView(filePath);
        return;
    }
    ToastUtil.showTextViewPrompt(mView.getContext().getString(R.string.downloading));
    BMXMessageAttachment.DownloadStatus status = body.downloadStatus();
private void onFileItemClick(BMXMessage bean) {
    if (mView == null || bean == null || bean.contentType() != BMXMessage.ContentType.File) {
        return;
    }
    final BMXFileAttachment body = BMXFileAttachment.dynamic_cast(bean.attachment());
    if (body == null) {
        return;
    }
    String filePath = null;
    if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
        filePath = body.path();
    } else {
        Log.i(TAG, "local path is null");
    }
    if (!TextUtils.isEmpty(filePath)) {
        openFilePreView(filePath);
        return;
    }
    ToastUtil.showTextViewPrompt(mView.getContext().getString(R.string.downloading));
    BMXMessageAttachment.DownloadStatus status = body.downloadStatus();
    if (body == null || TextUtils.isEmpty(body.path())) {
        return null;
    }
    messageBean.setPath(body.path());
    messageBean.setDuration(body.duration());
    return messageBean;
}
if (contentType == BMXMessage.ContentType.File) {
    // 文件
    BMXFileAttachment body = BMXFileAttachment.dynamic_cast(mBmxMessage.attachment());
    if (body == null || TextUtils.isEmpty(body.path())) {
        return null;
    }
    messageBean.setPath(body.path());
    messageBean.setDisplayName(body.displayName());
    return messageBean;
}
if (contentType == BMXMessage.ContentType.Location) {
    // 地图
    BMXLocationAttachment body = BMXLocationAttachment
    messageBean.setPath(body.path());
    messageBean.setDuration(body.duration());
    return messageBean;
}
if (contentType == BMXMessage.ContentType.File) {
    // 文件
    BMXFileAttachment body = BMXFileAttachment.dynamic_cast(mBmxMessage.attachment());
    if (body == null || TextUtils.isEmpty(body.path())) {
        return null;
    }
    messageBean.setPath(body.path());
    messageBean.setDisplayName(body.displayName());
    return messageBean;
}
if (contentType == BMXMessage.ContentType.Location) {
    // 地图
    BMXLocationAttachment body = BMXLocationAttachment
            .dynamic_cast(mBmxMessage.attachment());
    if (body == null) {
        return null;

function displayName

inline String displayName()

显示名

Return: std::string

Example:

private void showFile() {
    registerListener();
    showFileProgress();
    if (mMaxMessage == null || mMaxMessage.contentType() != BMXMessage.ContentType.File) {
        return;
    }
    BMXFileAttachment body = BMXFileAttachment.dynamic_cast(mMaxMessage.attachment());
    if (body == null) {
        return;
    }
    String title = body.displayName();
    mFileDesc.setText(title);
    messageBean.setDuration(body.duration());
    return messageBean;
}
if (contentType == BMXMessage.ContentType.File) {
    // 文件
    BMXFileAttachment body = BMXFileAttachment.dynamic_cast(mBmxMessage.attachment());
    if (body == null || TextUtils.isEmpty(body.path())) {
        return null;
    }
    messageBean.setPath(body.path());
    messageBean.setDisplayName(body.displayName());
    return messageBean;
}
if (contentType == BMXMessage.ContentType.Location) {
    // 地图
    BMXLocationAttachment body = BMXLocationAttachment
            .dynamic_cast(mBmxMessage.attachment());
    if (body == null) {
        return null;

function ratelUrl

inline String ratelUrl()

Example:

function url

inline String url()

远程URL

Return: std::string

Example:

function fileLength

inline long fileLength()

文件长度

Return: std::string

Example:

function downloadStatus

inline BMXMessageAttachment.DownloadStatus downloadStatus()

附件下载状态

Return: DownloadStatus

Example:

if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
    filePath = body.path();
} else {
    Log.i(TAG, "local path is null");
}
if (!TextUtils.isEmpty(filePath)) {
    openFilePreView(filePath);
    return;
}
ToastUtil.showTextViewPrompt(mView.getContext().getString(R.string.downloading));
BMXMessageAttachment.DownloadStatus status = body.downloadStatus();
if (status == BMXMessageAttachment.DownloadStatus.Downloaing) {
    return;
}
ChatManager.getInstance().downloadAttachment(bean);

function dynamic_cast

static inline BMXFileAttachment dynamic_cast(
    BMXMessageAttachment attachment
)

Reimplemented by: im::floo::floolib::BMXImageAttachment::dynamic_cast, im::floo::floolib::BMXVideoAttachment::dynamic_cast, im::floo::floolib::BMXVoiceAttachment::dynamic_cast

Protected Functions Documentation

Example:

private void showFile() {
    registerListener();
    showFileProgress();
    if (mMaxMessage == null || mMaxMessage.contentType() != BMXMessage.ContentType.File) {
        return;
    }
    BMXFileAttachment body = BMXFileAttachment.dynamic_cast(mMaxMessage.attachment());
    if (body == null) {
        return;
    }
    String title = body.displayName();
    mFileDesc.setText(title);
private void registerListener() {
    if (mMaxMessage == null) {
        return;
    }
    BMXFileAttachment body = BMXFileAttachment.dynamic_cast(mMaxMessage.attachment());
    boolean register = false;
    if (mItemPos == ITEM_RIGHT) {
        BMXMessage.DeliveryStatus sendStatus = mMaxMessage.deliveryStatus();
        register = sendStatus != null && sendStatus != BMXMessage.DeliveryStatus.Deliveried
                && sendStatus != BMXMessage.DeliveryStatus.Failed;
    } else if (mItemPos == ITEM_LEFT) {
        // 对方发送文件 需要在点击时候注册
    }
    long msgId = mMaxMessage.msgId();
    if (register) {
        if (mProgressCache.get(msgId, -1) == -1) {
            mProgressCache.put(msgId, 0);
        }
        ChatAttachmentManager.getInstance().registerListener(msgId, listener);
BMXFileAttachment body = BMXFileAttachment.dynamic_cast(mMaxMessage.attachment());
private void onFileItemClick(BMXMessage bean) {
    if (mView == null || bean == null || bean.contentType() != BMXMessage.ContentType.File) {
        return;
    }
    final BMXFileAttachment body = BMXFileAttachment.dynamic_cast(bean.attachment());
    if (body == null) {
        return;
    }
    String filePath = null;
    if (!TextUtils.isEmpty(body.path()) && new File(body.path()).exists()) {
        filePath = body.path();
    } else {
        Log.i(TAG, "local path is null");
    }
    if (!TextUtils.isEmpty(filePath)) {
        openFilePreView(filePath);
        return;
    }
    ToastUtil.showTextViewPrompt(mView.getContext().getString(R.string.downloading));
    BMXMessageAttachment.DownloadStatus status = body.downloadStatus();
    BMXVoiceAttachment body = BMXVoiceAttachment.dynamic_cast(mBmxMessage.attachment());
    if (body == null || TextUtils.isEmpty(body.path())) {
        return null;
    }
    messageBean.setPath(body.path());
    messageBean.setDuration(body.duration());
    return messageBean;
}
if (contentType == BMXMessage.ContentType.File) {
    // 文件
    BMXFileAttachment body = BMXFileAttachment.dynamic_cast(mBmxMessage.attachment());
    if (body == null || TextUtils.isEmpty(body.path())) {
        return null;
    }
    messageBean.setPath(body.path());
    messageBean.setDisplayName(body.displayName());
    return messageBean;
}
if (contentType == BMXMessage.ContentType.Location) {
    // 地图

function BMXFileAttachment

inline BMXFileAttachment(
    long cPtr,
    boolean cMemoryOwn
)

Example:

function finalize

inline void finalize()

Reimplements: im::floo::floolib::BMXMessageAttachment::finalize

Reimplemented by: im::floo::floolib::BMXImageAttachment::finalize, im::floo::floolib::BMXVideoAttachment::finalize, im::floo::floolib::BMXVoiceAttachment::finalize

Example:

function getCPtr

static inline long getCPtr(
    BMXFileAttachment obj
)

Example:


Updated on 2022-01-26 at 17:18:31 +0800

© 2019-2024 美信拓扑 | 官网 | 网站地图 该文件修订时间: 2024-09-26 03:17:35

results matching ""

    No results matching ""