Browse Source

Flow done

master
preyearegmi 6 years ago
parent
commit
2854b80367
  1. 101
      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

101
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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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); setContentView(R.layout.activity_exchange_method_v2);
ButterKnife.bind(this); ButterKnife.bind(this);
init(); 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); paymentModeViewContainer.setVisibility(View.VISIBLE);
paymentModeRvAdapter.setData(paymentModeList); paymentModeRvAdapter.setData(paymentModeList);
paymentModeRvAdapter.setSelectedItem(0); paymentModeRvAdapter.setSelectedItem(0);
@ -139,7 +135,8 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
super.onStart(); super.onStart();
countrySelectionSpinner.setOnClickListener(this); countrySelectionSpinner.setOnClickListener(this);
exRateCalculateButton.setOnClickListener(this); exRateCalculateButton.setOnClickListener(this);
registerTextWatchers(true);
registerTextWatchers(true);
} }
@ -161,7 +158,7 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
public void onCountrySelected(CountryPaymentService countryPaymentService) { public void onCountrySelected(CountryPaymentService countryPaymentService) {
this.selectedCountryPaymentService = countryPaymentService; this.selectedCountryPaymentService = countryPaymentService;
showSelectedRecipient(countryPaymentService.getCountryCode(), countryPaymentService.getCurrency()); showSelectedRecipient(countryPaymentService.getCountryCode(), countryPaymentService.getCurrency());
showPaymentService(true,countryPaymentService.getServiceAvailable());
showPaymentService(true, countryPaymentService.getServiceAvailable());
if (this.countryListingDialog != null) if (this.countryListingDialog != null)
this.countryListingDialog.dismiss(); this.countryListingDialog.dismiss();
} }
@ -169,9 +166,9 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
private void showSelectedRecipient(String selectedCountryCode, String selectedCountryCurrency) { private void showSelectedRecipient(String selectedCountryCode, String selectedCountryCurrency) {
int flagResId = CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode); int flagResId = CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode);
if (flagResId != -1) if (flagResId != -1)
this.recepientFlagImageView.setBackgroundResource(CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode));
if(selectedCountryCurrency!=null)
this.recepientCurrencyTextView.setText(selectedCountryCurrency);
this.recepientFlagImageView.setBackgroundResource(CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode));
if (selectedCountryCurrency != null)
this.recepientCurrencyTextView.setText(selectedCountryCurrency);
} }
@Override @Override
@ -180,41 +177,39 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
case R.id.countrySelectionSpinner: case R.id.countrySelectionSpinner:
showCountryListinDialog(); showCountryListinDialog();
break; break;
case R.id.exRateCalculateButton:
prepareToGetForex();
break;
case R.id.exRateCalculateButton:
prepareToGetForex();
break;
} }
} }
@Override @Override
public void showCountryServiceData(List<CountryPaymentService> countryPaymentServiceList, CountryPaymentService defaultCountryPaymentService, String seedValue) { 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) //Update some flag here for forexchange (i.e either recieve)
if (seedValue != null) { if (seedValue != null) {
this.recieveMoneyEditText.setText(seedValue); this.recieveMoneyEditText.setText(seedValue);
} }
showSelectedRecipient(defaultCountryPaymentService.getCountryCode(), defaultCountryPaymentService.getCurrency()); showSelectedRecipient(defaultCountryPaymentService.getCountryCode(), defaultCountryPaymentService.getCurrency());
showPaymentService(true,defaultCountryPaymentService.getServiceAvailable());
showPaymentService(true, defaultCountryPaymentService.getServiceAvailable());
this.selectedCountryPaymentService = defaultCountryPaymentService; 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) //Update some flag here for forexchange (i.e either send)
if (seedValue != null) { if (seedValue != null) {
this.sendMoneyEditText.setText(seedValue); this.sendMoneyEditText.setText(seedValue);
recieveMoneyEditText.setText(""); recieveMoneyEditText.setText("");
} }
//We are taking first item as default as we don't have any default item enlisted //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()); showSelectedRecipient(firstSelectedItem.getCountryCode(), firstSelectedItem.getCurrency());
showPaymentService(true,firstSelectedItem.getServiceAvailable());
showPaymentService(true, firstSelectedItem.getServiceAvailable());
this.selectedCountryPaymentService = firstSelectedItem; 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(); prepareToGetForex();
} }
private void registerTextWatchers(boolean action)
{
if(action)
{
private void registerTextWatchers(boolean action) {
if (action) {
sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher); sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher);
recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher); recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher);
}
else
{
} else {
sendMoneyEditText.addTextChangedListener(null); sendMoneyEditText.addTextChangedListener(null);
recieveMoneyEditText.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 @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -267,11 +274,14 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
@Override @Override
public void afterTextChanged(Editable s) { 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 @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -285,7 +295,10 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod
@Override @Override
public void afterTextChanged(Editable s) { 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:inputType="numberDecimal"
android:gravity="center_vertical" android:gravity="center_vertical"
android:backgroundTint="@android:color/transparent" android:backgroundTint="@android:color/transparent"
android:hint="10,000,000"
android:textColor="@color/colorPrimary" android:textColor="@color/colorPrimary"
android:imeOptions="actionDone" android:imeOptions="actionDone"
android:textSize="21sp"/> android:textSize="21sp"/>
@ -211,6 +212,7 @@
android:inputType="numberDecimal" android:inputType="numberDecimal"
android:gravity="center_vertical" android:gravity="center_vertical"
android:imeOptions="actionDone" android:imeOptions="actionDone"
android:hint="10,000,000"
android:backgroundTint="@android:color/transparent" android:backgroundTint="@android:color/transparent"
android:textColor="@color/colorPrimary" android:textColor="@color/colorPrimary"
android:textSize="21sp"/> android:textSize="21sp"/>

Loading…
Cancel
Save