Hi I'm new to android studio and I have an app that draws some shapes. Currently when I tap the screen once the app deletes the last shape drawn.
However, I need it to delete the shapes only when the user clicks on the top left 1/16 of the canvas followed by the bottom right 1/16 of the canvas?
This is what I tried.Is there something wrong with my getWidth and getHeight?
This is my onViewCreated
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getWidth=view.getWidth();
getHeight=view.getHeight();
OnsingleTap confirmed method
public boolean onSingleTapConfirmed(MotionEvent e) {
Cursor cursor = getLastShape();
if (cursor.getCount() > 0) {
cursor.moveToFirst();
}
int x1 = (int) e.getX();
int y1 = (int) e.getY();
if((x1<1/16*getWidth) &&(y1<1/16 * getHeight)){
int x2 = (int) e.getX();
int y2 = (int) e.getY();
if((x2>=getWidth-1/16*getWidth) && (y2>=getHeight-1/16*getHeight)) {
resolver.delete(Shape.CONTENT_URI, "_id=" + cursor.getInt(cursor.getColumnIndex(Shape.ID)), null);
}
}
return true;
}