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
This commit is contained in:
parent
6565929358
commit
5deb528695
|
@ -82,7 +82,16 @@ public class ReactScrollView extends ScrollView implements ReactClippingViewGrou
|
||||||
|
|
||||||
if (sScrollerField != null) {
|
if (sScrollerField != null) {
|
||||||
try {
|
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) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new RuntimeException("Failed to get mScroller from ScrollView!", e);
|
throw new RuntimeException("Failed to get mScroller from ScrollView!", e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue