use of run.wallet.common.json.JSONArray in project run-wallet-android by runplay.
the class WebGetExchangeRatesRequestHandler method handle.
@Override
public ApiResponse handle(ApiRequest apiRequest) {
JSONObject result = JSONUrlReader.readJsonObjectFromUrl(context, Constants.WWW_RUN_IOTA + "/xchange.jsp");
if (result != null) {
Store.updateTickers(context, result);
JSONArray msgs = result.optJSONArray("sysmsg");
if (msgs != null && msgs.length() > 0) {
for (int i = 0; i < msgs.length(); i++) {
Store.addSystemMessage(context, msgs.optJSONObject(i));
}
}
return new WebGetExchangeRatesResponse(result);
}
return new WebGetExchangeRatesResponse(new JSONObject());
// NetworkError error = new NetworkError();
// error.setErrorType(NetworkErrorType.NETWORK_ERROR);
// return error;
}
use of run.wallet.common.json.JSONArray 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) {
}
}
}
use of run.wallet.common.json.JSONArray 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) {
}
}
}
use of run.wallet.common.json.JSONArray in project run-wallet-android by runplay.
the class MsgStore 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) {
}
for (Transfer tran : transfers) {
ntransfers.add(tran);
}
JSONArray trans = new JSONArray();
for (Transfer t : ntransfers) {
trans.put(t.toJson());
}
SpManager.setEncryptedPreference(sp, PREF_TRANSFERS, trans.toString());
return transfers;
}
use of run.wallet.common.json.JSONArray in project run-wallet-android by runplay.
the class Nodes method load.
private void load(Context context) {
usenodes.add(getRandomDefault());
SharedPreferences sp = context.getSharedPreferences(SP_NODES, Context.MODE_PRIVATE);
String uarrayString = sp.getString(PREF_USE_NODEs, "[]");
try {
JSONArray jar = new JSONArray(uarrayString);
if (jar.length() != 0) {
usenodes.clear();
for (int i = 0; i < jar.length(); i++) {
JSONObject job = jar.getJSONObject(i);
Node node = new Node();
node.ip = job.optString(J_IP);
node.port = job.optInt(J_PORT);
node.syncVal = job.optInt(J_SYNC);
node.protocol = job.optString(J_PROTO);
node.name = job.optString(J_NAME);
node.lastused = job.optLong(J_LAST);
node.deadcount = job.optInt(J_Dead);
usenodes.add(node);
}
} else {
// Log.e("NODES","init()");
if (!alreadyinit) {
init(context);
}
}
} catch (Exception e) {
}
}
Aggregations