Search in sources :

Example 1 with BaseResultBean

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

the class DefaultNavigationAdapter method setCenterItem.

public static void setCenterItem(String params, final JSCallback jscallback) {
    ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
    NavigatorBarModel navigatorBarModel = parseManager.parseObject(params, NavigatorBarModel.class);
    BaseToolBar navigationBar = getToolBar();
    if (navigationBar == null)
        return;
    setTextView(navigationBar.getTitleTextView(), navigatorBarModel);
    if (jscallback != null)
        navigationBar.setOnTitleListenner(new BaseToolBar.OnTitleClick() {

            @Override
            public void onClick(View v) {
                jscallback.invokeAndKeepAlive(new BaseResultBean());
            }
        });
}
Also used : BaseResultBean(com.benmu.framework.model.BaseResultBean) NavigatorBarModel(com.benmu.framework.model.NavigatorBarModel) BaseToolBar(com.benmu.widget.view.BaseToolBar) ParseManager(com.benmu.framework.manager.impl.ParseManager) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with BaseResultBean

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

the class EventShare method downLoadResource.

private void downLoadResource(final Context context, final RelayBean bean, final int type) {
    List<String> urls = bean.getUrls();
    if (urls == null || urls.size() < 1) {
        if (mFailedCallback != null) {
            mFailedCallback.invoke(new BaseResultBean(WeChatRelayUtil.ERROR_ILLEGALARGUMENT, "参数有误"));
        }
        return;
    }
    List<String> safeUrls = new ArrayList<>();
    for (String url : urls) {
        Uri parse = Uri.parse(url);
        if (!TextUtils.isEmpty(parse.getScheme()) && !TextUtils.isEmpty(parse.getHost())) {
            safeUrls.add(url);
        }
    }
    if (safeUrls.size() < 1) {
        if (mFailedCallback != null) {
            mFailedCallback.invoke(new BaseResultBean(WeChatRelayUtil.ERROR_ILLEGALARGUMENT, "参数有误"));
        }
        return;
    }
    ModalManager.BmLoading.showLoading(context, "资源下载中", false);
    new MultipleFileDownloader(FileManager.getTempFilePath(context).getAbsolutePath(), safeUrls).setOnFinshListener(new MultipleFileDownloader.onDownloadFinish() {

        @Override
        public void onFinish(List<MultipleFileDownloader.FileItem> pathList, List<MultipleFileDownloader.FileItem> errorList) {
            ModalManager.BmLoading.dismissLoading(context);
            if (pathList.size() < 1) {
                if (mFailedCallback != null) {
                    mFailedCallback.invoke(new BaseResultBean(WeChatRelayUtil.ERROR_DOWNLOAD, "下载失败"));
                }
                return;
            }
            List<MultipleFileDownloader.FileItem> files = new ArrayList<>();
            if (WeChatRelayUtil.MEDIA_VIDEO.equals(bean.getMediaType())) {
                files.add(pathList.get(0));
            } else if (WeChatRelayUtil.MEDIA_IMAGE.equals(bean.getMediaType())) {
                files.clear();
                files.addAll(pathList);
            } else {
                if (mFailedCallback != null) {
                    mFailedCallback.invoke(new BaseResultBean(WeChatRelayUtil.ERROR_UNSUPPORT_MT, "不支持的媒体类型"));
                }
                return;
            }
            ArrayList<Uri> uris = new ArrayList<Uri>();
            for (MultipleFileDownloader.FileItem s : files) {
                Uri uri = ResourceUtil.getSafeUri(context, s.getPath(), s.getName());
                uris.add(uri);
            }
            if (ACTION_FRIEND == type) {
                WeChatRelayUtil.relayToFriend(context, bean.getDescription(), uris, bean.getMediaType(), mSuccessCallback, mFailedCallback);
            } else if (ACTION_CRICLE == type) {
                WeChatRelayUtil.relayToCircle(context, bean.getDescription(), uris, bean.getMediaType(), mSuccessCallback, mFailedCallback);
            }
        }
    }).execute();
}
Also used : BaseResultBean(com.benmu.framework.model.BaseResultBean) ArrayList(java.util.ArrayList) MultipleFileDownloader(com.benmu.framework.utils.MultipleFileDownloader) ArrayList(java.util.ArrayList) List(java.util.List) Uri(android.net.Uri)

Example 3 with BaseResultBean

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

the class WeChatRelayUtil method relayToFriend.

