示例#1
0
  public MButton(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MTextView, 0, 0);

    try {
      txtFont = a.getInteger(R.styleable.MTextView_txtFont, -1);
      txtTouch = a.getInteger(R.styleable.MTextView_txtTouch, -1);
      if (txtFont != -1) {
        Fonts.getIntance(getContext()).setFont(this, txtFont);
      }

      if (txtTouch != -1) {
        CommonAndroid.setAnimationOnClick(this);
      }
    } finally {
      a.recycle();
    }

    try {
      // ((SkypeApplication)
      // getContext().getApplicationContext()).setFonts(txtFont, this);
    } catch (Exception x) {

    }
  }
  /** Constructor required for XML inflation. */
  public FlipViewController(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    int orientation = VERTICAL;

    TypedArray a =
        context.getTheme().obtainStyledAttributes(attrs, R.styleable.FlipViewController, 0, 0);

    try {
      int value = a.getInteger(R.styleable.FlipViewController_orientation, VERTICAL);
      if (value == HORIZONTAL) {
        orientation = HORIZONTAL;
      }

      value = a.getInteger(R.styleable.FlipViewController_animationBitmapFormat, 0);
      if (value == 1) {
        setAnimationBitmapFormat(Bitmap.Config.ARGB_4444);
      } else if (value == 2) {
        setAnimationBitmapFormat(Bitmap.Config.RGB_565);
      } else {
        setAnimationBitmapFormat(Bitmap.Config.ARGB_8888);
      }
    } finally {
      a.recycle();
    }

    init(context, orientation);
  }
 private void initAttrs(Context context, AttributeSet attrs) {
   TypedArray array =
       context.obtainStyledAttributes(attrs, R.styleable.DownloadProgressView, 0, 0);
   try {
     mRadius = array.getDimension(R.styleable.DownloadProgressView_circleRadius, 0);
     mStrokeWidth = array.getDimension(R.styleable.DownloadProgressView_strokeWidth, 0);
     mLineWidth = array.getDimension(R.styleable.DownloadProgressView_lineWidth, 0);
     mProgressDuration =
         array.getInteger(
             R.styleable.DownloadProgressView_progressDuration, DEFAULT_PROGRESS_DURATION);
     mResultDuration =
         array.getInteger(
             R.styleable.DownloadProgressView_resultDuration, DEFAULT_RESULT_DURATION);
     mProgressBackgroundColor =
         array.getColor(R.styleable.DownloadProgressView_progressBackgroundColor, 0);
     mDrawingColor = array.getColor(R.styleable.DownloadProgressView_drawingColor, 0);
     mProgressColor = array.getColor(R.styleable.DownloadProgressView_progressColor, 0);
     mCircleBackgroundColor =
         array.getColor(R.styleable.DownloadProgressView_circleBackgroundColor, 0);
     mOvershootValue =
         array.getFloat(R.styleable.DownloadProgressView_overshootValue, DEFAULT_OVERSHOOT_VALUE);
   } finally {
     array.recycle();
   }
 }
  private void init(AttributeSet attrs) {
    getWindowVisibleDisplayFrame(mFrameRect);

    if (attrs == null) {
      mColumnNumber = (DEFAULT_COLUMN_NUMBER); // default column number is
      // 2.
    } else {
      TypedArray a =
          getContext().obtainStyledAttributes(attrs, R.styleable.PinterestLikeAdapterView);

      int landColNumber =
          a.getInteger(R.styleable.PinterestLikeAdapterView_plaLandscapeColumnNumber, 3);
      int defColNumber = a.getInteger(R.styleable.PinterestLikeAdapterView_plaColumnNumber, 2);

      if (mFrameRect.width() > mFrameRect.height() && landColNumber != -1) {
        mColumnNumber = (landColNumber);
      } else if (defColNumber != -1) {
        mColumnNumber = (defColNumber);
      } else {
        mColumnNumber = (DEFAULT_COLUMN_NUMBER);
      }

      mColumnPaddingLeft =
          a.getDimensionPixelSize(R.styleable.PinterestLikeAdapterView_plaColumnPaddingLeft, 0);
      mColumnPaddingRight =
          a.getDimensionPixelSize(R.styleable.PinterestLikeAdapterView_plaColumnPaddingRight, 0);
      a.recycle();
    }

    mColumns = new Column[getColumnNumber()];
    for (int i = 0; i < getColumnNumber(); ++i) mColumns[i] = new Column(i);

    mFixedColumn = new FixedColumn();
  }
示例#5
0
  public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    final Resources res = getResources();

    // Load defaults from resources
    final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades);
    final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay);
    final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length);
    final int defaultSelectedColor =
        res.getColor(R.color.default_underline_indicator_selected_color);

    // Retrieve styles attributes
    TypedArray a =
        context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0);

    setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades));
    setSelectedColor(
        a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor));
    setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay));
    setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength));

    Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background);
    if (background != null) {
      setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
  }
  private void loadAttributes(Context context, AttributeSet attrs) {
    TypedValue outValue = new TypedValue();
    Resources.Theme theme = context.getTheme();

    // use ?attr/colorPrimary as background color
    theme.resolveAttribute(R.attr.colorPrimary, outValue, true);

    TypedArray a =
        getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.FooterLayout, 0, 0);

    int containerGravity;
    try {
      setColor(a.getColor(R.styleable.FooterLayout_ft_color, outValue.data));
      startAnimationDuration =
          a.getInteger(
              R.styleable.FooterLayout_ft_start_anim_duration, DEFAULT_START_ANIMATION_DURATION);
      endAnimationDuration =
          a.getInteger(
              R.styleable.FooterLayout_ft_end_anim_duration, DEFAULT_END_ANIMATION_DURATION);
      containerGravity = a.getInteger(R.styleable.FooterLayout_ft_container_gravity, 1);
      mFabSize = a.getInteger(R.styleable.FooterLayout_ft_fab_type, DEFAULT_FAB_SIZE);
    } finally {
      a.recycle();
    }

    mFabExpandLayout.setGravity(getGravity(containerGravity));
  }
  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);
  }
示例#8
0
  public CustomPicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray typedArray =
        context.getTheme().obtainStyledAttributes(attrs, R.styleable.CustomPicker, 0, 0);

    try {
      min = typedArray.getInteger(R.styleable.CustomPicker_minValue, 0);
      max = typedArray.getInteger(R.styleable.CustomPicker_maxValue, 0);
      digitsNumber = typedArray.getInteger(R.styleable.CustomPicker_digitNumber, 1);
      incrementValue = typedArray.getInteger(R.styleable.CustomPicker_incrementValue, 1);
      visibility =
          typedArray.getInteger(R.styleable.CustomPicker_editTextVisibility, VISIBILITY_VISIBLE);
      orientation =
          typedArray.getInteger(R.styleable.CustomPicker_orientation, ORIENTATION_VERTICAL);
    } finally {
      typedArray.recycle();
    }

    LayoutInflater inflator =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    switch (orientation) {
      case ORIENTATION_VERTICAL:
        myPickerView = inflator.inflate(R.layout.picker_control, null);
        break;
      case ORIENTATION_HORIZONTAL:
        myPickerView = inflator.inflate(R.layout.picker_control_horizontal, null);
        break;
    }

    this.addView(myPickerView);

    initializeReference();
  }
  private void init(Context context, AttributeSet attributeSet) {
    TypedArray attr = getTypedArray(context, attributeSet, R.styleable.MaterialMenuView);

    try {
      int color = attr.getColor(R.styleable.MaterialMenuView_mm_color, DEFAULT_COLOR);
      int scale = attr.getInteger(R.styleable.MaterialMenuView_mm_scale, DEFAULT_SCALE);
      int transformDuration =
          attr.getInteger(
              R.styleable.MaterialMenuView_mm_transformDuration, DEFAULT_TRANSFORM_DURATION);
      int pressedDuration =
          attr.getInteger(
              R.styleable.MaterialMenuView_mm_pressedDuration, DEFAULT_PRESSED_DURATION);
      MaterialMenuDrawable.Stroke stroke =
          MaterialMenuDrawable.Stroke.valueOf(
              attr.getInteger(R.styleable.MaterialMenuView_mm_strokeWidth, 0));
      boolean rtlEnabled = attr.getBoolean(R.styleable.MaterialMenuView_mm_rtlEnabled, false);

      drawable =
          new MaterialMenuDrawable(
              context, color, stroke, scale, transformDuration, pressedDuration);
      drawable.setRTLEnabled(rtlEnabled);
    } finally {
      attr.recycle();
    }

    drawable.setCallback(this);
  }
  private void initFromXml(AttributeSet attr) {
    TypedArray a = getContext().obtainStyledAttributes(attr, R.styleable.CardContainer);

    setGravity(a.getInteger(R.styleable.CardContainer_android_gravity, Gravity.CENTER));
    int orientation = a.getInteger(R.styleable.CardContainer_orientation, 1);
    setOrientation(Orientation.fromIndex(orientation));

    a.recycle();
  }
  private void init(Context context, AttributeSet attrs) {
    mDisplayMetrics = context.getResources().getDisplayMetrics();

    mStrokeWidth = mStrokeWidth * mDisplayMetrics.density;
    mTextSize = mTextSize * mDisplayMetrics.scaledDensity;

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressPieView);
    final Resources res = getResources();

    mMax = a.getInteger(R.styleable.ProgressPieView_max1, mMax);
    mProgress = a.getInteger(R.styleable.ProgressPieView_progress1, mProgress);
    mStartAngle = a.getInt(R.styleable.ProgressPieView_startAngle, mStartAngle);
    mStrokeWidth = a.getDimension(R.styleable.ProgressPieView_strokeWidth, mStrokeWidth);
    mTypeface = a.getString(R.styleable.ProgressPieView_typeface);
    mTextSize = a.getDimension(R.styleable.ProgressPieView_android_textSize, mTextSize);
    mText = a.getString(R.styleable.ProgressPieView_android_text);

    mShowStroke = a.getBoolean(R.styleable.ProgressPieView_showStroke, mShowStroke);
    mShowText = a.getBoolean(R.styleable.ProgressPieView_showText, mShowText);
    mImage = a.getDrawable(R.styleable.ProgressPieView_image);

    int backgroundColor = res.getColor(R.color.default_background_color);
    backgroundColor = a.getColor(R.styleable.ProgressPieView_backgroundColor, backgroundColor);
    int progressColor = res.getColor(R.color.default_progress_color);
    progressColor = a.getColor(R.styleable.ProgressPieView_progressColor1, progressColor);
    int strokeColor = res.getColor(R.color.default_stroke_color);
    strokeColor = a.getColor(R.styleable.ProgressPieView_strokeColor, strokeColor);
    int textColor = res.getColor(R.color.default_text_color);
    textColor = a.getColor(R.styleable.ProgressPieView_android_textColor, textColor);

    mProgressFillType =
        a.getInteger(R.styleable.ProgressPieView_progressFillType, mProgressFillType);

    a.recycle();

    mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBackgroundPaint.setColor(backgroundColor);
    mBackgroundPaint.setStyle(Paint.Style.FILL);

    mProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mProgressPaint.setColor(progressColor);
    mProgressPaint.setStyle(Paint.Style.FILL);

    mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mStrokePaint.setColor(strokeColor);
    mStrokePaint.setStyle(Paint.Style.STROKE);
    mStrokePaint.setStrokeWidth(mStrokeWidth);

    mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setColor(textColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setTextAlign(Paint.Align.CENTER);

    mInnerRectF = new RectF();
    mImageRect = new Rect();
  }
示例#12
0
 public MeterView(Context context, AttributeSet attributes) {
   super(context, attributes);
   TypedArray a = context.obtainStyledAttributes(attributes, R.styleable.MeterViewAttr);
   this.angle = a.getInteger(R.styleable.MeterViewAttr_angle, 0);
   this.spacing = a.getInteger(R.styleable.MeterViewAttr_spacing, 0);
   this.lineWidth = a.getInteger(R.styleable.MeterViewAttr_lineWidth, 0);
   this.lineColor = a.getInteger(R.styleable.MeterViewAttr_lineColor, 0);
   this.pathColor = a.getInteger(R.styleable.MeterViewAttr_pathColor, 0);
   a.recycle();
 }
