diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java index af8a6e43..b3a43837 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java @@ -192,6 +192,7 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod sendMoneyEditText.setOnEditorActionListener(null); sendMoneyEditText.setOnFocusChangeListener(null); + } @Override @@ -268,7 +269,6 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod switch (v.getId()) { case R.id.sendAmountEdTxt: if (actionId == EditorInfo.IME_ACTION_DONE) { - hideKeyBoard(); shouldCaulatedByRecipient = false; if (sendMoneyEditText.getText().toString().length() > 0) prepareToGetForex(); @@ -279,7 +279,6 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod case R.id.receiveAmountEdTxt: if (actionId == EditorInfo.IME_ACTION_DONE) { - hideKeyBoard(); shouldCaulatedByRecipient = true; if (recieveMoneyEditText.getText().toString().length() > 0) prepareToGetForex(); @@ -451,8 +450,10 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod private void prepareToGetForex() { - if (sendMoneyEditText.getText().length() > 0 || recieveMoneyEditText.getText().length() > 0) + if (sendMoneyEditText.getText().length() > 0 || recieveMoneyEditText.getText().length() > 0) { this.presenter.getForex(this.selectedCountryPaymentService, this.selectedPaymentMode, recieveMoneyEditText.getText().toString(), sendMoneyEditText.getText().toString(), shouldCaulatedByRecipient); + hideKeyBoard(); + } else showToastMessage("Please specify either of the amount."); } @@ -537,10 +538,10 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod // if(e.getAction()==MotionEvent.ACTION_UP&&( sendMoneyEditText.hasFocus()||recieveMoneyEditText.hasFocus())) if (e.getAction() == MotionEvent.ACTION_UP) { if (hasValidOutsideAmountWidgetTouch(e.getX(), e.getY())) { - View currentViewWithFocus = getCurrentFocus(); - if (currentViewWithFocus != null) - currentViewWithFocus.clearFocus(); - hideKeyBoard(); +// View currentViewWithFocus = getCurrentFocus(); +// if (currentViewWithFocus != null) +// currentViewWithFocus.clearFocus(); + prepareToGetForex(); return true; @@ -551,15 +552,23 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod private boolean hasValidOutsideAmountWidgetTouch(float x, float y) { - + int posX=(int)x; + int posY=(int)y; int[] sendMoneyLeftAndTopCoordinates = new int[2]; + int[] receiveMoneyLeftAndTopCoordinates = new int[2]; int[] backButtonLeftAndTopCoordinates = new int[2]; + int[] paymentModeRvLeftAndTopCoordinates = new int[2]; + + int[] calculateButtonLeftAndTopCoordinates = new int[2]; + sendMoneyViewContainer.getLocationOnScreen(sendMoneyLeftAndTopCoordinates); receiveMoneyViewContainer.getLocationOnScreen(receiveMoneyLeftAndTopCoordinates); iv_back.getLocationOnScreen(backButtonLeftAndTopCoordinates); + paymentModeRv.getLocationOnScreen(paymentModeRvLeftAndTopCoordinates); + exRateCalculateButton.getLocationOnScreen(paymentModeRvLeftAndTopCoordinates); Rect sendMoneyBoundRect = new Rect(sendMoneyLeftAndTopCoordinates[0], sendMoneyLeftAndTopCoordinates[1], sendMoneyLeftAndTopCoordinates[0] + sendMoneyViewContainer.getMeasuredWidth(), @@ -574,9 +583,21 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod backButtonLeftAndTopCoordinates[1] + iv_back.getMeasuredHeight()); + Rect rvBoundRect = new Rect(paymentModeRvLeftAndTopCoordinates[0], paymentModeRvLeftAndTopCoordinates[1], + paymentModeRvLeftAndTopCoordinates[0] + paymentModeRv.getMeasuredWidth(), + paymentModeRvLeftAndTopCoordinates[1] + paymentModeRv.getMeasuredHeight()); + + Rect calcButtonBoundRect = new Rect(calculateButtonLeftAndTopCoordinates[0], calculateButtonLeftAndTopCoordinates[1], + calculateButtonLeftAndTopCoordinates[0] + exRateCalculateButton.getMeasuredWidth(), + calculateButtonLeftAndTopCoordinates[1] + exRateCalculateButton.getMeasuredHeight()); + - boolean hasValidOutsideTouch = !sendMoneyBoundRect.contains((int) x, (int) y) && !receiveMoneyBoundRect.contains((int) x, (int) y); - return (hasValidOutsideTouch) &&(recieveMoneyEditText.hasFocus()||sendMoneyEditText.hasFocus()); + return !sendMoneyBoundRect.contains(posX, posY) && + !receiveMoneyBoundRect.contains(posX, posY) + &&(recieveMoneyEditText.hasFocus()||sendMoneyEditText.hasFocus()) + &&!backButtonBoundRect.contains(posX, posY) + &&!rvBoundRect.contains(posX, posY) + &&!calcButtonBoundRect.contains(posX,posY); } @@ -591,7 +612,7 @@ public class ExchangeMethodV2Activity extends BaseActivity implements PaymentMod { rootView.postDelayed(()->{ rootView.smoothScrollTo(0, rootView.getBottom()); - },300); + },350); } }