public ChartGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setWillNotDraw(false);

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

    mPrimary = a.getDrawable(R.styleable.ChartGridView_primaryDrawable);
    mSecondary = a.getDrawable(R.styleable.ChartGridView_secondaryDrawable);
    mBorder = a.getDrawable(R.styleable.ChartGridView_borderDrawable);

    final int taId = a.getResourceId(R.styleable.ChartGridView_android_textAppearance, -1);
    final TypedArray ta =
        context.obtainStyledAttributes(taId, com.android.internal.R.styleable.TextAppearance);
    mLabelSize =
        ta.getDimensionPixelSize(com.android.internal.R.styleable.TextAppearance_textSize, 0);
    ta.recycle();

    final ColorStateList labelColor =
        a.getColorStateList(R.styleable.ChartGridView_android_textColor);
    mLabelColor = labelColor.getDefaultColor();

    a.recycle();
  }
  /**
   * Tries to pull the Font Path from the Text Appearance.
   *
   * @param context Activity Context
   * @param attrs View Attributes
   * @param attributeId if -1 returns null.
   * @return returns null if attribute is not defined or if no TextAppearance is found.
   */
  static String pullFontPathFromTextAppearance(
      final Context context, AttributeSet attrs, int attributeId) {
    if (attributeId == -1 || attrs == null) {
      return null;
    }

    int textAppearanceId = -1;
    final TypedArray typedArrayAttr =
        context.obtainStyledAttributes(attrs, new int[] {android.R.attr.textAppearance});
    if (typedArrayAttr != null) {
      try {
        textAppearanceId = typedArrayAttr.getResourceId(0, -1);
      } catch (Exception ignored) {
        // Failed for some reason
        return null;
      } finally {
        typedArrayAttr.recycle();
      }
    }

    final TypedArray textAppearanceAttrs =
        context.obtainStyledAttributes(textAppearanceId, new int[] {attributeId});
    if (textAppearanceAttrs != null) {
      try {
        return textAppearanceAttrs.getString(0);
      } catch (Exception ignore) {
        // Failed for some reason.
        return null;
      } finally {
        textAppearanceAttrs.recycle();
      }
    }
    return null;
  }
  /**
   * Constructor that is called when inflating SwipeRefreshLayout from XML.
   *
   * @param context
   * @param attrs
   */
  public NoisySwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    final TypedArray va =
        context.obtainStyledAttributes(attrs, R.styleable.SuperSwipeRefreshLayout);
    mProgressBarOffsetTop =
        a.getDimensionPixelSize(R.styleable.SuperSwipeRefreshLayout_topOffset, 0);
    mProgressBarHeight =
        a.getDimensionPixelSize(
            R.styleable.SuperSwipeRefreshLayout_progressBarHeight,
            (int) (metrics.density * PROGRESS_BAR_HEIGHT));
    va.recycle();
  }
  public VDVideoSoundSeekButton(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
    mContext = context;
    // 支持自定义背景
    TypedArray typedArr =
        context.obtainStyledAttributes(attrs, new int[] {android.R.attr.background});

    mResID = R.drawable.play_ctrl_volume;
    if (typedArr != null) {
      mResID = typedArr.getResourceId(0, -1);
      if (mResID == -1) {
        mResID = R.drawable.play_ctrl_volume;
      }
      typedArr.recycle();
    }
    setBackgroundResource(mResID);

    // 指定相应的音量控制容器类
    typedArr = context.obtainStyledAttributes(attrs, R.styleable.VDVideoSoundSeekButton);
    mSilentResID = R.drawable.ad_silent_selcetor;
    if (typedArr != null) {
      for (int i = 0; i < typedArr.getIndexCount(); i++) {
        if (typedArr.getIndex(i) == R.styleable.VDVideoSoundSeekButton_soundSeekContainer) {
          mContainerID = typedArr.getResourceId(i, -1);
        } else if (typedArr.getIndex(i) == R.styleable.VDVideoSoundSeekButton_soundSeekSilent) {
          // 自定义背景的时候,换静音按钮
          mSilentResID = typedArr.getResourceId(i, -1);
        }
      }
      typedArr.recycle();
    }

    registerListeners();
  }
 public VDVideoResolutionListButton(Context context, AttributeSet attrs) {
   super(context, attrs);
   // 自定义背景
   TypedArray typedArr =
       context.obtainStyledAttributes(attrs, new int[] {android.R.attr.background});
   int background = R.drawable.quality_bg;
   if (typedArr != null) {
     int res = typedArr.getResourceId(0, -1);
     if (res != -1) {
       background = res;
     }
     typedArr.recycle();
   }
   setBackgroundResource(background);
   // 自定义属性部分
   typedArr = context.obtainStyledAttributes(attrs, R.styleable.VDVideoResolutionListButton);
   if (typedArr != null) {
     for (int i = 0; i < typedArr.getIndexCount(); i++) {
       if (typedArr.getIndex(i) == R.styleable.VDVideoResolutionListButton_resolutionTag) {
         mResolutionIndex = typedArr.getInt(i, -1);
       }
     }
     typedArr.recycle();
   }
   init(context);
 }
  public ListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    TypedArray a =
        context.obtainStyledAttributes(
            attrs, R.styleable.ListPreference, defStyleAttr, defStyleRes);

    mEntries =
        TypedArrayUtils.getTextArray(
            a, R.styleable.ListPreference_entries, R.styleable.ListPreference_android_entries);

    mEntryValues =
        TypedArrayUtils.getTextArray(
            a,
            R.styleable.ListPreference_entryValues,
            R.styleable.ListPreference_android_entryValues);

    a.recycle();

    /* Retrieve the Preference summary attribute since it's private
     * in the Preference class.
     */
    a = context.obtainStyledAttributes(attrs, R.styleable.Preference, defStyleAttr, defStyleRes);

    mSummary =
        TypedArrayUtils.getString(
            a, R.styleable.Preference_summary, R.styleable.Preference_android_summary);

    a.recycle();
  }
