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:
@@ -346,6 +346,9 @@ public class ExpandedAnimationController
|
|||||||
* bubble is dragged back into the row.
|
* bubble is dragged back into the row.
|
||||||
*/
|
*/
|
||||||
public void dragBubbleOut(View bubbleView, float x, float y) {
|
public void dragBubbleOut(View bubbleView, float x, float y) {
|
||||||
|
if (mMagnetizedBubbleDraggingOut == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mSpringToTouchOnNextMotionEvent) {
|
if (mSpringToTouchOnNextMotionEvent) {
|
||||||
springBubbleTo(mMagnetizedBubbleDraggingOut.getUnderlyingObject(), x, y);
|
springBubbleTo(mMagnetizedBubbleDraggingOut.getUnderlyingObject(), x, y);
|
||||||
mSpringToTouchOnNextMotionEvent = false;
|
mSpringToTouchOnNextMotionEvent = false;
|
||||||
|
|||||||
@@ -59,19 +59,21 @@ public class ExpandedAnimationControllerTest extends PhysicsAnimationLayoutTestC
|
|||||||
private int mStackOffset;
|
private int mStackOffset;
|
||||||
private PointF mExpansionPoint;
|
private PointF mExpansionPoint;
|
||||||
private BubblePositioner mPositioner;
|
private BubblePositioner mPositioner;
|
||||||
private BubbleStackView.StackViewState mStackViewState;
|
private BubbleStackView.StackViewState mStackViewState = new BubbleStackView.StackViewState();
|
||||||
|
|
||||||
@SuppressLint("VisibleForTests")
|
@SuppressLint("VisibleForTests")
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
BubbleStackView stackView = mock(BubbleStackView.class);
|
|
||||||
when(stackView.getState()).thenReturn(getStackViewState());
|
|
||||||
mPositioner = new BubblePositioner(getContext(), mock(WindowManager.class));
|
mPositioner = new BubblePositioner(getContext(), mock(WindowManager.class));
|
||||||
mPositioner.updateInternal(Configuration.ORIENTATION_PORTRAIT,
|
mPositioner.updateInternal(Configuration.ORIENTATION_PORTRAIT,
|
||||||
Insets.of(0, 0, 0, 0),
|
Insets.of(0, 0, 0, 0),
|
||||||
new Rect(0, 0, mDisplayWidth, mDisplayHeight));
|
new Rect(0, 0, mDisplayWidth, mDisplayHeight));
|
||||||
|
|
||||||
|
BubbleStackView stackView = mock(BubbleStackView.class);
|
||||||
|
when(stackView.getState()).thenReturn(getStackViewState());
|
||||||
|
|
||||||
mExpandedController = new ExpandedAnimationController(mPositioner,
|
mExpandedController = new ExpandedAnimationController(mPositioner,
|
||||||
mOnBubbleAnimatedOutAction,
|
mOnBubbleAnimatedOutAction,
|
||||||
stackView);
|
stackView);
|
||||||
@@ -135,6 +137,12 @@ public class ExpandedAnimationControllerTest extends PhysicsAnimationLayoutTestC
|
|||||||
testBubblesInCorrectExpandedPositions();
|
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. */
|
/** Expand the stack and wait for animations to finish. */
|
||||||
private void expand() throws InterruptedException {
|
private void expand() throws InterruptedException {
|
||||||
mExpandedController.expandFromStack(mock(Runnable.class));
|
mExpandedController.expandFromStack(mock(Runnable.class));
|
||||||
|
|||||||
Reference in New Issue
Block a user