use of run.wallet.common.json.JSONObject in project run-wallet-android by runplay.
the class Store method loadWallet.
private static void loadWallet(Context context) {
if (store.currentSeed != null) {
SharedPreferences sp = context.getSharedPreferences(store.currentSeed.id, Context.MODE_PRIVATE);
String jobString = SpManager.getEncryptedPreference(sp, PREF_WALLET, "[]");
store.currentWallet = null;
try {
JSONObject job = new JSONObject(jobString);
if (job != null) {
store.currentWallet = new Wallet(job);
}
} catch (Exception e) {
}
}
}
use of run.wallet.common.json.JSONObject in project run-wallet-android by runplay.
the class Store method updateTickers.
public static void updateTickers(Context context, JSONObject job) {
if (job != null && job.optInt("result") == 200 && job.has("data")) {
store.tickers.clear();
JSONArray jar = job.optJSONArray("data");
if (jar != null && jar.length() > 0) {
SharedPreferences sp = context.getSharedPreferences(SP_STORE, Context.MODE_PRIVATE);
sp.edit().putString(PREF_EXCHANGERATES, jar.toString()).commit();
for (int i = 0; i < jar.length(); i++) {
JSONObject ob = null;
try {
ob = jar.optJSONObject(i);
} catch (Exception e) {
Log.e("EXCH", "e2: " + e.getMessage());
}
if (ob != null) {
Ticker ticker = new Ticker(ob);
if (ticker.getCp() != null) {
store.tickers.put(ticker.getCp(), ticker);
}
}
}
}
}
}
use of run.wallet.common.json.JSONObject in project run-wallet-android by runplay.
the class Store method addTransfers.
public static List<Transfer> addTransfers(Context context, Seeds.Seed seed, List<Transfer> transfers) {
List<Transfer> ntransfers = new ArrayList<>();
SharedPreferences sp = context.getSharedPreferences(seed.id, Context.MODE_PRIVATE);
String jarrayString = SpManager.getEncryptedPreference(sp, PREF_TRANSFERS, "[]");
try {
JSONArray jar = new JSONArray(jarrayString);
for (int i = 0; i < jar.length(); i++) {
JSONObject job = jar.getJSONObject(i);
Transfer add = new Transfer(job);
ntransfers.add(add);
}
} catch (Exception e) {
}
Collections.reverse(transfers);
for (Transfer tran : transfers) {
ntransfers.add(0, tran);
}
JSONArray trans = new JSONArray();
for (Transfer t : ntransfers) {
trans.put(t.toJson());
}
SpManager.setEncryptedPreference(sp, PREF_TRANSFERS, trans.toString());
if (store.currentSeed.id.equals(seed.id)) {
loadTransfers(context);
}
return transfers;
}
use of run.wallet.common.json.JSONObject in project run-wallet-android by runplay.
the class Store method loadTickerValues.
private static void loadTickerValues(Context context) {
SharedPreferences sp = context.getSharedPreferences(SP_STORE, Context.MODE_PRIVATE);
JSONArray jar = null;
try {
jar = new JSONArray(sp.getString(PREF_EXCHANGERATES, "[]"));
} catch (Exception e) {
}
if (jar != null) {
store.tickers.clear();
for (int i = 0; i < jar.length(); i++) {
JSONObject ob = null;
try {
ob = jar.optJSONObject(i);
} catch (Exception e) {
}
if (ob != null) {
Ticker ticker = new Ticker(ob);
if (ticker.getCp() != null) {
store.tickers.put(ticker.getCp(), ticker);
}
}
}
}
}
use of run.wallet.common.json.JSONObject in project run-wallet-android by runplay.
the class Wallet method toJson.
public JSONObject toJson() {
JSONObject job = new JSONObject();
job.put("seedid", seedId);
job.put("balance", balance);
job.put("lastupdate", getLastUpdate());
job.put("pendingin", balancePendingIn);
job.put("pendingout", balancePendingOut);
return job;
}
Aggregations