示例#13
0
 // 从资源文件获取数据
 private void initObtainStyledAttr(Context context, AttributeSet attrs) {
   TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.SwipeMenu);
   mType = array.getInteger(R.styleable.SwipeMenu_sm_type, 1111);
   mDragWipeOffset =
       (int) array.getDimension(R.styleable.SwipeMenu_sm_dragoffset, SizeUtil.Dp2Px(context, 100));
   mMenuOffset =
       (int) array.getDimension(R.styleable.SwipeMenu_sm_menuoffset, SizeUtil.Dp2Px(context, 50));
   mStartScale = array.getFloat(R.styleable.SwipeMenu_sm_startscale, 0.2f);
   mStartAlpha = array.getFloat(R.styleable.SwipeMenu_sm_startalpha, 0.2f);
   mStart3DAngle = array.getInteger(R.styleable.SwipeMenu_sm_start3dangle, 60);
   array.recycle();
 }
示例#14
0
  /**
   * Inits the.
   *
   * @param context the context
   * @param attrs the attrs
   * @param defStyle the def style
   */
  private void init(Context context, AttributeSet attrs, int defStyle) {
    mFast = new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG, 0);
    mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.WheelRadio, defStyle, 0);
    mSmallTicksCount = a.getInteger(R.styleable.WheelRadio_smallTicks, 25) - 1;
    mBigTicksCount = a.getInteger(R.styleable.WheelRadio_bigTicks, 5) - 1;
    mValueIndicatorColor = a.getColor(R.styleable.WheelRadio_valueIndicatorColor, 0xFFFFFFFF);
    mSmallIndicatorColor = a.getColor(R.styleable.WheelRadio_smallIndicatorColor, 0x33FFFFFF);
    mBigIndicatorColor = a.getColor(R.styleable.WheelRadio_bigIndicatorColor, 0x66FFFFFF);
    a.recycle();
  }
示例#15
0
  /**
   * Method that initializes all fields and sets listeners
   *
   * @param context Context used to create this view
   * @param attrs Attribute used to initialize fields
   */
  private void init(final Context context, final AttributeSet attrs) {
    if (isInEditMode()) return;

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleView);
    rippleColor =
        typedArray.getColor(
            R.styleable.RippleView_rv_color, getResources().getColor(R.color.white));
    rippleType = typedArray.getInt(R.styleable.RippleView_rv_type, 0);
    hasToZoom = typedArray.getBoolean(R.styleable.RippleView_rv_zoom, false);
    isCentered = typedArray.getBoolean(R.styleable.RippleView_rv_centered, false);
    rippleDuration =
        typedArray.getInteger(R.styleable.RippleView_rv_rippleDuration, rippleDuration);
    frameRate = typedArray.getInteger(R.styleable.RippleView_rv_framerate, frameRate);
    rippleAlpha = typedArray.getInteger(R.styleable.RippleView_rv_alpha, rippleAlpha);
    ripplePadding = typedArray.getDimensionPixelSize(R.styleable.RippleView_rv_ripplePadding, 0);
    canvasHandler = new Handler();
    zoomScale = typedArray.getFloat(R.styleable.RippleView_rv_zoomScale, 1.03f);
    zoomDuration = typedArray.getInt(R.styleable.RippleView_rv_zoomDuration, 200);
    typedArray.recycle();
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL);
    paint.setColor(rippleColor);
    paint.setAlpha(rippleAlpha);
    this.setWillNotDraw(false);

    gestureDetector =
        new GestureDetector(
            context,
            new GestureDetector.SimpleOnGestureListener() {
              @Override
              public void onLongPress(MotionEvent event) {
                super.onLongPress(event);
                animateRipple(event);
                sendClickEvent(true);
              }

              @Override
              public boolean onSingleTapConfirmed(MotionEvent e) {
                return true;
              }

              @Override
              public boolean onSingleTapUp(MotionEvent e) {
                return true;
              }
            });

    this.setDrawingCacheEnabled(true);
    this.setClickable(true);
  }
 d(Context paramContext, AttributeSet paramAttributeSet)
 {
   super(paramAttributeSet);
   TypedArray localTypedArray = paramContext.obtainStyledAttributes(paramAttributeSet, a.i.CoordinatorLayout_LayoutParams);
   c = localTypedArray.getInteger(a.i.CoordinatorLayout_LayoutParams_android_layout_gravity, 0);
   f = localTypedArray.getResourceId(a.i.CoordinatorLayout_LayoutParams_layout_anchor, -1);
   d = localTypedArray.getInteger(a.i.CoordinatorLayout_LayoutParams_layout_anchorGravity, 0);
   e = localTypedArray.getInteger(a.i.CoordinatorLayout_LayoutParams_layout_keyline, -1);
   b = localTypedArray.hasValue(a.i.CoordinatorLayout_LayoutParams_layout_behavior);
   if (b) {
     a = CoordinatorLayout.a(paramContext, paramAttributeSet, localTypedArray.getString(a.i.CoordinatorLayout_LayoutParams_layout_behavior));
   }
   localTypedArray.recycle();
 }
 public LayoutConfiguration(Context context, AttributeSet attributeSet) {
   TypedArray a = context.obtainStyledAttributes(attributeSet, R.styleable.FlowLayout);
   try {
     this.setOrientation(
         a.getInteger(R.styleable.FlowLayout_android_orientation, FlowLayout.HORIZONTAL));
     this.setDebugDraw(a.getBoolean(R.styleable.FlowLayout_debugDraw, false));
     this.setWeightDefault(a.getFloat(R.styleable.FlowLayout_weightDefault, 0.0f));
     this.setGravity(a.getInteger(R.styleable.FlowLayout_android_gravity, Gravity.NO_GRAVITY));
     this.setLayoutDirection(
         a.getInteger(R.styleable.FlowLayout_layoutDirection, FlowLayout.LAYOUT_DIRECTION_LTR));
   } finally {
     a.recycle();
   }
 }
  /** bannerHeight banner的高度 animDuration 每次切换动画时间 gap banner切换时间 */
  private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    setOrientation(VERTICAL);
    mDebugPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.VerticalBannerView);
    mGap = array.getInteger(R.styleable.VerticalBannerView_gap, mGap);
    mAnimDuration = array.getInteger(R.styleable.VerticalBannerView_animDuration, mAnimDuration);

    if (mGap <= mAnimDuration) {
      mGap = 4000;
      mAnimDuration = 1000;
    }

    array.recycle();
  }
