public CustomGauge(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomGauge, 0, 0);

    // stroke style
    mStrokeWidth = a.getDimension(R.styleable.CustomGauge_strokeWidth, 10);
    mStrokeColor = a.getColor(R.styleable.CustomGauge_strokeColor, android.R.color.darker_gray);
    mStrokeCap = a.getString(R.styleable.CustomGauge_strokeCap);

    // angel start and sweep (opposite direction 0, 270, 180, 90)
    mStartAngel = a.getInt(R.styleable.CustomGauge_startAngel, 0);
    mSweepAngel = a.getInt(R.styleable.CustomGauge_sweepAngel, 360);

    // scale (from mStartValue to mEndValue)
    mStartValue = a.getInt(R.styleable.CustomGauge_startValue, 0);
    mEndValue = a.getInt(R.styleable.CustomGauge_endValue, 1000);

    // pointer size and color
    mPointSize = a.getColor(R.styleable.CustomGauge_pointSize, 0);
    mPointStartColor = a.getColor(R.styleable.CustomGauge_pointStartColor, android.R.color.white);
    mPointEndColor = a.getColor(R.styleable.CustomGauge_pointEndColor, android.R.color.white);

    // calculating one point sweep
    mPointAngel = ((double) Math.abs(mSweepAngel) / (mEndValue - mStartValue));
    a.recycle();
    init();
  }
  @Override
  protected View createScreenletView(Context context, AttributeSet attributes) {
    TypedArray typedArray =
        context
            .getTheme()
            .obtainStyledAttributes(attributes, R.styleable.UserPortraitScreenlet, 0, 0);

    _autoLoad = typedArray.getBoolean(R.styleable.UserPortraitScreenlet_autoLoad, true);
    _male = typedArray.getBoolean(R.styleable.UserPortraitScreenlet_male, true);
    _portraitId = typedArray.getInt(R.styleable.UserPortraitScreenlet_portraitId, 0);
    _uuid = typedArray.getString(R.styleable.UserPortraitScreenlet_uuid);
    _editable = typedArray.getBoolean(R.styleable.UserPortraitScreenlet_editable, false);

    int offlinePolicy =
        typedArray.getInt(
            R.styleable.UserPortraitScreenlet_offlinePolicy, OfflinePolicy.REMOTE_ONLY.ordinal());
    _offlinePolicy = OfflinePolicy.values()[offlinePolicy];

    _userId =
        castToLongOrUseDefault(typedArray.getString(R.styleable.UserPortraitScreenlet_userId), 0L);

    if (SessionContext.hasUserInfo() && _portraitId == 0 && _uuid == null && _userId == 0) {
      _userId = SessionContext.getLoggedUser().getId();
    }

    int layoutId =
        typedArray.getResourceId(R.styleable.UserPortraitScreenlet_layoutId, getDefaultLayoutId());

    typedArray.recycle();

    return LayoutInflater.from(context).inflate(layoutId, null);
  }
  public CropImageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CropImageView, 0, 0);
    try {
      mGuidelines = ta.getInteger(R.styleable.CropImageView_guidelines, DEFAULT_GUIDELINES);
      mFixAspectRatio =
          ta.getBoolean(R.styleable.CropImageView_fixAspectRatio, DEFAULT_FIXED_ASPECT_RATIO);
      mAspectRatioX = ta.getInteger(R.styleable.CropImageView_aspectRatioX, DEFAULT_ASPECT_RATIO_X);
      mAspectRatioY = ta.getInteger(R.styleable.CropImageView_aspectRatioY, DEFAULT_ASPECT_RATIO_Y);
      mImageResource =
          ta.getResourceId(R.styleable.CropImageView_imageResource, DEFAULT_IMAGE_RESOURCE);
      mBackgroundColor =
          ta.getColor(R.styleable.CropImageView_backgroundColor, DEFAULT_BACKGROUND_COLOR);
      mMainColor = ta.getColor(R.styleable.CropImageView_borderLinesColor, DEFAULT_COLOR);
      mScaleType =
          VALID_SCALE_TYPES[
              ta.getInt(R.styleable.CropImageView_scaleType, DEFAULT_SCALE_TYPE_INDEX)];
      mCropShape =
          VALID_CROP_SHAPES[
              ta.getInt(R.styleable.CropImageView_cropShape, DEFAULT_CROP_SHAPE_INDEX)];
      mCornersShape =
          VALID_CORNERS_SHAPES[
              ta.getInt(R.styleable.CropImageView_cornersShape, DEFAULT_CORNERS_SHAPE_INDEX)];
    } finally {
      ta.recycle();
    }

    init(context);
  }
  /**
   * Initializes the ViewGroup and modifies it's default behavior by the passed attributes
   *
   * @param attrs the attributes used to modify default settings
   */
  protected void init(AttributeSet attrs) {
    gestureDetector = new GestureDetector(getContext(), new MyGestureListener());
    quadrantTouched = new boolean[] {false, false, false, false, false};

    if (attrs != null) {
      TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CircleLayout);

      speed = a.getInt(R.styleable.CircleLayout_speed, speed);
      radius = a.getDimension(R.styleable.CircleLayout_radius, radius);
      isRotating = a.getBoolean(R.styleable.CircleLayout_isRotating, isRotating);

      // The angle where the first menu item will be drawn
      angle = a.getInt(R.styleable.CircleLayout_firstChildPosition, (int) angle);
      for (FirstChildPosition pos : FirstChildPosition.values()) {
        if (pos.getAngle() == angle) {
          firstChildPosition = pos;
          break;
        }
      }

      a.recycle();

      // Needed for the ViewGroup to be drawn
      setWillNotDraw(false);
    }
  }
  public VerticalProgressBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mUiThreadId = Thread.currentThread().getId();
    initProgressBar();

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressBar, defStyle, 0);

    mNoInvalidate = true;

    Drawable drawable = a.getDrawable(R.styleable.ProgressBar_android_progressDrawable);
    if (drawable != null) {
      drawable = tileify(drawable, false);
      // Calling this method can set mMaxHeight, make sure the corresponding
      // XML attribute for mMaxHeight is read after calling this method
      setProgressDrawable(drawable);
    }

    mMinWidth = a.getDimensionPixelSize(R.styleable.ProgressBar_android_minWidth, mMinWidth);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.ProgressBar_android_maxWidth, mMaxWidth);
    mMinHeight = a.getDimensionPixelSize(R.styleable.ProgressBar_android_minHeight, mMinHeight);
    mMaxHeight = a.getDimensionPixelSize(R.styleable.ProgressBar_android_maxHeight, mMaxHeight);

    setMax(a.getInt(R.styleable.ProgressBar_android_max, mMax));

    setProgress(a.getInt(R.styleable.ProgressBar_android_progress, mProgress));

    setSecondaryProgress(
        a.getInt(R.styleable.ProgressBar_android_secondaryProgress, mSecondaryProgress));

    mNoInvalidate = false;

    a.recycle();
  }
  /**
   * * Creates a new grid layout animation controller from external resources.
   *
   * @param context the Context the view group is running in, through which it can access the
   *     resources
   * @param attrs the attributes of the XML tag that is inflating the layout animation controller
   */
  public GridLayoutAnimationController(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a =
        context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.GridLayoutAnimation);

    Animation.Description d =
        Animation.Description.parseValue(
            a.peekValue(com.android.internal.R.styleable.GridLayoutAnimation_columnDelay));
    mColumnDelay = d.value;
    d =
        Animation.Description.parseValue(
            a.peekValue(com.android.internal.R.styleable.GridLayoutAnimation_rowDelay));
    mRowDelay = d.value;
    //noinspection PointlessBitwiseExpression
    mDirection =
        a.getInt(
            com.android.internal.R.styleable.GridLayoutAnimation_direction,
            DIRECTION_LEFT_TO_RIGHT | DIRECTION_TOP_TO_BOTTOM);
    mDirectionPriority =
        a.getInt(
            com.android.internal.R.styleable.GridLayoutAnimation_directionPriority, PRIORITY_NONE);

    a.recycle();
  }
 public DashboardViewAttr(Context context, AttributeSet attrs, int defStyleAttr) {
   TypedArray ta =
       context.obtainStyledAttributes(attrs, R.styleable.DashboardView, defStyleAttr, 0);
   mTikeCount = ta.getInt(R.styleable.DashboardView_tikeCount, 48);
   mTextSize =
       ta.getDimensionPixelSize(
           PxUtils.spToPx(R.styleable.DashboardView_android_textSize, context), 24);
   mText = ta.getString(R.styleable.DashboardView_android_text);
   //        progressHeight =
   // ta.getInt(PxUtils.dpToPx(R.styleable.DashboardView_progressHeight,context), 20);
   unit = ta.getString(R.styleable.DashboardView_Unit);
   textColor =
       ta.getColor(
           R.styleable.DashboardView_textColor,
           context.getResources().getColor(R.color.textColor));
   background = ta.getColor(R.styleable.DashboardView_backgroundColor, 0);
   startColor = ta.getColor(R.styleable.DashboardView_startProgressColor, 0);
   endColor = ta.getColor(R.styleable.DashboardView_endProgressColor, 0);
   startNum = ta.getInt(R.styleable.DashboardView_startNumber, 0);
   maxNum = ta.getInt(R.styleable.DashboardView_maxNumber, 120);
   padding = ta.getInt(PxUtils.dpToPx(R.styleable.DashboardView_padding, context), 0);
   progressColor =
       ta.getColor(
           R.styleable.DashboardView_progressColor,
           context.getResources().getColor(R.color.skyblue));
   ta.recycle();
 }
  private void initWorkspace(Context context, AttributeSet attrs, int defStyle) {

    Theme theme = context.getTheme();

    TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.AviaryWorkspace, defStyle, 0);
    mDefaultScreen = a.getInt(R.styleable.AviaryWorkspace_aviary_defaultScreen, 0);
    int overscrollMode = a.getInt(R.styleable.AviaryWorkspace_aviary_overscroll, 0);
    a.recycle();

    setHapticFeedbackEnabled(false);

    mScrollInterpolator = new DecelerateInterpolator(1.0f);
    mScroller = new Scroller(context, mScrollInterpolator);
    mPreviousScreen = INVALID_SCREEN;

    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    mPaddingTop = getPaddingTop();
    mPaddingBottom = getPaddingBottom();
    mPaddingLeft = getPaddingLeft();
    mPaddingRight = getPaddingRight();

    setOverScroll(overscrollMode);
  }
  public RoundProgressBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    paint = new Paint();

    TypedArray mTypedArray = context.obtainStyledAttributes(attrs, R.styleable.RoundProgressBar);

    // 获取自定义属性和默认值,第一个参数是从用户属性中得到的设置,如果用户没有设置,那么就用默认的属性,即:第二个参数
    // 圆环的颜色
    ringColor = mTypedArray.getColor(R.styleable.RoundProgressBar_ringColor, 0xff50c0e9);
    // 圆环进度条的颜色
    ringProgressColor =
        mTypedArray.getColor(R.styleable.RoundProgressBar_ringProgressColor, 0xffffc641);
    // 文字的颜色
    textColor = mTypedArray.getColor(R.styleable.RoundProgressBar_textColor, 0xffff5f5f);
    // 文字的大小
    textSize = mTypedArray.getDimension(R.styleable.RoundProgressBar_textSize, 25);
    // 圆环的宽度
    ringWidth = mTypedArray.getDimension(R.styleable.RoundProgressBar_ringWidth, 10);
    // 最大进度
    max = mTypedArray.getInteger(R.styleable.RoundProgressBar_max, 100);
    // 当前进度
    progress = mTypedArray.getInt(R.styleable.RoundProgressBar_progress, 30);
    // 是否显示中间的进度
    textIsDisplayable =
        mTypedArray.getBoolean(R.styleable.RoundProgressBar_textIsDisplayable, true);
    // 进度的风格,实心或者空心
    style = mTypedArray.getInt(R.styleable.RoundProgressBar_style, 0);
    // 进度开始的角度数
    startAngle = mTypedArray.getInt(R.styleable.RoundProgressBar_startAngle, -90);
    // 圆心的颜色
    centreColor = mTypedArray.getColor(R.styleable.RoundProgressBar_centreColor, 0);
    // 回收资源
    mTypedArray.recycle();
  }
 private void initAttributes(Context context, AttributeSet attributeSet) {
   TypedArray attr = getTypedArray(context, attributeSet, R.styleable.MaterialLetterIcon);
   if (attr != null) {
     try {
       mShapeColor =
           attr.getColor(R.styleable.MaterialLetterIcon_shape_color, DEFAULT_SHAPE_COLOR);
       mInitials =
           attr.getBoolean(R.styleable.MaterialLetterIcon_initials, DEFAULT_INITIALS_STATE);
       mInitialsNumber =
           attr.getInt(R.styleable.MaterialLetterIcon_initials_number, DEFAULT_INITIALS_NUMBER);
       mOriginalLetter = attr.getString(R.styleable.MaterialLetterIcon_letter);
       if (mOriginalLetter != null) {
         setLetter(mOriginalLetter);
       }
       mShapeType = attr.getInt(R.styleable.MaterialLetterIcon_shape_type, DEFAULT_SHAPE);
       mLetterColor =
           attr.getColor(R.styleable.MaterialLetterIcon_letter_color, DEFAULT_LETTER_COLOR);
       mLetterSize = attr.getInt(R.styleable.MaterialLetterIcon_letter_size, DEFAULT_LETTER_SIZE);
       mLettersNumber =
           attr.getInt(R.styleable.MaterialLetterIcon_letters_number, DEFAULT_LETTERS_NUMBER);
     } finally {
       attr.recycle();
     }
   }
 }
 private void initAttributes(TypedArray attributes) {
   finishedColor =
       attributes.getColor(R.styleable.RingProgress_finished_color, DEFAULT_FINISHED_COLOR);
   unfinishedColor =
       attributes.getColor(R.styleable.RingProgress_unfinished_color, DEFAULT_UNFINISHED_COLOR);
   innerTextColor =
       attributes.getColor(R.styleable.RingProgress_inner_text_color, DEFAULT_INNER_TEXT_COLOR);
   innerTextSize =
       attributes.getDimension(
           R.styleable.RingProgress_inner_text_size,
           DimensionUtils.sp2px(getResources(), DEFAULT_INNER_TEXT_SIZE));
   max = attributes.getInt(R.styleable.RingProgress_ring_max, DEFAULT_MAX);
   progress = attributes.getInt(R.styleable.RingProgress_ring_progress, 0);
   finishedStrokeWidth =
       attributes.getDimension(
           R.styleable.RingProgress_finished_stroke_width,
           DimensionUtils.dp2px(getResources(), DEFAULT_FINISHED_STROKE_WIDTH));
   unfinishedStrokeWidth =
       attributes.getDimension(
           R.styleable.RingProgress_unfinished_stroke_width,
           DimensionUtils.dp2px(getResources(), DEFAULT_UNFINISHED_STROKE_WIDTH));
   innerText = attributes.getString(R.styleable.RingProgress_inner_text);
   startingDegree = attributes.getInt(R.styleable.RingProgress_starting_degree, 0);
   innerBackgroundColor =
       attributes.getColor(R.styleable.RingProgress_background_color, DEFAULT_BACKGROUND_COLOR);
 }
