use of run.wallet.common.json.JSONArray in project run-wallet-android by runplay.
the class Store method addSystemMessage.
public static void addSystemMessage(Context context, JSONObject message) {
SharedPreferences sp = context.getSharedPreferences("sysmessages", Context.MODE_PRIVATE);
String strJson = sp.getString("msglist", "[]");
try {
JSONArray already = new JSONArray(strJson);
already.put(message);
sp.edit().putString("msglist", already.toString()).commit();
} catch (Exception e) {
}
}
use of run.wallet.common.json.JSONArray in project run-wallet-android by runplay.
the class Store method loadSystemMessages.
private static void loadSystemMessages(Context context) {
SharedPreferences sp = context.getSharedPreferences("sysmessages", Context.MODE_PRIVATE);
String strJson = sp.getString("msglist", "[]");
try {
store.sysMessages.clear();
JSONArray already = new JSONArray(strJson);
for (int i = 0; i < already.length(); i++) {
SystemMessage msg = new SystemMessage(already.optJSONObject(i));
if (!msg.isIsread())
store.sysMessages.add(msg);
}
} catch (Exception e) {
}
}
use of run.wallet.common.json.JSONArray in project run-wallet-android by runplay.
the class Store method updateAddressFromSecurity.
public static void updateAddressFromSecurity(Context context, AddressSecurityChangeRequest request, GetNewAddressResponse response) {
List<Address> alreadyAddress = getAddresses(context, request.getSeed());
Address oldAddress = request.getAddress();
String newAddressString = null;
try {
// Log.e("STORE"," addressSize: "+response.getAddresses().get(0).length()+" - ");
newAddressString = response.getAddresses().get(0);
} catch (Exception e) {
// Log.e("STORE","bad: addressSize: ");
}
if (newAddressString != null) {
// Log.e("STORE","NEW Address is: "+newAddressString);
for (Address address : alreadyAddress) {
if (address.getAddress().equals(oldAddress.getAddress())) {
// Log.e("STORE","Good upding address: "+newAddressString);
address.setAddress(newAddressString);
address.setSecurity(request.getSecurity());
}
}
JSONArray jar = new JSONArray();
for (Address add : alreadyAddress) {
jar.put(add.toJson());
}
// Log.e("ADDRESSES",jar.toString());
SharedPreferences sp = context.getSharedPreferences(request.getSeed().id, Context.MODE_PRIVATE);
SpManager.setEncryptedPreference(sp, PREF_ADDRESSES, jar.toString());
if (store.currentSeed.id.equals(request.getSeed().id)) {
loadAddresses(context);
}
AppService.refreshEvent();
}
}
use of run.wallet.common.json.JSONArray 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());
}
}
use of run.wallet.common.json.JSONArray in project run-wallet-android by runplay.
the class Store method saveNudgeTransfers.
public static synchronized void saveNudgeTransfers(Context context) {
SharedPreferences sp = context.getSharedPreferences(NT_STORE, Context.MODE_PRIVATE);
JSONArray trans = new JSONArray();
for (NudgeTransfer t : store.nudgeTransfers) {
trans.put(t.toJson());
}
SpManager.setEncryptedPreference(sp, PREF_NUDGE_TRANSFERS, trans.toString());
AppService.setFastMode();
}
Aggregations