react-native-navigation的迁移库

ContextualMenuButtonParamsParser.java 1.3KB

123456789101112131415161718192021222324252627282930313233
  1. package com.reactnativenavigation.params.parsers;
  2. import android.os.Bundle;
  3. import com.reactnativenavigation.params.ContextualMenuButtonParams;
  4. import com.reactnativenavigation.params.StyleParams;
  5. import com.reactnativenavigation.react.ImageLoader;
  6. import java.util.List;
  7. public class ContextualMenuButtonParamsParser extends TitleBarButtonParamsParser {
  8. public List<ContextualMenuButtonParams> parseContextualMenuButtons(Bundle params) {
  9. return parseBundle(params, new ParseStrategy<ContextualMenuButtonParams>() {
  10. @Override
  11. public ContextualMenuButtonParams parse(Bundle button) {
  12. return parseSingleContextualMenuButton(button);
  13. }
  14. });
  15. }
  16. private ContextualMenuButtonParams parseSingleContextualMenuButton(Bundle button) {
  17. ContextualMenuButtonParams result = new ContextualMenuButtonParams();
  18. if (button.get("icon") != null) {
  19. result.icon = ImageLoader.loadImage(button.getString("icon"));
  20. }
  21. result.showAsAction = parseShowAsAction(button.getString("showAsAction"));
  22. result.color = StyleParams.Color.parse(button, "color");
  23. result.label = button.getString("label");
  24. result.index = button.getInt("index");
  25. return result;
  26. }
  27. }