Example usage for android.content.res Resources getColor

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

Introduction

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

Prototype

@ColorInt
@Deprecated
public int getColor(@ColorRes int id) throws NotFoundException 

Source Link

Document

Returns a color integer associated with a particular resource ID.

Usage

From source file:com.common.view.recyclerviewpage.indicator.RecyclerCirclePageIndicator.java

public RecyclerCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;// ww  w . j  a  va  2 s .  c o  m

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

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

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

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

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:cn.lanqiushe.view.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*ww w . j  a va 2s.c  om*/

    // Load defaults from resources
    final Resources res = getResources();
    // 
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    // 
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    // 
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    // 
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    // 
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    // 
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    //
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    //
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

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

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

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

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.blue.sky.control.CirclePageIndicator.java

@SuppressWarnings("deprecation")
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from www.  j a  v a2 s.c  o  m*/

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);
    final float defaultPadding = res.getDimension(R.dimen.default_circle_indicator_padding);
    defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);

    // Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, Styleable.CirclePageIndicator, defStyle, 0);

    indicateCircleType = a.getInt(Styleable.CirclePageIndicator_unIndicateCircleType, 0);
    mCentered = a.getBoolean(Styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(Styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(Styleable.CirclePageIndicator_pageColor, defaultPageColor));
    if (indicateCircleType == 0) {
        mPaintStroke.setStyle(Style.STROKE);
    } else if (indicateCircleType == 1) {
        mPaintStroke.setStyle(Style.FILL);
    }
    mPaintStroke.setColor(a.getColor(Styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(a.getDimension(Styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(Styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(Styleable.CirclePageIndicator_radius, defaultRadius);
    padding = a.getDimension(Styleable.CirclePageIndicator_padding, defaultPadding);
    mSnap = a.getBoolean(Styleable.CirclePageIndicator_snap, defaultSnap);
    Drawable background = a.getDrawable(Styleable.CirclePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.saarang.samples.apps.iosched.ui.MyScheduleActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(com.saarang.samples.apps.iosched.R.layout.activity_my_schedule);

    /* [ANALYTICS:SCREEN]
     * TRIGGER:   View the My Schedule screen.
     * LABEL:     'My Schedule'/*from  w  w  w  .  j a v a  2  s .c  om*/
     * [/ANALYTICS]
     */
    AnalyticsManager.sendScreenView(SCREEN_LABEL);

    mViewPager = (ViewPager) findViewById(com.saarang.samples.apps.iosched.R.id.view_pager);
    mScrollViewWide = (ScrollView) findViewById(com.saarang.samples.apps.iosched.R.id.main_content_wide);
    mWideMode = findViewById(com.saarang.samples.apps.iosched.R.id.my_schedule_first_day) != null;

    int i;
    for (i = 0; i < Config.CONFERENCE_DAYS.length; i++) {
        mScheduleAdapters[i] = new MyScheduleAdapter(this, getLUtils());
    }

    mViewPagerAdapter = new OurViewPagerAdapter(getFragmentManager());
    mViewPager.setAdapter(mViewPagerAdapter);

    if (mWideMode) {
        mMyScheduleViewWide[0] = (MyScheduleView) findViewById(
                com.saarang.samples.apps.iosched.R.id.my_schedule_first_day);
        mMyScheduleViewWide[0].setAdapter(mScheduleAdapters[0]);
        mMyScheduleViewWide[1] = (MyScheduleView) findViewById(
                com.saarang.samples.apps.iosched.R.id.my_schedule_second_day);
        mMyScheduleViewWide[1].setAdapter(mScheduleAdapters[1]);

        TextView firstDayHeaderView = (TextView) findViewById(
                com.saarang.samples.apps.iosched.R.id.day_label_first_day);
        TextView secondDayHeaderView = (TextView) findViewById(
                com.saarang.samples.apps.iosched.R.id.day_label_second_day);
        if (firstDayHeaderView != null) {
            firstDayHeaderView.setText(getDayName(0));
        }
        if (secondDayHeaderView != null) {
            secondDayHeaderView.setText(getDayName(1));
        }
    } else {
        // it's PagerAdapter set.
        mSlidingTabLayout = (SlidingTabLayout) findViewById(com.saarang.samples.apps.iosched.R.id.sliding_tabs);
        mSlidingTabLayout.setCustomTabView(com.saarang.samples.apps.iosched.R.layout.tab_indicator,
                android.R.id.text1);

        setSlidingTabLayoutContentDescriptions();

        Resources res = getResources();
        mSlidingTabLayout.setSelectedIndicatorColors(
                res.getColor(com.saarang.samples.apps.iosched.R.color.tab_selected_strip));
        mSlidingTabLayout.setDistributeEvenly(true);
        mSlidingTabLayout.setViewPager(mViewPager);
    }

    mButterBar = findViewById(com.saarang.samples.apps.iosched.R.id.butter_bar);
    removeLoginFailed();

    if (mSlidingTabLayout != null) {
        mSlidingTabLayout.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    mSlidingTabLayout.announceForAccessibility(
                            getString(com.saarang.samples.apps.iosched.R.string.my_schedule_page_desc_a11y,
                                    getDayName(position)));
                }
            }

            @Override
            public void onPageScrollStateChanged(int state) {
                enableDisableSwipeRefresh(state == ViewPager.SCROLL_STATE_IDLE);
            }
        });
    }

    overridePendingTransition(0, 0);
    addDataObservers();
}

From source file:com.kerkr.edu.widget.viewpager.CircleZoomPageIndicator.java

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

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

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

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = HORIZONTAL;//from   www. jav a2  s  . c om

    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mMaxRadius = (int) (mRadius * 1.25f);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    mSelectedCorlor = a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor);
    mNormalCorlor = a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor);
    a.recycle();

    mPaintNormal = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintNormal.setStyle(Style.FILL);
    mPaintNormal.setColor(mNormalCorlor);
    mPaintCur = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintCur.setStyle(Style.FILL);
    mPaintCur.setColor(mSelectedCorlor);
    mPaintTarget = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintTarget.setStyle(Paint.Style.FILL);
    mPaintTarget.setColor(mNormalCorlor);
    mRadiusCur = mMaxRadius;
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.seasonsread.app.view.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/* w w  w .  jav a2 s  .  co m*/

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

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

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

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

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mPaintPageFill.setColor(context.getResources().getColor(R.color.trans_light));
    mPaintStroke.setColor(context.getResources().getColor(R.color.black2));
    mPaintStroke.setStrokeWidth(1);
    mPaintFill.setColor(context.getResources().getColor(R.color.colorPrimary));
}

