Browse Source

Flow done

master
preyearegmi 6 years ago
parent
commit
2854b80367
  1. 89
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java
  2. 2
      app/src/main/res/layout/activity_exchange_method_v2.xml

89
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java

@ -83,8 +83,8 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.sendAmountTextWatcher=new SendAmountTextWatcher();
this.recepientAmountTextWatcher=new RecipientAmountTextWatcher();
this.sendAmountTextWatcher = new SendAmountTextWatcher();
this.recepientAmountTextWatcher = new RecipientAmountTextWatcher();
setContentView(R.layout.activity_exchange_method_v2);
ButterKnife.bind(this);
init();
@ -106,13 +106,9 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
}
private void showPaymentService(boolean action, List<PaymentMode> paymentModeList)
{
if(paymentModeRvAdapter!=null&&action&&paymentModeList.size()>0)
{
if(paymentModeViewContainer.getVisibility()!=View.VISIBLE)
private void showPaymentService(boolean action, List<PaymentMode> paymentModeList) {
if (paymentModeRvAdapter != null && action && paymentModeList.size() > 0) {
if (paymentModeViewContainer.getVisibility() != View.VISIBLE)
paymentModeViewContainer.setVisibility(View.VISIBLE);
paymentModeRvAdapter.setData(paymentModeList);
paymentModeRvAdapter.setSelectedItem(0);
@ -141,6 +137,7 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
exRateCalculateButton.setOnClickListener(this);
registerTextWatchers(true);
}
@Override
@ -161,7 +158,7 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
public void onCountrySelected(CountryPaymentService countryPaymentService) {
this.selectedCountryPaymentService = countryPaymentService;
showSelectedRecipient(countryPaymentService.getCountryCode(), countryPaymentService.getCurrency());
showPaymentService(true,countryPaymentService.getServiceAvailable());
showPaymentService(true, countryPaymentService.getServiceAvailable());
if (this.countryListingDialog != null)
this.countryListingDialog.dismiss();
}
@ -170,7 +167,7 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
int flagResId = CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode);
if (flagResId != -1)
this.recepientFlagImageView.setBackgroundResource(CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode));
if(selectedCountryCurrency!=null)
if (selectedCountryCurrency != null)
this.recepientCurrencyTextView.setText(selectedCountryCurrency);
}
@ -188,33 +185,31 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
@Override
public void showCountryServiceData(List<CountryPaymentService> countryPaymentServiceList, CountryPaymentService defaultCountryPaymentService, String seedValue) {
if(defaultCountryPaymentService!=null) {
if (defaultCountryPaymentService != null) {
//Update some flag here for forexchange (i.e either recieve)
if (seedValue != null) {
this.recieveMoneyEditText.setText(seedValue);
}
showSelectedRecipient(defaultCountryPaymentService.getCountryCode(), defaultCountryPaymentService.getCurrency());
showPaymentService(true,defaultCountryPaymentService.getServiceAvailable());
showPaymentService(true, defaultCountryPaymentService.getServiceAvailable());
this.selectedCountryPaymentService = defaultCountryPaymentService;
this.selectedPaymentMode=defaultCountryPaymentService.getServiceAvailable().get(0);
shouldCaulatedByRecipient=true;
this.selectedPaymentMode = defaultCountryPaymentService.getServiceAvailable().get(0);
shouldCaulatedByRecipient = true;
}
else
{
} else {
//Update some flag here for forexchange (i.e either send)
if (seedValue != null) {
this.sendMoneyEditText.setText(seedValue);
recieveMoneyEditText.setText("");
}
//We are taking first item as default as we don't have any default item enlisted
CountryPaymentService firstSelectedItem=countryPaymentServiceList.get(0);
CountryPaymentService firstSelectedItem = countryPaymentServiceList.get(0);
showSelectedRecipient(firstSelectedItem.getCountryCode(), firstSelectedItem.getCurrency());
showPaymentService(true,firstSelectedItem.getServiceAvailable());
showPaymentService(true, firstSelectedItem.getServiceAvailable());
this.selectedCountryPaymentService = firstSelectedItem;
this.selectedPaymentMode=firstSelectedItem.getServiceAvailable().get(0);
shouldCaulatedByRecipient=true;
this.selectedPaymentMode = firstSelectedItem.getServiceAvailable().get(0);
shouldCaulatedByRecipient = true;
}
@ -222,23 +217,36 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
prepareToGetForex();
}
private void registerTextWatchers(boolean action)
{
if(action)
{
private void registerTextWatchers(boolean action) {
if (action) {
sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher);
recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher);
}
else
{
} else {
sendMoneyEditText.addTextChangedListener(null);
recieveMoneyEditText.addTextChangedListener(null);
}
}
private void prepareToGetForex()
{
this.presenter.getForex(this.selectedCountryPaymentService,this.selectedPaymentMode,recieveMoneyEditText.getText().toString(),sendMoneyEditText.getText().toString(),shouldCaulatedByRecipient);
private void registerAvailableTextWatchersForEditText(EditText editText, boolean action) {
switch (editText.getId()) {
case R.id.sendAmountEdTxt:
if(action)
sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher);
else
sendMoneyEditText.removeTextChangedListener(sendAmountTextWatcher);
break;
case R.id.receiveAmountEdTxt:
if(action)
recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher);
else
recieveMoneyEditText.removeTextChangedListener(recepientAmountTextWatcher);
break;
}
}
private void prepareToGetForex() {
this.presenter.getForex(this.selectedCountryPaymentService, this.selectedPaymentMode, recieveMoneyEditText.getText().toString(), sendMoneyEditText.getText().toString(), shouldCaulatedByRecipient);
}
@ -252,8 +260,7 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
}
private class SendAmountTextWatcher implements TextWatcher
{
private class SendAmountTextWatcher implements TextWatcher {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -267,11 +274,14 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
@Override
public void afterTextChanged(Editable s) {
shouldCaulatedByRecipient=false;
shouldCaulatedByRecipient = false;
registerAvailableTextWatchersForEditText(recieveMoneyEditText,false);
recieveMoneyEditText.setText("");
registerAvailableTextWatchersForEditText(recieveMoneyEditText,true);
}
}
private class RecipientAmountTextWatcher implements TextWatcher
{
private class RecipientAmountTextWatcher implements TextWatcher {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -285,7 +295,10 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
@Override
public void afterTextChanged(Editable s) {
shouldCaulatedByRecipient=true;
shouldCaulatedByRecipient = true;
registerAvailableTextWatchersForEditText(sendMoneyEditText,false);
sendMoneyEditText.setText("");
registerAvailableTextWatchersForEditText(sendMoneyEditText,true);
}
}

2
app/src/main/res/layout/activity_exchange_method_v2.xml

@ -47,6 +47,7 @@
android:inputType="numberDecimal"
android:gravity="center_vertical"
android:backgroundTint="@android:color/transparent"
android:hint="10,000,000"
android:textColor="@color/colorPrimary"
android:imeOptions="actionDone"
android:textSize="21sp"/>
@ -211,6 +212,7 @@
android:inputType="numberDecimal"
android:gravity="center_vertical"
android:imeOptions="actionDone"
android:hint="10,000,000"
android:backgroundTint="@android:color/transparent"
android:textColor="@color/colorPrimary"
android:textSize="21sp"/>

Loading…
Cancel
Save