From 583241e6556ee573541096bc28c17705d3f2e612 Mon Sep 17 00:00:00 2001 From: Randy Pfohl Date: Thu, 2 Mar 2023 03:26:56 +0000 Subject: [PATCH] fixing rare NPE test: replaced callback with null pointer and noted same crash error as provided in bug. testing crash to see if it was just small jank or obvious crash. its an obvious cash to user. by exiting earlier the UI isn't as fluid but we will stop crashing. bug: 261071811 Change-Id: Ia54ee8d4bccdb9de8c042bae8e837216eaac67bb --- src/com/android/launcher3/PagedView.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index c7431edb5b..e3bce87ebb 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -1370,8 +1370,14 @@ public abstract class PagedView extends ViewGrou int velocity = (int) mOrientationHandler.getPrimaryVelocity(velocityTracker, mActivePointerId); float delta = primaryDirection - mDownMotionPrimary; - int pageOrientedSize = (int) (mOrientationHandler.getMeasuredSize( - getPageAt(mCurrentPage)) + + View current = getPageAt(mCurrentPage); + if (current == null) { + Log.e(TAG, "current page was null. this should not happen."); + return true; + } + + int pageOrientedSize = (int) (mOrientationHandler.getMeasuredSize(current) * mOrientationHandler.getPrimaryScale(this)); boolean isSignificantMove = isSignificantMove(Math.abs(delta), pageOrientedSize);