Search in sources :

Example 21 with JSONArray

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

the class Store method setAddressesToNotAttached.

public static void setAddressesToNotAttached(Context context, Seeds.Seed seed, List<Address> setAddresses) {
    List<Address> addresses = getAddresses(context, seed);
    boolean updateAddress = false;
    if (!addresses.isEmpty()) {
        for (Address setadd : setAddresses) {
            for (Address add : addresses) {
                if (add.getAddress().equals(setadd.getAddress())) {
                    add.setAttached(false);
                    updateAddress = true;
                }
            }
        }
    }
    if (updateAddress) {
        // Log.e("Store","store - UPDATING Address");
        JSONArray jar = new JSONArray();
        for (Address add : addresses) {
            jar.put(add.toJson());
        }
        SharedPreferences sp = context.getSharedPreferences(seed.id, Context.MODE_PRIVATE);
        SpManager.setEncryptedPreference(sp, PREF_ADDRESSES, jar.toString());
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) JSONArray(run.wallet.common.json.JSONArray)

Example 22 with JSONArray

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

the class Transfer method toJson.

public JSONObject toJson() {
    JSONObject job = new JSONObject();
    job.put("ts", timestamp);
    job.put("add", address);
    job.put("hash", hash);
    job.put("ps", persistence);
    job.put("val", value);
    job.put("msg", message);
    job.put("tag", tag);
    job.put("mil", getMilestone());
    job.put("dbl", isMarkDoubleSpend());
    job.put("dba", markDoubleAddress);
    job.put("ldb", lastDoubleCheck);
    job.put("tsc", getTimestampConfirmed());
    JSONArray jar = new JSONArray();
    for (TransferTransaction t : getTransactions()) {
        jar.put(t.toJson());
    }
    job.put("tra", jar);
    JSONArray ojar = new JSONArray();
    for (TransferTransaction t : othertransactions) {
        ojar.put(t.toJson());
    }
    job.put("tro", ojar);
    JSONArray njar = new JSONArray();
    for (String hash : nudgeHashes) {
        njar.put(hash);
    }
    job.put("nudge", njar);
    job.put("milc", milestoneCreated);
    return job;
}
Also used : JSONObject(run.wallet.common.json.JSONObject) JSONArray(run.wallet.common.json.JSONArray)

Example 23 with JSONArray

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

the class MsgStore method addAddress.

public static void addAddress(Context context, MessageNewAddressResponse response) {
    // if(seed!=null) {
    SharedPreferences sp = context.getSharedPreferences(msgStore.currentSeed.id, Context.MODE_PRIVATE);
    // String jarrayString=SpManager.getEncryptedPreference(sp, PREF_ADDRESSES,"[]");
    JSONArray jar = new JSONArray();
    for (String add : response.getAddresses()) {
        Address address = new Address(add, false);
        jar.put(address.toJson());
    }
    // Log.e("MSG-SAVE-ADDRESS","NO ACTION:   "+jar.toString());
    SpManager.setEncryptedPreference(sp, PREF_ADDRESSES, jar.toString());
    // if(store.currentSeed.id.equals(seed.id)) {
    loadAddresses(context);
// }
}
Also used : SharedPreferences(android.content.SharedPreferences) JSONArray(run.wallet.common.json.JSONArray)

Example 24 with JSONArray

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

the class MsgStore method updateMessageData.

public static void updateMessageData(Context context, Wallet wallet, List<Transfer> transfers, List<Address> addresses) {
    if (msgStore.currentSeed != null) {
        SharedPreferences sp = context.getSharedPreferences(msgStore.currentSeed.id, Context.MODE_PRIVATE);
        JSONArray trans = new JSONArray();
        for (Transfer t : transfers) {
            trans.put(t.toJson());
        }
        SpManager.setEncryptedPreference(sp, PREF_TRANSFERS, trans.toString());
        JSONArray jar = new JSONArray();
        for (Address add : addresses) {
            jar.put(add.toJson());
        }
        SpManager.setEncryptedPreference(sp, PREF_ADDRESSES, jar.toString());
        // Wallet run.wallet.monero.wallet = new Wallet(seed.id,balance,System.currentTimeMillis());
        MsgStore.addUpdateWallet(context, msgStore.currentSeed, wallet);
    }
    // if(msgStore.currentSeed!=null && seed.id.equals(msgStore.currentSeed.id)) {
    reinit(context);
// }
}
Also used : SharedPreferences(android.content.SharedPreferences) JSONArray(run.wallet.common.json.JSONArray)

Example 25 with JSONArray

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

the class Nodes method saveDownloadNodes.

protected void saveDownloadNodes(Context context, List<Node> nodes) {
    SharedPreferences sp = context.getSharedPreferences(SP_NODES, Context.MODE_PRIVATE);
    JSONArray jar = new JSONArray();
    try {
        for (Node node : nodes) {
            JSONObject job = new JSONObject();
            job.put(J_IP, node.ip);
            job.put(J_PORT, node.port);
            job.put(J_SYNC, node.syncVal);
            job.put(J_PROTO, node.protocol);
            job.put(J_NAME, node.name);
            job.put(J_LAST, node.lastused);
            job.put(J_Dead, node.deadcount);
            jar.put(job);
        }
    } catch (Exception e) {
    }
    if (jar.length() > 0) {
        sp.edit().putString(PREF_NODES, jar.toString()).commit();
    }
}
Also used : JSONObject(run.wallet.common.json.JSONObject) 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