react-native-navigation的迁移库

SnackbarParamsParser.java 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. package com.reactnativenavigation.params.parsers;
  2. import android.os.Bundle;
  3. import android.support.design.widget.Snackbar;
  4. import com.reactnativenavigation.params.AppStyle;
  5. import com.reactnativenavigation.params.SnackbarParams;
  6. public class SnackbarParamsParser extends Parser {
  7. public SnackbarParams parse(Bundle params) {
  8. SnackbarParams result = new SnackbarParams();
  9. result.text = params.getString("text");
  10. result.buttonText = params.getString("actionText");
  11. result.buttonColor = getColor(params, "actionColor", AppStyle.appStyle.snackbarButtonColor);
  12. result.duration = getDuration(params.getString("duration", "short"));
  13. result.eventId = params.getString("actionId");
  14. return result;
  15. }
  16. private int getDuration(String duration) {
  17. switch (duration) {
  18. case "short":
  19. return Snackbar.LENGTH_SHORT;
  20. case "long":
  21. return Snackbar.LENGTH_LONG;
  22. case "indefinite":
  23. return Snackbar.LENGTH_INDEFINITE;
  24. default:
  25. return Snackbar.LENGTH_SHORT;
  26. }
  27. }
  28. }