Browse Source

Recipient CRUD completed

master
preyearegmi 6 years ago
parent
commit
b8b3929269
  1. 160
      app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV2/gateway/RecipientAddV2Gateway.java
  2. 7
      app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV2/presenter/recipientadd/RecipientAddV2Presenter.java
  3. 2
      app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV2/presenter/recipientadd/RecipientAddV2PresenterInterface.java
  4. 48
      app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV2/view/recipientadd/RecipientAddV2Activity.java
  5. 5
      app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV2/view/recipientlisting/RecipientListingV2Activity.java

160
app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV2/gateway/RecipientAddV2Gateway.java

@ -11,166 +11,6 @@ import io.reactivex.Observable;
public class RecipientAddV2Gateway extends PrivilegedGateway implements RecipientAddV2InteractorInterface.RecipientAddV2GatewayInterface {
String mockedData="{\n" +
"\"ErrorCode\": \"0\",\n" +
"\"Msg\": \"success\",\n" +
"\"Id\": \"\",\n" +
"\"Data\": {\n" +
"\"Country\": [\n" +
"{\n" +
"\"Name\": \"Vietnam\",\n" +
"\"Id\": \"203\",\n" +
"\"IsProvienceReq\": \"true\",\n" +
"\"Code\": \"VN\",\n" +
"\"Provinces\": [\n" +
"{\n" +
"\"id\": \"019\",\n" +
"\"text\": \"AN GIANG\",\n" +
"\"District\": [\n" +
"{\n" +
"\"id\": \"1200\",\n" +
"\"text\": \"sdfsf\"\n" +
"}\n" +
"]\n" +
"}\n" +
"]\n" +
"}\n" +
"],\n" +
"\"TransferReasons\": [\n" +
"{\n" +
"\"id\": \"10992\",\n" +
"\"text\": \"Lending\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8055\",\n" +
"\"text\": \"Business travel\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8056\",\n" +
"\"text\": \"Personal travels and tours\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8057\",\n" +
"\"text\": \"Educational expenses\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8058\",\n" +
"\"text\": \"Medical Expenses\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8059\",\n" +
"\"text\": \"Household expenses\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8060\",\n" +
"\"text\": \"Family maintenance\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8061\",\n" +
"\"text\": \"Savings\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8062\",\n" +
"\"text\": \"EMI payment to Bank and Nonbanking financial institutions\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8063\",\n" +
"\"text\": \"Loan payment / Interest\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8064\",\n" +
"\"text\": \"Salary / Commission\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8065\",\n" +
"\"text\": \"Utility payment\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8066\",\n" +
"\"text\": \"Purchase of land / property\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8067\",\n" +
"\"text\": \"Rent\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8068\",\n" +
"\"text\": \"Repair and maintenance\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8069\",\n" +
"\"text\": \"Commission\"\n" +
"}\n" +
"],\n" +
"\"Relations\": [\n" +
"{\n" +
"\"id\": \"10992\",\n" +
"\"text\": \"Lending\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8055\",\n" +
"\"text\": \"Business travel\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8056\",\n" +
"\"text\": \"Personal travels and tours\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8057\",\n" +
"\"text\": \"Educational expenses\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8058\",\n" +
"\"text\": \"Medical Expenses\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8059\",\n" +
"\"text\": \"Household expenses\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8060\",\n" +
"\"text\": \"Family maintenance\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8061\",\n" +
"\"text\": \"Savings\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8062\",\n" +
"\"text\": \"EMI payment to Bank and Nonbanking financial institutions\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8063\",\n" +
"\"text\": \"Loan payment / Interest\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8064\",\n" +
"\"text\": \"Salary / Commission\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8065\",\n" +
"\"text\": \"Utility payment\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8066\",\n" +
"\"text\": \"Purchase of land / property\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8067\",\n" +
"\"text\": \"Rent\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8068\",\n" +
"\"text\": \"Repair and maintenance\"\n" +
"},\n" +
"{\n" +
"\"id\": \"8069\",\n" +
"\"text\": \"Commission\"\n" +
"}\n" +
"]\n" +
"}\n" +
"}";
private final RecipientAddV2InteractorInterface interactor;

7
app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV2/presenter/recipientadd/RecipientAddV2Presenter.java

@ -81,10 +81,11 @@ public class RecipientAddV2Presenter extends BasePresenter implements RecipientA
@Override
public void prepareRecipientForEdit(RecipientInfoModel recipientToBeEdited) {
compositeDisposable.add( Observable.zip( this.gateway.getRelatedDataFromServer(gateway.getAuth()),
compositeDisposable.add( Observable.zip( this.gateway.getRelatedDataFromServer(gateway.getAuth()).subscribeOn(Schedulers.io()),
Observable.just(recipientToBeEdited), EditableMergedData::new)
.doOnSubscribe(disposable -> this.view.showProgressBar(true, "Fetching data..."))
.doOnError((err) -> this.view.showProgressBar(false, ""))
.doFinally(()->this.view.showProgressBar(false, ""))
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new EditableMergedDataObserver())
@ -143,7 +144,7 @@ public class RecipientAddV2Presenter extends BasePresenter implements RecipientA
if(addRecipientApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2))
{
view.showToastMessage(addRecipientApiResponse.getMsg());
view.exitView();
view.returnToCallingActivityForSucess();
}
else
{
@ -229,6 +230,8 @@ public class RecipientAddV2Presenter extends BasePresenter implements RecipientA
editableData.getEmail(),
selectedTransferDetailModel);
view.showRelatedData(metaData);
}
else

2
app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV2/presenter/recipientadd/RecipientAddV2PresenterInterface.java

@ -31,5 +31,7 @@ public interface RecipientAddV2PresenterInterface extends BasePresenterInterface
String mobileNo,
String email,
TransferDetailModel selectedTransfer);
void returnToCallingActivityForSucess();
}
}