示例#19
0
  public JazzyHelper(Context context, AttributeSet attrs) {

    mAlreadyAnimatedItems = new HashSet<Integer>();

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.JazzyListView);
    int transitionEffect = a.getInteger(R.styleable.JazzyListView_effect, STANDARD);
    int maxVelocity = a.getInteger(R.styleable.JazzyListView_max_velocity, MAX_VELOCITY_OFF);
    mOnlyAnimateNewItems = a.getBoolean(R.styleable.JazzyListView_only_animate_new_items, false);
    mOnlyAnimateOnFling = a.getBoolean(R.styleable.JazzyListView_max_velocity, false);
    mSimulateGridWithList = a.getBoolean(R.styleable.JazzyListView_simulate_grid_with_list, false);
    a.recycle();

    setTransitionEffect(transitionEffect);
    setMaxAnimationVelocity(maxVelocity);
  }
  private void initWithAttrs(AttributeSet attrs) {
    // Read attributes
    TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.UnitValuePickerPreference);
    mUnitsId = a.getResourceId(R.styleable.UnitValuePickerPreference_units, -1);
    mDefaultUnitIndex = a.getInteger(R.styleable.UnitValuePickerPreference_defaultUnitIndex, 0);
    mDefaultValue = a.getInteger(R.styleable.UnitValuePickerPreference_defaultValue, 0);
    mMinValue = a.getInteger(R.styleable.UnitValuePickerPreference_minValue, -1);
    mMaxValue = a.getInteger(R.styleable.UnitValuePickerPreference_maxValue, -1);
    a.recycle();

    // Will be overridden by onSetInitialValue() if there's a persistent value
    // already
    mValue = mDefaultValue;
    mUnitIndex = mDefaultUnitIndex;
  }
  public NumberPickerPreference(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    if (attrs == null) {
      return;
    }

    TypedArray arr = context.obtainStyledAttributes(attrs, R.styleable.numberpicker);
    mStartRange = arr.getInteger(R.styleable.numberpicker_startRange, 0);
    mEndRange = arr.getInteger(R.styleable.numberpicker_endRange, 200);
    mDefault = arr.getInteger(R.styleable.numberpicker_defaultValue, 0);

    arr.recycle();

    setDialogLayoutResource(R.layout.pref_number_picker);
  }
  /**
   * Parse the attributes passed to the view from the XML
   *
   * @param a the attributes to parse
   */
  private void parseAttributes(TypedArray a) {
    barWidth = (int) a.getDimension(R.styleable.ProgressWheel_barWidth, barWidth);

    rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_rimWidth, rimWidth);

    spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_spinSpeed, spinSpeed);

    delayMillis = (int) a.getInteger(R.styleable.ProgressWheel_delayMillis, delayMillis);
    if (delayMillis < 0) {
      delayMillis = 0;
    }

    barColor = a.getColor(R.styleable.ProgressWheel_barColor, barColor);

    barLength = (int) a.getDimension(R.styleable.ProgressWheel_barLength, barLength);

    textSize = (int) a.getDimension(R.styleable.ProgressWheel_textSize, textSize);

    textColor = (int) a.getColor(R.styleable.ProgressWheel_textColor, textColor);

    setText(a.getString(R.styleable.ProgressWheel_text));

    rimColor = (int) a.getColor(R.styleable.ProgressWheel_rimColor, rimColor);

    circleColor = (int) a.getColor(R.styleable.ProgressWheel_circleColor, circleColor);
  }
 private void init(Context context, AttributeSet attrs, int defStyle) {
   TypedArray a =
       context.obtainStyledAttributes(attrs, R.styleable.EffectThumbLayout, defStyle, 0);
   mThumbAnimationDuration =
       a.getInteger(R.styleable.EffectThumbLayout_selectionAnimationDuration, 200);
   a.recycle();
 }
