예제 #1
0
    public static ObjectType fromInt(int enumValue) {
      for (ObjectType objectType : values()) {
        if (objectType.getValue() == enumValue) {
          return objectType;
        }
      }

      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, ""));
    params.putString(AnalyticsEvents.PARAMETER_LIKE_VIEW_OBJECT_TYPE, objectType.toString());

    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();
  }