Fix RTL crash

This commit is contained in:
Nazar-Kutz 2020-05-08 14:29:20 +03:00
parent 56d865c01b
commit 820c18de7c

View file

@ -293,33 +293,35 @@ public class AddPOIAction extends QuickAction {
@Override @Override
public boolean onTouch(final View v, MotionEvent event) { public boolean onTouch(final View v, MotionEvent event) {
final EditText editText = (EditText) v; final EditText editText = (EditText) v;
final int DRAWABLE_END = 2; if (event.getAction() == MotionEvent.ACTION_UP) {
int expandBtnWidth = AndroidUtils.getCompoundDrawables(editText)[DRAWABLE_END].getBounds().width(); final int DRAWABLE_END = 2;
int expandBtnWidth = AndroidUtils.getCompoundDrawables(editText)[DRAWABLE_END].getBounds().width();
boolean expandButtonPressed; boolean expandButtonPressed;
if (isLayoutRtl) { if (isLayoutRtl) {
expandButtonPressed = event.getX() <= (editText.getLeft() + expandBtnWidth expandButtonPressed = event.getX() <= (editText.getLeft() + expandBtnWidth
+ editText.getPaddingLeft()); + editText.getPaddingLeft());
} else { } else {
expandButtonPressed = event.getX() >= (editText.getRight() - expandBtnWidth expandButtonPressed = event.getX() >= (editText.getRight() - expandBtnWidth
- editText.getPaddingRight()); - editText.getPaddingRight());
} }
if (expandButtonPressed) { if (expandButtonPressed) {
PoiCategory category = getCategory(getAllTranslatedNames(activity)); PoiCategory category = getCategory(getAllTranslatedNames(activity));
PoiCategory tempPoiCategory = (category != null) ? category : getPoiTypes(activity).getOtherPoiCategory(); PoiCategory tempPoiCategory = (category != null) ? category : getPoiTypes(activity).getOtherPoiCategory();
PoiSubTypeDialogFragment f = PoiSubTypeDialogFragment f =
PoiSubTypeDialogFragment.createInstance(tempPoiCategory); PoiSubTypeDialogFragment.createInstance(tempPoiCategory);
f.setOnItemSelectListener(new PoiSubTypeDialogFragment.OnItemSelectListener() { f.setOnItemSelectListener(new PoiSubTypeDialogFragment.OnItemSelectListener() {
@Override @Override
public void select(String category) { public void select(String category) {
poiTypeEditText.setText(category); poiTypeEditText.setText(category);
} }
}); });
CreateEditActionDialog parentFragment = (CreateEditActionDialog) activity.getSupportFragmentManager().findFragmentByTag(CreateEditActionDialog.TAG); CreateEditActionDialog parentFragment = (CreateEditActionDialog) activity.getSupportFragmentManager().findFragmentByTag(CreateEditActionDialog.TAG);
f.show(activity.getSupportFragmentManager(), "PoiSubTypeDialogFragment"); f.show(activity.getSupportFragmentManager(), "PoiSubTypeDialogFragment");
return true; return true;
}
} }
return false; return false;
} }