Exemple #12
0
  public CellLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0);

    mCellWidth = a.getDimensionPixelSize(R.styleable.CellLayout_cellWidth, 10);
    mCellHeight = a.getDimensionPixelSize(R.styleable.CellLayout_cellHeight, 10);

    mLongAxisStartPadding =
        a.getDimensionPixelSize(R.styleable.CellLayout_longAxisStartPadding, 10);
    mLongAxisEndPadding = a.getDimensionPixelSize(R.styleable.CellLayout_longAxisEndPadding, 10);
    mShortAxisStartPadding =
        a.getDimensionPixelSize(R.styleable.CellLayout_shortAxisStartPadding, 10);
    mShortAxisEndPadding = a.getDimensionPixelSize(R.styleable.CellLayout_shortAxisEndPadding, 10);

    mShortAxisCells = a.getInt(R.styleable.CellLayout_shortAxisCells, 4);
    mLongAxisCells = a.getInt(R.styleable.CellLayout_longAxisCells, 4);

    a.recycle();

    setAlwaysDrawnWithCacheEnabled(false);

    if (mOccupied == null) {
      if (mPortrait) {
        mOccupied = new boolean[mShortAxisCells][mLongAxisCells];
      } else {
        mOccupied = new boolean[mLongAxisCells][mShortAxisCells];
      }
    }

    ///  mWallpaperManager = WallpaperManager.getInstance(getContext());
  }
  private void init(Context context, AttributeSet attrs, int defStyle) {
    TypedArray typedArray =
        context.obtainStyledAttributes(attrs, R.styleable.IncreasingSeekBar, defStyle, 0);
    try {
      mOrientation =
          Orientation.fromId(
              typedArray.getInt(
                  R.styleable.IncreasingSeekBar_isb_orientation, Orientation.HORIZONTAL.id));
      mMaxRang = typedArray.getInt(R.styleable.IncreasingSeekBar_isb_max, DEF_MAX_RANG);
      mCurrValue = typedArray.getInt(R.styleable.IncreasingSeekBar_isb_curr_value, 0);
      mGapWidthPercent =
          typedArray.getFraction(
              R.styleable.IncreasingSeekBar_isb_gap_percent, 1, 1, DEF_GAP_PERCENT);
      mAllowUserTouch =
          typedArray.getBoolean(R.styleable.IncreasingSeekBar_isb_allow_user_touch, true);
      mDrawBorder = typedArray.getBoolean(R.styleable.IncreasingSeekBar_isb_draw_border, false);
      mBorderColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_border_color, DEF_COLOR);
      mBorderWidth =
          typedArray.getDimension(R.styleable.IncreasingSeekBar_isb_border_width, DEF_BORDER_WIDTH);
      mMainColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_color, DEF_COLOR);
      mStartColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_color_start, -1);
      mEndColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_color_end, -1);

    } finally {
      typedArray.recycle();
    }

    mBarItemPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBarItemPaint.setColor(mMainColor);
    mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBorderPaint.setStyle(Paint.Style.STROKE);
    mBorderPaint.setStrokeWidth(mBorderWidth);
    mBarItemPaint.setColor(mBorderColor);
  }
 protected void initByAttributes(TypedArray attributes) {
   finishedStrokeColor =
       attributes.getColor(R.styleable.ArcProgress_arc_finished_color, default_finished_color);
   unfinishedStrokeColor =
       attributes.getColor(R.styleable.ArcProgress_arc_unfinished_color, default_unfinished_color);
   textColor = attributes.getColor(R.styleable.ArcProgress_arc_text_color, default_text_color);
   textSize = attributes.getDimension(R.styleable.ArcProgress_arc_text_size, default_text_size);
   arcAngle = attributes.getFloat(R.styleable.ArcProgress_arc_angle, default_arc_angle);
   setMax(attributes.getInt(R.styleable.ArcProgress_arc_max, default_max));
   setProgress(attributes.getInt(R.styleable.ArcProgress_arc_progress, 0));
   strokeWidth =
       attributes.getDimension(R.styleable.ArcProgress_arc_stroke_width, default_stroke_width);
   suffixTextSize =
       attributes.getDimension(
           R.styleable.ArcProgress_arc_suffix_text_size, default_suffix_text_size);
   suffixText =
       TextUtils.isEmpty(attributes.getString(R.styleable.ArcProgress_arc_suffix_text))
           ? default_suffix_text
           : attributes.getString(R.styleable.ArcProgress_arc_suffix_text);
   suffixTextPadding =
       attributes.getDimension(
           R.styleable.ArcProgress_arc_suffix_text_padding, default_suffix_padding);
   bottomTextSize =
       attributes.getDimension(
           R.styleable.ArcProgress_arc_bottom_text_size, default_bottom_text_size);
   bottomText = attributes.getString(R.styleable.ArcProgress_arc_bottom_text);
 }
 private void init(AttributeSet attrs) {
   if (attrs != null) {
     TypedArray a =
         getContext()
             .getTheme()
             .obtainStyledAttributes(attrs, R.styleable.DexCrossFadeImageView, 0, 0);
     setTransitionDurationMillis(
         a.getInt(
             R.styleable.DexCrossFadeImageView_transition_duration_millis,
             transitionDurationMillis));
     setStillImageDurationMillis(
         a.getInt(
             R.styleable.DexCrossFadeImageView_still_image_duration_millis,
             stillImageDurationMillis));
     setLoop(a.getBoolean(R.styleable.DexCrossFadeImageView_loop, loop));
     int intArrayRes = a.getResourceId(R.styleable.DexCrossFadeImageView_images_array, 0);
     if (intArrayRes != 0) {
       TypedArray images = getResources().obtainTypedArray(intArrayRes);
       drawables = new Drawable[images.length()];
       for (int i = 0; i < images.length(); i++) drawables[i] = images.getDrawable(i);
       images.recycle();
       start();
     }
     a.recycle();
   }
 }
  private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    TypedArray attr =
        context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, 0);
    mColorNormal = attr.getColor(R.styleable.FloatingActionButton_fab_colorNormal, 0xFFDA4336);
    mColorPressed = attr.getColor(R.styleable.FloatingActionButton_fab_colorPressed, 0xFFE75043);
    mColorDisabled = attr.getColor(R.styleable.FloatingActionButton_fab_colorDisabled, 0xFFAAAAAA);
    mColorRipple = attr.getColor(R.styleable.FloatingActionButton_fab_colorRipple, 0x99FFFFFF);
    mShowShadow = attr.getBoolean(R.styleable.FloatingActionButton_fab_showShadow, true);
    mShadowColor = attr.getColor(R.styleable.FloatingActionButton_fab_shadowColor, 0x66000000);
    mShadowRadius =
        attr.getDimensionPixelSize(
            R.styleable.FloatingActionButton_fab_shadowRadius, mShadowRadius);
    mShadowXOffset =
        attr.getDimensionPixelSize(
            R.styleable.FloatingActionButton_fab_shadowXOffset, mShadowXOffset);
    mShadowYOffset =
        attr.getDimensionPixelSize(
            R.styleable.FloatingActionButton_fab_shadowYOffset, mShadowYOffset);
    mFabSize = attr.getInt(R.styleable.FloatingActionButton_fab_size, SIZE_NORMAL);
    mLabelText = attr.getString(R.styleable.FloatingActionButton_fab_label);
    mShouldProgressIndeterminate =
        attr.getBoolean(R.styleable.FloatingActionButton_fab_progress_indeterminate, false);
    mProgressColor = attr.getColor(R.styleable.FloatingActionButton_fab_progress_color, 0xFF009688);
    mProgressBackgroundColor =
        attr.getColor(R.styleable.FloatingActionButton_fab_progress_backgroundColor, 0x4D000000);
    mProgressMax = attr.getInt(R.styleable.FloatingActionButton_fab_progress_max, mProgressMax);
    mShowProgressBackground =
        attr.getBoolean(R.styleable.FloatingActionButton_fab_progress_showBackground, true);

    if (attr.hasValue(R.styleable.FloatingActionButton_fab_progress)) {
      mProgress = attr.getInt(R.styleable.FloatingActionButton_fab_progress, 0);
      mShouldSetProgress = true;
    }

    if (attr.hasValue(R.styleable.FloatingActionButton_fab_elevationCompat)) {
      float elevation =
          attr.getDimensionPixelOffset(R.styleable.FloatingActionButton_fab_elevationCompat, 0);
      if (isInEditMode()) {
        setElevation(elevation);
      } else {
        setElevationCompat(elevation);
      }
    }

    initShowAnimation(attr);
    initHideAnimation(attr);
    attr.recycle();

    if (isInEditMode()) {
      if (mShouldProgressIndeterminate) {
        setIndeterminate(true);
      } else if (mShouldSetProgress) {
        saveButtonOriginalPosition();
        setProgress(mProgress, false);
      }
    }

    //        updateBackground();
    setClickable(true);
  }
  /**
   * The contructor used with an inflater
   *
   * @param context
   * @param attrs
   */
  public CircleFlowIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    // Retrieve styles attributs
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleFlowIndicator);

    // Gets the inactive circle type, defaulting to "fill"
    int activeType = a.getInt(R.styleable.CircleFlowIndicator_activeType, STYLE_FILL);

    int activeDefaultColor = 0xFFFFFFFF;

    // Get a custom inactive color if there is one
    int activeColor = a.getColor(R.styleable.CircleFlowIndicator_activeColor, activeDefaultColor);

    // Gets the inactive circle type, defaulting to "stroke"
    int inactiveType = a.getInt(R.styleable.CircleFlowIndicator_inactiveType, STYLE_STROKE);

    int inactiveDefaultColor = 0x44FFFFFF;
    // Get a custom inactive color if there is one
    int inactiveColor =
        a.getColor(R.styleable.CircleFlowIndicator_inactiveColor, inactiveDefaultColor);

    // Retrieve the radius
    radius = a.getDimension(R.styleable.CircleFlowIndicator_radius, 4.0f);

    // Retrieve the fade out time
    fadeOutTime = a.getInt(R.styleable.CircleFlowIndicator_fadeOut, 0);

    initColors(activeColor, inactiveColor, activeType, inactiveType);
  }