From source file:com.android.messaging.ui.conversationlist.ConversationListItemView.java

@Override
protected void onFinishInflate() {
    mSwipeableContainer = (ViewGroup) findViewById(R.id.swipeableContainer);
    mCrossSwipeBackground = (ViewGroup) findViewById(R.id.crossSwipeBackground);
    mSwipeableContent = (ViewGroup) findViewById(R.id.swipeableContent);
    mConversationNameView = (TextView) findViewById(R.id.conversation_name);
    mSnippetTextView = (TextView) findViewById(R.id.conversation_snippet);
    mSubjectTextView = (TextView) findViewById(R.id.conversation_subject);
    mTimestampTextView = (TextView) findViewById(R.id.conversation_timestamp);
    mContactIconView = (ContactIconView) findViewById(R.id.conversation_icon);
    mContactCheckmarkView = (ImageView) findViewById(R.id.conversation_checkmark);
    mNotificationBellView = (ImageView) findViewById(R.id.conversation_notification_bell);
    mFailedStatusIconView = (ImageView) findViewById(R.id.conversation_failed_status_icon);
    mCrossSwipeArchiveLeftImageView = (ImageView) findViewById(R.id.crossSwipeArchiveIconLeft);
    mCrossSwipeArchiveRightImageView = (ImageView) findViewById(R.id.crossSwipeArchiveIconRight);
    mImagePreviewView = (AsyncImageView) findViewById(R.id.conversation_image_preview);
    mAudioAttachmentView = (AudioAttachmentView) findViewById(R.id.audio_attachment_view);
    mConversationNameView.addOnLayoutChangeListener(this);
    mSnippetTextView.addOnLayoutChangeListener(this);

    final Resources resources = getContext().getResources();
    mListItemReadColor = resources.getColor(R.color.conversation_list_item_read);
    mListItemUnreadColor = resources.getColor(R.color.conversation_list_item_unread);

    mListItemReadTypeface = Typefaces.getRobotoNormal();
    mListItemUnreadTypeface = Typefaces.getRobotoBold();

    if (OsUtil.isAtLeastL()) {
        setTransitionGroup(true);//from www .  ja v a  2 s.  c o  m
    }
}

