react-native-navigation的迁移库

ButtonParser.java 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.reactnativenavigation.params.parsers;
  2. import android.os.Bundle;
  3. import com.reactnativenavigation.params.FabParams;
  4. import com.reactnativenavigation.params.TitleBarButtonParams;
  5. import com.reactnativenavigation.params.TitleBarLeftButtonParams;
  6. import java.util.List;
  7. public class ButtonParser extends Parser {
  8. private static final String KEY_RIGHT_BUTTONS = "rightButtons";
  9. private static final String KEY_LEFT_BUTTON = "leftButton";
  10. private static final String KEY_FAB = "fab";
  11. private static final String KEY_BACK_BUTTON_HIDDEN = "backButtonHidden";
  12. public static List<TitleBarButtonParams> parseRightButton(Bundle params) {
  13. List<TitleBarButtonParams> rightButtons = null;
  14. if (hasKey(params, KEY_RIGHT_BUTTONS)) {
  15. rightButtons = new TitleBarButtonParamsParser().parseButtons(params.getBundle(KEY_RIGHT_BUTTONS));
  16. }
  17. return rightButtons;
  18. }
  19. public static TitleBarLeftButtonParams parseLeftButton(Bundle params) {
  20. TitleBarLeftButtonParams leftButton = null;
  21. if (hasKey(params, KEY_LEFT_BUTTON)) {
  22. leftButton = new TitleBarLeftButtonParamsParser().parseSingleButton(params.getBundle(KEY_LEFT_BUTTON));
  23. boolean backButtonHidden = params.getBoolean(KEY_BACK_BUTTON_HIDDEN, false);
  24. if (backButtonHidden && leftButton.isBackButton()) {
  25. leftButton = null;
  26. }
  27. }
  28. return leftButton;
  29. }
  30. public static FabParams parseFab(Bundle params, String navigatorEventId, String screenInstanceId) {
  31. FabParams fabParams = null;
  32. if (hasKey(params, KEY_FAB)) {
  33. fabParams = new FabParamsParser().parse(params.getBundle(KEY_FAB), navigatorEventId, screenInstanceId);
  34. }
  35. return fabParams;
  36. }
  37. }