Exemple #7
0
  private void parseAttrs(Context context, AttributeSet attrs) {
    // Load from custom attributes
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.FButton);
    if (typedArray == null) return;
    for (int i = 0; i < typedArray.getIndexCount(); i++) {
      int attr = typedArray.getIndex(i);
      if (attr == R.styleable.FButton_shadowEnabled) {
        isShadowEnabled = typedArray.getBoolean(attr, true); // Default is true
      } else if (attr == R.styleable.FButton_buttonColor) {
        mButtonColor =
            typedArray.getColor(attr, getResources().getColor(R.color.fbutton_default_color));
      } else if (attr == R.styleable.FButton_shadowColor) {
        mShadowColor =
            typedArray.getColor(
                attr, getResources().getColor(R.color.fbutton_default_shadow_color));
        isShadowColorDefined = true;
      } else if (attr == R.styleable.FButton_shadowHeight) {
        mShadowHeight =
            typedArray.getDimensionPixelSize(attr, R.dimen.fbutton_default_shadow_height);
      } else if (attr == R.styleable.FButton_cornerRadius) {
        mCornerRadius =
            typedArray.getDimensionPixelSize(attr, R.dimen.fbutton_default_conner_radius);
      }
    }
    typedArray.recycle();

    // Get paddingLeft, paddingRight
    int[] attrsArray =
        new int[] {
          android.R.attr.paddingLeft, // 0
          android.R.attr.paddingRight, // 1
        };
    TypedArray ta = context.obtainStyledAttributes(attrs, attrsArray);
    if (ta == null) return;
    mPaddingLeft = ta.getDimensionPixelSize(0, 0);
    mPaddingRight = ta.getDimensionPixelSize(1, 0);
    ta.recycle();

    // Get paddingTop, paddingBottom
    int[] attrsArray2 =
        new int[] {
          android.R.attr.paddingTop, // 0
          android.R.attr.paddingBottom, // 1
        };
    TypedArray ta1 = context.obtainStyledAttributes(attrs, attrsArray2);
    if (ta1 == null) return;
    mPaddingTop = ta1.getDimensionPixelSize(0, 0);
    mPaddingBottom = ta1.getDimensionPixelSize(1, 0);
    ta1.recycle();
  }
  private void init(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircleTextView);

    mText = typedArray.getString(R.styleable.CircleTextView_Text);
    mTextColor = typedArray.getColor(R.styleable.CircleTextView_TextColor, Color.WHITE);
    mCircleColor = typedArray.getColor(R.styleable.CircleTextView_CircleColor, Color.BLACK);
    mTextSize = typedArray.getDimension(R.styleable.CircleTextView_TextSize, 30);
    boolean isRandomColor = typedArray.getBoolean(R.styleable.CircleTextView_RandomColor, true);

    typedArray.recycle();

    mCirclePaint = new Paint();
    mCirclePaint.setAntiAlias(true);
    if (isRandomColor) mCirclePaint.setColor(getRandomColor());
    else mCirclePaint.setColor(mCircleColor);

    mTextPaint = new Paint();
    mTextPaint.setAntiAlias(true);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
    Paint.FontMetrics fm = mTextPaint.getFontMetrics();
    offY = (fm.bottom - fm.top) / 2 - fm.bottom;

    if (mText == null || mText.length() == 0) mText = "无";
    if (mText.length() > 1) mText = mText.substring(0, 1);
  }
 private void initialize(Context context, AttributeSet attrs, int defStyleAttr) {
   TypedArray a =
       context.obtainStyledAttributes(
           attrs, R.styleable.CardView, defStyleAttr, R.style.CardView_Light);
   int backgroundColor = a.getColor(R.styleable.CardView_cardBackgroundColor, 0);
   float radius = a.getDimension(R.styleable.CardView_cardCornerRadius, 0);
   float elevation = a.getDimension(R.styleable.CardView_cardElevation, 0);
   float maxElevation = a.getDimension(R.styleable.CardView_cardMaxElevation, 0);
   mCompatPadding = a.getBoolean(R.styleable.CardView_cardUseCompatPadding, false);
   mPreventCornerOverlap = a.getBoolean(R.styleable.CardView_cardPreventCornerOverlap, true);
   int defaultPadding = a.getDimensionPixelSize(R.styleable.CardView_contentPadding, 0);
   mContentPadding.left =
       a.getDimensionPixelSize(R.styleable.CardView_contentPaddingLeft, defaultPadding);
   mContentPadding.top =
       a.getDimensionPixelSize(R.styleable.CardView_contentPaddingTop, defaultPadding);
   mContentPadding.right =
       a.getDimensionPixelSize(R.styleable.CardView_contentPaddingRight, defaultPadding);
   mContentPadding.bottom =
       a.getDimensionPixelSize(R.styleable.CardView_contentPaddingBottom, defaultPadding);
   if (elevation > maxElevation) {
     maxElevation = elevation;
   }
   a.recycle();
   IMPL.initialize(this, context, backgroundColor, radius, elevation, maxElevation);
 }
 public static Drawable getDrawableFromAttribute(Context ctx, @AttrRes int attr) {
   int[] attrs = new int[] {attr};
   TypedArray ta = ctx.obtainStyledAttributes(attrs);
   Drawable d = ta.getDrawable(0);
   ta.recycle();
   return d;
 }
 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();
 }
  @Override
  protected final ListView createRefreshableView(Context context, AttributeSet attrs) {
    ListView lv = new InternalListView(context, attrs);

    // Get Styles from attrs
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PullToRefresh);

    // Create Loading Views ready for use later
    FrameLayout frame = new FrameLayout(context);
    mHeaderLoadingView = new LoadingLayout(context, Mode.PULL_DOWN_TO_REFRESH, a);
    frame.addView(
        mHeaderLoadingView,
        FrameLayout.LayoutParams.MATCH_PARENT,
        FrameLayout.LayoutParams.WRAP_CONTENT);
    mHeaderLoadingView.setVisibility(View.GONE);
    lv.addHeaderView(frame, null, false);

    mLvFooterLoadingFrame = new FrameLayout(context);
    mFooterLoadingView = new LoadingLayout(context, Mode.PULL_UP_TO_REFRESH, a);
    mLvFooterLoadingFrame.addView(
        mFooterLoadingView,
        FrameLayout.LayoutParams.MATCH_PARENT,
        FrameLayout.LayoutParams.WRAP_CONTENT);
    mFooterLoadingView.setVisibility(View.GONE);

    a.recycle();

    // Set it to this so it can be used in ListActivity/ListFragment
    lv.setId(android.R.id.list);
    return lv;
  }
 public ButtonBarLayout(Context paramContext, AttributeSet paramAttributeSet)
 {
   super(paramContext, paramAttributeSet);
   paramContext = paramContext.obtainStyledAttributes(paramAttributeSet, sb.S);
   a = paramContext.getBoolean(sb.T, false);
   paramContext.recycle();
 }
 private void setCustomAttributes(AttributeSet attrs) {
   TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.roundedimageview);
   mBorderThickness = a.getDimensionPixelSize(R.styleable.roundedimageview_border_thickness, 0);
   mBorderOutsideColor =
       a.getColor(R.styleable.roundedimageview_border_outside_color, defaultColor);
   mBorderInsideColor = a.getColor(R.styleable.roundedimageview_border_inside_color, defaultColor);
 }
  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);
  }
  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);
  }
  public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    strokeWidth = 5f;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.com_displayer_CircleImageView);
    strokeWidth = a.getFloat(R.styleable.com_displayer_CircleImageView_stroke_width, 5f);
    String tempColor = a.getString(R.styleable.com_displayer_CircleImageView_stroke_color);
    Log.d("CircularImageView", "ColorTag: " + tempColor);

    if (tempColor != null && !tempColor.equalsIgnoreCase("#0")) {
      String black = tempColor.replaceAll("0", "");
      String white = tempColor.replaceAll("f", "");
      white = white.replaceAll("F", "");

      if (black.equalsIgnoreCase("#")) {
        tempColor = "#000000";
      }

      if (white.equalsIgnoreCase("#")) {
        tempColor = "#ffffff";
      }

      strokeColor = Color.parseColor(tempColor);
    } else {
      strokeColor = Color.TRANSPARENT;
    }
    a.recycle();
  }
 public ActionBarContainer(Context context, AttributeSet attrs) {
   boolean z = true;
   super(context, attrs);
   setBackgroundDrawable(
       VERSION.SDK_INT >= 21
           ? new ActionBarBackgroundDrawableV21(this)
           : new ActionBarBackgroundDrawable(this));
   TypedArray a = context.obtainStyledAttributes(attrs, C0170R.styleable.ActionBar);
   this.mBackground = a.getDrawable(C0170R.styleable.ActionBar_background);
   this.mStackedBackground = a.getDrawable(C0170R.styleable.ActionBar_backgroundStacked);
   this.mHeight = a.getDimensionPixelSize(C0170R.styleable.ActionBar_height, -1);
   if (getId() == C0170R.id.split_action_bar) {
     this.mIsSplit = true;
     this.mSplitBackground = a.getDrawable(C0170R.styleable.ActionBar_backgroundSplit);
   }
   a.recycle();
   if (this.mIsSplit) {
     if (this.mSplitBackground != null) {
       z = false;
     }
   } else if (!(this.mBackground == null && this.mStackedBackground == null)) {
     z = false;
   }
   setWillNotDraw(z);
 }
  public ForegroundLinearLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

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

    final Drawable d = a.getDrawable(R.styleable.ForegroundLayout_foreground);
    foregroundPadding =
        a.getBoolean(R.styleable.ForegroundLayout_foregroundLayoutInsidePadding, false);

    backgroundAsForeground =
        a.getBoolean(R.styleable.ForegroundLayout_backgroundAsForeground, false);

    // Apply foreground padding for ninepatches automatically
    if (!foregroundPadding && getBackground() instanceof NinePatchDrawable) {
      final NinePatchDrawable npd = (NinePatchDrawable) getBackground();
      if (npd != null && npd.getPadding(rectPadding)) {
        foregroundPadding = true;
      }
    }

    final Drawable b = getBackground();
    if (backgroundAsForeground && b != null) {
      setForeground(b);
    } else if (d != null) {
      setForeground(d);
    }

    a.recycle();
  }
  /**
   * Last but not least, try to pull the Font Path from the Theme, which is defined.
   *
   * @param context Activity Context
   * @param styleAttrId Theme style id
   * @param subStyleAttrId the sub style from the theme to look up after the first style
   * @param attributeId if -1 returns null.
   * @return null if no theme or attribute defined.
   */
  static String pullFontPathFromTheme(
      Context context, int styleAttrId, int subStyleAttrId, int attributeId) {
    if (styleAttrId == -1 || attributeId == -1) return null;

    final Resources.Theme theme = context.getTheme();
    final TypedValue value = new TypedValue();

    theme.resolveAttribute(styleAttrId, value, true);
    int subStyleResId = -1;
    final TypedArray parentTypedArray =
        theme.obtainStyledAttributes(value.resourceId, new int[] {subStyleAttrId});
    try {
      subStyleResId = parentTypedArray.getResourceId(0, -1);
    } catch (Exception ignore) {
      // Failed for some reason.
      return null;
    } finally {
      parentTypedArray.recycle();
    }

    if (subStyleResId == -1) return null;
    final TypedArray subTypedArray =
        context.obtainStyledAttributes(subStyleResId, new int[] {attributeId});
    if (subTypedArray != null) {
      try {
        return subTypedArray.getString(0);
      } catch (Exception ignore) {
        // Failed for some reason.
        return null;
      } finally {
        subTypedArray.recycle();
      }
    }
    return null;
  }
 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();
 }
