Skip to content

Commit

Permalink
fix min bet amount bug, add balance listener to EventsActivity, fixed…
Browse files Browse the repository at this point in the history
… random ConcurrentModificationException b 248
  • Loading branch information
MIPPL committed Nov 5, 2019
1 parent f256959 commit 26c5a3b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Expand Up @@ -7,8 +7,8 @@ android {
applicationId = 'com.wagerrwallet'
minSdkVersion 23
targetSdkVersion 28
versionCode 247
versionName "247"
versionCode 248
versionName "248"
multiDexEnabled true

// Similar to other properties in the defaultConfig block,
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/com/wagerrwallet/WagerrApp.java
Expand Up @@ -23,6 +23,7 @@
import com.google.firebase.crash.FirebaseCrash;

import java.util.ArrayList;
import java.util.ConcurrentModificationException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -226,7 +227,14 @@ public static void setBreadContext(Activity app) {
public static synchronized void fireListeners() {
if (listeners == null) return;
List<OnAppBackgrounded> copy = listeners;
for (OnAppBackgrounded lis : copy) if (lis != null) lis.onBackgrounded();

for (OnAppBackgrounded lis : copy) {
try {
if (lis != null) lis.onBackgrounded();
}
catch (ConcurrentModificationException e) {
}
}
}

public static void addOnBackgroundedListener(OnAppBackgrounded listener) {
Expand Down
Expand Up @@ -66,6 +66,7 @@
import com.wagerrwallet.tools.util.Utils;
import com.wagerrwallet.wallet.WalletsMaster;
import com.wagerrwallet.wallet.abstracts.BaseWalletManager;
import com.wagerrwallet.wallet.abstracts.OnBalanceChangedListener;
import com.wagerrwallet.wallet.abstracts.OnEventTxListModified;
import com.wagerrwallet.wallet.abstracts.OnTxListModified;
import com.wagerrwallet.wallet.abstracts.SyncListener;
Expand Down Expand Up @@ -293,6 +294,12 @@ public void onClick(View v) {
BRDialog.showSimpleDialog(this, getString(R.string.Dialog_screenAlteringTitle), getString(R.string.Dialog_screenAlteringMessage));
}

WalletsMaster.getInstance(this).getCurrentWallet(this).addBalanceChangedListener(new OnBalanceChangedListener() {
@Override
public void onBalanceChanged(String iso, long newBalance) {
updateBalance();
}
});
}

public boolean isSearchActive() {
Expand Down Expand Up @@ -455,6 +462,19 @@ private void updateUi() {

// String fiatIso = BRSharedPrefs.getPreferredFiatIso(this);

updateBalance();

mToolbar.setBackgroundColor(Color.parseColor(wallet.getUiConfiguration().colorHex));
//mSendButton.setColor(Color.parseColor(wallet.getUiConfiguration().colorHex));
//mBuyButton.setColor(Color.parseColor(wallet.getUiConfiguration().colorHex));
//mReceiveButton.setColor(Color.parseColor(wallet.getUiConfiguration().colorHex));

EventTxManager.getInstance().updateTxList(EventsActivity.this);
}

protected void updateBalance() {
final BaseWalletManager wallet = WalletsMaster.getInstance(this).getCurrentWallet(this);

String fiatExchangeRate = CurrencyUtils.getFormattedAmount(this, BRSharedPrefs.getPreferredFiatIso(this), wallet.getFiatExchangeRate(this));
String fiatBalance = CurrencyUtils.getFormattedAmount(this, BRSharedPrefs.getPreferredFiatIso(this), wallet.getFiatBalance(this));
String cryptoBalance = CurrencyUtils.getFormattedAmount(this, wallet.getIso(this), new BigDecimal(wallet.getCachedBalance(this)));
Expand All @@ -463,12 +483,6 @@ private void updateUi() {
mCurrencyPriceUsd.setText(String.format("%s per %s", fiatExchangeRate, wallet.getIso(this)));
mBalancePrimary.setText(fiatBalance);
mBalanceSecondary.setText(cryptoBalance);
mToolbar.setBackgroundColor(Color.parseColor(wallet.getUiConfiguration().colorHex));
//mSendButton.setColor(Color.parseColor(wallet.getUiConfiguration().colorHex));
//mBuyButton.setColor(Color.parseColor(wallet.getUiConfiguration().colorHex));
//mReceiveButton.setColor(Color.parseColor(wallet.getUiConfiguration().colorHex));

EventTxManager.getInstance().updateTxList(EventsActivity.this);
}

// This method checks if a screen altering app(such as Twightlight) is currently running
Expand Down
Expand Up @@ -333,7 +333,7 @@ public void afterTextChanged(Editable s) {
mAmountWhenSent = rootView.findViewById(R.id.amount_when_sent);

mTxNoBetBalance = rootView.findViewById(R.id.tx_no_bet_balance);
boolean canBet = ((int)(walletManager.getWallet().getBalance()/UNIT_MULTIPLIER) > getContext().getResources().getInteger(R.integer.min_bet_amount));
boolean canBet = (((float)walletManager.getWallet().getBalance())/UNIT_MULTIPLIER) > getContext().getResources().getInteger(R.integer.min_bet_amount);

if (canBet) {
mTxHomeOdds.setOnClickListener(this);
Expand Down

0 comments on commit 26c5a3b

Please sign in to comment.