Example usage for android.content.res Resources getInteger

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

Introduction

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

Prototype

public int getInteger(@IntegerRes int id) throws NotFoundException 

Source Link

Document

Return an integer associated with a particular resource ID.

Usage

From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.lb_dialog_fragment, container, false);

    View contentContainer = v.findViewById(R.id.content_fragment);
    View content = inflater.inflate(R.layout.lb_dialog_content, container, false);
    ((ViewGroup) contentContainer).addView(content);
    initializeContentView(content);/*from w  w  w .  j  a v a  2  s. c o m*/
    v.setTag(R.id.content_fragment, content);

    View actionContainer = v.findViewById(R.id.action_fragment);
    View action = inflater.inflate(R.layout.lb_dialog_action_list, container, false);
    ((ViewGroup) actionContainer).addView(action);
    setActionView(action);
    v.setTag(R.id.action_fragment, action);

    Resources res = getActivity().getResources();
    mAnimateInDuration = res.getInteger(R.integer.animate_in_duration);
    mAnimateDelay = res.getInteger(R.integer.animate_delay);
    mSecondaryAnimateDelay = res.getInteger(R.integer.secondary_animate_delay);
    mSlideInStagger = res.getInteger(R.integer.slide_in_stagger);
    mSlideInDistance = res.getInteger(R.integer.slide_in_distance);

    return v;
}

From source file:com.icloud.listenbook.base.view.viewpagerindicator.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/* www. jav  a 2s  .c o  m*/

    // ?
    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);

    // ?
    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:com.jakewharton.android.viewpagerindicator.TitlePageIndicator.java

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

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color);
    final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height);
    final int defaultFooterIndicatorStyle = res
            .getInteger(R.integer.default_title_indicator_footer_indicator_style);
    final float defaultFooterIndicatorHeight = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_height);
    final float defaultFooterIndicatorUnderlinePadding = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding);
    final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding);
    final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color);
    final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold);
    final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color);
    final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size);
    final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding);
    final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding);

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

    //Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight,
            defaultFooterLineHeight);// ww w  .jav  a 2  s  .  c o  m
    mFooterIndicatorStyle = IndicatorStyle.fromValue(
            a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle));
    mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight,
            defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a.getDimension(
            R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
            defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
    mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
    mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
    mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
    mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor);
    mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

    final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize);
    final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor);
    mPaintText = new Paint();
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);
    mPaintFooterLine = new Paint();
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
    mPaintFooterLine.setColor(footerColor);
    mPaintFooterIndicator = new Paint();
    mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterIndicator.setColor(footerColor);

    a.recycle();
}

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

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from   ww w.j  av 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 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.fanfou.app.opensource.ui.viewpager.TitlePageIndicator.java

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

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color);
    final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height);
    final int defaultFooterIndicatorStyle = res
            .getInteger(R.integer.default_title_indicator_footer_indicator_style);
    final float defaultFooterIndicatorHeight = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_height);
    final float defaultFooterIndicatorUnderlinePadding = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding);
    final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding);
    final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color);
    final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold);
    final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color);
    final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size);
    final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding);
    final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding);

    // Retrieve styles attributes
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle,
            R.style.Widget_TitlePageIndicator);

    // Retrieve the colors to be used for this view and apply them.
    this.mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight,
            defaultFooterLineHeight);//from  w  ww  .j a v a  2s . c o m
    this.mFooterIndicatorStyle = IndicatorStyle.fromValue(
            a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle));
    this.mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight,
            defaultFooterIndicatorHeight);
    this.mFooterIndicatorUnderlinePadding = a.getDimension(
            R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
            defaultFooterIndicatorUnderlinePadding);
    this.mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
    this.mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
    this.mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
    this.mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
    this.mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor);
    this.mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

    final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize);
    final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor);
    this.mPaintText = new Paint();
    this.mPaintText.setTextSize(textSize);
    this.mPaintText.setAntiAlias(true);
    this.mPaintFooterLine = new Paint();
    this.mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    this.mPaintFooterLine.setStrokeWidth(this.mFooterLineHeight);
    this.mPaintFooterLine.setColor(footerColor);
    this.mPaintFooterIndicator = new Paint();
    this.mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    this.mPaintFooterIndicator.setColor(footerColor);

    a.recycle();

    this.mPath = new Path();
}

