Browse Source

Branch search fixes

master
preyearegmi 6 years ago
parent
commit
2fbf80a72f
  1. 1
      app/src/main/java/com/gmeremit/online/gmeremittance_native/customwidgets/exchangecountrylistingdialog/CountryFlagMapper.java
  2. 23
      app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailSendMoneyFragment.java
  3. 85
      app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/payoutmode/PayoutModeBranchListingDialog.java

1
app/src/main/java/com/gmeremit/online/gmeremittance_native/customwidgets/exchangecountrylistingdialog/CountryFlagMapper.java

@ -6,6 +6,7 @@ public class CountryFlagMapper {
public static int getFlagFromCountryCode(String countryCode) { public static int getFlagFromCountryCode(String countryCode) {
switch (countryCode) { switch (countryCode) {
case "BD": case "BD":
return R.drawable.flag_bangladesh; return R.drawable.flag_bangladesh;
case "KH": case "KH":

23
app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailSendMoneyFragment.java

@ -219,9 +219,14 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View.
} }
private void showSelectedCurrency(String selectedCountryCode, String selectedCountryCurrency) { private void showSelectedCurrency(String selectedCountryCode, String selectedCountryCurrency) {
int flagResId = CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode);
int flagResId = -1;
if (selectedCountryCode != null)
flagResId = CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode);
if (flagResId != -1) if (flagResId != -1)
this.recepientFlagImageView.setBackgroundResource(CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode));
this.recepientFlagImageView.setBackgroundResource(flagResId);
else
this.recepientFlagImageView.setBackgroundResource(0);
if (selectedCountryCurrency != null) if (selectedCountryCurrency != null)
this.recepientCurrencyTextView.setText(selectedCountryCurrency); this.recepientCurrencyTextView.setText(selectedCountryCurrency);
} }
@ -366,15 +371,25 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View.
protected void onSuccess(AmountDetailRelatedDataModel amountDetailRelatedDataModel) { protected void onSuccess(AmountDetailRelatedDataModel amountDetailRelatedDataModel) {
if (isUIReady()) { if (isUIReady()) {
amountDetailRelatedData = amountDetailRelatedDataModel; amountDetailRelatedData = amountDetailRelatedDataModel;
if (amountDetailRelatedData.getDefaultSelectedCurrency() != null)
if (amountDetailRelatedData == null||amountDetailRelatedData.getDefaultSelectedCurrency()==null){
showSelectedCurrency("", "---");
showPopUpMessage("No payout currency defined, please contact support.", CustomAlertDialog.AlertType.ALERT, null);
continueBtn.setOnClickListener(null);
} else {
showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode());
updateButtonToCalculate(true); updateButtonToCalculate(true);
} }
}
scheduleTaskLater(() -> { scheduleTaskLater(() -> {
amountDetailRelatedData = amountDetailRelatedDataModel; amountDetailRelatedData = amountDetailRelatedDataModel;
if (amountDetailRelatedData.getDefaultSelectedCurrency() != null)
if (amountDetailRelatedData == null||amountDetailRelatedData.getDefaultSelectedCurrency()==null) {
showSelectedCurrency("", "---");
showPopUpMessage("No payout currency defined, please contact support.", CustomAlertDialog.AlertType.ALERT, null);
continueBtn.setOnClickListener(null);
} else {
showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode());
updateButtonToCalculate(true); updateButtonToCalculate(true);
}
}); });
} }

85
app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/payoutmode/PayoutModeBranchListingDialog.java

