-
-
Save jezinka/86b4e784c614dd8752eba947e6b54827 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filterEditText.setOnTouchListener(new View.OnTouchListener() { | |
@Override | |
public boolean onTouch(View v, MotionEvent event) { | |
if (event.getAction() == MotionEvent.ACTION_UP) { | |
Drawable drawable = filterEditText.getCompoundDrawables()[DRAWABLE_RIGHT]; | |
if (drawable != null) { | |
Rect bounds = drawable.getBounds(); | |
if (event.getRawX() >= (filterEditText.getRight() - bounds.width())) { | |
String text = filterEditText.getText().toString().trim(); | |
if (text.length() != 0) { | |
long ingredientId = ingredientContract.insert(dbHelper, text); | |
mealIngredientContract.insert(dbHelper, meal.getId(), ingredientId); | |
ingredientListAdapter.updateResults(mealIngredientContract.getIngredientsWithMeal(meal, dbHelper)); | |
filterEditText.setText(""); | |
Toast.makeText(v.getContext(), R.string.ingredient_added_message, Toast.LENGTH_SHORT).show(); | |
return true; | |
} | |
} | |
} | |
} | |
return false; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment