Search in sources :

Example 21 with JSONObject

use of com.alibaba.fastjson.JSONObject in project weex-example by KalicyZhou.

the class WXMetaModule method setViewport.

@JSMethod(uiThread = false)
public void setViewport(String param) {
    if (!TextUtils.isEmpty(param)) {
        try {
            param = URLDecoder.decode(param, "utf-8");
            JSONObject jsObj = JSON.parseObject(param);
            if (DEVICE_WIDTH.endsWith(jsObj.getString(WIDTH))) {
                mWXSDKInstance.setViewPortWidth(WXViewUtils.getScreenWidth(mWXSDKInstance.getContext()));
            } else {
                int width = jsObj.getInteger(WIDTH);
                if (width > 0) {
                    mWXSDKInstance.setViewPortWidth(width);
                }
            }
        } catch (Exception e) {
            WXLogUtils.e("[WXModalUIModule] alert param parse error ", e);
        }
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 22 with JSONObject

use of com.alibaba.fastjson.JSONObject in project weex-example by KalicyZhou.

the class WXModalUIModule method alert.

@JSMethod(uiThread = true)
public void alert(String param, final JSCallback callback) {
    if (mWXSDKInstance.getContext() instanceof Activity) {
        String message = "";
        String okTitle = OK;
        if (!TextUtils.isEmpty(param)) {
            try {
                param = URLDecoder.decode(param, "utf-8");
                JSONObject jsObj = JSON.parseObject(param);
                message = jsObj.getString(MESSAGE);
                okTitle = jsObj.getString(OK_TITLE);
            } catch (Exception e) {
                WXLogUtils.e("[WXModalUIModule] alert param parse error ", e);
            }
        }
        if (TextUtils.isEmpty(message)) {
            message = "";
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(mWXSDKInstance.getContext());
        builder.setMessage(message);
        final String okTitle_f = TextUtils.isEmpty(okTitle) ? OK : okTitle;
        builder.setPositiveButton(okTitle_f, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (callback != null) {
                    callback.invoke(okTitle_f);
                }
            }
        });
        AlertDialog alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(false);
        alertDialog.show();
        tracking(alertDialog);
    } else {
        WXLogUtils.e("[WXModalUIModule] when call alert mWXSDKInstance.getContext() must instanceof Activity");
    }
}
Also used : AlertDialog(android.app.AlertDialog) JSONObject(com.alibaba.fastjson.JSONObject) DialogInterface(android.content.DialogInterface) Activity(android.app.Activity) OnClickListener(android.content.DialogInterface.OnClickListener) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 23 with JSONObject

use of com.alibaba.fastjson.JSONObject in project weex-example by KalicyZhou.

the class WXModalUIModule method confirm.

@JSMethod(uiThread = true)
public void confirm(String param, final JSCallback callback) {
    if (mWXSDKInstance.getContext() instanceof Activity) {
        String message = "";
        String okTitle = OK;
        String cancelTitle = CANCEL;
        if (!TextUtils.isEmpty(param)) {
            try {
                param = URLDecoder.decode(param, "utf-8");
                JSONObject jsObj = JSON.parseObject(param);
                message = jsObj.getString(MESSAGE);
                okTitle = jsObj.getString(OK_TITLE);
                cancelTitle = jsObj.getString(CANCEL_TITLE);
            } catch (Exception e) {
                WXLogUtils.e("[WXModalUIModule] confirm param parse error ", e);
            }
        }
        if (TextUtils.isEmpty(message)) {
            message = "";
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(mWXSDKInstance.getContext());
        builder.setMessage(message);
        final String okTitleFinal = TextUtils.isEmpty(okTitle) ? OK : okTitle;
        final String cancelTitleFinal = TextUtils.isEmpty(cancelTitle) ? CANCEL : cancelTitle;
        builder.setPositiveButton(okTitleFinal, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (callback != null) {
                    callback.invoke(okTitleFinal);
                }
            }
        });
        builder.setNegativeButton(cancelTitleFinal, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (callback != null) {
                    callback.invoke(cancelTitleFinal);
                }
            }
        });
        AlertDialog alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(false);
        alertDialog.show();
        tracking(alertDialog);
    } else {
        WXLogUtils.e("[WXModalUIModule] when call confirm mWXSDKInstance.getContext() must instanceof Activity");
    }
}
Also used : AlertDialog(android.app.AlertDialog) JSONObject(com.alibaba.fastjson.JSONObject) DialogInterface(android.content.DialogInterface) Activity(android.app.Activity) OnClickListener(android.content.DialogInterface.OnClickListener) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 24 with JSONObject

use of com.alibaba.fastjson.JSONObject 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();
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 25 with JSONObject

use of com.alibaba.fastjson.JSONObject in project weex-example by KalicyZhou.

the class WXSDKInstance method setSize.

public void setSize(int width, int height) {
    if (width < 0 || height < 0 || isDestroy || !mRendered) {
        return;
    }
    float realWidth = WXViewUtils.getWebPxByWidth(width, getViewPortWidth());
    float realHeight = WXViewUtils.getWebPxByWidth(height, getViewPortWidth());
    View godView = mRenderContainer;
    if (godView != null) {
        ViewGroup.LayoutParams layoutParams = godView.getLayoutParams();
        if (layoutParams != null) {
            if (godView.getWidth() != width || godView.getHeight() != height) {
                layoutParams.width = width;
                layoutParams.height = height;
                godView.setLayoutParams(layoutParams);
            }
            JSONObject style = new JSONObject();
            WXComponent rootComponent = mRootComp;
            if (rootComponent == null) {
                return;
            }
            style.put(Constants.Name.DEFAULT_WIDTH, realWidth);
            style.put(Constants.Name.DEFAULT_HEIGHT, realHeight);
            updateRootComponentStyle(style);
        }
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) WXComponent(com.taobao.weex.ui.component.WXComponent) ViewGroup(android.view.ViewGroup) View(android.view.View) WXScrollView(com.taobao.weex.ui.view.WXScrollView) ScrollView(android.widget.ScrollView)

Aggregations

JSONObject (com.alibaba.fastjson.JSONObject)1750 HashMap (java.util.HashMap)302 JSONArray (com.alibaba.fastjson.JSONArray)279 Test (org.junit.Test)217 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)182 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)165 IOException (java.io.IOException)138 ArrayList (java.util.ArrayList)125 Map (java.util.Map)111 AuthPassport (com.ngtesting.platform.util.AuthPassport)96 UserVo (com.ngtesting.platform.vo.UserVo)76 Date (java.util.Date)76 List (java.util.List)72 File (java.io.File)70 UnitResponse (info.xiancloud.core.message.UnitResponse)61 JSONException (com.alibaba.fastjson.JSONException)46 StringEntity (org.apache.http.entity.StringEntity)46 HttpResponse (org.apache.http.HttpResponse)44 Header (org.apache.http.Header)36 DefaultJSONParser (com.alibaba.fastjson.parser.DefaultJSONParser)30