use of com.taobao.weex.annotation.JSMethod in project weex-example by KalicyZhou.
the class WXModalUIModule method toast.
@JSMethod(uiThread = true)
public void toast(String param) {
String message = "";
int duration = Toast.LENGTH_SHORT;
if (!TextUtils.isEmpty(param)) {
try {
param = URLDecoder.decode(param, "utf-8");
JSONObject jsObj = JSON.parseObject(param);
message = jsObj.getString(MESSAGE);
duration = jsObj.getInteger(DURATION);
} catch (Exception e) {
WXLogUtils.e("[WXModalUIModule] alert param parse error ", e);
}
}
if (TextUtils.isEmpty(message)) {
WXLogUtils.e("[WXModalUIModule] toast param parse is null ");
return;
}
if (duration > 3) {
duration = Toast.LENGTH_LONG;
} else {
duration = Toast.LENGTH_SHORT;
}
if (toast == null) {
toast = Toast.makeText(mWXSDKInstance.getContext(), message, duration);
} else {
toast.setDuration(duration);
toast.setText(message);
}
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
use of com.taobao.weex.annotation.JSMethod in project weex-example by KalicyZhou.
the class WXClipboardModule method getString.
@Override
@JSMethod
public void getString(@Nullable JSCallback callback) {
Context context = mWXSDKInstance.getContext();
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
Map<String, Object> map = new HashMap<>(2);
ClipData clip = clipboard.getPrimaryClip();
if (clip != null && clip.getItemCount() > 0) {
ClipData.Item item = clip.getItemAt(0);
CharSequence text = coerceToText(context, item);
map.put(RESULT, text != null ? RESULT_OK : RESULT_FAILED);
map.put(DATA, text != null ? text : "");
} else {
map.put(RESULT, RESULT_FAILED);
map.put(DATA, "");
}
if (null != callback) {
callback.invoke(map);
}
}
use of com.taobao.weex.annotation.JSMethod in project WeexErosFramework by bmfe.
the class AxiosModule method fetch.
@JSMethod(uiThread = false)
public void fetch(String params, final JSCallback jsCallback) {
WeexEventBean eventBean = new WeexEventBean();
eventBean.setContext(mWXSDKInstance.getContext());
eventBean.setKey(WXConstant.WXEventCenter.EVENT_FETCH);
eventBean.setJsParams(params);
eventBean.setJscallback(jsCallback);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(eventBean);
}
use of com.taobao.weex.annotation.JSMethod in project WeexErosFramework by bmfe.
the class BrowserImgModule method open.
@JSMethod(uiThread = true)
public void open(String json) {
WeexEventBean eventBean = new WeexEventBean();
eventBean.setContext(mWXSDKInstance.getContext());
eventBean.setKey(WXConstant.WXEventCenter.EVENT_BROWSERIMG);
eventBean.setJsParams(json);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(eventBean);
}
use of com.taobao.weex.annotation.JSMethod in project WeexErosFramework by bmfe.
the class CameraModule method uploadScreenshot.
@JSMethod(uiThread = true)
public void uploadScreenshot(JSCallback callback) {
WeexEventBean eventBean = new WeexEventBean();
eventBean.setContext(mWXSDKInstance.getContext());
eventBean.setKey(WXConstant.WXEventCenter.EVENT_CAMERA_UPLOADSCREENSHOT);
eventBean.setJscallback(callback);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(eventBean);
}
Aggregations