示例#1
0
    static Style fromInt(int enumValue) {
      for (Style style : values()) {
        if (style.getValue() == enumValue) {
          return style;
        }
      }

      return null;
    }
示例#2
0
 private Bundle getAnalyticsParameters() {
   Bundle params = new Bundle();
   params.putString(AnalyticsEvents.PARAMETER_LIKE_VIEW_STYLE, likeViewStyle.toString());
   params.putString(
       AnalyticsEvents.PARAMETER_LIKE_VIEW_AUXILIARY_POSITION, auxiliaryViewPosition.toString());
   params.putString(
       AnalyticsEvents.PARAMETER_LIKE_VIEW_HORIZONTAL_ALIGNMENT, horizontalAlignment.toString());
   params.putString(
       AnalyticsEvents.PARAMETER_LIKE_VIEW_OBJECT_ID,
       Utility.coerceValueIfNullOrEmpty(objectId, ""));
   return params;
 }
示例#3
0
  private void parseAttributes(AttributeSet attrs) {
    if (attrs == null || getContext() == null) {
      return;
    }

    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.com_facebook_like_view);
    if (a == null) {
      return;
    }

    objectId =
        Utility.coerceValueIfNullOrEmpty(
            a.getString(R.styleable.com_facebook_like_view_object_id), null);
    objectType =
        ObjectType.fromInt(
            a.getInt(
                R.styleable.com_facebook_like_view_object_type, ObjectType.DEFAULT.getValue()));
    likeViewStyle =
        Style.fromInt(a.getInt(R.styleable.com_facebook_like_view_style, Style.DEFAULT.getValue()));
    if (likeViewStyle == null) {
      throw new IllegalArgumentException("Unsupported value for LikeView 'style'");
    }

    auxiliaryViewPosition =
        AuxiliaryViewPosition.fromInt(
            a.getInt(
                R.styleable.com_facebook_like_view_auxiliary_view_position,
                AuxiliaryViewPosition.DEFAULT.getValue()));
    if (auxiliaryViewPosition == null) {
      throw new IllegalArgumentException(
          "Unsupported value for LikeView 'auxiliary_view_position'");
    }

    horizontalAlignment =
        HorizontalAlignment.fromInt(
            a.getInt(
                R.styleable.com_facebook_like_view_horizontal_alignment,
                HorizontalAlignment.DEFAULT.getValue()));
    if (horizontalAlignment == null) {
      throw new IllegalArgumentException("Unsupported value for LikeView 'horizontal_alignment'");
    }

    foregroundColor =
        a.getColor(R.styleable.com_facebook_like_view_foreground_color, NO_FOREGROUND_COLOR);

    a.recycle();
  }