Exemple #18
0
  public DoubleProgress(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.DoubleProgress);
    try {
      stringHaut = styledAttrs.getString(R.styleable.DoubleProgress_texteHaut);
      stringBas = styledAttrs.getString(R.styleable.DoubleProgress_texteBas);
      max = styledAttrs.getFloat(R.styleable.DoubleProgress_max, 5);
      temps = styledAttrs.getInt(R.styleable.DoubleProgress_temps, 1000);
      attente = styledAttrs.getInt(R.styleable.DoubleProgress_attente, 0);
      textFromAlpha = styledAttrs.getInt(R.styleable.DoubleProgress_attente, 0);
      textToAlpha = styledAttrs.getInt(R.styleable.DoubleProgress_attente, 0);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      styledAttrs.recycle();
    }

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mView = inflater.inflate(R.layout.double_progress, this, true); // ajoute la view

    charger();
    remplir();
  }
  /**
   * @param anim The animator, must not be null
   * @param arrayAnimator Incoming typed array for Animator's attributes.
   * @param arrayObjectAnimator Incoming typed array for Object Animator's attributes.
   */
  private static void parseAnimatorFromTypeArray(
      ValueAnimator anim, TypedArray arrayAnimator, TypedArray arrayObjectAnimator) {
    long duration = arrayAnimator.getInt(R.styleable.Animator_android_duration, 300);

    long startDelay = arrayAnimator.getInt(R.styleable.Animator_android_startOffset, 0);

    int valueType = arrayAnimator.getInt(R.styleable.Animator_vc_valueType, 0);

    TypeEvaluator evaluator = null;

    // Must be a path animator by the time I reach here
    if (valueType == VALUE_TYPE_PATH) {
      evaluator = setupAnimatorForPath(anim, arrayAnimator);
    } else {
      throw new IllegalArgumentException("target is not a pathType target");
    }

    anim.setDuration(duration);
    anim.setStartDelay(startDelay);

    if (arrayAnimator.hasValue(R.styleable.Animator_android_repeatCount)) {
      anim.setRepeatCount(arrayAnimator.getInt(R.styleable.Animator_android_repeatCount, 0));
    }
    if (arrayAnimator.hasValue(R.styleable.Animator_android_repeatMode)) {
      anim.setRepeatMode(
          arrayAnimator.getInt(R.styleable.Animator_android_repeatMode, ValueAnimator.RESTART));
    }
    if (evaluator != null) {
      anim.setEvaluator(evaluator);
    }

    if (arrayObjectAnimator != null) {
      setupObjectAnimator(anim, arrayObjectAnimator);
    }
  }
 public LinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
   super(context, attrs, defStyleAttr, defStyleRes);
   this.mBaselineAligned = true;
   this.mBaselineAlignedChildIndex = -1;
   this.mBaselineChildTop = SHOW_DIVIDER_NONE;
   this.mGravity = 8388659;
   TypedArray a =
       context.obtainStyledAttributes(attrs, R.styleable.LinearLayout, defStyleAttr, defStyleRes);
   int index = a.getInt(VERTICAL, -1);
   if (index >= 0) {
     setOrientation(index);
   }
   index = a.getInt(SHOW_DIVIDER_NONE, -1);
   if (index >= 0) {
     setGravity(index);
   }
   boolean baselineAligned = a.getBoolean(SHOW_DIVIDER_MIDDLE, true);
   if (!baselineAligned) {
     setBaselineAligned(baselineAligned);
   }
   this.mWeightSum =
       a.getFloat(
           VERTICAL_GRAVITY_COUNT,
           android.view.WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE);
   this.mBaselineAlignedChildIndex = a.getInt(INDEX_FILL, -1);
   this.mUseLargestChild = a.getBoolean(6, false);
   setDividerDrawable(a.getDrawable(5));
   this.mShowDividers = a.getInt(7, SHOW_DIVIDER_NONE);
   this.mDividerPadding = a.getDimensionPixelSize(8, SHOW_DIVIDER_NONE);
   a.recycle();
 }
 public SliderLayout(Context context, AttributeSet attrs, int defStyle) {
   super(context, attrs, defStyle);
   mContext = context;
   LayoutInflater.from(context).inflate(R.layout.slider_layout, this, true);
   final TypedArray attributes =
       context.getTheme().obtainStyledAttributes(attrs, R.styleable.SliderLayout, defStyle, 0);
   mTransformerSpan = attributes.getInteger(R.styleable.SliderLayout_pager_animation_span, 1100);
   mTransformerId =
       attributes.getInt(R.styleable.SliderLayout_pager_animation, Transformer.Default.ordinal());
   mSliderIndicatorPresentations =
       attributes.getInt(
           R.styleable.SliderLayout_lns_use_presentation, PresentationConfig.Smart.ordinal());
   mAutoCycle = attributes.getBoolean(R.styleable.SliderLayout_auto_cycle, true);
   int visibility = attributes.getInt(R.styleable.SliderLayout_indicator_visibility, 0);
   for (PagerIndicator.IndicatorVisibility v : PagerIndicator.IndicatorVisibility.values()) {
     if (v.ordinal() == visibility) {
       mIndicatorVisibility = v;
       break;
     }
   }
   mSliderAdapter = new SliderAdapter(mContext);
   mSliderAdapter.registerDataSetObserver(sliderDataObserver);
   pagerSetup();
   attributes.recycle();
   setPresetIndicator(PresetIndicators.Center_Bottom);
   setPresetTransformer(mTransformerId);
   setSliderTransformDuration(mTransformerSpan, null);
   setIndicatorVisibility(mIndicatorVisibility);
   if (mAutoCycle) {
     startAutoCycle();
   }
 }
  private void initView(Context context, AttributeSet attrs) {
    color = Color.WHITE;
    width = dpToPx(context, DEFAULT_WIDTH);
    shadowPosition = dpToPx(getContext(), DEFAULT_SHADOW_POSITION);

    if (null != attrs) {
      TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RotateLoading);
      color = typedArray.getColor(R.styleable.RotateLoading_loading_color, Color.WHITE);
      width =
          typedArray.getDimensionPixelSize(
              R.styleable.RotateLoading_loading_width, dpToPx(context, DEFAULT_WIDTH));
      shadowPosition =
          typedArray.getInt(R.styleable.RotateLoading_shadow_position, DEFAULT_SHADOW_POSITION);
      speedOfDegree =
          typedArray.getInt(R.styleable.RotateLoading_loading_speed, DEFAULT_SPEED_OF_DEGREE);
      typedArray.recycle();
    }
    speedOfArc = speedOfDegree / 4;
    mPaint = new Paint();
    mPaint.setColor(color);
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(width);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
  }
