Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better NPE handling #530

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -685,12 +685,15 @@ public boolean onTouchEvent(@NonNull MotionEvent event) {
}

if (vTranslateStart == null) { vTranslateStart = new PointF(0, 0); }
if (vTranslateBefore == null) { vTranslateBefore = new PointF(0, 0); }
if (vTranslateBefore == null) {
vTranslateBefore = new PointF(vTranslate.x, vTranslate.y);
} else {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this part to maintain the exact same behavior as before but I think just assigning a new PointF instance will be enough if you're not worried about the overhead and GC cost

vTranslateBefore.set(vTranslate);
}
if (vCenterStart == null) { vCenterStart = new PointF(0, 0); }

// Store current values so we can send an event if they change
float scaleBefore = scale;
vTranslateBefore.set(vTranslate);

boolean handled = onTouchEventInternal(event);
sendStateChanged(scaleBefore, vTranslateBefore, ORIGIN_TOUCH);
Expand Down