Merge "Fix a potential NPE" into sc-v2-dev am: 4b3ea38f9b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16470586

Change-Id: Iac4afaa1caaf0969346e2c2ada0445a7dbc74be7
This commit is contained in:
Mady Mellor
2021-12-15 18:21:15 +00:00
committed by Automerger Merge Worker
2 changed files with 14 additions and 3 deletions

View File

@@ -346,6 +346,9 @@ public class ExpandedAnimationController
* bubble is dragged back into the row.
*/
public void dragBubbleOut(View bubbleView, float x, float y) {
if (mMagnetizedBubbleDraggingOut == null) {
return;
}
if (mSpringToTouchOnNextMotionEvent) {
springBubbleTo(mMagnetizedBubbleDraggingOut.getUnderlyingObject(), x, y);
mSpringToTouchOnNextMotionEvent = false;

View File

@@ -59,19 +59,21 @@ public class ExpandedAnimationControllerTest extends PhysicsAnimationLayoutTestC
private int mStackOffset;
private PointF mExpansionPoint;
private BubblePositioner mPositioner;
private BubbleStackView.StackViewState mStackViewState;
private BubbleStackView.StackViewState mStackViewState = new BubbleStackView.StackViewState();
@SuppressLint("VisibleForTests")
@Before
public void setUp() throws Exception {
super.setUp();
BubbleStackView stackView = mock(BubbleStackView.class);
when(stackView.getState()).thenReturn(getStackViewState());
mPositioner = new BubblePositioner(getContext(), mock(WindowManager.class));
mPositioner.updateInternal(Configuration.ORIENTATION_PORTRAIT,
Insets.of(0, 0, 0, 0),
new Rect(0, 0, mDisplayWidth, mDisplayHeight));
BubbleStackView stackView = mock(BubbleStackView.class);
when(stackView.getState()).thenReturn(getStackViewState());
mExpandedController = new ExpandedAnimationController(mPositioner,
mOnBubbleAnimatedOutAction,
stackView);
@@ -135,6 +137,12 @@ public class ExpandedAnimationControllerTest extends PhysicsAnimationLayoutTestC
testBubblesInCorrectExpandedPositions();
}
@Test
public void testDragBubbleOutDoesntNPE() throws InterruptedException {
mExpandedController.onGestureFinished();
mExpandedController.dragBubbleOut(mViews.get(0), 1, 1);
}
/** Expand the stack and wait for animations to finish. */
private void expand() throws InterruptedException {
mExpandedController.expandFromStack(mock(Runnable.class));