From source file:com.androtex.viewpagerindicator.TitlePageIndicator.java

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

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color);
    final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height);
    final int defaultFooterIndicatorStyle = res
            .getInteger(R.integer.default_title_indicator_footer_indicator_style);
    final float defaultFooterIndicatorHeight = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_height);
    final float defaultFooterIndicatorUnderlinePadding = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding);
    final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding);
    @SuppressWarnings("unused")
    final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color);
    final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold);
    final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color);
    final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size);
    final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding);
    final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding);
    final float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding);

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

    //Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight,
            defaultFooterLineHeight);//from w w w .  j a v a2s. c  o m
    mFooterIndicatorStyle = IndicatorStyle.fromValue(
            a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle));
    mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight,
            defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a.getDimension(
            R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
            defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
    mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding);
    mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
    mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
    mColorSelected = 0; //a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
    mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor);
    mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

    final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize);
    final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor);
    mPaintText = new Paint();
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);
    mPaintFooterLine = new Paint();
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
    mPaintFooterLine.setColor(footerColor);
    mPaintFooterIndicator = new Paint();
    mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterIndicator.setColor(footerColor);

    a.recycle();
}

From source file:com.lbk.app.weiliao.ui.views.TitlePageIndicator.java

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

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color);
    final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height);
    final int defaultFooterIndicatorStyle = res
            .getInteger(R.integer.default_title_indicator_footer_indicator_style);
    final float defaultFooterIndicatorHeight = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_height);
    final float defaultFooterIndicatorUnderlinePadding = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding);
    final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding);
    final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color);
    final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold);
    final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color);
    final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size);
    final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding);
    final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding);
    final float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding);

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

    //Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight,
            defaultFooterLineHeight);// w ww  .j  a v a 2  s  . c o m
    mFooterIndicatorStyle = IndicatorStyle.fromValue(
            a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle));
    mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight,
            defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a.getDimension(
            R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
            defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
    mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding);
    mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
    mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
    mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
    mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor);
    mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

    final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize);
    final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor);
    mPaintText = new Paint();
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);
    mPaintFooterLine = new Paint();
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
    mPaintFooterLine.setColor(footerColor);
    mPaintFooterIndicator = new Paint();
    mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterIndicator.setColor(footerColor);

    a.recycle();
}

From source file:com.nick.scalpel.core.AutoFoundWirer.java

private void wireFromContext(Context context, AutoFound.Type type, int idRes, Resources.Theme theme,
        Field field, Object forWho) {
    Resources resources = context.getResources();
    switch (type) {
    case STRING://w w w  . ja v a 2  s .  com
        setField(field, forWho, resources.getString(idRes));
        break;
    case COLOR:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            setField(field, forWho, resources.getColor(idRes, theme));
        } else {
            //noinspection deprecation
            setField(field, forWho, resources.getColor(idRes));
        }
        break;
    case INTEGER:
        setField(field, forWho, resources.getInteger(idRes));
        break;
    case BOOL:
        setField(field, forWho, resources.getBoolean(idRes));
        break;
    case STRING_ARRAY:
        setField(field, forWho, resources.getStringArray(idRes));
        break;
    case INT_ARRAY:
        setField(field, forWho, resources.getIntArray(idRes));
        break;
    case PM:
        setField(field, forWho, context.getSystemService(Context.POWER_SERVICE));
        break;
    case ACCOUNT:
        setField(field, forWho, context.getSystemService(Context.ACCOUNT_SERVICE));
        break;
    case ALARM:
        setField(field, forWho, context.getSystemService(Context.ALARM_SERVICE));
        break;
    case AM:
        setField(field, forWho, context.getSystemService(Context.ACTIVITY_SERVICE));
        break;
    case WM:
        setField(field, forWho, context.getSystemService(Context.WINDOW_SERVICE));
        break;
    case NM:
        setField(field, forWho, context.getSystemService(Context.NOTIFICATION_SERVICE));
        break;
    case TM:
        setField(field, forWho, context.getSystemService(Context.TELEPHONY_SERVICE));
        break;
    case TCM:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setField(field, forWho, context.getSystemService(Context.TELECOM_SERVICE));
        }
        break;
    case SP:
        setField(field, forWho, PreferenceManager.getDefaultSharedPreferences(context));
        break;
    case PKM:
        setField(field, forWho, context.getPackageManager());
        break;
    case HANDLE:
        setField(field, forWho, new Handler(Looper.getMainLooper()));
        break;
    case ASM:
        setField(field, forWho, context.getSystemService(Context.ACCESSIBILITY_SERVICE));
        break;
    case CAP:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            setField(field, forWho, context.getSystemService(Context.CAPTIONING_SERVICE));
        }
        break;
    case KGD:
        setField(field, forWho, context.getSystemService(Context.KEYGUARD_SERVICE));
        break;
    case LOCATION:
        setField(field, forWho, context.getSystemService(Context.LOCATION_SERVICE));
        break;
    case SEARCH:
        setField(field, forWho, context.getSystemService(Context.SEARCH_SERVICE));
        break;
    case SENSOR:
        setField(field, forWho, context.getSystemService(Context.SENSOR_SERVICE));
        break;
    case STORAGE:
        setField(field, forWho, context.getSystemService(Context.STORAGE_SERVICE));
        break;
    case WALLPAPER:
        setField(field, forWho, context.getSystemService(Context.WALLPAPER_SERVICE));
        break;
    case VIBRATOR:
        setField(field, forWho, context.getSystemService(Context.VIBRATOR_SERVICE));
        break;
    case CONNECT:
        setField(field, forWho, context.getSystemService(Context.CONNECTIVITY_SERVICE));
        break;
    case NETWORK_STATUS:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            setField(field, forWho, context.getSystemService(Context.NETWORK_STATS_SERVICE));
        }
        break;
    case WIFI:
        setField(field, forWho, context.getSystemService(Context.WIFI_SERVICE));
        break;
    case AUDIO:
        setField(field, forWho, context.getSystemService(Context.AUDIO_SERVICE));
        break;
    case FP:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            setField(field, forWho, context.getSystemService(Context.FINGERPRINT_SERVICE));
        }
        break;
    case MEDIA_ROUTER:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            setField(field, forWho, context.getSystemService(Context.MEDIA_ROUTER_SERVICE));
        }
        break;
    case SUB:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
            setField(field, forWho, context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE));
        }
        break;
    case IME:
        setField(field, forWho, context.getSystemService(Context.INPUT_METHOD_SERVICE));
        break;
    case CLIP_BOARD:
        setField(field, forWho, context.getSystemService(Context.CLIPBOARD_SERVICE));
        break;
    case APP_WIDGET:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setField(field, forWho, context.getSystemService(Context.APPWIDGET_SERVICE));
        }
        break;
    case DEVICE_POLICY:
        setField(field, forWho, context.getSystemService(Context.DEVICE_POLICY_SERVICE));
        break;
    case DOWNLOAD:
        setField(field, forWho, context.getSystemService(Context.DOWNLOAD_SERVICE));
        break;
    case BATTERY:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setField(field, forWho, context.getSystemService(Context.BATTERY_SERVICE));
        }
        break;
    case NFC:
        setField(field, forWho, context.getSystemService(Context.NFC_SERVICE));
        break;
    case DISPLAY:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            setField(field, forWho, context.getSystemService(Context.DISPLAY_SERVICE));
        }
        break;
    case USER:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            setField(field, forWho, context.getSystemService(Context.USER_SERVICE));
        }
        break;
    case APP_OPS:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            setField(field, forWho, context.getSystemService(Context.APP_OPS_SERVICE));
        }
        break;
    case BITMAP:
        setField(field, forWho, BitmapFactory.decodeResource(resources, idRes, null));
        break;
    }
}

