Search in sources :

Example 11 with JSONArray

use of run.wallet.common.json.JSONArray in project run-wallet-android by runplay.

the class Store method addSystemMessage.

public static void addSystemMessage(Context context, JSONObject message) {
    SharedPreferences sp = context.getSharedPreferences("sysmessages", Context.MODE_PRIVATE);
    String strJson = sp.getString("msglist", "[]");
    try {
        JSONArray already = new JSONArray(strJson);
        already.put(message);
        sp.edit().putString("msglist", already.toString()).commit();
    } catch (Exception e) {
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) JSONArray(run.wallet.common.json.JSONArray)

Example 12 with JSONArray

use of run.wallet.common.json.JSONArray in project run-wallet-android by runplay.

the class Store method loadSystemMessages.

private static void loadSystemMessages(Context context) {
    SharedPreferences sp = context.getSharedPreferences("sysmessages", Context.MODE_PRIVATE);
    String strJson = sp.getString("msglist", "[]");
    try {
        store.sysMessages.clear();
        JSONArray already = new JSONArray(strJson);
        for (int i = 0; i < already.length(); i++) {
            SystemMessage msg = new SystemMessage(already.optJSONObject(i));
            if (!msg.isIsread())
                store.sysMessages.add(msg);
        }
    } catch (Exception e) {
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) JSONArray(run.wallet.common.json.JSONArray)

Example 13 with JSONArray

use of run.wallet.common.json.JSONArray in project run-wallet-android by runplay.

the class Store method updateAddressFromSecurity.

public static void updateAddressFromSecurity(Context context, AddressSecurityChangeRequest request, GetNewAddressResponse response) {
    List<Address> alreadyAddress = getAddresses(context, request.getSeed());
    Address oldAddress = request.getAddress();
    String newAddressString = null;
    try {
        // Log.e("STORE"," addressSize: "+response.getAddresses().get(0).length()+" - ");
        newAddressString = response.getAddresses().get(0);
    } catch (Exception e) {
    // Log.e("STORE","bad: addressSize: ");
    }
    if (newAddressString != null) {
        // Log.e("STORE","NEW Address is: "+newAddressString);
        for (Address address : alreadyAddress) {
            if (address.getAddress().equals(oldAddress.getAddress())) {
                // Log.e("STORE","Good upding address: "+newAddressString);
                address.setAddress(newAddressString);
                address.setSecurity(request.getSecurity());
            }
        }
        JSONArray jar = new JSONArray();
        for (Address add : alreadyAddress) {
            jar.put(add.toJson());
        }
        // Log.e("ADDRESSES",jar.toString());
        SharedPreferences sp = context.getSharedPreferences(request.getSeed().id, Context.MODE_PRIVATE);
        SpManager.setEncryptedPreference(sp, PREF_ADDRESSES, jar.toString());
        if (store.currentSeed.id.equals(request.getSeed().id)) {
            loadAddresses(context);
        }
        AppService.refreshEvent();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) JSONArray(run.wallet.common.json.JSONArray)

Example 14 with JSONArray

use of run.wallet.common.json.JSONArray in project run-wallet-android by runplay.

the class Store method loadNudgeTransfers.

public static void loadNudgeTransfers(Context context) {
    SharedPreferences sp = context.getSharedPreferences(NT_STORE, Context.MODE_PRIVATE);
    String jarrayString = SpManager.getEncryptedPreference(sp, PREF_NUDGE_TRANSFERS, "[]");
    try {
        JSONArray jar = new JSONArray(jarrayString);
        store.nudgeTransfers.clear();
        // Log.e("LOAD-NUDGE-TRANSFERS","json: "+jar.toString());
        for (int i = 0; i < jar.length(); i++) {
            JSONObject job = jar.getJSONObject(i);
            NudgeTransfer add = new NudgeTransfer(job);
            store.nudgeTransfers.add(add);
        }
    } catch (Exception e) {
        Log.e("ERR-S-01", "ex: " + e.getMessage());
    }
}
Also used : JSONObject(run.wallet.common.json.JSONObject) SharedPreferences(android.content.SharedPreferences) JSONArray(run.wallet.common.json.JSONArray)

Example 15 with JSONArray

use of run.wallet.common.json.JSONArray in project run-wallet-android by runplay.

the class Store method saveNudgeTransfers.

public static synchronized void saveNudgeTransfers(Context context) {
    SharedPreferences sp = context.getSharedPreferences(NT_STORE, Context.MODE_PRIVATE);
    JSONArray trans = new JSONArray();
    for (NudgeTransfer t : store.nudgeTransfers) {
        trans.put(t.toJson());
    }
    SpManager.setEncryptedPreference(sp, PREF_NUDGE_TRANSFERS, trans.toString());
    AppService.setFastMode();
}
Also used : SharedPreferences(android.content.SharedPreferences) JSONArray(run.wallet.common.json.JSONArray)

Aggregations

JSONArray (run.wallet.common.json.JSONArray)36 SharedPreferences (android.content.SharedPreferences)33 JSONObject (run.wallet.common.json.JSONObject)21 ArrayList (java.util.ArrayList)6 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 WebGetExchangeRatesResponse (run.wallet.iota.api.responses.WebGetExchangeRatesResponse)1