Search in sources :

Example 6 with JSONObject

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

the class MsgStore method loadSeed.

private static void loadSeed(Context context) {
    SharedPreferences sp = context.getSharedPreferences(SP_STORE, Context.MODE_PRIVATE);
    String jString = SpManager.getEncryptedPreference(sp, PREF_MSG_SEED, "");
    if (!jString.isEmpty()) {
        JSONObject job = new JSONObject(jString);
        Seeds.Seed seed = new Seeds.Seed();
        seed.value = job.optString(Seeds.J_VALUE).toCharArray();
        seed.name = job.optString(Seeds.J_NAME);
        seed.isdefault = job.optBoolean(Seeds.J_DEFAULT);
        seed.id = job.optString(Seeds.J_ID);
        msgStore.currentSeed = seed;
    }
}
Also used : JSONObject(run.wallet.common.json.JSONObject) SharedPreferences(android.content.SharedPreferences)

Example 7 with JSONObject

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

the class MsgStore method loadAddresses.

private static void loadAddresses(Context context) {
    if (msgStore.currentSeed != null) {
        SharedPreferences sp = context.getSharedPreferences(msgStore.currentSeed.id, Context.MODE_PRIVATE);
        String jarrayString = SpManager.getEncryptedPreference(sp, PREF_ADDRESSES, "[]");
        // Log.e("MSG-LOAD-ADDRESS",jarrayString);
        msgStore.addresses.clear();
        try {
            JSONArray jar = new JSONArray(jarrayString);
            for (int i = 0; i < jar.length(); i++) {
                JSONObject job = jar.getJSONObject(i);
                Address add = new Address(job.optString("address"), job.optBoolean("used"));
                msgStore.addresses.add(add);
            }
        } catch (Exception e) {
        }
    }
}
Also used : JSONObject(run.wallet.common.json.JSONObject) SharedPreferences(android.content.SharedPreferences) JSONArray(run.wallet.common.json.JSONArray)

Example 8 with JSONObject

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

the class MsgStore method loadWallet.

private static void loadWallet(Context context) {
    if (msgStore.currentSeed != null) {
        SharedPreferences sp = context.getSharedPreferences(msgStore.currentSeed.id, Context.MODE_PRIVATE);
        String jobString = SpManager.getEncryptedPreference(sp, PREF_WALLET, "[]");
        msgStore.currentWallet = null;
        try {
            JSONObject job = new JSONObject(jobString);
            if (job != null) {
                msgStore.currentWallet = new Wallet(job);
            }
        } catch (Exception e) {
        }
    }
}
Also used : JSONObject(run.wallet.common.json.JSONObject) SharedPreferences(android.content.SharedPreferences)

Example 9 with JSONObject

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

the class MsgStore method setSeed.

private static void setSeed(Context context, Seeds.Seed seed) {
    SharedPreferences sp = context.getSharedPreferences(SP_STORE, Context.MODE_PRIVATE);
    JSONObject job = new JSONObject();
    msgStore.currentSeed = seed;
    job.put(Seeds.J_ID, seed.id);
    job.put(Seeds.J_VALUE, String.valueOf(seed.value));
    job.put(Seeds.J_NAME, seed.name);
    job.put(Seeds.J_DEFAULT, seed.isdefault);
    sp.edit().putString(PREF_MSG_SEED, job.toString()).commit();
}
Also used : JSONObject(run.wallet.common.json.JSONObject) SharedPreferences(android.content.SharedPreferences)

Example 10 with JSONObject

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

the class MsgStore method loadTransfers.

private static void loadTransfers(Context context) {
    if (msgStore.currentSeed != null) {
        SharedPreferences sp = context.getSharedPreferences(msgStore.currentSeed.id, Context.MODE_PRIVATE);
        String jarrayString = SpManager.getEncryptedPreference(sp, PREF_TRANSFERS, "[]");
        // String jarrayString = sp.getString(PREF_SEEDS,"[]");
        msgStore.transfers.clear();
        try {
            JSONArray jar = new JSONArray(jarrayString);
            for (int i = 0; i < jar.length(); i++) {
                JSONObject job = jar.getJSONObject(i);
                Transfer add = new Transfer(job);
                msgStore.transfers.add(add);
            }
        } catch (Exception e) {
        }
    }
}
Also used : JSONObject(run.wallet.common.json.JSONObject) SharedPreferences(android.content.SharedPreferences) JSONArray(run.wallet.common.json.JSONArray)

Aggregations

JSONObject (run.wallet.common.json.JSONObject)37 SharedPreferences (android.content.SharedPreferences)24 JSONArray (run.wallet.common.json.JSONArray)21 ArrayList (java.util.ArrayList)6 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 URL (java.net.URL)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 Fragment (android.app.Fragment)1 FragmentManager (android.app.FragmentManager)1 FragmentTransaction (android.app.FragmentTransaction)1 Bundle (android.os.Bundle)1 Nullable (android.support.annotation.Nullable)1 File (java.io.File)1 HttpURLConnection (java.net.HttpURLConnection)1 TextFile (run.wallet.common.TextFile)1 JSONException (run.wallet.common.json.JSONException)1 WebGetExchangeRatesHistoryRequest (run.wallet.iota.api.requests.WebGetExchangeRatesHistoryRequest)1