public static void relayToFriend(Context context, String content, ArrayList<Uri> uris, String type, JSCallback success, JSCallback failed) {
    Intent localIntent = new Intent();
    localIntent.setComponent(new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools" + ".ShareImgUI"));
    localIntent.putExtra("Kdescription", content);
    if (MEDIA_VIDEO.equals(type)) {
        localIntent.setAction(Intent.ACTION_SEND);
        localIntent.setType("video/*");
        localIntent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
    } else if (MEDIA_IMAGE.equals(type)) {
        localIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
        localIntent.setType("image/*");
        localIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    } else if (MEDIA_TEXT.equals(type)) {
        localIntent.setAction(Intent.ACTION_SEND);
        localIntent.setType("text/plain");
        localIntent.putExtra(Intent.EXTRA_TEXT, content);
        localIntent.putExtra("Kdescription", content);
    }
    try {
        context.startActivity(localIntent);
        if (success != null) {
            success.invoke(new BaseResultBean(WeChatRelayUtil.RELAY_SUCCESS, "分享成功"));
        }
    } catch (Exception e) {
        e.printStackTrace();
        if (failed != null) {
            failed.invoke(new BaseResultBean(ERROR_UNKOWN, "未知错误"));
        }
    }
}
Also used : BaseResultBean(com.benmu.framework.model.BaseResultBean) Intent(android.content.Intent) ComponentName(android.content.ComponentName) URISyntaxException(java.net.URISyntaxException)

Example 4 with BaseResultBean

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

the class WeChatRelayUtil method relayToCircle.

public static void relayToCircle(final Context context, String content, ArrayList<Uri> uris, String type, final JSCallback success, JSCallback failed) {
    if (MEDIA_IMAGE.equals(type)) {
        final Intent localIntent = new Intent();
        localIntent.setComponent(new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools" + ".ShareToTimeLineUI"));
        localIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
        localIntent.setType("image/*");
        localIntent.putExtra("Kdescription", content);
        localIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        context.startActivity(localIntent);
        if (success != null) {
            success.invoke(new BaseResultBean(WeChatRelayUtil.RELAY_SUCCESS, "分享成功"));
        }
    } else if (MEDIA_VIDEO.equals(type)) {
        // 检查内存卡权限
        PermissionManager permissionManager = ManagerFactory.getManagerService(PermissionManager.class);
        if (permissionManager.hasPermissions(context, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
            execute(context, content, uris, type, success, failed);
        } else {
            // 没有权限
            ModalManager.BmToast.toast(context, "访问外部存储卡权限被拒绝,请到设置页面开启后再试", Toast.LENGTH_SHORT);
            if (failed != null) {
                failed.invoke(new BaseResultBean(ERROR_PERMISSION, "权限被拒绝"));
            }
        }
    }
}
Also used : BaseResultBean(com.benmu.framework.model.BaseResultBean) PermissionManager(com.benmu.framework.manager.impl.PermissionManager) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 5 with BaseResultBean

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

the class DefaultNavigationAdapter method setRightItem.

public static void setRightItem(String params, final JSCallback jscallback) {
    ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
    NavigatorBarModel navigatorBarModel = parseManager.parseObject(params, NavigatorBarModel.class);
    BaseToolBar navigationBar = getToolBar();
    if (navigationBar == null)
        return;
    setTextView(navigationBar.getRightText(), navigatorBarModel);
    if (!TextUtils.isEmpty(navigatorBarModel.getImage())) {
        setImage(BMWXEnvironment.mApplicationContext, navigatorBarModel.getImage(), navigationBar.getRightIcon());
    }
    if (jscallback != null) {
        navigationBar.setOnRightListenner(new BaseToolBar.OnRightIconClick() {

            @Override
            public void onClick(View v) {
                jscallback.invokeAndKeepAlive(new BaseResultBean());
            }
        });
    }
}
Also used : BaseResultBean(com.benmu.framework.model.BaseResultBean) NavigatorBarModel(com.benmu.framework.model.NavigatorBarModel) BaseToolBar(com.benmu.widget.view.BaseToolBar) ParseManager(com.benmu.framework.manager.impl.ParseManager) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

BaseResultBean (com.benmu.framework.model.BaseResultBean)10 ParseManager (com.benmu.framework.manager.impl.ParseManager)6 View (android.view.View)4 ImageView (android.widget.ImageView)4 TextView (android.widget.TextView)4 NavigatorBarModel (com.benmu.framework.model.NavigatorBarModel)4 BaseToolBar (com.benmu.widget.view.BaseToolBar)4 ComponentName (android.content.ComponentName)3 Intent (android.content.Intent)3 Uri (android.net.Uri)2 RelayBean (com.benmu.framework.model.RelayBean)2 URISyntaxException (java.net.URISyntaxException)2 Handler (android.os.Handler)1 PermissionManager (com.benmu.framework.manager.impl.PermissionManager)1 MultipleFileDownloader (com.benmu.framework.utils.MultipleFileDownloader)1 File (java.io.File)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1