Search in sources :

Example 16 with JSONObject

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

the class Store method loadTransfers.

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

Example 17 with JSONObject

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

the class Store method getAddresses.

public static List<Address> getAddresses(Context context, Seeds.Seed seed) {
    List<Address> addresses = new ArrayList<>();
    if (Validator.isValidCaller()) {
        SharedPreferences sp = context.getSharedPreferences(seed.id, Context.MODE_PRIVATE);
        String jarrayString = SpManager.getEncryptedPreference(sp, PREF_ADDRESSES, "[]");
        // Log.e("TMP-LOAD-ADDRESS",jarrayString);
        try {
            JSONArray jar = new JSONArray(jarrayString);
            for (int i = 0; i < jar.length(); i++) {
                JSONObject job = jar.getJSONObject(i);
                Address add = new Address(job);
                addresses.add(add);
            }
        } catch (Exception e) {
        }
    }
    return addresses;
}
Also used : JSONObject(run.wallet.common.json.JSONObject) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) JSONArray(run.wallet.common.json.JSONArray)

Example 18 with JSONObject

use of run.wallet.common.json.JSONObject 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 19 with JSONObject

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

the class Store method getTickerHist.

public static TickerHist getTickerHist(Context context, String ticker, int step) {
    TickerHist hist = store.tickerHist.get(ticker + step);
    if (hist == null) {
        SharedPreferences sp = context.getSharedPreferences(SP_STORE, Context.MODE_PRIVATE);
        String strJson = sp.getString(PREF_TICKHIST, null);
        if (strJson != null) {
            JSONObject tickerHistories = new JSONObject(strJson);
            JSONObject gottickerhist = tickerHistories.optJSONObject(ticker + step);
            // Log.e("GTL",""+gottickerhist);
            if (gottickerhist != null) {
                String cp = gottickerhist.optString("cp");
                if (!cp.isEmpty()) {
                    long last = gottickerhist.optLong("last");
                    // Log.e("STORE-THIST", "get: " + cp);
                    List<Tick> history = new ArrayList<>();
                    JSONArray jar = gottickerhist.optJSONArray("data");
                    for (int i = 0; i < jar.length(); i++) {
                        Tick aticker = new Tick(jar.optJSONObject(i));
                        // Log.e("TCIK",ticker.getLast()+"--"+jar.optJSONObject(i).toString());
                        history.add(aticker);
                    }
                    TickerHist thist = new TickerHist();
                    thist.setTicker(cp);
                    thist.setStep(gottickerhist.optInt("step"));
                    thist.setTicks(history);
                    thist.setLastUpdate(last);
                    // Log.e("STORE-THIST",cp);
                    store.tickerHist.put(cp + step, thist);
                }
            }
        }
    }
    return store.tickerHist.get(ticker + step);
}
Also used : JSONObject(run.wallet.common.json.JSONObject) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) JSONArray(run.wallet.common.json.JSONArray)

Example 20 with JSONObject

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

the class SystemMessage method toJson.

public JSONObject toJson() {
    JSONObject job = new JSONObject();
    job.put("date", date);
    job.put("dis", disable);
    job.put("msg", message);
    job.put("read", isread);
    return job;
}
Also used : JSONObject(run.wallet.common.json.JSONObject)

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