im::floo::floolib::BMXFileAttachment

Message file attachment

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)
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
BMXMessageAttachment.Type type()
Type of returned file
BMXMessageAttachment clone()
Cloning function
String path()
Local path
String displayName()
Display name
String ratelUrl()
String url()
Remote URL
long fileLength()
File length
BMXMessageAttachment.DownloadStatus downloadStatus()
Attachment download state
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
)

Constructor to build the message attachment of sent file

Parameters:

  • path Local path of file
  • displayName Display name of file

Example:

function BMXFileAttachment

inline BMXFileAttachment(
    String path
)

Example:

function BMXFileAttachment

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

Constructor to build the message attachment of received file

Parameters:

  • ratelUrl ratel server address
  • displayName Display name of file
  • fileLength File size

Example:

function type

inline BMXMessageAttachment.Type type()

Type of returned file

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()

Cloning function

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()

Local 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()

Display name

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()

Remote URL

Return: std::string

Example:

function fileLength

inline long fileLength()

File length

Return: std::string

Example:

function downloadStatus

inline BMXMessageAttachment.DownloadStatus downloadStatus()

Attachment download state

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-2023 MaximTop | Homepage Last modified time: 2023-08-09 14:48:15

results matching ""

    No results matching ""