@ -25,6 +25,7 @@ import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import com.gmeremit.online.gmeremittance_native.R; import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.base.UIStateHandler;
import com.gmeremit.online.gmeremittance_native.customwidgets.LineDividerItemDecoration; import com.gmeremit.online.gmeremittance_native.customwidgets.LineDividerItemDecoration;
import com.gmeremit.online.gmeremittance_native.sendmoneyV2.adapter.PayoutModeBranchListingRvAdapter; import com.gmeremit.online.gmeremittance_native.sendmoneyV2.adapter.PayoutModeBranchListingRvAdapter;
import com.gmeremit.online.gmeremittance_native.sendmoneyV2.model.amountdetail.BranchListApiResponse; import com.gmeremit.online.gmeremittance_native.sendmoneyV2.model.amountdetail.BranchListApiResponse;
@ -55,6 +56,9 @@ public class PayoutModeBranchListingDialog extends DialogFragment implements Vie
private CompositeDisposable compositeDisposable; private CompositeDisposable compositeDisposable;
private ProgressBar progressBar; private ProgressBar progressBar;
private Interpolator interpolator; private Interpolator interpolator;
private boolean isUIReady=false;
UIStateHandler uiStateHandler;
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
@ -74,9 +78,26 @@ public class PayoutModeBranchListingDialog extends DialogFragment implements Vie
} }
@Override
public void onPause() {
super.onPause();
isUIReady=false;
}
@Override
public void onResume() {
super.onResume();
isUIReady=true;
if(uiStateHandler!=null)
uiStateHandler.performPendingUITask();
}
private void initialize() { private void initialize() {
dialogTitle.setText("Select Branch"); dialogTitle.setText("Select Branch");
uiStateHandler=new UIStateHandler();
cancelButton.setOnClickListener(this); cancelButton.setOnClickListener(this);
searchEditTextView.addTextChangedListener(this); searchEditTextView.addTextChangedListener(this);
payoutModeBranchListingRvAdapter = new PayoutModeBranchListingRvAdapter(this.listener); payoutModeBranchListingRvAdapter = new PayoutModeBranchListingRvAdapter(this.listener);
@ -127,6 +148,8 @@ public class PayoutModeBranchListingDialog extends DialogFragment implements Vie
@Override @Override
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog); super.onDismiss(dialog);
uiStateHandler.clearPendingTask();
uiStateHandler=null;
cancelButton.setOnClickListener(null); cancelButton.setOnClickListener(null);
searchEditTextView.removeTextChangedListener(this); searchEditTextView.removeTextChangedListener(this);
compositeDisposable.dispose(); compositeDisposable.dispose();
@ -188,14 +211,11 @@ public class PayoutModeBranchListingDialog extends DialogFragment implements Vie
if(noCountryFoundView.getVisibility()!=View.VISIBLE) if(noCountryFoundView.getVisibility()!=View.VISIBLE)
noCountryFoundView.setVisibility(View.VISIBLE); noCountryFoundView.setVisibility(View.VISIBLE);
noCountryFoundView.setHint(message); noCountryFoundView.setHint(message);
} }
else { else {
if(noCountryFoundView.getVisibility()==View.VISIBLE) if(noCountryFoundView.getVisibility()==View.VISIBLE)
noCountryFoundView.setVisibility(View.INVISIBLE); noCountryFoundView.setVisibility(View.INVISIBLE);
noCountryFoundView.setHint(""); noCountryFoundView.setHint("");
} }
} }
@ -255,44 +275,77 @@ public class PayoutModeBranchListingDialog extends DialogFragment implements Vie
@Override @Override
protected void onSuccess(BranchListApiResponse branchListApiResponse) { protected void onSuccess(BranchListApiResponse branchListApiResponse) {
if(isUIReady) {
hideProgressView(true); hideProgressView(true);
if(branchListApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2))
{
if(branchListApiResponse.getData().isEmpty())
{
showErrorMessage(false,NO_BRANCH_FOUND);
if (branchListApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) {
if (branchListApiResponse.getData().isEmpty()) {
showErrorMessage(false, NO_BRANCH_FOUND);
}
else
{
} else {
showErrorMessage(false, ""); showErrorMessage(false, "");
showRecyclerView(true); showRecyclerView(true);
payoutModeBranchListingRvAdapter.setData(branchListApiResponse.getData()); payoutModeBranchListingRvAdapter.setData(branchListApiResponse.getData());
} }
} else {
showErrorMessage(true, branchListApiResponse.getMsg());
showRecyclerView(false);
}
} }
else else
{ {
showErrorMessage(true,branchListApiResponse.getMsg());
uiStateHandler.enqueueUITask(()->{
hideProgressView(true);
if (branchListApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) {
if (branchListApiResponse.getData().isEmpty()) {
showErrorMessage(false, NO_BRANCH_FOUND);
} else {
showErrorMessage(false, "");
showRecyclerView(true);
payoutModeBranchListingRvAdapter.setData(branchListApiResponse.getData());
}
} else {
showErrorMessage(true, branchListApiResponse.getMsg());
showRecyclerView(false); showRecyclerView(false);
} }
});
}
} }
@Override @Override
public void onFailed(String message) { public void onFailed(String message) {
if(isUIReady) {
hideProgressView(true); hideProgressView(true);
showErrorMessage(true,message);
showErrorMessage(true, message);
}
else
{
uiStateHandler.enqueueUITask(()->{
hideProgressView(true);
showErrorMessage(true, message);
});
}
} }
@Override @Override
protected void onConnectionNotEstablished(String message) { protected void onConnectionNotEstablished(String message) {
if(isUIReady) {
hideProgressView(true); hideProgressView(true);
showErrorMessage(true,message);
showErrorMessage(true, message);
}
else
{
uiStateHandler.enqueueUITask(()->{
hideProgressView(true);
showErrorMessage(true, message);
});
}
} }
} }

Loading…
Cancel
Save