Example usage for org.json JSONArray getJSONArray

List of usage examples for org.json JSONArray getJSONArray

Introduction

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

Prototype

public JSONArray getJSONArray(int index) throws JSONException 

Source Link

Document

Get the JSONArray associated with an index.

Usage

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

public JSONArray getGroupFileEntries(long groupId, long userId, int start, int end, JSONObjectWrapper obc)
        throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from   w  ww  .  j  a va2s.c  o  m*/
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("userId", userId);
        _params.put("start", start);
        _params.put("end", end);
        mangleWrapper(_params, "obc", "com.liferay.portal.kernel.util.OrderByComparator", obc);

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getJSONArray(0);
}

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

public JSONArray getGroupFileEntries(long groupId, long userId, long rootFolderId, int start, int end,
        JSONObjectWrapper obc) throws Exception {
    JSONObject _command = new JSONObject();

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

        _params.put("groupId", groupId);
        _params.put("userId", userId);
        _params.put("rootFolderId", rootFolderId);
        _params.put("start", start);
        _params.put("end", end);
        mangleWrapper(_params, "obc", "com.liferay.portal.kernel.util.OrderByComparator", obc);

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getJSONArray(0);
}

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

public JSONArray getGroupFileEntries(long groupId, long userId, long rootFolderId, JSONArray mimeTypes,
        int status, int start, int end, JSONObjectWrapper obc) throws Exception {
    JSONObject _command = new JSONObject();

    try {//  w w  w  .  ja  va2 s.c  o  m
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("userId", userId);
        _params.put("rootFolderId", rootFolderId);
        _params.put("mimeTypes", checkNull(mimeTypes));
        _params.put("status", status);
        _params.put("start", start);
        _params.put("end", end);
        mangleWrapper(_params, "obc", "com.liferay.portal.kernel.util.OrderByComparator", obc);

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getJSONArray(0);
}

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

public JSONArray getMountFolders(long repositoryId, long parentFolderId) throws Exception {
    JSONObject _command = new JSONObject();

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

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

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getJSONArray(0);
}

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

public JSONArray getMountFolders(long repositoryId, long parentFolderId, int start, int end) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from  w w  w .  j  a  va2 s. com
        JSONObject _params = new JSONObject();

        _params.put("repositoryId", repositoryId);
        _params.put("parentFolderId", parentFolderId);
        _params.put("start", start);
        _params.put("end", end);

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getJSONArray(0);
}

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

public JSONArray getMountFolders(long repositoryId, long parentFolderId, int start, int end,
        JSONObjectWrapper obc) throws Exception {
    JSONObject _command = new JSONObject();

    try {/* www. j  a  va 2  s  .c  o  m*/
        JSONObject _params = new JSONObject();

        _params.put("repositoryId", repositoryId);
        _params.put("parentFolderId", parentFolderId);
        _params.put("start", start);
        _params.put("end", end);
        mangleWrapper(_params, "obc", "com.liferay.portal.kernel.util.OrderByComparator", obc);

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getJSONArray(0);
}

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

public JSONArray getSubfolderIds(long repositoryId, long folderId) throws Exception {
    JSONObject _command = new JSONObject();

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

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

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getJSONArray(0);
}

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

public JSONArray getSubfolderIds(long repositoryId, long folderId, boolean recurse) 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);
        _params.put("recurse", recurse);

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getJSONArray(0);
}

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

public JSONArray getTempFileEntryNames(long groupId, long folderId, String tempFolderName) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from   ww w . j av  a  2  s  .co m
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("folderId", folderId);
        _params.put("tempFolderName", checkNull(tempFolderName));

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getJSONArray(0);
}

From source file:widgets.Graphical_Info_with_achartengine.java

