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:fyp.project.S_File.S_Activities.java

public void doWay(String server_output) {
    /*        tvOutput.setText(Environment.getExternalStorageDirectory() + "/DCIM/Camera/a.mp4");*/

    JSONArray array = null;
    List<String> list_output = new ArrayList<String>();
    String output = server_output;
    if (!output.equals("[]")) {

        Logger.getLogger(S_Login.class.getName()).info("true...............");
        try {//from ww w . j a  v  a2s  . c om
            array = new JSONArray(server_output);
        } catch (JSONException ex) {
            Logger.getLogger(S_Login.class.getName()).log(Level.SEVERE, null, ex);
        }

        for (int n = 0; n < array.length(); n++) {
            String temp = "";
            for (int m = 0; m < 3; m++) {
                try {
                    output += " " + array.getJSONArray(n).get(m).toString() + "\n ";
                    temp += " " + array.getJSONArray(n).get(m).toString() + "\n ";
                } catch (JSONException ex) {
                    Logger.getLogger(S_Login.class.getName()).log(Level.SEVERE, null, ex);

                }
            }

            list_output.add(temp);
            output += "\n";
        }
        aryAdapter_list = new ArrayAdapter(activity, android.R.layout.simple_list_item_1, list_output);
        gv.setAdapter(aryAdapter_list);
        Logger.getLogger(S_Login.class.getName()).info(output);

    } else {
        EditText edit_username = (EditText) activity.findViewById(R.id.edit_username);
        EditText edit_password = (EditText) activity.findViewById(R.id.edit_password);
        if (output.equals("[]")) {
            tvOutput.setText("Please Login Again" + server_output);
            edit_username.setText("");
            edit_password.setText("");
        } else {
            tvOutput.setText("Page Not Found 404" + server_output);
        }
        /*AlertDialog.Builder MyAlertDialog = new AlertDialog.Builder(activity);
         MyAlertDialog.setTitle("Login Fail");
         MyAlertDialog.setMessage("Please Login Again");
         MyAlertDialog.show();
                 
         */

    }

    mProgressDialog.dismiss();

}

From source file:com.liferay.mobile.android.v7.kaleodefinition.KaleodefinitionService.java

public JSONArray getKaleoDefinitions(int start, int end) throws Exception {
    JSONObject _command = new JSONObject();

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

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

        _command.put("/kaleo.kaleodefinition/get-kaleo-definitions", _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.v7.kaleodefinition.KaleodefinitionService.java

public JSONArray getKaleoDefinitions(long companyId, int start, int end) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from ww  w.  j  av  a2 s  .c om*/
        JSONObject _params = new JSONObject();

        _params.put("companyId", companyId);
        _params.put("start", start);
        _params.put("end", end);

        _command.put("/kaleo.kaleodefinition/get-kaleo-definitions", _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.v7.mbmessage.MBMessageService.java

public JSONArray getThreadMessages(long groupId, long categoryId, long threadId, int status, int start, int end)
        throws Exception {
    JSONObject _command = new JSONObject();

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

        _params.put("groupId", groupId);
        _params.put("categoryId", categoryId);
        _params.put("threadId", threadId);
        _params.put("status", status);
        _params.put("start", start);
        _params.put("end", end);

        _command.put("/mbmessage/get-thread-messages", _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.v7.mbmessage.MBMessageService.java

public JSONArray getCategoryMessages(long groupId, long categoryId, int status, int start, int end)
        throws Exception {
    JSONObject _command = new JSONObject();

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

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

        _command.put("/mbmessage/get-category-messages", _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.mirasense.scanditsdk.plugin.PickerControllerBase.java

@Override
public void finishDidScanCallback(JSONArray data) {
    mNextState = 0;/*from   w ww .j  a  v  a2  s  . co m*/
    if (data != null && data.length() > 0) {
        try {
            mNextState = data.getInt(0);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        ArrayList<Long> rejectedCodeIds = new ArrayList<Long>();
        try {
            JSONArray jsonData = data.getJSONArray(1);
            for (int i = 0; i < jsonData.length(); ++i) {
                rejectedCodeIds.add(jsonData.getLong(i));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        setRejectedCodeIds(rejectedCodeIds);
    }
    synchronized (mSync) {
        mInFlightDidScanCallbackId.set(0); // zero means no in-flight didScan callback
        mSync.notifyAll();
    }
}

From source file:com.liferay.mobile.android.v62.dlfileentry.DLFileEntryService.java

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

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

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

        _command.put("/dlfileentry/get-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.dlfileentry.DLFileEntryService.java

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

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

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

        _command.put("/dlfileentry/get-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.dlfileentry.DLFileEntryService.java

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

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

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

        _command.put("/dlfileentry/get-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.dlfileentry.DLFileEntryService.java

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

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

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

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getJSONArray(0);
}