Exemple #23
0
    /** Called when the parser is pointing to an item tag. */
    public void readItem(AttributeSet attrs) {
      TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.SherlockMenuItem);

      // Inherit attributes from the group as default value
      itemId = a.getResourceId(R.styleable.SherlockMenuItem_android_id, defaultItemId);
      final int category =
          a.getInt(R.styleable.SherlockMenuItem_android_menuCategory, groupCategory);
      final int order = a.getInt(R.styleable.SherlockMenuItem_android_orderInCategory, groupOrder);
      itemCategoryOrder = (category & Menu.CATEGORY_MASK) | (order & Menu.USER_MASK);
      itemTitle = a.getText(R.styleable.SherlockMenuItem_android_title);
      itemTitleCondensed = a.getText(R.styleable.SherlockMenuItem_android_titleCondensed);
      itemIconResId = a.getResourceId(R.styleable.SherlockMenuItem_android_icon, 0);
      itemAlphabeticShortcut =
          getShortcut(a.getString(R.styleable.SherlockMenuItem_android_alphabeticShortcut));
      itemNumericShortcut =
          getShortcut(a.getString(R.styleable.SherlockMenuItem_android_numericShortcut));
      if (a.hasValue(R.styleable.SherlockMenuItem_android_checkable)) {
        // Item has attribute checkable, use it
        itemCheckable = a.getBoolean(R.styleable.SherlockMenuItem_android_checkable, false) ? 1 : 0;
      } else {
        // Item does not have attribute, use the group's (group can have one more state
        // for checkable that represents the exclusive checkable)
        itemCheckable = groupCheckable;
      }

      itemChecked = a.getBoolean(R.styleable.SherlockMenuItem_android_checked, defaultItemChecked);
      itemVisible = a.getBoolean(R.styleable.SherlockMenuItem_android_visible, groupVisible);
      itemEnabled = a.getBoolean(R.styleable.SherlockMenuItem_android_enabled, groupEnabled);

      TypedValue value = new TypedValue();
      a.getValue(R.styleable.SherlockMenuItem_android_showAsAction, value);
      itemShowAsAction = value.type == TypedValue.TYPE_INT_HEX ? value.data : -1;

      itemListenerMethodName = a.getString(R.styleable.SherlockMenuItem_android_onClick);
      itemActionViewLayout = a.getResourceId(R.styleable.SherlockMenuItem_android_actionLayout, 0);
      itemActionViewClassName = a.getString(R.styleable.SherlockMenuItem_android_actionViewClass);
      itemActionProviderClassName =
          a.getString(R.styleable.SherlockMenuItem_android_actionProviderClass);

      final boolean hasActionProvider = itemActionProviderClassName != null;
      if (hasActionProvider && itemActionViewLayout == 0 && itemActionViewClassName == null) {
        itemActionProvider =
            newInstance(
                itemActionProviderClassName,
                ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE,
                mActionProviderConstructorArguments);
      } else {
        if (hasActionProvider) {
          Log.w(
              LOG_TAG,
              "Ignoring attribute 'actionProviderClass'." + " Action view already specified.");
        }
        itemActionProvider = null;
      }

      a.recycle();

      itemAdded = false;
    }
 public CalculatorPadLayout(Context context, AttributeSet attrs, int defStyle) {
   super(context, attrs, defStyle);
   final TypedArray a =
       context.obtainStyledAttributes(
           attrs, new int[] {android.R.attr.rowCount, android.R.attr.columnCount}, defStyle, 0);
   mRowCount = a.getInt(0, 1);
   mColumnCount = a.getInt(1, 1);
   a.recycle();
 }
  public ProgressBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mUiThreadId = Thread.currentThread().getId();
    initProgressBar();

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressBar, defStyle, 0);

    mNoInvalidate = true;

    Drawable drawable = a.getDrawable(R.styleable.ProgressBar_progressDrawable);
    if (drawable != null) {
      drawable = tileify(drawable, false);
      // Calling this method can set mMaxHeight, make sure the corresponding
      // XML attribute for mMaxHeight is read after calling this method
      setProgressDrawable(drawable);
    }

    mDuration = a.getInt(R.styleable.ProgressBar_indeterminateDuration, mDuration);

    mMinWidth = a.getDimensionPixelSize(R.styleable.ProgressBar_minWidth, mMinWidth);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.ProgressBar_maxWidth, mMaxWidth);
    mMinHeight = a.getDimensionPixelSize(R.styleable.ProgressBar_minHeight, mMinHeight);
    mMaxHeight = a.getDimensionPixelSize(R.styleable.ProgressBar_maxHeight, mMaxHeight);

    mBehavior = a.getInt(R.styleable.ProgressBar_indeterminateBehavior, mBehavior);

    final int resID =
        a.getResourceId(
            com.android.internal.R.styleable.ProgressBar_interpolator,
            android.R.anim.linear_interpolator); // default to linear interpolator
    if (resID > 0) {
      setInterpolator(context, resID);
    }

    setMax(a.getInt(R.styleable.ProgressBar_max, mMax));

    setProgress(a.getInt(R.styleable.ProgressBar_progress, mProgress));

    setSecondaryProgress(a.getInt(R.styleable.ProgressBar_secondaryProgress, mSecondaryProgress));

    drawable = a.getDrawable(R.styleable.ProgressBar_indeterminateDrawable);
    if (drawable != null) {
      drawable = tileifyIndeterminate(drawable);
      setIndeterminateDrawable(drawable);
    }

    mOnlyIndeterminate =
        a.getBoolean(R.styleable.ProgressBar_indeterminateOnly, mOnlyIndeterminate);

    mNoInvalidate = false;

    setIndeterminate(
        mOnlyIndeterminate || a.getBoolean(R.styleable.ProgressBar_indeterminate, mIndeterminate));

    a.recycle();
  }
  @Override
  public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs)
      throws XmlPullParserException, IOException {

    super.inflate(r, parser, attrs);

    int type;

    int low = 0;

    final int innerDepth = parser.getDepth() + 1;
    int depth;
    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
        && ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) {
      if (type != XmlPullParser.START_TAG) {
        continue;
      }

      if (depth > innerDepth || !parser.getName().equals("item")) {
        continue;
      }

      TypedArray a =
          r.obtainAttributes(attrs, com.android.internal.R.styleable.LevelListDrawableItem);

      low = a.getInt(com.android.internal.R.styleable.LevelListDrawableItem_minLevel, 0);
      int high = a.getInt(com.android.internal.R.styleable.LevelListDrawableItem_maxLevel, 0);
      int drawableRes =
          a.getResourceId(com.android.internal.R.styleable.LevelListDrawableItem_drawable, 0);

      a.recycle();

      if (high < 0) {
        throw new XmlPullParserException(
            parser.getPositionDescription() + ": <item> tag requires a 'maxLevel' attribute");
      }

      Drawable dr;
      if (drawableRes != 0) {
        dr = r.getDrawable(drawableRes);
      } else {
        while ((type = parser.next()) == XmlPullParser.TEXT) {}
        if (type != XmlPullParser.START_TAG) {
          throw new XmlPullParserException(
              parser.getPositionDescription()
                  + ": <item> tag requires a 'drawable' attribute or "
                  + "child tag defining a drawable");
        }
        dr = Drawable.createFromXmlInner(r, parser, attrs);
      }

      mLevelListState.addLevel(low, high, dr);
    }

    onLevelChange(getLevel());
  }
