Support commands as strings in ViewPagerAndroid

Summary:
See https://github.com/facebook/react-native/commit/3cae6fa950eed54bccccf61a28c0e85d5a004c6c for more context

This component isn't exposed from the public API anymore because it has been moved to https://github.com/react-native-community/react-native-viewpager

This change will need to be made there but for FB internal which is still using this native code for now we need this migration

Reviewed By: mdvacca

Differential Revision: D16015151

fbshipit-source-id: 7a1b35e782e4ab4f6c01fa1824cdb9c61718a2db
This commit is contained in:
Eli White
2019-06-26 16:50:36 -07:00
committed by Facebook Github Bot
parent 84330f36de
commit f7608d553c
@@ -94,6 +94,30 @@ public class ReactViewPagerManager extends ViewGroupManager<ReactViewPager> {
}
}
@Override
public void receiveCommand(
ReactViewPager viewPager,
String commandType,
@Nullable ReadableArray args) {
Assertions.assertNotNull(viewPager);
Assertions.assertNotNull(args);
switch (commandType) {
case "setPage": {
viewPager.setCurrentItemFromJs(args.getInt(0), true);
return;
}
case "setPageWithoutAnimation": {
viewPager.setCurrentItemFromJs(args.getInt(0), false);
return;
}
default:
throw new IllegalArgumentException(String.format(
"Unsupported command %d received by %s.",
commandType,
getClass().getSimpleName()));
}
}
@Override
public void addView(ReactViewPager parent, View child, int index) {
parent.addViewToAdapter(child, index);