Loading src/com/android/settings/widget/ActionBarShadowController.java +1 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ public class ActionBarShadowController implements LifecycleObserver, OnStart, On final boolean shouldShowShadow = view.canScrollVertically(-1); if (mAnchorView != null) { mAnchorView.setElevation(shouldShowShadow ? ELEVATION_HIGH : ELEVATION_LOW); } else { } else if (mActivity != null) { // activity can become null when running monkey final ActionBar actionBar = mActivity.getActionBar(); if (actionBar != null) { actionBar.setElevation(shouldShowShadow ? ELEVATION_HIGH : ELEVATION_LOW); Loading tests/robotests/src/com/android/settings/widget/ActionBarShadowControllerTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -104,4 +104,15 @@ public class ActionBarShadowControllerTest { verify(mRecyclerView, times(2)).addOnScrollListener(any()); } @Test public void onScrolled_nullAnchorViewAndActivity_shouldNotCrash() { final Activity activity = null; final ActionBarShadowController controller = ActionBarShadowController.attachToRecyclerView(activity, mLifecycle, mRecyclerView); // Scroll controller.mScrollChangeWatcher.onScrolled(mRecyclerView, 10 /* dx */, 10 /* dy */); // no crash } } Loading
src/com/android/settings/widget/ActionBarShadowController.java +1 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ public class ActionBarShadowController implements LifecycleObserver, OnStart, On final boolean shouldShowShadow = view.canScrollVertically(-1); if (mAnchorView != null) { mAnchorView.setElevation(shouldShowShadow ? ELEVATION_HIGH : ELEVATION_LOW); } else { } else if (mActivity != null) { // activity can become null when running monkey final ActionBar actionBar = mActivity.getActionBar(); if (actionBar != null) { actionBar.setElevation(shouldShowShadow ? ELEVATION_HIGH : ELEVATION_LOW); Loading
tests/robotests/src/com/android/settings/widget/ActionBarShadowControllerTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -104,4 +104,15 @@ public class ActionBarShadowControllerTest { verify(mRecyclerView, times(2)).addOnScrollListener(any()); } @Test public void onScrolled_nullAnchorViewAndActivity_shouldNotCrash() { final Activity activity = null; final ActionBarShadowController controller = ActionBarShadowController.attachToRecyclerView(activity, mLifecycle, mRecyclerView); // Scroll controller.mScrollChangeWatcher.onScrolled(mRecyclerView, 10 /* dx */, 10 /* dy */); // no crash } }