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.ca.mas.cordova.storage.MASStoragePlugin.java

private void saveToLocal(final JSONArray args, final CallbackContext callbackContext) {
    try {/*  w  w w. jav a2s.c om*/
        MASStorage storage = new MASSecureLocalStorage();
        String key = args.optString(1);
        Object data = args.opt(2);
        int segment_0 = args.getInt(3);
        int segment = fetchSegmentLocal(segment_0);

        storage.save(key, data, segment, new MASCallback<Void>() {
            @Override
            public void onSuccess(Void result) {
                success(callbackContext, true, false);
            }

            @Override
            public void onError(Throwable e) {
                callbackContext.error(getError(e));
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
        callbackContext.error(getError(e));
    }
}

From source file:com.ca.mas.cordova.storage.MASStoragePlugin.java

private void findByUsingKeyAndModeLocal(final JSONArray args, final CallbackContext callbackContext) {
    try {//w ww . ja va  2  s .c o  m
        MASStorage storage = new MASSecureLocalStorage();
        String key = args.optString(0);
        int segment_0 = args.getInt(1);
        int segment = fetchSegmentLocal(segment_0);

        storage.findByKey(key, segment, new MASCallback() {
            @Override
            public void onSuccess(Object result) {
                JSONObject response = null;
                try {
                    response = getResultJson(result);
                    success(callbackContext, response, false);
                } catch (Exception ex) {
                    Log.e(TAG, ex.getMessage());
                    callbackContext.error(getError(ex));
                }
            }

            @Override
            public void onError(Throwable e) {
                callbackContext.error(getError(e));
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
        callbackContext.error(getError(e));
    }
}

From source file:com.ca.mas.cordova.storage.MASStoragePlugin.java

private void deleteByUsingKeyAndModeLocal(final JSONArray args, final CallbackContext callbackContext) {
    try {//from   ww  w .j a va  2s  .c  o  m
        MASStorage storage = new MASSecureLocalStorage();
        String key = args.optString(0);
        int segment_0 = args.getInt(1);
        int segment = fetchSegmentLocal(segment_0);

        storage.delete(key, segment, new MASCallback<Void>() {
            @Override
            public void onSuccess(Void result) {
                success(callbackContext, true, false);
            }

            @Override
            public void onError(Throwable e) {
                LOG.e(TAG, e.getMessage());
                callbackContext.error(getError(e));
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
        callbackContext.error(getError(e));
    }
}

From source file:com.ca.mas.cordova.storage.MASStoragePlugin.java

private void deleteAllUsingModeLocal(final JSONArray args, final CallbackContext callbackContext) {
    try {//  w w  w .j a  v a2 s  . co m
        MASSecureLocalStorage storage = new MASSecureLocalStorage();
        int segment_0 = args.getInt(0);
        int segment = fetchSegmentLocal(segment_0);

        storage.deleteAll(segment, new MASCallback<Void>() {
            @Override
            public void onSuccess(Void result) {
                success(callbackContext, true, false);
            }

            @Override
            public void onError(Throwable e) {
                LOG.e(TAG, e.getMessage());
                callbackContext.error(getError(e));
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
        callbackContext.error(getError(e));
    }
}

From source file:com.ca.mas.cordova.storage.MASStoragePlugin.java

private void keySetForModeLocal(final JSONArray args, final CallbackContext callbackContext) {
    try {/*from www.ja  va2s  .  c om*/
        MASStorage storage = new MASSecureLocalStorage();
        int segment_0 = args.getInt(0);
        int segment = fetchSegmentLocal(segment_0);

        storage.keySet(segment, new MASCallback<Set<String>>() {
            @Override
            public void onSuccess(Set<String> result) {
                JSONArray array = new JSONArray(result);
                success(callbackContext, array, false);
            }

            @Override
            public void onError(Throwable e) {
                LOG.e(TAG, e.getMessage());
                callbackContext.error(getError(e));
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
        callbackContext.error(getError(e));
    }
}

From source file:com.ca.mas.cordova.storage.MASStoragePlugin.java

private void saveToCloud(final JSONArray args, final CallbackContext callbackContext) {
    try {//w  w  w  .j  a  va  2s  .  c  om
        MASStorage storage = new MASSecureStorage();
        String key = args.optString(1);
        Object data = args.opt(2);
        int segment_0 = args.getInt(3);
        int segment = fetchSegmentCloud(segment_0);

        storage.save(key, data, segment, new MASCallback<Void>() {
            @Override
            public void onSuccess(Void result) {
                success(callbackContext, true, false);
            }

            @Override
            public void onError(Throwable e) {
                Log.e(TAG, e.getMessage());
                callbackContext.error(getError(e));
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
        callbackContext.error(getError(e));
    }
}

From source file:com.ca.mas.cordova.storage.MASStoragePlugin.java

private void findByUsingKeyAndModeCloud(final JSONArray args, final CallbackContext callbackContext) {
    try {/*from   w  w w. j  a  va  2s. c  o m*/
        MASStorage storage = new MASSecureStorage();
        String key = args.optString(0);
        int segment_0 = args.getInt(1);
        int segment = fetchSegmentCloud(segment_0);

        storage.findByKey(key, segment, new MASCallback() {
            @Override
            public void onSuccess(Object result) {
                JSONObject response = null;
                try {
                    response = getResultJson(result);
                    success(callbackContext, response, false);
                } catch (Exception ex) {
                    LOG.e(TAG, ex.getMessage());
                    callbackContext.error(getError(ex));
                }
            }

            @Override
            public void onError(Throwable e) {
                LOG.e(TAG, e.getMessage());
                callbackContext.error(getError(e));
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
        callbackContext.error(getError(e));
    }
}

From source file:com.ca.mas.cordova.storage.MASStoragePlugin.java

private void deleteByUsingKeyAndModeCloud(final JSONArray args, final CallbackContext callbackContext) {
    try {/*from  www.  j  a  v  a 2 s .  com*/
        MASStorage storage = new MASSecureStorage();
        String key = args.optString(0);
        int segment_0 = args.getInt(1);
        int segment = fetchSegmentCloud(segment_0);

        storage.delete(key, segment, new MASCallback<Void>() {
            @Override
            public void onSuccess(Void result) {
                success(callbackContext, true, false);
            }

            @Override
            public void onError(Throwable e) {
                Log.e(TAG, e.getMessage(), e);
                callbackContext.error(getError(e));
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
        callbackContext.error(getError(e));
    }
}

From source file:com.ca.mas.cordova.storage.MASStoragePlugin.java

private void keySetForModeCloud(final JSONArray args, final CallbackContext callbackContext) {
    try {//from www.ja  v a 2s  .co  m
        MASStorage storage = new MASSecureStorage();
        int segment_0 = args.getInt(0);
        int segment = fetchSegmentCloud(segment_0);

        storage.keySet(segment, new MASCallback<Set<String>>() {
            @Override
            public void onSuccess(Set<String> result) {
                JSONArray array = new JSONArray(result);
                success(callbackContext, array, false);
            }

            @Override
            public void onError(Throwable e) {
                Log.e(TAG, e.getMessage(), e);
                callbackContext.error(getError(e));
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
        callbackContext.error(getError(e));
    }
}

From source file:com.liferay.mobile.android.v62.contact.ContactService.java

public Integer getContactsCount(long classNameId, long classPK) throws Exception {
    JSONObject _command = new JSONObject();

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

        _params.put("classNameId", classNameId);
        _params.put("classPK", classPK);

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getInt(0);
}