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());
}
});
}
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();
}
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, "未知错误"));
}
}
}
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, "权限被拒绝"));
}
}
}
}
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());
}
});
}
}
Aggregations