Search in sources :

Example 1 with RelayBean

use of com.benmu.framework.model.RelayBean in project WeexErosFramework by bmfe.

the class EventShare method relayToFriend.

public void relayToFriend(Context context, String params, ArrayList<JSCallback> callbacks) {
    mSuccessCallback = callbacks.get(0);
    mFailedCallback = callbacks.get(1);
    if (context == null || TextUtils.isEmpty(params)) {
        if (mFailedCallback != null) {
            mFailedCallback.invoke(new BaseResultBean(WeChatRelayUtil.ERROR_ILLEGALARGUMENT, "参数有误"));
        }
        return;
    }
    // 参数有误
    ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
    RelayBean object = parseManager.parseObject(params, RelayBean.class);
    if (object == null) {
        if (mFailedCallback != null) {
            mFailedCallback.invoke(new BaseResultBean(WeChatRelayUtil.ERROR_ILLEGALARGUMENT, "参数有误"));
        }
        return;
    }
    // 参数有误
    if (!WeChatRelayUtil.PLATFORM_WECHAT.equals(object.getPlatform())) {
        if (mFailedCallback != null) {
            mFailedCallback.invoke(new BaseResultBean(WeChatRelayUtil.ERROR_UNSUPPORT_PLATFORM, "不支持的平台"));
        }
        return;
    }
    // 不支持的平台
    // 粘贴描述到剪切板
    String description = object.getDescription();
    if (!TextUtils.isEmpty(description) && !WeChatRelayUtil.MEDIA_TEXT.equals(object.getMediaType())) {
        BaseCommonUtil.copyString(context, object.getDescription());
        if (!TextUtils.isEmpty(object.getClipboardNotice())) {
            ModalManager.BmToast.toast(context, object.getClipboardNotice(), Toast.LENGTH_SHORT);
        }
    }
    if (WeChatRelayUtil.MEDIA_TEXT.equals(object.getMediaType())) {
        WeChatRelayUtil.relayToFriend(context, object.getDescription(), null, object.getMediaType(), mSuccessCallback, mFailedCallback);
    } else {
        downLoadResource(context, object, ACTION_FRIEND);
    }
}
Also used : RelayBean(com.benmu.framework.model.RelayBean) BaseResultBean(com.benmu.framework.model.BaseResultBean) ParseManager(com.benmu.framework.manager.impl.ParseManager)

Example 2 with RelayBean

use of com.benmu.framework.model.RelayBean in project WeexErosFramework by bmfe.

the class EventShare method relayToCricle.

public void relayToCricle(Context context, String params, ArrayList<JSCallback> callbacks) {
    mSuccessCallback = callbacks.get(0);
    mFailedCallback = callbacks.get(1);
    if (context == null || TextUtils.isEmpty(params)) {
        if (mFailedCallback != null) {
            mFailedCallback.invoke(new BaseResultBean(WeChatRelayUtil.ERROR_ILLEGALARGUMENT, "参数有误"));
        }
        return;
    }
    ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
    RelayBean object = parseManager.parseObject(params, RelayBean.class);
    if (object == null) {
        if (mFailedCallback != null) {
            mFailedCallback.invoke(new BaseResultBean(WeChatRelayUtil.ERROR_ILLEGALARGUMENT, "参数有误"));
        }
        return;
    }
    if (!WeChatRelayUtil.PLATFORM_WECHAT.equals(object.getPlatform())) {
        if (mFailedCallback != null) {
            mFailedCallback.invoke(new BaseResultBean(WeChatRelayUtil.ERROR_UNSUPPORT_PLATFORM, "不支持的平台"));
        }
        return;
    }
    // 不支持的平台
    if (WeChatRelayUtil.MEDIA_VIDEO.equals(object.getMediaType())) {
        // 粘贴描述到剪切板
        String description = object.getDescription();
        if (!TextUtils.isEmpty(description)) {
            BaseCommonUtil.copyString(context, object.getDescription());
            if (!TextUtils.isEmpty(object.getClipboardNotice())) {
                ModalManager.BmToast.toast(context, object.getClipboardNotice(), Toast.LENGTH_SHORT);
            }
        }
    }
    // 下载视频或图片
    downLoadResource(context, object, ACTION_CRICLE);
}
Also used : RelayBean(com.benmu.framework.model.RelayBean) BaseResultBean(com.benmu.framework.model.BaseResultBean) ParseManager(com.benmu.framework.manager.impl.ParseManager)

Aggregations

ParseManager (com.benmu.framework.manager.impl.ParseManager)2 BaseResultBean (com.benmu.framework.model.BaseResultBean)2 RelayBean (com.benmu.framework.model.RelayBean)2