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) {
switch (countryCode) {
case "BD":
return R.drawable.flag_bangladesh;
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) {
int flagResId = CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode);
int flagResId = -1;
if (selectedCountryCode != null)
flagResId = CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode);
if (flagResId != -1)
this.recepientFlagImageView.setBackgroundResource(CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode));
this.recepientFlagImageView.setBackgroundResource(flagResId);
else
this.recepientFlagImageView.setBackgroundResource(0);
if (selectedCountryCurrency != null)
this.recepientCurrencyTextView.setText(selectedCountryCurrency);
}
@ -366,15 +371,25 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View.
protected void onSuccess(AmountDetailRelatedDataModel amountDetailRelatedDataModel) {
if (isUIReady()) {
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());
updateButtonToCalculate(true);
}
}
scheduleTaskLater(() -> {
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());
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 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.sendmoneyV2.adapter.PayoutModeBranchListingRvAdapter;
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 ProgressBar progressBar;
private Interpolator interpolator;
private boolean isUIReady=false;
UIStateHandler uiStateHandler;
@Override
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() {
dialogTitle.setText("Select Branch");
uiStateHandler=new UIStateHandler();
cancelButton.setOnClickListener(this);
searchEditTextView.addTextChangedListener(this);
payoutModeBranchListingRvAdapter = new PayoutModeBranchListingRvAdapter(this.listener);
@ -127,6 +148,8 @@ public class PayoutModeBranchListingDialog extends DialogFragment implements Vie
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
uiStateHandler.clearPendingTask();
uiStateHandler=null;
cancelButton.setOnClickListener(null);
searchEditTextView.removeTextChangedListener(this);
compositeDisposable.dispose();
@ -188,14 +211,11 @@ public class PayoutModeBranchListingDialog extends DialogFragment implements Vie
if(noCountryFoundView.getVisibility()!=View.VISIBLE)
noCountryFoundView.setVisibility(View.VISIBLE);
noCountryFoundView.setHint(message);
}
else {
if(noCountryFoundView.getVisibility()==View.VISIBLE)
noCountryFoundView.setVisibility(View.INVISIBLE);
noCountryFoundView.setHint("");
}
}
@ -255,44 +275,77 @@ public class PayoutModeBranchListingDialog extends DialogFragment implements Vie
@Override
protected void onSuccess(BranchListApiResponse branchListApiResponse) {
if(isUIReady) {
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, "");
showRecyclerView(true);
payoutModeBranchListingRvAdapter.setData(branchListApiResponse.getData());
}
} else {
showErrorMessage(true, branchListApiResponse.getMsg());
showRecyclerView(false);
}
}
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);
}
});
}
}
@Override
public void onFailed(String message) {
if(isUIReady) {
hideProgressView(true);
showErrorMessage(true,message);
showErrorMessage(true, message);
}
else
{
uiStateHandler.enqueueUITask(()->{
hideProgressView(true);
showErrorMessage(true, message);
});
}
}
@Override
protected void onConnectionNotEstablished(String message) {
if(isUIReady) {
hideProgressView(true);
showErrorMessage(true,message);
showErrorMessage(true, message);
}
else
{
uiStateHandler.enqueueUITask(()->{
hideProgressView(true);
showErrorMessage(true, message);
});
}
}
}

Loading…
Cancel
Save