From source file:ru.phplego.core.etc.viewpagerindicator.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(Res.getId(Application.getContext().getPackageName(), "color",
            "default_circle_indicator_page_color"));
    final int defaultFillColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color",
            "default_circle_indicator_fill_color"));
    final int defaultOrientation = res.getInteger(Res.getId(Application.getContext().getPackageName(),
            "integer", "default_circle_indicator_orientation"));
    final int defaultStrokeColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color",
            "default_circle_indicator_stroke_color"));
    final float defaultStrokeWidth = res.getDimension(Res.getId(Application.getContext().getPackageName(),
            "dimen", "default_circle_indicator_stroke_width"));
    final float defaultRadius = res.getDimension(
            Res.getId(Application.getContext().getPackageName(), "dimen", "default_circle_indicator_radius"));
    final boolean defaultCentered = res.getBoolean(
            Res.getId(Application.getContext().getPackageName(), "bool", "default_circle_indicator_centered"));
    final boolean defaultSnap = res.getBoolean(
            Res.getId(Application.getContext().getPackageName(), "bool", "default_circle_indicator_snap"));

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs,
            Res.getIds(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator"), defStyle,
            Res.getId(Application.getContext().getPackageName(), "style", "Widget_CirclePageIndicator"));

    mCentered = a.getBoolean(/*  w ww  .jav  a 2 s .com*/
            Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_centered"),
            defaultCentered);
    mOrientation = a.getInt(Res.getId(Application.getContext().getPackageName(), "styleable",
            "CirclePageIndicator_orientation"), defaultOrientation);
    mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(
            Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_pageColor"),
            defaultPageColor));
    mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(Res.getId(Application.getContext().getPackageName(), "styleable",
            "CirclePageIndicator_strokeColor"), defaultStrokeColor));
    mPaintStroke.setStrokeWidth(a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable",
            "CirclePageIndicator_strokeWidth"), defaultStrokeWidth));
    mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(
            Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_fillColor"),
            defaultFillColor));
    mRadius = a.getDimension(
            Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_radius"),
            defaultRadius);
    mSnap = a.getBoolean(
            Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_snap"),
            defaultSnap);

    a.recycle();

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

From source file:com.google.android.apps.santatracker.village.Village.java

