Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillVolkov committed Oct 30, 2017
1 parent 10c66f5 commit 8638b30
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 53 deletions.
33 changes: 16 additions & 17 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
google()
}
android {
lintOptions {
Expand All @@ -33,7 +34,7 @@ android {

def appName = "QTUM"
compileSdkVersion 25
buildToolsVersion '25.0.3'
buildToolsVersion '26.0.2'
def versionPropertiesFile = file('version.properties')
def autoVersionCode
if (versionPropertiesFile.canRead()) {
Expand Down Expand Up @@ -78,10 +79,8 @@ android {
// }
// }
applicationVariants.all { variant ->
variant.outputs.each { output ->
def apk = output.outputFile;
def newName = appName + "-${versionName}(${versionCode})-${variant.buildType.name}.apk";
output.outputFile = new File(apk.parentFile, newName);
variant.outputs.all {
outputFileName = appName + "-${versionName}(${versionCode})-${variant.buildType.name}.apk"
}
}
}
Expand All @@ -97,25 +96,25 @@ dependencies {
exclude group: 'stax', module: 'stax'
}

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.4.0'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-all:$rootProject.ext.mockitoVersion"
testCompile "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"
testCompile 'org.assertj:assertj-core:2.8.0'

compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.android.support:design:25.4.0'
compile 'com.github.designsters:android-fork-bitcoinj:1.0.10'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.zxing:core:3.2.1'
compile 'com.android.support:multidex:1.0.2'
compile 'com.google.zxing:core:3.3.0'
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.google.zxing:android-core:3.3.0'
compile 'me.dm7.barcodescanner:zxing:1.8.4'
compile 'io.reactivex:rxjava:1.1.6'
compile 'io.reactivex:rxjava:1.2.2'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile('io.socket:socket.io-client:0.8.3') {
Expand All @@ -132,12 +131,12 @@ dependencies {
compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
compile 'com.mikhaellopez:hfrecyclerview:1.0.0'
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
compile 'com.google.firebase:firebase-core:11.4.2'
compile 'com.google.firebase:firebase-messaging:11.4.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.beloo.widget:ChipsLayoutManager:0.3.7@aar'
compile 'org.jsoup:jsoup:1.10.3'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
}
apply plugin: 'com.google.gms.google-services'
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class UpdateService extends Service {
private final int DEFAULT_NOTIFICATION_ID = 101;
private NotificationManager notificationManager;
private TransactionListener mTransactionListener = null;
private BalanceChangeListener mBalanceChangeListener;
private List<BalanceChangeListener> mBalanceChangeListeners = new ArrayList<>();
private HashMap<String,TokenBalanceChangeListener> mStringTokenBalanceChangeListenerHashMap = new HashMap<>();
private HashMap<String, TokenBalance> mAllTokenBalanceList = new HashMap<>();
private TokenListener mTokenListener;
Expand Down Expand Up @@ -136,8 +136,8 @@ public void call(Object... args) {
} catch (JSONException e) {
e.printStackTrace();
}
if (mBalanceChangeListener != null) {
mBalanceChangeListener.onChangeBalance(unconfirmedBalance, balance);
for(BalanceChangeListener balanceChangeListener : mBalanceChangeListeners){
balanceChangeListener.onChangeBalance(unconfirmedBalance, balance);
}
} catch (ClassCastException e) {
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
Expand Down Expand Up @@ -534,7 +534,7 @@ public void removeTransactionListener() {
}

public void addBalanceChangeListener(BalanceChangeListener balanceChangeListener) {
mBalanceChangeListener = balanceChangeListener;
mBalanceChangeListeners.add(balanceChangeListener);
if(balance!=null) {
balanceChangeListener.onChangeBalance(unconfirmedBalance, balance);
}
Expand Down Expand Up @@ -572,8 +572,8 @@ public void removeTokenBalanceChangeListener(String address){
mStringTokenBalanceChangeListenerHashMap.remove(address);
}

public void removeBalanceChangeListener() {
mBalanceChangeListener = null;
public void removeBalanceChangeListener(BalanceChangeListener balanceChangeListener) {
mBalanceChangeListeners.remove(balanceChangeListener);
}

public void clearNotification() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ public void onBackStackChanged() {
for (Fragment fr : fragments) {
if (fr != null && fr.getClass() != null) {
if (fr instanceof WalletFragment) {
((WalletFragment) fr).initBalanceListener();
showBottomNavigationView(false);
} else if (fr instanceof NewsFragment) {
showBottomNavigationView(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.regex.Pattern;

import rx.Subscriber;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

Expand All @@ -22,6 +23,7 @@ public class ImportWalletPresenterImpl extends BaseFragmentPresenterImpl impleme
private ImportWalletInteractor mImportWalletFragmentInteractor;
private boolean isDataLoaded = false;
private String mPassphrase;
private Subscription mSubscription;

public ImportWalletPresenterImpl(ImportWalletView importWalletFragmentView, ImportWalletInteractor importWalletInteractor) {
mImportWalletFragmentView = importWalletFragmentView;
Expand All @@ -43,7 +45,7 @@ public void onImportClick(String brainCode) {
getView().setProgressDialog();
getView().hideKeyBoard();
isDataLoaded = true;
getInteractor().importWallet(brainCode)
mSubscription = getInteractor().importWallet(brainCode)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<String>() {
Expand Down Expand Up @@ -106,6 +108,14 @@ public void onResume() {
}
}

@Override
public void onDestroyView() {
super.onDestroyView();
if(mSubscription!=null){
mSubscription.unsubscribe();
}
}

//setter for unit-testing
public void setDataLoaded(boolean dataLoaded) {
isDataLoaded = dataLoaded;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javax.crypto.Cipher;

import rx.Subscriber;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

Expand All @@ -31,6 +32,7 @@ public class PinPresenterImpl extends BaseFragmentPresenterImpl implements PinPr
private PinAction mAction;
private final Long mBanTime = 600000L;
private int titleID = 0;
private Subscription mSubscription;

private boolean isDataLoaded = false;

Expand Down Expand Up @@ -81,7 +83,7 @@ public void confirm(final String pin) {
getView().clearError();
getView().setProgressDialog();
getView().hideKeyBoard();
getInteractor().createWallet()
mSubscription = getInteractor().createWallet()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<String>() {
Expand Down Expand Up @@ -553,4 +555,12 @@ private void changeBanState(boolean isCorrect){
}
getInteractor().setFailedAttemptsCount(failedAttemptsCount);
}

@Override
public void onDestroyView() {
super.onDestroyView();
if(mSubscription!=null) {
mSubscription.unsubscribe();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,24 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (getTokenBalance() == null) {
mUpdateService = getMainActivity().getUpdateService();
mUpdateService.addBalanceChangeListener(new BalanceChangeListener() {
@Override
public void onChangeBalance(final BigDecimal unconfirmedBalance, final BigDecimal balance) {
getMainActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
getPresenter().onBalanceChanged(unconfirmedBalance, balance);
}
});
}
});
mUpdateService.addBalanceChangeListener(mBalanceChangeListener);
} else {
updateBalance(getTokenBalance(), null);
}
}

BalanceChangeListener mBalanceChangeListener = new BalanceChangeListener() {
@Override
public void onChangeBalance(final BigDecimal unconfirmedBalance, final BigDecimal balance) {
getMainActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
getPresenter().onBalanceChanged(unconfirmedBalance, balance);
}
});
}
};

@Override
public void onPause() {
if (zoomDialog != null) {
Expand All @@ -191,7 +193,7 @@ public void onDestroyView() {
super.onDestroyView();
hideKeyBoard();
if (mUpdateService != null) {
mUpdateService.removeBalanceChangeListener();
mUpdateService.removeBalanceChangeListener(mBalanceChangeListener);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ public abstract class SendFragment extends BaseFragment implements SendView {
protected SendPresenter sendBaseFragmentPresenter;
private boolean sendFrom = false;

BalanceChangeListener mBalanceChangeListener = new BalanceChangeListener() {
@Override
public void onChangeBalance(final BigDecimal unconfirmedBalance, final BigDecimal balance) {
getPresenter().handleBalanceChanges(unconfirmedBalance, balance);
}
};


@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
Expand All @@ -175,14 +182,8 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
public void onServiceConnectionChange(boolean isConnecting) {
if (isConnecting) {
mUpdateService = getUpdateService();
mUpdateService.removeBalanceChangeListener();

mUpdateService.addBalanceChangeListener(new BalanceChangeListener() {
@Override
public void onChangeBalance(final BigDecimal unconfirmedBalance, final BigDecimal balance) {
getPresenter().handleBalanceChanges(unconfirmedBalance, balance);
}
});

mUpdateService.addBalanceChangeListener(mBalanceChangeListener);
}
}
});
Expand Down Expand Up @@ -229,7 +230,7 @@ public void onResume() {
public void onDestroyView() {
super.onDestroyView();
mNetworkStateReceiver.removeNetworkStateListener(mNetworkStateListener);
mUpdateService.removeBalanceChangeListener();
mUpdateService.removeBalanceChangeListener(mBalanceChangeListener);
}

private void isQrCodeRecognition(boolean isQrCodeRecognition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void onDestroyView() {
super.onDestroyView();
mNetworkStateReceiver.removeNetworkStateListener(mNetworkStateListener);
mUpdateService.removeTransactionListener();
mUpdateService.removeBalanceChangeListener();
mUpdateService.removeBalanceChangeListener(balanceListener);
getMainActivity().removePermissionResultListener();
setAdapterNull();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ContractConfirmPresenterTest {

ContractConfirmPresenterImpl presenter;

private final static float minFee = 0.2f;
private final static BigDecimal minFee = new BigDecimal(0.2);
private final static int minGasPrice = 2;

@Before
Expand Down Expand Up @@ -75,7 +75,7 @@ public void initializeView_test(){
when(interactor.getMinGasPrice()).thenReturn(minGasPrice);
presenter.initializeViews();
verify(view,times(1)).updateGasPrice(eq(minGasPrice),anyInt());
verify(view,times(1)).updateFee(eq(minFee), anyDouble());
verify(view,times(1)).updateFee(eq(minFee.doubleValue()), anyDouble());
verify(view,times(1)).updateGasLimit(anyInt(),anyInt());
}

Expand Down
2 changes: 0 additions & 2 deletions app/src/test/java/org/qtum/wallet/PinPresenterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import org.qtum.wallet.ui.fragment.pin_fragment.PinInteractor;
import org.qtum.wallet.ui.fragment.pin_fragment.PinPresenterImpl;
import org.qtum.wallet.ui.fragment.pin_fragment.PinView;
import org.qtum.wallet.utils.fingerprint_utils.FingerprintUtils;
import org.qtum.wallet.utils.fingerprint_utils.SensorState;

import javax.crypto.Cipher;

Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.0'

// NOTE: Do not place your application dependencies here; they belong
Expand Down

0 comments on commit 8638b30

Please sign in to comment.