Permalink
Browse files

Don't crash if OEM has replaced OverScroller in ScrollView

Summary: Some OEMs have changed out the default scroller implementation in their ScrollView. We now check for that case and handle it gracefully instead of crashing.

Reviewed By: foghina

Differential Revision: D3876492

fbshipit-source-id: 4d03b88c4972e939c8352eeb9f30275e3ecf76e2
  • Loading branch information...
1 parent 6565929 commit 5deb528695a8a47156a331b2a0182fabef0253d7 @astreet astreet committed with Facebook Github Bot 9 Sep 19, 2016
Showing with 10 additions and 1 deletion.
  1. +10 −1 ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java
@@ -82,7 +82,16 @@ public ReactScrollView(ReactContext context, @Nullable FpsListener fpsListener)
if (sScrollerField != null) {
try {
- mScroller = (OverScroller) sScrollerField.get(this);
+ Object scroller = sScrollerField.get(this);
+ if (scroller instanceof OverScroller) {
+ mScroller = (OverScroller) scroller;
+ } else {
+ Log.w(
+ ReactConstants.TAG,
+ "Failed to cast mScroller field in ScrollView (probably due to OEM changes to AOSP)! " +
+ "This app will exhibit the bounce-back scrolling bug :(");
+ mScroller = null;
+ }
} catch (IllegalAccessException e) {
throw new RuntimeException("Failed to get mScroller from ScrollView!", e);
}

0 comments on commit 5deb528

Please sign in to comment.