public void initialiseVillageViews(int viewHeight, int viewWidth) {
    mViewHeight = viewHeight;//from   w w w.j  a v a 2s  .  co  m
    int maxDimension = viewHeight > viewWidth ? viewHeight : viewWidth;
    Resources resources = getResources();
    if (!mImagesInitialised) {
        UiModeManager mgr = (UiModeManager) getActivity().getApplicationContext()
                .getSystemService(Context.UI_MODE_SERVICE);
        if (Configuration.UI_MODE_TYPE_WATCH == mgr.getCurrentModeType()) {
            int referenceHeight = resources.getInteger(R.integer.wear_referenceHeight);

            mImageSkyDay = new StretchedFullWidthImage(R.drawable.sky_day,
                    resources.getInteger(R.integer.wear_skyReferenceHeight),
                    resources.getInteger(R.integer.wear_skyStart));
            mImageSkyNight = new StretchedFullWidthImage(R.drawable.sky_night,
                    resources.getInteger(R.integer.wear_skyReferenceHeight),
                    resources.getInteger(R.integer.wear_skyStart));
            mImageUfo = new HorizontalScrollingImage(R.drawable.ufo, referenceHeight,
                    resources.getInteger(R.integer.wear_ufoVerticalOffset), false,
                    resources.getInteger(R.integer.wear_ufoPercentagePerSecond));
            mImageSun = new SimpleImage(R.drawable.sun, resources.getInteger(R.integer.wear_sunReferenceHeight),
                    resources.getInteger(R.integer.wear_sunVerticalOffset),
                    resources.getInteger(R.integer.wear_sunHorizontalOffset));
            mImageMoon = new SimpleImage(R.drawable.moon,
                    resources.getInteger(R.integer.wear_sunReferenceHeight),
                    resources.getInteger(R.integer.wear_moonVerticalOffset),
                    resources.getInteger(R.integer.wear_moonHorizontalOffset));
            mImagePlane = new HorizontalScrollingImage(R.drawable.plane, referenceHeight,
                    resources.getInteger(R.integer.wear_planeVerticalOffset), true,
                    resources.getInteger(R.integer.wear_planePercentagePerSecond));

            mImageClouds = new HorizontalScrollingImageGroup(R.drawable.cloud,
                    resources.getInteger(R.integer.wear_numClouds),
                    resources.getInteger(R.integer.wear_sunVerticalOffset),
                    resources.getInteger(R.integer.wear_cloudsEnd), getParallax(R.integer.wear_cloudsParallax),
                    referenceHeight);
            mImageMountainsDay = loadImage(R.array.wear_mountainsDayIds, referenceHeight,
                    R.integer.wear_mountainsStart, R.integer.wear_mountainsParallax, R.integer.wear_med_res);
            mImageMountainsNight = loadImage(R.array.wear_mountainsNightIds, referenceHeight,
                    R.integer.wear_mountainsStart, R.integer.wear_mountainsParallax, R.integer.wear_med_res);
            mPaintMountainsDay = new SolidPaint(getString(R.color.colorMountainsDay),
                    resources.getInteger(R.integer.wear_mountainsPaintStart),
                    resources.getInteger(R.integer.wear_mountainsEnd), referenceHeight);
            mPaintMountainsNight = new SolidPaint(getString(R.color.colorMountainsNight),
                    resources.getInteger(R.integer.wear_mountainsPaintStart),
                    resources.getInteger(R.integer.wear_mountainsEnd), referenceHeight);

            mImageMonoRail = new HorizontalScrollingImage(R.drawable.monorail, referenceHeight,
                    resources.getInteger(R.integer.wear_monorailStart), false,
                    resources.getInteger(R.integer.wear_monorailPercentagePerSecond));
            mImageRail = new HorizontallyRepeatingImage(R.drawable.rail, referenceHeight,
                    resources.getInteger(R.integer.wear_railStart), getParallax(R.integer.wear_railParallax));

            mImageVillage = loadImage(R.array.wear_villageIds, referenceHeight, R.integer.wear_villageStart,
                    R.integer.wear_villageParallax, R.integer.wear_high_res);
            mImageSnow = loadImage(R.array.wear_snowIds, referenceHeight, R.integer.wear_snowStart,
                    R.integer.wear_snowParallax, R.integer.wear_low_res);
            mPaintSnow = new SolidPaint(getString(R.color.colorSnow),
                    resources.getInteger(R.integer.wear_snowPaintStart),
                    resources.getInteger(R.integer.wear_snowEnd), referenceHeight);

            mOffsetVertical = -1 * resources.getInteger(R.integer.wear_verticalOffset);
        } else {
            int referenceHeight = resources.getInteger(R.integer.referenceHeight);

            mImageSkyDay = new StretchedFullWidthImage(R.drawable.sky_day,
                    resources.getInteger(R.integer.skyReferenceHeight),
                    resources.getInteger(R.integer.skyStart));
            mImageSkyNight = new StretchedFullWidthImage(R.drawable.sky_night,
                    resources.getInteger(R.integer.skyReferenceHeight),
                    resources.getInteger(R.integer.skyStart));
            mImageUfo = new HorizontalScrollingImage(R.drawable.ufo, referenceHeight,
                    resources.getInteger(R.integer.ufoVerticalOffset), false,
                    resources.getInteger(R.integer.ufoPercentagePerSecond));
            mImageSun = new SimpleImage(R.drawable.sun, resources.getInteger(R.integer.sunReferenceHeight),
                    resources.getInteger(R.integer.sunVerticalOffset),
                    resources.getInteger(R.integer.sunHorizontalOffset));
            mImageMoon = new SimpleImage(R.drawable.moon, resources.getInteger(R.integer.sunReferenceHeight),
                    resources.getInteger(R.integer.moonVerticalOffset),
                    resources.getInteger(R.integer.moonHorizontalOffset));
            mImagePlane = new HorizontalScrollingImage(R.drawable.plane, referenceHeight,
                    resources.getInteger(R.integer.planeVerticalOffset), true,
                    resources.getInteger(R.integer.wear_planePercentagePerSecond));

            mImageClouds = new HorizontalScrollingImageGroup(R.drawable.cloud,
                    resources.getInteger(R.integer.numClouds),
                    resources.getInteger(R.integer.sunVerticalOffset),
                    resources.getInteger(R.integer.cloudsEnd), getParallax(R.integer.cloudsParallax),
                    referenceHeight);
            mImageMountainsDay = loadImage(R.array.mountainsDayIds, referenceHeight, R.integer.mountainsStart,
                    R.integer.mountainsParallax, R.integer.med_res);
            mImageMountainsNight = loadImage(R.array.mountainsNightIds, referenceHeight,
                    R.integer.mountainsStart, R.integer.mountainsParallax, R.integer.med_res);
            mPaintMountainsDay = new SolidPaint(getString(R.color.colorMountainsDay),
                    resources.getInteger(R.integer.mountainsPaintStart),
                    resources.getInteger(R.integer.mountainsEnd), referenceHeight);
            mPaintMountainsNight = new SolidPaint(getString(R.color.colorMountainsNight),
                    resources.getInteger(R.integer.mountainsPaintStart),
                    resources.getInteger(R.integer.mountainsEnd), referenceHeight);

            mImageMonoRail = new HorizontalScrollingImage(R.drawable.monorail, referenceHeight,
                    resources.getInteger(R.integer.monorailStart), false,
                    resources.getInteger(R.integer.wear_monorailPercentagePerSecond));
            mImageRail = new HorizontallyRepeatingImage(R.drawable.rail, referenceHeight,
                    resources.getInteger(R.integer.railStart), getParallax(R.integer.railParallax));

            mImageVillage = loadImage(R.array.villageIds, referenceHeight, R.integer.villageStart,
                    R.integer.villageParallax, R.integer.high_res);
            mImageSnow = loadImage(R.array.snowIds, referenceHeight, R.integer.snowStart,
                    R.integer.snowParallax, R.integer.low_res);
            mPaintSnow = new SolidPaint(getString(R.color.colorSnow),
                    resources.getInteger(R.integer.snowPaintStart), resources.getInteger(R.integer.snowEnd),
                    referenceHeight);
        }

        mImageSkyDay.loadImages(resources);
        mImageSkyNight.loadImages(resources);
        mImageUfo.loadImages(resources);
        mImageSun.loadImages(resources);
        mImageMoon.loadImages(resources);
        mImagePlane.loadImages(resources);

        mImageClouds.loadImages(resources);
        mImageMountainsDay.loadImages(resources);
        mImageMountainsNight.loadImages(resources);

        mImageMonoRail.loadImages(resources);
        mImageRail.loadImages(resources);

        mImageVillage.loadImages(resources);
        mImageSnow.loadImages(getResources());

        mImagesInitialised = true;

        setIsDay(initialiseSunMoon(), false);
    }

    // Set easter egg state to empty
    for (int i = 0; i < EGG_COUNT; i++) {
        mEasterEggTracker[i] = false;
    }
    mImageUfo.setAlpha(ImageWithAlphaAndSize.INVISIBLE);

    mMaxOffsetHorizontalVillage = mImageVillage.geTotalWidthScaled(viewHeight) / 2;
    int percentPerSecond = getResources().getInteger(R.integer.scrollPercentagePerSecond);
    mScrollPerSecond = (float) (percentPerSecond) / 100f * maxDimension;
}