From source file:com.tandong.sa.vpic.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from  w  w  w  .ja  v a 2  s  .c o  m

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(context.getResources()
            .getIdentifier("default_circle_indicator_page_color", "color", context.getPackageName()));
    final int defaultFillColor = res.getColor(context.getResources()
            .getIdentifier("default_circle_indicator_fill_color", "color", context.getPackageName()));

    final int defaultOrientation = res.getInteger(context.getResources()
            .getIdentifier("default_circle_indicator_orientation", "integer", context.getPackageName()));

    final int defaultStrokeColor = res.getColor(context.getResources()
            .getIdentifier("default_circle_indicator_stroke_color", "color", context.getPackageName()));
    final float defaultStrokeWidth = res.getDimension(context.getResources()
            .getIdentifier("default_circle_indicator_stroke_width", "dimen", context.getPackageName()));
    final float defaultRadius = res.getDimension(context.getResources()
            .getIdentifier("default_circle_indicator_radius", "dimen", context.getPackageName()));
    final boolean defaultCentered = res.getBoolean(context.getResources()
            .getIdentifier("default_circle_indicator_centered", "bool", context.getPackageName()));

    final boolean defaultSnap = res.getBoolean(context.getResources()
            .getIdentifier("default_circle_indicator_snap", "bool", context.getPackageName()));

    // Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] {
            getResources().getIdentifier("CirclePageIndicator", "styleable", context.getPackageName()) },
            defStyle, 0);

    mCentered = a.getBoolean(
            getResources().getIdentifier("CirclePageIndicator_centered", "styleable", context.getPackageName()),
            defaultCentered);

    mOrientation = a.getInt(getResources().getIdentifier("CirclePageIndicator_android_orientation", "styleable",
            context.getPackageName()), defaultOrientation);

    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(getResources().getIdentifier("CirclePageIndicator_pageColor",
            "styleable", context.getPackageName()), defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(getResources().getIdentifier("CirclePageIndicator_strokeColor",
            "styleable", context.getPackageName()), defaultStrokeColor));
    mPaintStroke.setStrokeWidth(a.getDimension(getResources().getIdentifier("CirclePageIndicator_strokeWidth",
            "styleable", context.getPackageName()), defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(getResources().getIdentifier("CirclePageIndicator_fillColor", "styleable",
            context.getPackageName()), defaultFillColor));
    mRadius = a.getDimension(
            getResources().getIdentifier("CirclePageIndicator_radius", "styleable", context.getPackageName()),
            defaultRadius);
    mSnap = a.getBoolean(
            getResources().getIdentifier("CirclePageIndicator_snap", "styleable", context.getPackageName()),
            defaultSnap);

    Drawable background = a.getDrawable(getResources().getIdentifier("CirclePageIndicator_android_background",
            "styleable", context.getPackageName()));

    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.bolaa.medical.view.banner.CirclePageIndicator.java

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

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle,
            R.style.Widget_CirclePageIndicator);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation);

    mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintPageFill.setStyle(Style.STROKE);
    mPaintPageFill.setStrokeWidth(1);//
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));

    mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke/*from w  w  w  .j ava  2s. c  o  m*/
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));

    mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintFill.setStyle(Style.FILL);//
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));

    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);

    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.xandy.calendar.month.SimpleDayPickerFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mContext = activity;//from w ww. j  a v a 2s  .c  o m
    String tz = Time.getCurrentTimezone();
    ViewConfiguration viewConfig = ViewConfiguration.get(activity);
    mMinimumFlingVelocity = viewConfig.getScaledMinimumFlingVelocity();

    // Ensure we're in the correct time zone
    mSelectedDay.switchTimezone(tz);
    mSelectedDay.normalize(true);
    mFirstDayOfMonth.timezone = tz;
    mFirstDayOfMonth.normalize(true);
    mFirstVisibleDay.timezone = tz;
    mFirstVisibleDay.normalize(true);
    mTempTime.timezone = tz;

    Resources res = activity.getResources();
    mSaturdayColor = res.getColor(R.color.month_saturday);
    mSundayColor = res.getColor(R.color.month_sunday);
    mDayNameColor = res.getColor(R.color.month_day_names_color);

    // Adjust sizes for screen density
    if (mScale == 0) {
        mScale = activity.getResources().getDisplayMetrics().density;
        if (mScale != 1) {
            WEEK_MIN_VISIBLE_HEIGHT *= mScale;
            BOTTOM_BUFFER *= mScale;
            LIST_TOP_OFFSET *= mScale;
        }
    }
    setUpAdapter();
    setListAdapter(mAdapter);
}