Add support for multiple Binance accounts

- Small UI improvement for the Exchange list activity
- New Binance API jar created from this [fork](https://github.com/TanguyHerbron/binance-java-api)
- Disable VET display, waiting for the swap to be completely done
This commit is contained in:
Tanguy Herbron 2018-08-01 15:57:30 +02:00
parent 2d12cc3dbe
commit 3efa225e5c
7 changed files with 10 additions and 26 deletions

Binary file not shown.

View File

@ -64,6 +64,6 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('../libs/binance-api.jar') implementation files('../libs/binance-api-forked.jar')
implementation files('../libs/commons-codec-1.11.jar') implementation files('../libs/commons-codec-1.11.jar')
} }

View File

@ -69,23 +69,6 @@ public class BalanceManager {
this.dataNotifierInterface = dataNotifierInterface; this.dataNotifierInterface = dataNotifierInterface;
} }
public List<String> getBiggestCurrencies()
{
List<String> currenciesDetails = new ArrayList<>();
int index = 0;
Iterator<String> coinIterator = currencyDetailsList.getCoinInfosHashmap().keySet().iterator();
while(index < 11)
{
index++;
Log.d("moodl", "For " + index + " : " + coinIterator.next());
}
return currenciesDetails;
}
public void updateExchangeKeys() public void updateExchangeKeys()
{ {
hitBtcManagers.clear(); hitBtcManagers.clear();
@ -95,8 +78,6 @@ public class BalanceManager {
binanceManagers.clear(); binanceManagers.clear();
binanceManagers = databaseManager.getBinanceAccounts(); binanceManagers = databaseManager.getBinanceAccounts();
Log.d("moodl", "Number of binance accounts " + binanceManagers.size());
} }
public List<Currency> getTotalBalance() public List<Currency> getTotalBalance()
@ -120,8 +101,8 @@ public class BalanceManager {
for(int i = 0; i < binanceManagers.size(); i++) for(int i = 0; i < binanceManagers.size(); i++)
{ {
final int index = i; final BinanceManager binanceManager = binanceManagers.get(i);
binanceManagers.get(i).updateBalance(new BinanceManager.BinanceCallBack() { binanceManager.updateBalance(new BinanceManager.BinanceCallBack() {
@Override @Override
public void onSuccess() { public void onSuccess() {
countBalances(); countBalances();
@ -129,7 +110,7 @@ public class BalanceManager {
@Override @Override
public void onError(String error) { public void onError(String error) {
databaseManager.disableExchangeAccount(binanceManagers.get(index).getId()); databaseManager.disableExchangeAccount(binanceManager.getId());
dataNotifierInterface.onBalanceError(error); dataNotifierInterface.onBalanceError(error);
} }
}); });

View File

@ -43,6 +43,7 @@ public class BinanceManager extends Exchange {
public void updateBalance(BinanceCallBack callBack) public void updateBalance(BinanceCallBack callBack)
{ {
BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(publicKey, privateKey); BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(publicKey, privateKey);
BinanceApiRestClient client = factory.newRestClient(); BinanceApiRestClient client = factory.newRestClient();
try { try {
@ -55,7 +56,10 @@ public class BinanceManager extends Exchange {
{ {
if(Double.parseDouble(assets.get(i).getFree()) > 0 || Double.parseDouble(assets.get(i).getLocked()) > 0) if(Double.parseDouble(assets.get(i).getFree()) > 0 || Double.parseDouble(assets.get(i).getLocked()) > 0)
{ {
balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree()) + Double.parseDouble(assets.get(i).getLocked()))); if(!assets.get(i).getAsset().equals("VET"))
{
balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree()) + Double.parseDouble(assets.get(i).getLocked())));
}
} }
} }
@ -69,7 +73,6 @@ public class BinanceManager extends Exchange {
{ {
trades = new ArrayList<>(); trades = new ArrayList<>();
for(int i = 0; i < pairSymbolList.size(); i++) for(int i = 0; i < pairSymbolList.size(); i++)
{ {
if(!pairSymbolList.get(i).equals(symbol)) if(!pairSymbolList.get(i).equals(symbol))

View File

@ -11,6 +11,6 @@
<ListView <ListView
android:id="@+id/exchange_listView" android:id="@+id/exchange_listView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="match_parent"/>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>

BIN
libs/binance-api-forked.jar Normal file

Binary file not shown.

Binary file not shown.