48
app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV2/view/recipientadd/RecipientAddV2Activity.java

@ -1,5 +1,7 @@
package com.gmeremit.online.gmeremittance_native.recipientV2.view.recipientadd;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
@ -23,7 +25,6 @@ import com.gmeremit.online.gmeremittance_native.recipientV2.view.RecipientDistri
import com.gmeremit.online.gmeremittance_native.recipientV2.view.RecipientProvinceListingDialog;
import com.gmeremit.online.gmeremittance_native.recipientV2.view.RecipientRelationListingDialog;
import com.gmeremit.online.gmeremittance_native.recipientV2.view.RecipientTransferListingDialog;
import com.gmeremit.online.gmeremittance_native.recipientV2.view.recipientlisting.RecipientListingV2Activity;
import com.gmeremit.online.gmeremittance_native.utils.Constants;
import java.util.List;
@ -89,7 +90,7 @@ public class RecipientAddV2Activity extends BaseActivity implements View.OnClick
private CountryDetailModel selectedCountry;
private ProvinceDetailModel selectedProvince;
private TransferDetailModel selectedTransferReason;
private RelationDetailModel seletedRelation;
private RelationDetailModel selectedRelation;
private DistrictDetailModel selectedDistrict;
private List<TransferDetailModel> transferReasonList;
@ -225,7 +226,7 @@ public class RecipientAddV2Activity extends BaseActivity implements View.OnClick
selectedProvince,
selectedDistrict,
ed_address.getText().toString(),
seletedRelation,
selectedRelation,
ed_mobile_no.getText().toString(),
ed_email.getText().toString(),
selectedTransferReason
@ -315,6 +316,43 @@ public class RecipientAddV2Activity extends BaseActivity implements View.OnClick
}
@Override
public void showDataForEditing(String firstName, String middleName, String lastName, CountryDetailModel selectedCountry, ProvinceDetailModel selectedProvince, DistrictDetailModel selectedDistrict, String address, RelationDetailModel selectedRelation, String mobileNo, String email, TransferDetailModel selectedTransfer) {
ed_firstname.setText(firstName);
ed_middlename.setText(middleName);
ed_lastname.setText(lastName);
this.selectedCountry=selectedCountry;
this.selectedProvince=selectedProvince;
this.selectedDistrict=selectedDistrict;
ed_address.setText(address);
this.selectedRelation =selectedRelation;
ed_mobile_no.setText(mobileNo);
ed_email.setText(email);
this.selectedTransferReason=selectedTransfer;
if(this.selectedCountry!=null)
ed_country.setText(this.selectedCountry.getName());
if(this.selectedProvince!=null)
ed_province.setText(this.selectedProvince.getText());
if(this.selectedDistrict!=null)
ed_district.setText(this.selectedDistrict.getText());
if(this.selectedRelation!=null)
ed_relation.setText(this.selectedRelation.getText());
if(selectedTransferReason!=null)
ed_transfer.setText(selectedTransferReason.getText());
}
@Override
public void returnToCallingActivityForSucess() {
Intent returnIntent = new Intent();
setResult(Activity.RESULT_OK,returnIntent);
finish();
}
@Override
public void onProvinceSelected(ProvinceDetailModel provinceDetailModel) {
this.selectedProvince = provinceDetailModel;
@ -347,8 +385,8 @@ public class RecipientAddV2Activity extends BaseActivity implements View.OnClick
@Override
public void onRelationSelected(RelationDetailModel relationDetailModel) {
this.seletedRelation = relationDetailModel;
this.ed_relation.setText(this.seletedRelation.getText());
this.selectedRelation = relationDetailModel;
this.ed_relation.setText(this.selectedRelation.getText());
if (relationListingDialog != null) {
relationListingDialog.dismiss();
relationListingDialog = null;

5
app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV2/view/recipientlisting/RecipientListingV2Activity.java

@ -82,7 +82,8 @@ public class RecipientListingV2Activity extends BaseActivity implements Recipien
switch(v.getId())
{
case R.id.addReceipient:
startActivity(new Intent(getApplicationContext(), RecipientAddV2Activity.class));
Intent intent = new Intent(getApplicationContext(), RecipientAddV2Activity.class);
startActivityForResult(intent,RecipientListingV2Activity.RECIPIENT_INFO_ACTION_EDIT);
break;
}
@ -127,7 +128,7 @@ public class RecipientListingV2Activity extends BaseActivity implements Recipien
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RecipientListingV2Activity.RECIPIENT_INFO_ACTION_EDIT && resultCode == RESULT_OK) {
//fetchDataOnce
this.recipientListingV2PresenterInterface.getAllRecipientList();
}
}

Loading…
Cancel
Save