Example usage for android.content.res TypedArray getColor

List of usage examples for android.content.res TypedArray getColor

Introduction

In this page you can find the example usage for android.content.res TypedArray getColor.

Prototype

@ColorInt
public int getColor(@StyleableRes int index, @ColorInt int defValue) 

Source Link

Document

Retrieve the color value for the attribute at index.

Usage

From source file:com.android.hcframe.DraggableGridViewPager.java

public DraggableGridViewPager(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (attrs != null) {
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.dragGridView, defStyle, 0);
        mShowDivider = typedArray.getBoolean(R.styleable.dragGridView_dividerShowed, false);
        mDividerColor = typedArray.getColor(R.styleable.dragGridView_dividerColor, 0);
        mDividerPaddingTop = typedArray.getDimensionPixelSize(R.styleable.dragGridView_dividerPaddingTop, 0);
        mDividerPaddingBottom = typedArray.getDimensionPixelSize(R.styleable.dragGridView_dividerPaddingBottom,
                0);//from  w ww . j  a va2s  .  c  o  m
        mDividerWidth = typedArray.getDimensionPixelSize(R.styleable.dragGridView_dividerWidth, 1);
        typedArray.recycle();
        HcLog.D(TAG + " divider color = " + mDividerColor);
    }
    initDraggableGridViewPager();
}

From source file:com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (getShowsDialog()) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }//  w ww .  ja va2s.c  om

    View view = inflater.inflate(R.layout.radial_time_picker_dialog, null);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);

    Resources res = getResources();
    TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId,
            R.styleable.BetterPickersRadialTimePickerDialog);

    mHourPickerDescription = res.getString(R.string.hour_picker_description);
    mSelectHours = res.getString(R.string.select_hours);
    mMinutePickerDescription = res.getString(R.string.minute_picker_description);
    mSelectMinutes = res.getString(R.string.select_minutes);
    mSelectedColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpAccentColor,
            R.color.bpBlue);
    mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainTextColor,
            R.color.numbers_text_color);

    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);
    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), mHapticFeedbackController, mInitialHourOfDay, mInitialMinute,
            mIs24HourMode);

    int currentItemShowing = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    setCurrentItemShowing(currentItemShowing, false, true, true);
    mTimePicker.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mDoneButton = (TextView) view.findViewById(R.id.done_button);
    if (mDoneText != null) {
        mDoneButton.setText(mDoneText);
    }
    mDoneButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            if (mCallback != null) {
                mCallback.onTimeSet(RadialTimePickerDialog.this, mTimePicker.getHours(),
                        mTimePicker.getMinutes());
            }
            dismiss();
        }
    });
    mDoneButton.setOnKeyListener(keyboardListener);

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);

        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM);
        mAmPmHitspace.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                updateAmPmDisplay(amOrPm);
                mTimePicker.setAmOrPm(amOrPm);
            }
        });
    }

    mAllowAutoAdvance = true;
    setHour(mInitialHourOfDay, true);
    setMinute(mInitialMinute);

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<Integer>();
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mTimePicker.setTheme(themeColors);

    // Prepare some colors to use.
    int mainColor1 = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainColor1,
            R.color.bpWhite);
    int mainColor2 = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainColor2,
            R.color.circle_background);
    int lineColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpLineColor,
            R.color.bpLine_background);
    int mainTextColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainTextColor,
            R.color.numbers_text_color);
    ColorStateList doneTextColor = themeColors
            .getColorStateList(R.styleable.BetterPickersRadialTimePickerDialog_bpDoneTextColor);
    int doneBackground = themeColors.getResourceId(
            R.styleable.BetterPickersRadialTimePickerDialog_bpDoneBackgroundColor,
            R.drawable.done_background_color);

    // Set the colors for each view based on the theme.
    view.findViewById(R.id.time_display_background).setBackgroundColor(mainColor1);
    view.findViewById(R.id.time_display).setBackgroundColor(mainColor1);
    ((TextView) view.findViewById(R.id.separator)).setTextColor(mainTextColor);
    ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mainTextColor);
    view.findViewById(R.id.line).setBackgroundColor(lineColor);
    mDoneButton.setTextColor(doneTextColor);
    mTimePicker.setBackgroundColor(mainColor2);
    mDoneButton.setBackgroundResource(doneBackground);
    return view;
}

From source file:com.android.settings.widget.DotsPageIndicator.java

public DotsPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    final int scaledDensity = (int) context.getResources().getDisplayMetrics().scaledDensity;

    // Load attributes
    final TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.DotsPageIndicator,
            defStyle, 0);/*from   w ww .jav a  2s . c om*/
    dotDiameter = typedArray.getDimensionPixelSize(R.styleable.DotsPageIndicator_dotDiameter,
            DEFAULT_DOT_SIZE * scaledDensity);
    dotRadius = dotDiameter / 2;
    halfDotRadius = dotRadius / 2;
    gap = typedArray.getDimensionPixelSize(R.styleable.DotsPageIndicator_dotGap, DEFAULT_GAP * scaledDensity);
    animDuration = (long) typedArray.getInteger(R.styleable.DotsPageIndicator_animationDuration,
            DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = typedArray.getColor(R.styleable.DotsPageIndicator_pageIndicatorColor,
            DEFAULT_UNSELECTED_COLOUR);
    selectedColour = typedArray.getColor(R.styleable.DotsPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);
    typedArray.recycle();
    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        interpolator = loadInterpolator(context, android.R.interpolator.fast_out_slow_in);
    } else {
        interpolator = loadInterpolator(context, android.R.anim.accelerate_decelerate_interpolator);
    }

    // create paths & rect now  reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
        @Override
        public void onViewAttachedToWindow(View v) {
            attachedState = true;
        }

        @Override
        public void onViewDetachedFromWindow(View v) {
            attachedState = false;
        }
    });
}

From source file:com.albedinsky.android.ui.widget.ViewPagerWidget.java

/**
 * Called from one of constructors of this view to perform its initialization.
 * <p>//w  ww . j  ava 2 s  .c  o  m
 * Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for
 * this view specific data from it that can be used to configure this new view instance. The
 * specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data
 * from the current theme provided by the specified <var>context</var>.
 */
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    this.ensureDecorator();
    mDecorator.processAttributes(context, attrs, defStyleAttr, defStyleRes);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_ViewPager, defStyleAttr,
            defStyleRes);
    if (typedArray != null) {
        final int n = typedArray.getIndexCount();
        for (int i = 0; i < n; i++) {
            final int index = typedArray.getIndex(i);
            if (index == R.styleable.Ui_ViewPager_android_background) {
                int resID = typedArray.getResourceId(index, -1);
                if (resID != -1) {
                    setBackgroundResource(resID);
                } else {
                    setBackgroundColor(typedArray.getColor(0, Color.TRANSPARENT));
                }
            } else if (index == R.styleable.Ui_ViewPager_uiPageMargin) {
                setPageMargin(typedArray.getDimensionPixelSize(index, 0));
            } else if (index == R.styleable.Ui_ViewPager_uiPageMarginDrawable) {
                setPageMarginDrawable(typedArray.getDrawable(index));
            } else if (index == R.styleable.Ui_ViewPager_uiPageSwipingEnabled) {
                mDecorator.updatePrivateFlags(PFLAG_PAGE_SWIPING_ENABLED, typedArray.getBoolean(index, true));
            } else if (index == R.styleable.Ui_ViewPager_uiPageFlingSwipingEnabled) {
                mDecorator.updatePrivateFlags(PFLAG_PAGE_FLING_SWIPING_ENABLED,
                        typedArray.getBoolean(index, false));
            } else if (index == R.styleable.Ui_ViewPager_uiPageFlingSwipingSensitivity) {
                this.mPageFlingSwipingSensitivity = Math.max(0,
                        typedArray.getFloat(index, mPageFlingSwipingSensitivity));
            } else if (index == R.styleable.Ui_ViewPager_uiCurrentPage) {
                this.mCurrentPage = typedArray.getInteger(index, 0);
            } else if (index == R.styleable.Ui_ViewPager_uiOffScreenPageLimit) {
                setOffscreenPageLimit(typedArray.getInt(index, getOffscreenPageLimit()));
            } else if (index == R.styleable.Ui_ViewPager_uiPageScrollDuration) {
                this.mPageScrollDuration = typedArray.getInteger(index, mPageScrollDuration);
            } else if (index == R.styleable.Ui_ViewPager_uiPageScrollRelativeDurationEnabled) {
                mDecorator.updatePrivateFlags(PFLAG_PAGE_SCROLL_RELATIVE_DURATION_ENABLED,
                        typedArray.getBoolean(index, false));
            } else if (index == R.styleable.Ui_ViewPager_uiPullEnabled) {
                setPullEnabled(typedArray.getBoolean(index, false));
            }
        }
        typedArray.recycle();
    }
    // Override default scroller so we can use custom durations for scroll if requested.
    setScroller(new WidgetScroller(context, SCROLLER_INTERPOLATOR));
}

