Updated on 2026-08-14

This commit is contained in:
Tangem 2018-07-17 17:37:47 +03:00
parent aad7f48601
commit a79b496bb6
4 changed files with 66 additions and 33 deletions

View file

@ -20,47 +20,55 @@ public class RateInfoTask extends ExchangeTask {
protected void onPostExecute(List<ExchangeRequest> requests) {
super.onPostExecute(requests);
LoadedWallet loadedWallet = reference.get();
for (ExchangeRequest request : requests) {
if (request.error == null) {
try {
try {
LoadedWallet loadedWallet = reference.get();
JSONArray arr = request.getAnswerList();
for (int i = 0; i < arr.length(); ++i) {
JSONObject obj = arr.getJSONObject(i);
String currency = obj.getString("id");
for (ExchangeRequest request : requests) {
if (request.error == null) {
try {
boolean stop = false;
boolean stopAlter = false;
if (currency.equals(request.currency)) {
String usd = obj.getString("price_usd");
JSONArray arr = request.getAnswerList();
for (int i = 0; i < arr.length(); ++i) {
JSONObject obj = arr.getJSONObject(i);
String currency = obj.getString("id");
boolean stop = false;
boolean stopAlter = false;
if (currency.equals(request.currency)) {
String usd = obj.getString("price_usd");
Float rate = Float.valueOf(usd);
loadedWallet.mCard.setRate(rate);
loadedWallet.updateViews();
stop = true;
}
if (currency.equals(request.currencyAlter)) {
String usd = obj.getString("price_usd");
Float rate = Float.valueOf(usd);
loadedWallet.mCard.setRateAlter(rate);
loadedWallet.updateViews();
stopAlter = true;
}
if (stop && stopAlter) {
break;
}
Float rate = Float.valueOf(usd);
loadedWallet.mCard.setRate(rate);
loadedWallet.updateViews();
stop = true;
}
if (currency.equals(request.currencyAlter)) {
String usd = obj.getString("price_usd");
Float rate = Float.valueOf(usd);
loadedWallet.mCard.setRateAlter(rate);
loadedWallet.updateViews();
stopAlter = true;
}
if (stop && stopAlter) {
break;
}
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
} catch (NullPointerException e) {
e.printStackTrace();
}
}
}