Exemple #22
0
  public IPSelector(Context context, AttributeSet attrs) {
    super(context, attrs);
    populateSelf(context);

    TypedArray sa = context.obtainStyledAttributes(attrs, R.styleable.IPSelector);
    setValue(sa.getInt(R.styleable.IPSelector_value, 1));
  }
  public SwipeBackLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    mDragHelper = ViewDragHelper.create(this, new ViewDragCallback());

    TypedArray a =
        context.obtainStyledAttributes(
            attrs, R.styleable.SwipeBackLayout, defStyle, R.style.SwipeBackLayout);

    int edgeSize = a.getDimensionPixelSize(R.styleable.SwipeBackLayout_edge_size, -1);
    if (edgeSize > 0) setEdgeSize(edgeSize);
    int mode = EDGE_FLAGS[a.getInt(R.styleable.SwipeBackLayout_edge_flag, 0)];
    setEdgeTrackingEnabled(mode);

    int shadowLeft =
        a.getResourceId(R.styleable.SwipeBackLayout_shadow_left, R.drawable.shadow_left);
    int shadowRight =
        a.getResourceId(R.styleable.SwipeBackLayout_shadow_right, R.drawable.shadow_right);
    int shadowBottom =
        a.getResourceId(R.styleable.SwipeBackLayout_shadow_bottom, R.drawable.shadow_bottom);
    setShadow(shadowLeft, EDGE_LEFT);
    setShadow(shadowRight, EDGE_RIGHT);
    setShadow(shadowBottom, EDGE_BOTTOM);
    a.recycle();
    final float density = getResources().getDisplayMetrics().density;
    final float minVel = MIN_FLING_VELOCITY * density;
    mDragHelper.setMinVelocity(minVel);
    mDragHelper.setMaxVelocity(minVel * 2f);
  }
  public void init(
      @NonNull View view, @Nullable AttributeSet attrs, @NonNull TextPaint baseTextPaint) {
    final Context context = view.getContext();
    final int defColor = baseTextPaint.getColor();
    final int defPadding =
        context.getResources().getDimensionPixelSize(R.dimen.drag_direction_text_default_padding);
    final float minTextSize =
        context.getResources().getDimensionPixelSize(R.dimen.drag_direction_text_min_size);

    if (attrs == null) {
      for (DragDirection direction : DragDirection.values()) {
        final Text text = new Text(direction, view, minTextSize);
        text.init(baseTextPaint, null, DEF_SCALE, defColor, DEF_ALPHA, defPadding);
        texts.put(direction, text);
      }
      return;
    }
    final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.DirectionText);
    final float scale = array.getFloat(R.styleable.DirectionText_directionTextScale, DEF_SCALE);
    final float alpha = array.getFloat(R.styleable.DirectionText_directionTextAlpha, DEF_ALPHA);
    final int color = array.getColor(R.styleable.DirectionText_directionTextColor, defColor);
    final int padding =
        array.getDimensionPixelSize(R.styleable.DirectionText_directionTextPadding, defPadding);
    for (DragDirection direction : DragDirection.values()) {
      final Text text = new Text(direction, view, minTextSize);
      text.init(baseTextPaint, array, scale, color, alpha, padding);
      texts.put(direction, text);
    }
    array.recycle();
  }
 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);
 }
  public IconListPreference(final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      setLayoutResource(R.layout.preference_icon);
    }
    mContext = context;

    final TypedArray a =
        context.obtainStyledAttributes(attrs, R.styleable.IconListPreference, defStyle, 0);
    setIcon(a.getDrawable(R.styleable.IconListPreference_prefIcon));
    setUpdateIcon(a.getBoolean(R.styleable.IconListPreference_updateIcon, true));
    setIconSide(a.getInt(R.styleable.IconListPreference_iconSide, ICON_SIDE_LEFT));

    int entryIconsResId = a.getResourceId(R.styleable.IconListPreference_entryIcons, -1);
    if (entryIconsResId != -1) {
      setEntryIcons(entryIconsResId);
    }

    a.recycle();

    //        setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
    //            public boolean onPreferenceChange(Preference preference, Object newValue) {
    //                int index = findIndexOfValue(newValue.toString());
    //                if (index != -1) {
    //                    setValueIndex(index);
    //                }
    //                return true;
    //            }
    //        });
  }
  public static BeveledTileAttributeSet extractAttributes(Context context, AttributeSet attrs) {
    BeveledTileAttributeSet beveledTileAttributeSet = null;

    TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.BeveledTileView);

    try {
      int[] colorList = new int[BeveledTileDrawable.REQUIRED_COLOR_COUNT];

      colorList[INNER_RECT_COLOR_INDICE] =
          attributesArray.getColor(R.styleable.BeveledTileView_innerRectColor, -1);
      colorList[LEFT_BEVEL_COLOR_INDICE] =
          attributesArray.getColor(R.styleable.BeveledTileView_leftBevelColor, -1);
      colorList[TOP_BEVEL_COLOR_INDICE] =
          attributesArray.getColor(R.styleable.BeveledTileView_topBevelColor, -1);
      colorList[RIGHT_BEVEL_COLOR_INDICE] =
          attributesArray.getColor(R.styleable.BeveledTileView_rightBevelColor, -1);
      colorList[BOTTOM_BEVEL_COLOR_INDICE] =
          attributesArray.getColor(R.styleable.BeveledTileView_bottomBevelColor, -1);
      float fillPercent = attributesArray.getFloat(R.styleable.BeveledTileView_fillPercentage, -1);

      beveledTileAttributeSet = new BeveledTileAttributeSet(colorList, fillPercent);
    } finally {
      attributesArray.recycle();
      return beveledTileAttributeSet;
    }
  }
 public DividerItemDecoration(Context context, int orientation, boolean hasFooter) {
   this.hasFooter = hasFooter;
   final TypedArray a = context.obtainStyledAttributes(ATTRS);
   mDivider = a.getDrawable(0);
   a.recycle();
   setOrientation(orientation);
 }
 public FloatingMenuLayout(Context context, AttributeSet attrs, int defStyleAttr) {
   super(context, attrs, defStyleAttr);
   TypedArray attr =
       context.obtainStyledAttributes(attrs, R.styleable.CustomFloatingActionMenu, 0, 0);
   mLabelStyle = attr.getResourceId(R.styleable.CustomFloatingActionMenu_menu_label_style, 0);
   attr.recycle();
 }
 public MediaAdapter(Context ctx, List<Uri> tappedUri) {
   mContext = ctx;
   mTappedUri = tappedUri;
   TypedArray a = mContext.obtainStyledAttributes(R.styleable.gallery);
   itemBackground = a.getResourceId(R.styleable.gallery_android_galleryItemBackground, 0);
   a.recycle();
 }