From source file:com.android.demos.module.animation.materialloadingprogressbar.CircleProgressBar.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0);
    //        <attr name="mlpb_inner_radius" format="dimension"/>
    //        <attr name="mlpb_background_color" format="color"/>
    //        <attr name="mlpb_progress_color" format="color"/>
    //        <attr name="mlpb_progress_stoke_width" format="dimension"/>
    //        <attr name="mlpb_arrow_width" format="dimension"/>
    //        <attr name="mlpb_arrow_height" format="dimension"/>
    ///*from w  w w. ja  va  2 s  .  c  o  m*/
    //        <attr name="mlpb_progress" format="integer"/>
    //        <attr name="mlpb_max" format="integer"/>
    //
    //
    //        <attr name="mlpb_progress_text_size" format="dimension"/>
    //        <attr name="mlpb_progress_text_color" format="color"/>
    //
    //        <attr name="mlpb_progress_text_offset" format="dimension"/>
    //
    //        <attr name="mlpb_progress_text_visibility" format="enum">
    //        <enum name="visible" value="0"/>
    //        <enum name="invisible" value="1"/>
    //        </attr>
    final float density = getContext().getResources().getDisplayMetrics().density;

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

    mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT);//ToDO 

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

    mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1);
    mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1);
    mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK);

    mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false);
    mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true);

    mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0);
    mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100);
    int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_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);
}

From source file:be.blinkt.openvpn.views.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);/*from w  w  w . ja  v  a2s . com*/
    setWillNotDraw(false);
    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    //Default color will be 'textColorPrimary'
    int colorPrimary = context.getResources().getColor(android.R.color.primary_text_dark);
    setTextColor(colorPrimary);
    underlineColor = colorPrimary;
    dividerColor = colorPrimary;
    indicatorColor = colorPrimary;

    DisplayMetrics dm = getResources().getDisplayMetrics();
    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)
    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    tabTextSize = a.getDimensionPixelSize(TEXT_SIZE_INDEX, tabTextSize);
    ColorStateList colorStateList = a.getColorStateList(TEXT_COLOR_INDEX);
    if (colorStateList != null) {
        tabTextColor = colorStateList;
    }
    paddingLeft = a.getDimensionPixelSize(PADDING_LEFT_INDEX, paddingLeft);
    paddingRight = a.getDimensionPixelSize(PADDING_RIGHT_INDEX, paddingRight);
    a.recycle();

    //In case we have the padding they must be equal so we take the biggest
    if (paddingRight < paddingLeft) {
        paddingRight = paddingLeft;
    }

    if (paddingLeft < paddingRight) {
        paddingLeft = paddingRight;
    }

    // get custom attrs
    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    dividerWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
    isPaddingMiddle = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsPaddingMiddle, isPaddingMiddle);
    tabTypefaceStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextStyle, Typeface.BOLD);
    tabTypefaceSelectedStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, Typeface.BOLD);
    tabTextAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextAlpha, HALF_TRANSP);
    tabTextSelectedAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextSelectedAlpha, OPAQUE);
    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.aspsine.swipetoloadlayout.widget.CircleProgressBar.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0);
    //        <attr name="mlpb_inner_radius" format="dimension"/>
    //        <attr name="mlpb_background_color" format="color"/>
    //        <attr name="mlpb_progress_color" format="color"/>
    //        <attr name="mlpb_progress_stoke_width" format="dimension"/>
    //        <attr name="mlpb_arrow_width" format="dimension"/>
    //        <attr name="mlpb_arrow_height" format="dimension"/>
    ///*from  w  w w .j a  v a 2 s  .c o  m*/
    //        <attr name="mlpb_progress" format="integer"/>
    //        <attr name="mlpb_max" format="integer"/>
    //
    //
    //        <attr name="mlpb_progress_text_size" format="dimension"/>
    //        <attr name="mlpb_progress_text_color" format="color"/>
    //
    //        <attr name="mlpb_progress_text_offset" format="dimension"/>
    //
    //        <attr name="mlpb_progress_text_visibility" format="enum">
    //        <enum name="visible" value="0"/>
    //        <enum name="invisible" value="1"/>
    //        </attr>
    final float density = getContext().getResources().getDisplayMetrics().density;

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

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

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

    mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1);
    mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1);
    mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK);

    mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false);
    mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true);

    mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0);
    mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100);
    int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_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);
}

From source file:com.devbrackets.android.exomediademo.test.CircleProgressBar.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0);
    //        <attr name="mlpb_inner_radius" format="dimension"/>
    //        <attr name="mlpb_background_color" format="color"/>
    //        <attr name="mlpb_progress_color" format="color"/>
    //        <attr name="mlpb_progress_stoke_width" format="dimension"/>
    //        <attr name="mlpb_arrow_width" format="dimension"/>
    //        <attr name="mlpb_arrow_height" format="dimension"/>
    ////from   ww  w  .j  av  a 2s  .  c  o m
    //        <attr name="mlpb_progress" format="integer"/>
    //        <attr name="mlpb_max" format="integer"/>
    //
    //
    //        <attr name="mlpb_progress_text_size" format="dimension"/>
    //        <attr name="mlpb_progress_text_color" format="color"/>
    //
    //        <attr name="mlpb_progress_text_offset" format="dimension"/>
    //
    //        <attr name="mlpb_progress_text_visibility" format="enum">
    //        <enum name="visible" value="0"/>
    //        <enum name="invisible" value="1"/>
    //        </attr>
    final float density = getContext().getResources().getDisplayMetrics().density;

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

    mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT);
    mColors = new int[] { Color.rgb(192, 255, 140), Color.rgb(255, 247, 140), Color.rgb(255, 208, 140),
            Color.rgb(140, 234, 255), Color.WHITE };

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

    mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1);
    mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1);
    mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK);

    mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false);
    mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, false);

    mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0);
    mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100);
    int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_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);
}

