Fix invalid API keys crash
This commit is contained in:
parent
04f997c675
commit
9cacb7a380
@ -27,6 +27,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
@ -729,7 +730,12 @@ public class HomeActivity extends AppCompatActivity {
|
||||
}
|
||||
else
|
||||
{
|
||||
countCoins(false, false);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
countCoins(false, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -739,12 +745,21 @@ public class HomeActivity extends AppCompatActivity {
|
||||
{
|
||||
case "com.android.volley.AuthFailureError":
|
||||
preferencesManager.disableHitBTC();
|
||||
Snackbar.make(findViewById(R.id.currencyListLayout), "HitBTC synchronization error : Invalid keys", Snackbar.LENGTH_LONG)
|
||||
Snackbar.make(findViewById(R.id.viewFlipperSummary), "HitBTC synchronization error : Invalid keys", Snackbar.LENGTH_LONG)
|
||||
.show();
|
||||
refreshLayout.setRefreshing(false);
|
||||
updateAll(true);
|
||||
break;
|
||||
case "API-key format invalid.":
|
||||
preferencesManager.disableBinance();
|
||||
Snackbar.make(findViewById(R.id.viewFlipperSummary), "Binance synchronization error : Invalid keys", Snackbar.LENGTH_LONG)
|
||||
.show();
|
||||
updateAll(true);
|
||||
break;
|
||||
default:
|
||||
Snackbar.make(findViewById(R.id.viewFlipperSummary), "Unexpected error", Snackbar.LENGTH_LONG)
|
||||
.show();
|
||||
Log.d("coinfolio", error);
|
||||
updateAll(true);
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ public class BalanceManager {
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
callBack.onError(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -205,7 +205,7 @@ public class BalanceManager {
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
callBack.onError(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -240,8 +240,6 @@ public class BalanceManager {
|
||||
|
||||
for(int i = 0; i < binanceManagers.size(); i++)
|
||||
{
|
||||
Log.d("coinfolio", "Merging binance " + i);
|
||||
|
||||
mergeBalanceTotal(binanceManagers.get(i).getBalance());
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import com.binance.api.client.BinanceApiClientFactory;
|
||||
import com.binance.api.client.BinanceApiRestClient;
|
||||
import com.binance.api.client.domain.account.Account;
|
||||
import com.binance.api.client.domain.account.AssetBalance;
|
||||
import com.binance.api.client.exception.BinanceApiException;
|
||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -38,20 +39,24 @@ public class BinanceManager {
|
||||
BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(publicKey, privateKey);
|
||||
BinanceApiRestClient client = factory.newRestClient();
|
||||
|
||||
Account account = client.getAccount();
|
||||
List<AssetBalance> assets = account.getBalances();
|
||||
try {
|
||||
Account account = client.getAccount();
|
||||
List<AssetBalance> assets = account.getBalances();
|
||||
|
||||
balance = new ArrayList<>();
|
||||
balance = new ArrayList<>();
|
||||
|
||||
for(int i = 0; i < assets.size(); i++)
|
||||
{
|
||||
if(Double.parseDouble(assets.get(i).getFree()) > 0)
|
||||
for(int i = 0; i < assets.size(); i++)
|
||||
{
|
||||
balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree())));
|
||||
if(Double.parseDouble(assets.get(i).getFree()) > 0)
|
||||
{
|
||||
balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callBack.onSuccess();
|
||||
callBack.onSuccess();
|
||||
} catch (BinanceApiException e) {
|
||||
callBack.onError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void setPublicKey(String publicKey)
|
||||
|
@ -82,6 +82,7 @@
|
||||
|
||||
<!--Exchange strings-->
|
||||
<string name="pref_header_exchange">Exchanges settings</string>
|
||||
<string name="pref_fingerprint">Touch ID</string>
|
||||
|
||||
<!--HitBTC-->
|
||||
<string name="pref_title_enable_synchronization_hitbtc">Enable synchronization</string>
|
||||
|
Loading…
Reference in New Issue
Block a user