|
@ -4,9 +4,9 @@ import androidx.appcompat.app.AppCompatActivity; |
|
|
import androidx.lifecycle.LiveData; |
|
|
import androidx.lifecycle.LiveData; |
|
|
import androidx.lifecycle.MutableLiveData; |
|
|
import androidx.lifecycle.MutableLiveData; |
|
|
|
|
|
|
|
|
|
|
|
import com.google.gson.reflect.TypeToken; |
|
|
import com.swifttech.remit.android.base.BaseViewModel; |
|
|
import com.swifttech.remit.android.base.BaseViewModel; |
|
|
import com.swifttech.remit.android.common.customwidgets.CustomAlertDialog; |
|
|
import com.swifttech.remit.android.common.customwidgets.CustomAlertDialog; |
|
|
import com.swifttech.remit.android.common.model.FormInputStateDTO; |
|
|
|
|
|
import com.swifttech.remit.android.features.security.RemitAuthManager; |
|
|
import com.swifttech.remit.android.features.security.RemitAuthManager; |
|
|
import com.swifttech.remit.android.features.security.model.RemitAuthFailedResult; |
|
|
import com.swifttech.remit.android.features.security.model.RemitAuthFailedResult; |
|
|
import com.swifttech.remit.android.features.security.model.RemitAuthSuccessResult; |
|
|
import com.swifttech.remit.android.features.security.model.RemitAuthSuccessResult; |
|
@ -18,6 +18,8 @@ import com.swifttech.remit.android.utils.https.GenericApiObserverResponseV2; |
|
|
import com.swifttech.remit.android.utils.https.GenericResponseDataModel; |
|
|
import com.swifttech.remit.android.utils.https.GenericResponseDataModel; |
|
|
import com.swifttech.remit.android.utils.https.MessageResponseDataModel; |
|
|
import com.swifttech.remit.android.utils.https.MessageResponseDataModel; |
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Type; |
|
|
|
|
|
|
|
|
import io.reactivex.Observable; |
|
|
import io.reactivex.Observable; |
|
|
import io.reactivex.android.schedulers.AndroidSchedulers; |
|
|
import io.reactivex.android.schedulers.AndroidSchedulers; |
|
|
import io.reactivex.disposables.CompositeDisposable; |
|
|
import io.reactivex.disposables.CompositeDisposable; |
|
@ -92,14 +94,15 @@ public class WithdrawPresenter extends BaseViewModel implements WithdrawPresente |
|
|
).setListener(new RemitAuthManager.RemitAuthListener() { |
|
|
).setListener(new RemitAuthManager.RemitAuthListener() { |
|
|
@Override |
|
|
@Override |
|
|
public void onRemitAuthSuccess(RemitAuthSuccessResult result) { |
|
|
public void onRemitAuthSuccess(RemitAuthSuccessResult result) { |
|
|
// useCaseSubs.add( |
|
|
|
|
|
// gateway.performWithdraw(gateway.getAuth(), gateway.getUserID(), selectedWithdrawAmount, result.getResult()) |
|
|
|
|
|
// .doOnSubscribe(subs -> view.showProgressBar(true, "")) |
|
|
|
|
|
// .subscribeOn(Schedulers.io()) |
|
|
|
|
|
// .observeOn(AndroidSchedulers.mainThread()) |
|
|
|
|
|
// .doFinally(() -> view.showProgressBar(false, "")) |
|
|
|
|
|
// .subscribeWith(new WithdrawTxnbserver()) |
|
|
|
|
|
// ); |
|
|
|
|
|
|
|
|
useCaseSubs.add( |
|
|
|
|
|
gateway.performWithdraw(gateway.getAuth(), gateway.getUserID(), selectedWithdrawAmount, result.getResult()) |
|
|
|
|
|
.doOnSubscribe(subs -> view.showProgressBar(true, "")) |
|
|
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
|
|
.doFinally(() -> view.showProgressBar(false, "")) |
|
|
|
|
|
.subscribeWith(new WithdrawTxnbserver()) |
|
|
|
|
|
); |
|
|
|
|
|
//TODO Mock Success Response |
|
|
view.showPopUpMessage("Withdraw Success", CustomAlertDialog.AlertType.SUCCESS, alertType -> view.exitView()); |
|
|
view.showPopUpMessage("Withdraw Success", CustomAlertDialog.AlertType.SUCCESS, alertType -> view.exitView()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -118,18 +121,19 @@ public class WithdrawPresenter extends BaseViewModel implements WithdrawPresente |
|
|
@Override |
|
|
@Override |
|
|
public void getWithdrawDetail() { |
|
|
public void getWithdrawDetail() { |
|
|
view.hideKeyBoard(); |
|
|
view.hideKeyBoard(); |
|
|
// useCaseSubs.add( |
|
|
|
|
|
// gateway.checkWithdrawStatus(gateway.getAuth(), gateway.getUserID(),selectedWithdrawAmount ) |
|
|
|
|
|
// .doOnSubscribe(subs -> view.showProgressBar(true, "")) |
|
|
|
|
|
// .subscribeOn(Schedulers.io()) |
|
|
|
|
|
// .observeOn(AndroidSchedulers.mainThread()) |
|
|
|
|
|
// .doFinally(() -> view.showProgressBar(false, "")) |
|
|
|
|
|
// .subscribeWith(new WithdrawStatusObserver()) |
|
|
|
|
|
// ); |
|
|
|
|
|
WithdrawStatusResponseDTO dummyData = new WithdrawStatusResponseDTO(); |
|
|
|
|
|
dummyData.seedDummyValues(); |
|
|
|
|
|
|
|
|
|
|
|
onReceivingWithdrawStatus(dummyData); |
|
|
|
|
|
|
|
|
useCaseSubs.add( |
|
|
|
|
|
gateway.checkWithdrawStatus(gateway.getAuth(), gateway.getUserID(),selectedWithdrawAmount ) |
|
|
|
|
|
.doOnSubscribe(subs -> view.showProgressBar(true, "")) |
|
|
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
|
|
.doFinally(() -> view.showProgressBar(false, "")) |
|
|
|
|
|
.subscribeWith(new WithdrawStatusObserver()) |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
//TODO Mock Success Response |
|
|
|
|
|
// WithdrawStatusResponseDTO dummyData = new WithdrawStatusResponseDTO(); |
|
|
|
|
|
// dummyData.seedDummyValues(); |
|
|
|
|
|
// onReceivingWithdrawStatus(dummyData); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -166,24 +170,29 @@ public class WithdrawPresenter extends BaseViewModel implements WithdrawPresente |
|
|
|
|
|
|
|
|
public class WithdrawStatusObserver extends GenericApiObserverResponseV2<WithdrawStatusResponseDTO> { |
|
|
public class WithdrawStatusObserver extends GenericApiObserverResponseV2<WithdrawStatusResponseDTO> { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected Type getDataType() { |
|
|
|
|
|
return TypeToken.getParameterized(WithdrawStatusResponseDTO.class).getType(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void onSuccess(GenericResponseDataModel<WithdrawStatusResponseDTO> t) { |
|
|
protected void onSuccess(GenericResponseDataModel<WithdrawStatusResponseDTO> t) { |
|
|
if (Constants.SUCCESS_CODE_V2.equalsIgnoreCase(t.getErrorCode()) && t.getData() != null) { |
|
|
if (Constants.SUCCESS_CODE_V2.equalsIgnoreCase(t.getErrorCode()) && t.getData() != null) { |
|
|
onReceivingWithdrawStatus(t.getData()); |
|
|
onReceivingWithdrawStatus(t.getData()); |
|
|
} else { |
|
|
} else { |
|
|
view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
|
|
|
|
|
view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, null); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void onFailed(String message) { |
|
|
public void onFailed(String message) { |
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
|
|
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void onConnectionNotEstablished(String message) { |
|
|
protected void onConnectionNotEstablished(String message) { |
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
|
|
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|