Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Validate if platform doesn't return a null motion event #9434

Merged
merged 1 commit into from
Jul 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.graphics.PointF;
import android.location.Location;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.GestureDetectorCompat;
import android.support.v4.view.ScaleGestureDetectorCompat;
Expand Down Expand Up @@ -134,7 +133,12 @@ private Location getLocationFromGesture(float x, float y) {
* @param event the MotionEvent
* @return True if touch event is handled
*/
boolean onTouchEvent(@NonNull MotionEvent event) {
boolean onTouchEvent(MotionEvent event) {
// framework can return null motion events in edge cases #9432
if (event == null) {
return false;
}

// Check and ignore non touch or left clicks
if ((event.getButtonState() != 0) && (event.getButtonState() != MotionEvent.BUTTON_PRIMARY)) {
return false;
Expand Down