react-native-navigation的迁移库

TopTabOptions.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package com.reactnativenavigation.parse;
  2. import android.graphics.Typeface;
  3. import android.support.annotation.Nullable;
  4. import com.reactnativenavigation.parse.params.NullText;
  5. import com.reactnativenavigation.parse.params.Text;
  6. import com.reactnativenavigation.parse.parsers.TextParser;
  7. import com.reactnativenavigation.utils.TypefaceLoader;
  8. import org.json.JSONObject;
  9. public class TopTabOptions {
  10. public Text title = new NullText();
  11. @Nullable public Typeface fontFamily;
  12. public int tabIndex;
  13. public static TopTabOptions parse(TypefaceLoader typefaceManager, JSONObject json) {
  14. TopTabOptions result = new TopTabOptions();
  15. if (json == null) return result;
  16. result.title = TextParser.parse(json, "title");
  17. result.fontFamily = typefaceManager.getTypeFace(json.optString("titleFontFamily"));
  18. return result;
  19. }
  20. void mergeWith(TopTabOptions other) {
  21. if (other.title.hasValue()) title = other.title;
  22. if (other.fontFamily != null) fontFamily = other.fontFamily;
  23. if (other.tabIndex >= 0) tabIndex = other.tabIndex;
  24. }
  25. void mergeWithDefault(TopTabOptions other) {
  26. if (fontFamily == null) fontFamily = other.fontFamily;
  27. }
  28. }