Exemple #27
0
  public SwipeLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mDragHelper = ViewDragHelper.create(this, mDragHelperCallback);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeLayout);
    int ordinal = a.getInt(R.styleable.SwipeLayout_drag_edge, DragEdge.Right.ordinal());
    mDragEdge = DragEdge.values()[ordinal];
    ordinal = a.getInt(R.styleable.SwipeLayout_show_mode, ShowMode.PullOut.ordinal());
    mShowMode = ShowMode.values()[ordinal];
  }
  private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a =
        context.obtainStyledAttributes(
            attrs, R.styleable.GoogleCircleProgressView, defStyleAttr, 0);
    final float density = getContext().getResources().getDisplayMetrics().density;

    mBackGroundColor =
        a.getColor(
            R.styleable.GoogleCircleProgressView_gcp_background_color, DEFAULT_CIRCLE_BG_LIGHT);

    mProgressColor =
        a.getColor(
            R.styleable.GoogleCircleProgressView_gcp_progress_color, DEFAULT_CIRCLE_BG_LIGHT);
    mColors = new int[] {mProgressColor};

    mInnerRadius =
        a.getDimensionPixelOffset(R.styleable.GoogleCircleProgressView_gcp_inner_radius, -1);

    mProgressStokeWidth =
        a.getDimensionPixelOffset(
            R.styleable.GoogleCircleProgressView_gcp_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth =
        a.getDimensionPixelOffset(R.styleable.GoogleCircleProgressView_gcp_arrow_width, -1);
    mArrowHeight =
        a.getDimensionPixelOffset(R.styleable.GoogleCircleProgressView_gcp_arrow_height, -1);
    mTextSize =
        a.getDimensionPixelOffset(
            R.styleable.GoogleCircleProgressView_gcp_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor =
        a.getColor(R.styleable.GoogleCircleProgressView_gcp_progress_text_color, Color.BLACK);

    mShowArrow = a.getBoolean(R.styleable.GoogleCircleProgressView_gcp_show_arrow, true);
    mCircleBackgroundEnabled =
        a.getBoolean(R.styleable.GoogleCircleProgressView_gcp_enable_circle_background, true);

    mProgress = a.getInt(R.styleable.GoogleCircleProgressView_gcp_progress, 0);
    mMax = a.getInt(R.styleable.GoogleCircleProgressView_gcp_max, 100);
    int textVisible =
        a.getInt(R.styleable.GoogleCircleProgressView_gcp_progress_text_visibility, 1);
    if (textVisible != 1) {
      mIfDrawText = true;
    }

    mTextPaint = new Paint();
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setAntiAlias(true);
    a.recycle();
    mProgressDrawable = new MaterialProgressDrawable(getContext(), this);
    super.setImageDrawable(mProgressDrawable);
  }
  public SwipeFlingAdapterView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a =
        context.obtainStyledAttributes(attrs, R.styleable.SwipeFlingAdapterView, defStyle, 0);
    MAX_VISIBLE = a.getInt(R.styleable.SwipeFlingAdapterView_max_visible, MAX_VISIBLE);
    MIN_ADAPTER_STACK =
        a.getInt(R.styleable.SwipeFlingAdapterView_min_adapter_stack, MIN_ADAPTER_STACK);
    ROTATION_DEGREES =
        a.getFloat(R.styleable.SwipeFlingAdapterView_rotation_degrees, ROTATION_DEGREES);
    a.recycle();
  }
 public LCalendarView(Context context, AttributeSet attrs, int defStyleAttr) {
   super(context, attrs, defStyleAttr);
   days = new int[42];
   year = 2015;
   month = 9;
   today = 0;
   textSize = 0;
   textY = 0;
   selectColor = Color.parseColor("#99c9f2");
   textColor = Color.BLACK;
   weekColor = Color.GRAY;
   backgroundColor = Color.parseColor("#50EEEEEE");
   todayColor = Color.parseColor("#50000000");
   /** 获得我们所定义的自定义样式属性 */
   TypedArray a =
       context.getTheme().obtainStyledAttributes(attrs, R.styleable.calendarview, defStyleAttr, 0);
   int n = a.getIndexCount();
   for (int i = 0; i < n; i++) {
     int attr = a.getIndex(i);
     switch (attr) {
       case R.styleable.calendarview_background_color:
         backgroundColor = a.getColor(attr, Color.parseColor("#ebebeb"));
         break;
       case R.styleable.calendarview_month:
         month = a.getInt(attr, 0);
         break;
       case R.styleable.calendarview_selected:
         selectedDay = a.getInt(attr, 0);
         break;
       case R.styleable.calendarview_selected_color:
         selectColor = a.getColor(attr, Color.parseColor("#99c9f2"));
         break;
       case R.styleable.calendarview_today:
         today = a.getInt(attr, 0);
         break;
       case R.styleable.calendarview_text_color:
         textColor = a.getColor(attr, Color.BLACK);
         break;
       case R.styleable.calendarview_today_color:
         todayColor = a.getColor(attr, Color.parseColor("#50000000"));
         break;
       case R.styleable.calendarview_weeks_color:
         weekColor = a.getColor(attr, Color.GRAY);
         break;
       case R.styleable.calendarview_year:
         year = a.getColor(attr, 0);
         break;
     }
   }
   a.recycle();
   init();
   initPaint();
 }