示例#24
0
  public CropImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mFocusWidth =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, mFocusWidth, getResources().getDisplayMetrics());
    mFocusHeight =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, mFocusHeight, getResources().getDisplayMetrics());
    mBorderWidth =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, mBorderWidth, getResources().getDisplayMetrics());

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CropImageView);
    mMaskColor = a.getColor(R.styleable.CropImageView_cropMaskColor, mMaskColor);
    mBorderColor = a.getColor(R.styleable.CropImageView_cropBorderColor, mBorderColor);
    mBorderWidth = a.getDimensionPixelSize(R.styleable.CropImageView_cropBorderWidth, mBorderWidth);
    mFocusWidth = a.getDimensionPixelSize(R.styleable.CropImageView_cropFocusWidth, mFocusWidth);
    mFocusHeight = a.getDimensionPixelSize(R.styleable.CropImageView_cropFocusHeight, mFocusHeight);
    mDefaultStyleIndex = a.getInteger(R.styleable.CropImageView_cropStyle, mDefaultStyleIndex);
    mStyle = styles[mDefaultStyleIndex];
    a.recycle();

    // 只允许图片为当前的缩放模式
    setScaleType(ScaleType.MATRIX);
  }
示例#25
0
 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();
   }
 }
示例#26
0
  public Pacman(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray typedArray =
        context.getTheme().obtainStyledAttributes(attrs, R.styleable.Pacman, 0, 0);
    try {
      backgroundColor = typedArray.getColor(R.styleable.Pacman_pacmanBackgroundColor, Color.BLACK);
      foregroundColor = typedArray.getColor(R.styleable.Pacman_pacmanForegroundColor, Color.WHITE);
      progress = typedArray.getInteger(R.styleable.Pacman_pacmanProgress, 0);
    } finally {
      typedArray.recycle();
    }

    backgroundPaint = new Paint();
    backgroundPaint.setAntiAlias(true);
    backgroundPaint.setStyle(Paint.Style.FILL);
    backgroundPaint.setColor(backgroundColor);

    foregroundPaint = new Paint();
    foregroundPaint.setAntiAlias(true);
    foregroundPaint.setStrokeWidth(10);
    foregroundPaint.setStyle(Paint.Style.FILL);
    foregroundPaint.setColor(foregroundColor);

    rect = new RectF(0, 0, 0, 0);
    setProgress(progress);
  }
 public WeightProgressBar(Context context, AttributeSet attributeSet, int i) {
   super(context, attributeSet, i);
   this.a = null;
   this.b = 0.0f;
   this.c = 0;
   this.d = 0;
   this.e = 0;
   this.f = 0;
   this.g = 150.0f;
   this.h = 0.0f;
   this.i = 0.0f;
   TypedArray obtainStyledAttributes =
       context.obtainStyledAttributes(attributeSet, t.WeightProgressBar);
   this.b = obtainStyledAttributes.getDimension(0, BitmapDescriptorFactory.HUE_ORANGE);
   this.c = obtainStyledAttributes.getColor(1, -1);
   this.e = obtainStyledAttributes.getColor(3, -10919831);
   this.d = obtainStyledAttributes.getColor(2, -12827569);
   this.f = obtainStyledAttributes.getColor(4, -8476672);
   this.g = (float) obtainStyledAttributes.getInteger(5, a.ap);
   this.h = obtainStyledAttributes.getFloat(6, 0.0f);
   this.i = obtainStyledAttributes.getFloat(6, 0.0f);
   obtainStyledAttributes.recycle();
   this.a = new Paint();
   this.a.setColor(this.e);
   this.a.setStyle(Style.STROKE);
   this.a.setStrokeWidth(this.b);
   this.a.setAntiAlias(true);
 }
