Example usage for org.json JSONArray getInt

List of usage examples for org.json JSONArray getInt

Introduction

In this page you can find the example usage for org.json JSONArray getInt.

Prototype

public int getInt(int index) throws JSONException 

Source Link

Document

Get the int value associated with an index.

Usage

From source file:com.liferay.mobile.android.v7.mbthread.MBThreadService.java

public Integer getGroupThreadsCount(long groupId, long userId, int status, boolean subscribed,
        boolean includeAnonymous) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from   www .ja v a 2s.  c  o  m
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("userId", userId);
        _params.put("status", status);
        _params.put("subscribed", subscribed);
        _params.put("includeAnonymous", includeAnonymous);

        _command.put("/mbthread/get-group-threads-count", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getInt(0);
}

From source file:com.liferay.mobile.android.v7.mbthread.MBThreadService.java

public Integer getGroupThreadsCount(long groupId, long userId, int status, boolean subscribed)
        throws Exception {
    JSONObject _command = new JSONObject();

    try {/*w ww .  j a  v  a  2  s.com*/
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("userId", userId);
        _params.put("status", status);
        _params.put("subscribed", subscribed);

        _command.put("/mbthread/get-group-threads-count", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getInt(0);
}

From source file:com.liferay.mobile.android.v7.mbthread.MBThreadService.java

public Integer getGroupThreadsCount(long groupId, long userId, int status) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from   ww w .  j a  v a  2  s.  c  o m
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("userId", userId);
        _params.put("status", status);

        _command.put("/mbthread/get-group-threads-count", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getInt(0);
}

From source file:com.liferay.mobile.android.v7.mbthread.MBThreadService.java

public Integer getGroupThreadsCount(long groupId, long userId, long modifiedDate, int status) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from   www . j a v a 2 s .co  m*/
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("userId", userId);
        _params.put("modifiedDate", modifiedDate);
        _params.put("status", status);

        _command.put("/mbthread/get-group-threads-count", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getInt(0);
}

From source file:com.liferay.mobile.android.v7.mbthread.MBThreadService.java

public Integer getThreadsCount(long groupId, long categoryId, int status) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from   ww w .ja v a2s.c o  m*/
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("categoryId", categoryId);
        _params.put("status", status);

        _command.put("/mbthread/get-threads-count", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getInt(0);
}

From source file:com.breel.wearables.shadowclock.graphics.ShapeShadow.java

public void parseJSON(String jsonFile) {
    if (jsonFile != null) {
        // Load all the JSONs with the numbers information
        try {//from w  w w  .j a va2 s  .  co  m
            JSONObject obj = new JSONObject(loadJSONFromAsset(jsonFile));
            Log.d(TAG, "SHAPE SHADOW JSON FILE " + jsonFile + ": LOADED");

            id = obj.getString("id");

            JSONArray jsonPathData;
            JSONArray jsonShadowData;

            if (!id.equals("5")) {
                jsonPathData = obj.getJSONArray("path");
                jsonShadowData = obj.getJSONArray("shadow");

                Log.d(TAG, "JSON PATH DATA LENGTH: " + jsonPathData.length() + "");
                Log.d(TAG, "JSON SHADOW DATA LENGTH: " + jsonShadowData.length() + "");

                shapePath.reset();
                for (int i = 0; i < jsonPathData.length(); i++) {
                    try {
                        JSONObject elem = jsonPathData.getJSONObject(i);
                        String type = elem.getString("type");
                        JSONArray data = elem.getJSONArray("data");
                        if (type.equals("move")) {
                            shapePath.moveTo((float) data.getInt(0), (float) data.getInt(1));
                        } else if (type.equals("line")) {
                            shapePath.lineTo((float) data.getInt(0), (float) data.getInt(1));
                        } else if (type.equals("bezier")) {
                            shapePath.cubicTo((float) data.getInt(0), (float) data.getInt(1),
                                    (float) data.getInt(2), (float) data.getInt(3), (float) data.getInt(4),
                                    (float) data.getInt(5));
                        }
                    } catch (JSONException e) {
                        Log.d(TAG, "JSON ELEM EXCEPTION" + e.getMessage() + "");
                    }
                }
                shapePath.close();

                Random r = new Random();
                r.nextGaussian();

                JSONArray holesContainer = obj.getJSONArray("holes");
                Path holePath = new Path();
                for (int i = 0; i < holesContainer.length(); i++) {
                    JSONObject jsonInside = holesContainer.getJSONObject(i);
                    JSONArray hole = jsonInside.getJSONArray("data");
                    holePath.reset();
                    for (int j = 0; j < hole.length(); j++) {
                        try {
                            JSONObject elem = hole.getJSONObject(j);
                            String type = elem.getString("type");
                            JSONArray data = elem.getJSONArray("data");
                            if (type.equals("move")) {
                                holePath.moveTo((float) data.getInt(0), (float) data.getInt(1));
                            } else if (type.equals("line")) {
                                holePath.lineTo((float) data.getInt(0), (float) data.getInt(1));
                            } else if (type.equals("bezier")) {
                                holePath.cubicTo((float) data.getInt(0), (float) data.getInt(1),
                                        (float) data.getInt(2), (float) data.getInt(3), (float) data.getInt(4),
                                        (float) data.getInt(5));
                            }
                        } catch (JSONException e) {
                            Log.d(TAG, "JSON HOLE EXCEPTION" + e.getMessage() + "");
                        }
                    }
                    holePath.close();
                    shapePath.op(holePath, Path.Op.DIFFERENCE);
                }

                pathTransform.reset();
                pathTransform.setScale(scale + 0.04f, scale + 0.04f);
                shapePath.transform(pathTransform);
                boundsPath.transform(pathTransform);

                pathTransform.setTranslate(positionX - 0.3f, positionY - 0.3f);
                shapePath.transform(pathTransform);
                boundsPath.transform(pathTransform);

                int shadowTmpX;
                int shadowTmpY;

                shadowPaths.clear();
                vertexArray.clear();

                for (int i = 0; i < jsonShadowData.length(); i += 2) {
                    shadowTmpX = jsonShadowData.getInt(i);
                    shadowTmpY = jsonShadowData.getInt(i + 1);
                    addVertex(shadowTmpX, shadowTmpY);
                }
            } else {
                jsonPathData = obj.getJSONArray("path");
                jsonShadowData = obj.getJSONArray("shadow");

                Log.d(TAG, "JSON PATH DATA LENGTH: " + jsonPathData.length() + "");
                Log.d(TAG, "JSON SHADOW DATA LENGTH: " + jsonShadowData.length() + "");

                shapePath.reset();
                for (int i = 0; i < jsonPathData.length(); i++) {
                    JSONArray cords = jsonPathData.getJSONArray(i);
                    Path chunk = new Path();
                    chunk.reset();
                    for (int j = 0; j < cords.length(); j++) {
                        try {
                            JSONObject elem = cords.getJSONObject(j);
                            String type = elem.getString("type");
                            JSONArray data = elem.getJSONArray("data");
                            if (type.equals("move")) {
                                chunk.moveTo((float) data.getInt(0), (float) data.getInt(1));
                            } else if (type.equals("line")) {
                                chunk.lineTo((float) data.getInt(0), (float) data.getInt(1));
                            } else if (type.equals("bezier")) {
                                chunk.cubicTo((float) data.getInt(0), (float) data.getInt(1),
                                        (float) data.getInt(2), (float) data.getInt(3), (float) data.getInt(4),
                                        (float) data.getInt(5));
                            }
                        } catch (JSONException e) {
                            Log.d(TAG, "JSON 5 NUMBER ELEM EXCEPTION" + e.getMessage() + "");
                        }
                    }
                    chunk.close();
                    shapePath.op(chunk, Path.Op.UNION);
                }

                pathTransform.reset();
                pathTransform.setScale(scale, scale);
                shapePath.transform(pathTransform);
                boundsPath.transform(pathTransform);

                pathTransform.setTranslate(positionX, positionY);
                shapePath.transform(pathTransform);
                boundsPath.transform(pathTransform);

                shadowPaths.clear();
                vertexArray.clear();

                int shadowTmpX;
                int shadowTmpY;
                for (int i = 0; i < jsonShadowData.length(); i++) {
                    JSONArray coords = jsonShadowData.getJSONArray(i);
                    for (int j = 0; j < coords.length(); j += 2) {
                        shadowTmpX = coords.getInt(j);
                        shadowTmpY = coords.getInt(j + 1);
                        addVertex((float) shadowTmpX, (float) shadowTmpY);
                    }

                }
            }
        } catch (JSONException e) {
            Log.d(TAG, "JSON ROOT EXCEPTION" + e.getMessage() + "");
        }
    }
}

From source file:com.liferay.mobile.android.v62.dlapp.DLAppService.java

public Integer getFileEntriesAndFileShortcutsCount(long repositoryId, long folderId, int status)
        throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from  w ww  . ja  v  a 2  s. c  o m*/
        JSONObject _params = new JSONObject();

        _params.put("repositoryId", repositoryId);
        _params.put("folderId", folderId);
        _params.put("status", status);

        _command.put("/dlapp/get-file-entries-and-file-shortcuts-count", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getInt(0);
}

From source file:com.liferay.mobile.android.v62.dlapp.DLAppService.java

public Integer getFileEntriesAndFileShortcutsCount(long repositoryId, long folderId, int status,
        JSONArray mimeTypes) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from   ww  w  .  ja v  a  2  s .c om
        JSONObject _params = new JSONObject();

        _params.put("repositoryId", repositoryId);
        _params.put("folderId", folderId);
        _params.put("status", status);
        _params.put("mimeTypes", checkNull(mimeTypes));

        _command.put("/dlapp/get-file-entries-and-file-shortcuts-count", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getInt(0);
}

From source file:com.liferay.mobile.android.v62.dlapp.DLAppService.java

public Integer getFileEntriesCount(long repositoryId, long folderId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*  w  w w.  j  a va 2  s  .com*/
        JSONObject _params = new JSONObject();

        _params.put("repositoryId", repositoryId);
        _params.put("folderId", folderId);

        _command.put("/dlapp/get-file-entries-count", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getInt(0);
}

From source file:com.liferay.mobile.android.v62.dlapp.DLAppService.java

public Integer getFileEntriesCount(long repositoryId, long folderId, long fileEntryTypeId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*  ww w.j  ava 2 s.  c  om*/
        JSONObject _params = new JSONObject();

        _params.put("repositoryId", repositoryId);
        _params.put("folderId", folderId);
        _params.put("fileEntryTypeId", fileEntryTypeId);

        _command.put("/dlapp/get-file-entries-count", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getInt(0);
}