|
|
@ -4,8 +4,12 @@ import com.gmeremit.online.gmeremittance_native.base.BasePresenter; |
|
|
|
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog; |
|
|
|
import com.gmeremit.online.gmeremittance_native.domesticremit.receipt.model.DomesticRemitTxnReceiptDTO; |
|
|
|
import com.gmeremit.online.gmeremittance_native.domesticremit.receipt.view.DomesticRemitReceiptActivity; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.Constants; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.https.GenericApiObserverResponseV2; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.https.GenericResponseDataModel; |
|
|
|
import com.google.gson.reflect.TypeToken; |
|
|
|
|
|
|
|
import java.lang.reflect.Type; |
|
|
|
|
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers; |
|
|
|
import io.reactivex.disposables.CompositeDisposable; |
|
|
@ -17,28 +21,35 @@ public class DomesticRemitReceiptPresenterImpl extends BasePresenter implements |
|
|
|
private final DomesticRemitReceiptGatewayInterface gateway; |
|
|
|
private final CompositeDisposable compositeDisposable; |
|
|
|
private final String txnId; |
|
|
|
private final boolean requestFromDomesticRemitProcess; |
|
|
|
|
|
|
|
public DomesticRemitReceiptPresenterImpl(DomesticRemitReceiptViewContract view, DomesticRemitReceiptGatewayInterface gateway, String txnId) { |
|
|
|
public DomesticRemitReceiptPresenterImpl(DomesticRemitReceiptViewContract view, DomesticRemitReceiptGatewayInterface gateway, String txnId, boolean requestFromDomesticremitProcess) { |
|
|
|
this.view=view; |
|
|
|
this.gateway=gateway; |
|
|
|
this.compositeDisposable =new CompositeDisposable(); |
|
|
|
this.txnId=txnId; |
|
|
|
this.requestFromDomesticRemitProcess=requestFromDomesticremitProcess; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void getReceiptData() { |
|
|
|
// compositeDisposable.add( |
|
|
|
// this.gateway.getReceiptData(gateway.getAuth(),this.txnId) |
|
|
|
// .doOnSubscribe(dis->view.showProgressBar(true,"")) |
|
|
|
// .doFinally(()->view.showProgressBar(false,"")) |
|
|
|
// .subscribeOn(Schedulers.io()) |
|
|
|
// .observeOn(AndroidSchedulers.mainThread()) |
|
|
|
// .subscribeWith(new DomesticRemitReceiptObserver()) |
|
|
|
// |
|
|
|
// ); |
|
|
|
compositeDisposable.add( |
|
|
|
this.gateway.getReceiptData(gateway.getAuth(),this.txnId) |
|
|
|
.doOnSubscribe(dis->view.showProgressBar(true,"")) |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.doFinally(()->view.showProgressBar(false,"")) |
|
|
|
.subscribeWith(new DomesticRemitReceiptObserver()) |
|
|
|
|
|
|
|
); |
|
|
|
formatDataAndUpdateReceipt(this.gateway.getMockedReciept()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean isRequestFromDomesticRemitProcess() { |
|
|
|
return requestFromDomesticRemitProcess; |
|
|
|
} |
|
|
|
|
|
|
|
private void formatDataAndUpdateReceipt(DomesticRemitTxnReceiptDTO domesticRemitTxnReceiptDTO) |
|
|
|
{ |
|
|
|
DomesticRemitReceiptActivity.TxnReceiptViewModel txnReceiptViewModel=new DomesticRemitReceiptActivity.TxnReceiptViewModel(); |
|
|
@ -58,10 +69,21 @@ public class DomesticRemitReceiptPresenterImpl extends BasePresenter implements |
|
|
|
|
|
|
|
public class DomesticRemitReceiptObserver extends GenericApiObserverResponseV2<DomesticRemitTxnReceiptDTO> |
|
|
|
{ |
|
|
|
@Override |
|
|
|
protected Type getDataType() { |
|
|
|
return TypeToken.getParameterized(DomesticRemitTxnReceiptDTO.class).getType(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onSuccess(GenericResponseDataModel<DomesticRemitTxnReceiptDTO> t) { |
|
|
|
|
|
|
|
if(t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) |
|
|
|
{ |
|
|
|
formatDataAndUpdateReceipt(t.getData()); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|