diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/QSFragment.java | 5 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java | 18 |
2 files changed, 22 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java index a64b67023da8..76ec6bd086db 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java @@ -519,7 +519,10 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca @Override public void setOverScrollAmount(int overScrollAmount) { mOverScrolling = overScrollAmount != 0; - getView().setTranslationY(overScrollAmount); + View view = getView(); + if (view != null) { + view.setTranslationY(overScrollAmount); + } } @Override diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java index f5d19e24bfa6..4fbdb7c512bd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java @@ -315,6 +315,24 @@ public class QSFragmentTest extends SysuiBaseFragmentTest { verify(mQuickQSPanelController).setCollapseExpandAction(action); } + @Test + public void setOverScrollAmount_setsTranslationOnView() { + QSFragment fragment = resumeAndGetFragment(); + + fragment.setOverScrollAmount(123); + + assertThat(mQsFragmentView.getTranslationY()).isEqualTo(123); + } + + @Test + public void setOverScrollAmount_beforeViewCreated_translationIsNotSet() { + QSFragment fragment = getFragment(); + + fragment.setOverScrollAmount(123); + + assertThat(mQsFragmentView.getTranslationY()).isEqualTo(0); + } + @Override protected Fragment instantiate(Context context, String className, Bundle arguments) { MockitoAnnotations.initMocks(this); |