示例#28
0
  public FlyInMenu(Context context, AttributeSet attrs) {
    super(context, attrs);
    myContext = context;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FlyInMenu);
    duration = a.getInteger(R.styleable.FlyInMenu_animationDuration, 200);
    RuntimeException e = null;
    menuId = a.getResourceId(R.styleable.FlyInMenu_menu, 0);
    if (menuId == 0) {
      e =
          new IllegalArgumentException(
              a.getPositionDescription()
                  + ": The handle attribute is required and must refer to a valid child.");
    }
    rightLayoutId = a.getResourceId(R.styleable.FlyInMenu_content, 0);
    if (rightLayoutId == 0) {
      e =
          new IllegalArgumentException(
              a.getPositionDescription()
                  + ": The content attribute is required and must refer to a valid child.");
    }
    a.recycle();

    if (e != null) {
      throw e;
    }

    myHandler = new Handler();

    mState = State.READY;
  }
示例#29
0
  /**
   * Parse the attributes passed to the view from the XML
   *
   * @param a the attributes to parse
   */
  private void parseAttributes(TypedArray a) {
    barWidth = (int) a.getDimension(R.styleable.ProgressWheel_pwBarWidth, barWidth);
    rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_pwRimWidth, rimWidth);
    spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_pwSpinSpeed, spinSpeed);
    barLength = (int) a.getDimension(R.styleable.ProgressWheel_pwBarLength, barLength);

    delayMillis = a.getInteger(R.styleable.ProgressWheel_pwDelayMillis, delayMillis);
    if (delayMillis < 0) {
      delayMillis = 10;
    }

    // Only set the text if it is explicitly defined
    if (a.hasValue(R.styleable.ProgressWheel_pwText)) {
      setText(a.getString(R.styleable.ProgressWheel_pwText));
    }

    barColor = a.getColor(R.styleable.ProgressWheel_pwBarColor, barColor);
    textColor = a.getColor(R.styleable.ProgressWheel_pwTextColor, textColor);
    rimColor = a.getColor(R.styleable.ProgressWheel_pwRimColor, rimColor);
    circleColor = a.getColor(R.styleable.ProgressWheel_pwCircleColor, circleColor);
    contourColor = a.getColor(R.styleable.ProgressWheel_pwContourColor, contourColor);

    textSize = (int) a.getDimension(R.styleable.ProgressWheel_pwTextSize, textSize);
    contourSize = a.getDimension(R.styleable.ProgressWheel_pwContourSize, contourSize);

    a.recycle();
  }
  private void initAttrs(AttributeSet attrs, int defStyle) {
    TypedArray a =
        getContext()
            .getTheme()
            .obtainStyledAttributes(attrs, R.styleable.ColorPreference, defStyle, defStyle);

    try {
      mItemLayoutId = a.getResourceId(R.styleable.ColorPreference_itemLayout, mItemLayoutId);
      mNumColumns = a.getInteger(R.styleable.ColorPreference_numColumns, mNumColumns);
      int choicesResId =
          a.getResourceId(R.styleable.ColorPreference_choices, R.array.default_color_choice_values);
      if (choicesResId > 0) {
        String[] choices = a.getResources().getStringArray(choicesResId);
        mColorChoices = new int[choices.length];
        for (int i = 0; i < choices.length; i++) {
          mColorChoices[i] = Color.parseColor(choices[i]);
        }
      }

    } finally {
      a.recycle();
    }

    setWidgetLayoutResource(mItemLayoutId);
  }