react-native-navigation的迁移库

TopBarBackgroundOptions.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package com.reactnativenavigation.parse;
  2. import com.reactnativenavigation.parse.params.Color;
  3. import com.reactnativenavigation.parse.params.NullColor;
  4. import com.reactnativenavigation.parse.parsers.ColorParser;
  5. import org.json.JSONObject;
  6. public class TopBarBackgroundOptions {
  7. public static TopBarBackgroundOptions parse(JSONObject json) {
  8. TopBarBackgroundOptions options = new TopBarBackgroundOptions();
  9. if (json == null) return options;
  10. options.color = ColorParser.parse(json, "color");
  11. options.component = Component.parse(json.optJSONObject("component"));
  12. if (options.component.hasValue()) {
  13. options.color = new Color(android.graphics.Color.TRANSPARENT);
  14. }
  15. return options;
  16. }
  17. public Color color = new NullColor();
  18. public Component component = new Component();
  19. void mergeWith(final TopBarBackgroundOptions other) {
  20. if (other.color.hasValue()) color = other.color;
  21. component.mergeWith(other.component);
  22. }
  23. void mergeWithDefault(TopBarBackgroundOptions defaultOptions) {
  24. if (!color.hasValue()) color = defaultOptions.color;
  25. component.mergeWithDefault(defaultOptions.component);
  26. }
  27. }