Search in sources :

Example 56 with JSMethod

use of com.taobao.weex.annotation.JSMethod in project weex-example by KalicyZhou.

the class WXServiceModule method fetch.

@JSMethod(uiThread = true)
public void fetch(Map params, final JSCallback callback) {
    this.jsCallback = callback;
    Map attr = (Map) params.get("attr");
    attr.put("datatype", "json/xml");
    BXDataManager.getInstance().st.getServiceAgent().callService(JSON.toJSONString(params), this, "fetchCallBack");
}
Also used : Map(java.util.Map) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 57 with JSMethod

use of com.taobao.weex.annotation.JSMethod in project weex-example by KalicyZhou.

the class SyncTestModule method getObject.

/**
     * JSON NOT allow KeyValue  as  non-string value
     * @return
     */
@JSMethod(uiThread = false)
public Object getObject() {
    ArrayList list = new ArrayList();
    list.add("222");
    list.add("test");
    Map map = new HashMap();
    map.put(11, "test11");
    map.put("22", "test22");
    list.add(map);
    return list;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 58 with JSMethod

use of com.taobao.weex.annotation.JSMethod in project weex-example by KalicyZhou.

the class SyncTestModule method getArray.

@JSMethod(uiThread = false)
public ArrayList getArray() {
    ArrayList list = new ArrayList();
    list.add("ArrayList test 1");
    list.add("ArrayList test 2");
    return list;
}
Also used : ArrayList(java.util.ArrayList) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 59 with JSMethod

use of com.taobao.weex.annotation.JSMethod in project weex-example by KalicyZhou.

the class WXEventModule method openURL.

@JSMethod(uiThread = true)
public void openURL(String url) {
    if (TextUtils.isEmpty(url)) {
        return;
    }
    String scheme = Uri.parse(url).getScheme();
    StringBuilder builder = new StringBuilder();
    if (TextUtils.equals("http", scheme) || TextUtils.equals("https", scheme) || TextUtils.equals("file", scheme)) {
        builder.append(url);
    } else {
        builder.append("http:");
        builder.append(url);
    }
    Uri uri = Uri.parse(builder.toString());
    Intent intent = new Intent(WEEX_ACTION, uri);
    intent.addCategory(WEEX_CATEGORY);
    mWXSDKInstance.getContext().startActivity(intent);
    if (mWXSDKInstance.checkModuleEventRegistered("event", this)) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("param1", "param1");
        params.put("param2", "param2");
        params.put("param3", "param3");
        mWXSDKInstance.fireModuleEvent("event", this, params);
    }
}
Also used : HashMap(java.util.HashMap) Intent(android.content.Intent) Uri(android.net.Uri) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 60 with JSMethod

use of com.taobao.weex.annotation.JSMethod in project WeexErosFramework by bmfe.

the class AppConfigModule method changeFontSize.

@JSMethod(uiThread = false)
public void changeFontSize(String options, JSCallback jsCallback) {
    initFontSize();
    if (options == null) {
        JsPoster.postSuccess(mFontSizeBean, jsCallback);
        return;
    }
    Object obj = ManagerFactory.getManagerService(ParseManager.class).parseObject(options).get("fontSize");
    if (obj != null && obj instanceof String) {
        String fontSize = (String) obj;
        if (fontSize.equals(mFontSizeBean.fontSize)) {
            JsPoster.postSuccess(mFontSizeBean, jsCallback);
            return;
        }
        mFontSizeBean.fontSize = fontSize;
        Intent intent = new Intent(Constant.Action.ACTION_GOBALFONTSIZE_CHANGE);
        intent.putExtra("currentFontSize", fontSize);
        LocalBroadcastManager.getInstance(mWXSDKInstance.getContext()).sendBroadcast(intent);
        SharePreferenceUtil.setAppFontSizeOption(mWXSDKInstance.getContext(), fontSize);
    }
    JsPoster.postSuccess(mFontSizeBean, jsCallback);
}
Also used : Intent(android.content.Intent) JSMethod(com.taobao.weex.annotation.JSMethod)

Aggregations

JSMethod (com.taobao.weex.annotation.JSMethod)85 WeexEventBean (com.benmu.framework.model.WeexEventBean)50 ArrayList (java.util.ArrayList)13 JSONObject (com.alibaba.fastjson.JSONObject)11 Intent (android.content.Intent)8 HashMap (java.util.HashMap)8 JSCallback (com.taobao.weex.bridge.JSCallback)7 Activity (android.app.Activity)4 EventCenter (com.benmu.framework.event.mediator.EventCenter)4 WXEditText (com.taobao.weex.ui.view.WXEditText)4 Map (java.util.Map)4 AlertDialog (android.app.AlertDialog)3 DialogInterface (android.content.DialogInterface)3 OnClickListener (android.content.DialogInterface.OnClickListener)3 Uri (android.net.Uri)3 EditText (android.widget.EditText)3 JSONException (com.alibaba.fastjson.JSONException)3 LightlyWebSocketAdapter (com.benmu.framework.extend.adapter.LightlyWebSocketAdapter)3 ClipData (android.content.ClipData)2 ClipboardManager (android.content.ClipboardManager)2