From b919e164e5057f0048df8cd5a2182acda5e2963b Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Wed, 1 Aug 2018 16:14:20 +0200 Subject: [PATCH] Exchange activities fix - Refresh balance after exchange update - Invalid HitBTC accounts are now disabled after balance refresh --- .../com/herbron/moodl/Activities/AddExchangeActivity.java | 7 +++++++ .../com/herbron/moodl/DataManagers/BalanceManager.java | 2 ++ 2 files changed, 9 insertions(+) diff --git a/app/src/main/java/com/herbron/moodl/Activities/AddExchangeActivity.java b/app/src/main/java/com/herbron/moodl/Activities/AddExchangeActivity.java index 424de9c..ac57d9b 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/AddExchangeActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/AddExchangeActivity.java @@ -17,6 +17,7 @@ import android.widget.Spinner; import com.herbron.moodl.DataManagers.DatabaseManager; import com.herbron.moodl.DataManagers.ExchangeManager.Exchange; +import com.herbron.moodl.DataManagers.PreferencesManager; import com.herbron.moodl.R; public class AddExchangeActivity extends AppCompatActivity { @@ -115,6 +116,9 @@ public class AddExchangeActivity extends AppCompatActivity { public void onClick(View v) { if(isEditTextFilled(accountLabelEditText) && isEditTextFilled(publicKeyEditText) && isEditTextFilled(secretKeyEditText)) { + PreferencesManager preferencesManager = new PreferencesManager(getBaseContext()); + preferencesManager.setMustUpdateSummary(true); + databaseManager.deleteExchangeAccountFromId(exchangeInfos.getId()); databaseManager.addExchange(accountLabelEditText.getText().toString(), exchangeSpinner.getSelectedItemPosition() , accountDescriptionEditText.getText().toString(), publicKeyEditText.getText().toString() @@ -139,6 +143,9 @@ public class AddExchangeActivity extends AppCompatActivity { public void onClick(View v) { if(isEditTextFilled(accountLabelEditText) && isEditTextFilled(publicKeyEditText) && isEditTextFilled(secretKeyEditText)) { + PreferencesManager preferencesManager = new PreferencesManager(getBaseContext()); + preferencesManager.setMustUpdateSummary(true); + databaseManager.addExchange(accountLabelEditText.getText().toString(), exchangeSpinner.getSelectedItemPosition() , accountDescriptionEditText.getText().toString(), publicKeyEditText.getText().toString() , secretKeyEditText.getText().toString()); diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java b/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java index 35e130d..e851449 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java @@ -123,6 +123,7 @@ public class BalanceManager { for(int i = 0; i < hitBtcManagers.size(); i++) { + final HitBtcManager hitBtcManager = hitBtcManagers.get(i); hitBtcManagers.get(i).updateGlobalBalance(new HitBtcManager.HitBtcCallBack() { @Override public void onSuccess() { @@ -131,6 +132,7 @@ public class BalanceManager { @Override public void onError(String error) { + databaseManager.disableExchangeAccount(hitBtcManager.getId()); dataNotifierInterface.onBalanceError(error); } });