From source file:com.demo.wpq.mydemo.customview.progressbar.QLKCircleProgressBar.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.QLKCircleProgressBar, defStyleAttr,
            0);/*w  w w  .ja  va2 s.c  om*/
    //        <attr name="mlpb_inner_radius" format="dimension"/>
    //        <attr name="mlpb_background_color" format="color"/>
    //        <attr name="mlpb_progress_color" format="color"/>
    //        <attr name="mlpb_progress_stoke_width" format="dimension"/>
    //        <attr name="mlpb_arrow_width" format="dimension"/>
    //        <attr name="mlpb_arrow_height" format="dimension"/>
    //
    //        <attr name="mlpb_progress" format="integer"/>
    //        <attr name="mlpb_max" format="integer"/>
    //
    //
    //        <attr name="mlpb_progress_text_size" format="dimension"/>
    //        <attr name="mlpb_progress_text_color" format="color"/>
    //
    //        <attr name="mlpb_progress_text_offset" format="dimension"/>
    //
    //        <attr name="mlpb_progress_text_visibility" format="enum">
    //        <enum name="visible" value="0"/>
    //        <enum name="invisible" value="1"/>
    //        </attr>
    final float density = getContext().getResources().getDisplayMetrics().density;

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

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

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

    mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.QLKCircleProgressBar_mlpb_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth = a.getDimensionPixelOffset(R.styleable.QLKCircleProgressBar_mlpb_arrow_width, -1);
    mArrowHeight = a.getDimensionPixelOffset(R.styleable.QLKCircleProgressBar_mlpb_arrow_height, -1);
    mTextSize = a.getDimensionPixelOffset(R.styleable.QLKCircleProgressBar_mlpb_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor = a.getColor(R.styleable.QLKCircleProgressBar_mlpb_progress_text_color, Color.BLACK);

    mShowArrow = a.getBoolean(R.styleable.QLKCircleProgressBar_mlpb_show_arrow, false);
    mCircleBackgroundEnabled = a.getBoolean(R.styleable.QLKCircleProgressBar_mlpb_enable_circle_background,
            true);

    mProgress = a.getInt(R.styleable.QLKCircleProgressBar_mlpb_progress, 0);
    mMax = a.getInt(R.styleable.QLKCircleProgressBar_mlpb_max, 100);
    int textVisible = a.getInt(R.styleable.QLKCircleProgressBar_mlpb_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 QLKCircleProgressDrawable(getContext(), this);
    super.setImageDrawable(mProgressDrawable);
}

From source file:ca.mymenuapp.ui.widgets.SlidingUpPanelLayout.java

public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (attrs != null) {
        TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS);

        if (defAttrs != null) {
            int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY);
            if (gravity != Gravity.TOP && gravity != Gravity.BOTTOM) {
                throw new IllegalArgumentException("layout_gravity must be set to either top or bottom");
            }/*from ww w. j  a va2s .  c o  m*/
            mIsSlidingUp = gravity == Gravity.BOTTOM;
        }

        defAttrs.recycle();

        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingUpPanelLayout);

        if (ta != null) {
            mPanelHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_collapsedHeight, -1);
            mShadowHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_shadowHeight, -1);

            mMinFlingVelocity = ta.getInt(R.styleable.SlidingUpPanelLayout_flingVelocity,
                    DEFAULT_MIN_FLING_VELOCITY);
            mCoveredFadeColor = ta.getColor(R.styleable.SlidingUpPanelLayout_fadeColor, DEFAULT_FADE_COLOR);

            mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_dragView, -1);
        }

        ta.recycle();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    if (mPanelHeight == -1) {
        mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f);
    }
    if (mShadowHeight == -1) {
        mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);
    }

    setWillNotDraw(false);

    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mDragHelper.setMinVelocity(mMinFlingVelocity * density);

    mCanSlide = true;
    mIsSlidingEnabled = true;

    ViewConfiguration vc = ViewConfiguration.get(context);
    mScrollTouchSlop = vc.getScaledTouchSlop();
}