use of org.thoughtcrime.securesms.payments.currency.CurrencyExchange in project Signal-Android by WhisperSystems.
the class Payments method getCurrencyExchange.
@WorkerThread
@NonNull
public synchronized CurrencyExchange getCurrencyExchange(boolean refreshIfAble) throws IOException {
if (currencyConversions == null || shouldRefresh(refreshIfAble, currencyConversions.getTimestamp())) {
Log.i(TAG, "Currency conversion data is unavailable or a refresh was requested and available");
CurrencyConversions newCurrencyConversions = ApplicationDependencies.getSignalServiceAccountManager().getCurrencyConversions();
if (currencyConversions == null || (newCurrencyConversions != null && newCurrencyConversions.getTimestamp() > currencyConversions.getTimestamp())) {
currencyConversions = newCurrencyConversions;
}
}
if (currencyConversions != null) {
for (CurrencyConversion currencyConversion : currencyConversions.getCurrencies()) {
if ("MOB".equals(currencyConversion.getBase())) {
return new CurrencyExchange(currencyConversion.getConversions(), currencyConversions.getTimestamp());
}
}
}
throw new IOException("Unable to retrieve currency conversions");
}
Aggregations