mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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:
committed by
Facebook Github Bot
parent
84330f36de
commit
f7608d553c
+24
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user