private void drawgraph() throws JSONException {
    minf = 0;//from   w w w . j a v  a  2 s  .  c  o m
    maxf = 0;
    avgf = 0;
    //Clear to avoid crash on multiple redraw
    EmptySeries.clear();
    nameSeries.clear();
    dataset.clear();
    //Clear all labels
    multiRenderer.clearXTextLabels();
    multiRenderer.clearYTextLabels();
    multiRenderer.removeAllRenderers();
    //Set position of graph to 0
    multiRenderer.setXAxisMin(0);
    //Adding nameSeries Series to the dataset
    dataset.addSeries(nameSeries);
    dataset.addSeries(EmptySeries);
    //Adding incomeRenderer and emptyRenderer to multipleRenderer
    //Note: The order of adding dataseries to dataset and renderers to multipleRenderer
    //should be same
    multiRenderer.addSeriesRenderer(incomeRenderer);
    multiRenderer.addSeriesRenderer(emptyRenderer);

    values = new Vector<Vector<Float>>();
    chartContainer = new LinearLayout(context);
    // Getting a reference to LinearLayout of the MainActivity Layout
    chartContainer
            .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    chartContainer.setGravity(Gravity.CENTER_VERTICAL);
    chartContainer.setPadding((int) size5, (int) size10, (int) size5, (int) size10);

    currentTimestamp = time_end.getTime() / 1000;
    startTimestamp = time_start.getTime() / 1000;

    //Tracer.i(mytag,"UpdateThread ("+dev_id+") : "+url+"stats/"+dev_id+"/"+state_key+"/from/"+startTimestamp+"/to/"+currentTimestamp+"/interval/"+step+"/selector/avg");
    Tracer.i(mytag, "UpdateThread (" + dev_id + ") : " + url + "stats/" + dev_id + "/" + state_key + "/from/"
            + startTimestamp + "/to/" + currentTimestamp + "/interval/" + step + "/selector/avg");
    JSONObject json_GraphValues = null;
    try {
        //json_GraphValues = Rest_com.connect(url+"stats/"+dev_id+"/"+state_key+"/from/"+startTimestamp+"/to/"+1385857510+"/interval/"+step+"/selector/avg");
        json_GraphValues = Rest_com.connect(url + "stats/" + dev_id + "/" + state_key + "/from/"
                + startTimestamp + "/to/" + currentTimestamp + "/interval/" + step + "/selector/avg", login,
                password);

    } catch (Exception e) {
        //return null;
        Tracer.e(mytag, "Error with json");
    }
    JSONArray itemArray = json_GraphValues.getJSONArray("stats");
    JSONArray valueArray = itemArray.getJSONObject(0).getJSONArray("values");
    j = 0;
    Boolean ruptur = false;
    for (int i = 0; i < valueArray.length() - 1; i++) {
        real_val = valueArray.getJSONArray(i).getDouble(limit - 1);
        real_val = round(real_val, 2);
        int year = valueArray.getJSONArray(i).getInt(0);
        int month = valueArray.getJSONArray(i).getInt(1);
        int week = valueArray.getJSONArray(i).getInt(2);
        int day = valueArray.getJSONArray(i).getInt(3);
        int hour = valueArray.getJSONArray(i).getInt(4);
        int hour_next = valueArray.getJSONArray(i + 1).getInt(4);
        String date = String.valueOf(hour) + "'";
        if (hour != 23 && (hour < hour_next)) {
            //no day change
            if ((hour + 1) != hour_next) {
                //ruptur : simulate next missing steps
                EmptySeries.add(j, real_val);
                nameSeries.add(j, real_val);
                multiRenderer.addXTextLabel(j, date);
                Tracer.d(mytag, "Ok " + j + " hour: " + hour + " value: " + real_val);
                for (int k = 1; k < (hour_next - hour); k++) {
                    nameSeries.add(j + k, MathHelper.NULL_VALUE);
                    EmptySeries.add(j + k, real_val);
                    Tracer.d(mytag, "Missing " + (j + k) + " hour: " + (hour + k) + " value: " + real_val);
                }
                j = j + (hour_next - hour);
                ruptur = true;
            } else {
                if (ruptur) {
                    EmptySeries.add(j, real_val);
                } else {
                    EmptySeries.add(j, MathHelper.NULL_VALUE);
                }
                ruptur = false;
                nameSeries.add(j, real_val); //change to j to avoid missing value
                //EmptySeries.add(j+1,real_val );
                multiRenderer.addXTextLabel(j, date);
                Tracer.d(mytag, "Ok " + j + " hour: " + hour + " value: " + real_val);
                j++;
            }
        } else if (hour == 23) {
            if (ruptur) {
                EmptySeries.add(j, real_val);
            } else {
                EmptySeries.add(j, MathHelper.NULL_VALUE);
            }
            ruptur = false;
            nameSeries.add(j, real_val); //change to j to avoid missing value
            multiRenderer.addXTextLabel(j, date);
            Tracer.d(mytag, "Ok " + j + " value for 23h: " + real_val);
            j++;
        }
        if (minf == 0)
            minf = real_val.floatValue();
        avgf += real_val; // Get the real 'value'

        if (real_val > maxf) {
            maxf = real_val.floatValue();

        }
        if (real_val < minf) {
            minf = real_val.floatValue();

        }
    }
    avgf = avgf / values.size();
    multiRenderer.addYTextLabel(((double) minf) - 1, ("" + minf));
    multiRenderer.addYTextLabel(((double) avgf), ("" + avgf));
    multiRenderer.addYTextLabel(((double) maxf), ("" + maxf));
    //SET limit up and down on Y axis
    multiRenderer.setYAxisMin(minf - 1);
    multiRenderer.setYAxisMax(maxf + 1);
    Tracer.d(mytag, "minf (" + dev_id + ")=" + minf);
    Tracer.d(mytag, "maxf (" + dev_id + ")=" + maxf);
    Tracer.d(mytag, "avgf (" + dev_id + ")=" + avgf);
    Tracer.d(mytag, "UpdateThread (" + dev_id + ") Refreshing graph");

    // Specifying chart types to be drawn in the graph
    // Number of data series and number of types should be same
    // Order of data series and chart type will be same
    String[] types = new String[] { LineChart.TYPE, LineChart.TYPE };
    // Creating a combined chart with the chart types specified in types array
    mChart = (GraphicalView) ChartFactory.getCombinedXYChartView(context, dataset, multiRenderer, types);

    mChart.addPanListener(new PanListener() {
        public void panApplied() {
            Tracer.i(mytag + "Pan",
                    "New X range=[" + multiRenderer.getXAxisMin() + ", " + multiRenderer.getXAxisMax() + "]");
            //TO move the graph to left or right
            if (multiRenderer.getXAxisMin() < -2) {
                period_type = -1;
                compute_period();
                try {
                    mChart.destroyDrawingCache();
                    drawgraph();
                } catch (JSONException e) {
                    Tracer.d(mytag, e.toString());
                }
            }
            if (multiRenderer.getXAxisMax() > j + 2) {
                period_type = 0;
                compute_period();
                try {
                    mChart.destroyDrawingCache();
                    drawgraph();
                } catch (JSONException e) {
                    Tracer.d(mytag, e.toString());
                }
            }
        }
    });

    // Adding the Combined Chart to the LinearLayout
    chartContainer.addView(mChart);
}