Example usage for android.content.res Resources getDimension

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

Introduction

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

Prototype

public float getDimension(@DimenRes int id) throws NotFoundException 

Source Link

Document

Retrieve a dimensional for a particular resource ID.

Usage

From source file:android.hqs.view.pager.indicator.TitlePageIndicator.java

/**
 * ?//from www . j a  va2s  . co  m
 * @param context
 * @param attrs
 * @param defStyle
 */
@SuppressWarnings("deprecation")
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color);
    final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color);
    final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_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 defaultLinePosition = res.getInteger(R.integer.default_title_indicator_line_position);
    final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold);
    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, 0);

    //Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight,
            defaultFooterLineHeight);
    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);
    mLinePosition = LinePosition
            .fromValue(a.getInteger(R.styleable.TitlePageIndicator_linePosition, defaultLinePosition));
    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_android_textColor, defaultTextColor);
    mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

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

    Drawable background = a.getDrawable(R.styleable.TitlePageIndicator_android_background);
    if (background != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            setBackground(background);
        } else {
            setBackgroundDrawable(background);
        }
    }

    a.recycle();

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

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(/*from  w w w . j  a va  2s  . co m*/
            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.tandong.sa.vpic.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from  ww  w .  ja va2  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.example.anumbrella.viewpager.CirclePagerIndicator.java

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

    ///*from www  .  j  a  va  2  s.co  m*/
    if (isInEditMode()) {
        return;
    }

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

    //xml
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.CirclePagerIndicator, defStyle, 0);

    mCentered = array.getBoolean(R.styleable.CirclePagerIndicator_centered, defaultCentered);
    mOrientation = array.getInteger(R.styleable.CirclePagerIndicator_android_orientation, defaultOrientation);
    //
    mPaintPageFill.setStyle(Paint.Style.FILL);
    //
    mPaintPageFill.setColor(array.getColor(R.styleable.CirclePagerIndicator_pageColor, defaultPageColor));
    //
    mPaintFill.setStyle(Paint.Style.FILL);
    //
    mPaintFill.setColor(array.getColor(R.styleable.CirclePagerIndicator_fillColor, defaultFillColor));
    //
    mPaintStroke.setColor(array.getColor(R.styleable.CirclePagerIndicator_strokeColor, defaultStrokeColor));
    //(??)
    mPaintStroke.setStyle(Paint.Style.STROKE);
    //
    mPaintStroke.setStrokeWidth(
            array.getDimension(R.styleable.CirclePagerIndicator_strokeWidth, defaultStrokeWidth));
    //???
    mRadius = array.getDimension(R.styleable.CirclePagerIndicator_radius, defaultRadius);
    //?
    mSnap = array.getBoolean(R.styleable.CirclePagerIndicator_snap, defaultSnap);
    Drawable background = array.getDrawable(R.styleable.CirclePagerIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }
    array.recycle();
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);

}

From source file:net.hadifar.dope.ui.widget.pagerIndicator.NumericPageIndicator.java

@SuppressWarnings("deprecation")
public NumericPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) {
        return;/*  w  ww  .java 2  s.co m*/
    }

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultTextColor = res.getColor(R.color.default_page_number_indicator_text_color);
    final int defaultPageNumberTextColor = res
            .getColor(R.color.default_page_number_indicator_page_number_text_color);
    final boolean defaultPageNumberTextBold = res
            .getBoolean(R.bool.default_page_number_indicator_page_number_text_bold);
    final int defaultButtonPressedColor = res
            .getColor(R.color.default_page_number_indicator_pressed_button_color);
    final float defaultTopPadding = res.getDimension(R.dimen.default_page_number_indicator_top_padding);
    final float defaultBottomPadding = res.getDimension(R.dimen.default_page_number_indicator_bottom_padding);
    final float defaultTextSize = res.getDimension(R.dimen.default_page_number_indicator_text_size);
    final boolean defaultShowChangePageButtons = res
            .getBoolean(R.bool.default_page_number_indicator_show_change_page_buttons);
    final boolean defaultShowStartEndButtons = res
            .getBoolean(R.bool.default_page_number_indicator_show_start_end_buttons);

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

    mTextTemplate = a.getString(R.styleable.NumericPageIndicator_textTemplate);
    if (mTextTemplate == null) {
        mTextTemplate = res.getString(R.string.default_page_number_indicator_text_template);
    }
    parseTextTemplate();

    mTextPreviousButton = a.getString(R.styleable.NumericPageIndicator_previousButtonText);
    if (mTextPreviousButton == null) {
        mTextPreviousButton = res.getString(R.string.default_page_number_indicator_previous_button_text);
    }
    mTextNextButton = a.getString(R.styleable.NumericPageIndicator_nextButtonText);
    if (mTextNextButton == null) {
        mTextNextButton = res.getString(R.string.default_page_number_indicator_next_button_text);
    }

    mColorText = a.getColor(R.styleable.NumericPageIndicator_android_textColor, defaultTextColor);
    mColorPageNumberText = a.getColor(R.styleable.NumericPageIndicator_pageNumberTextColor,
            defaultPageNumberTextColor);
    mPageNumberTextBold = a.getBoolean(R.styleable.NumericPageIndicator_pageNumberTextBold,
            defaultPageNumberTextBold);
    mColorPressedButton = a.getColor(R.styleable.NumericPageIndicator_pressedButtonColor,
            defaultButtonPressedColor);
    mPaddingTop = a.getDimension(R.styleable.NumericPageIndicator_android_paddingTop, defaultTopPadding);
    mPaddingBottom = a.getDimension(R.styleable.NumericPageIndicator_android_paddingBottom,
            defaultBottomPadding);
    mPaintText.setColor(mColorText);
    mShowChangePageButtons = a.getBoolean(R.styleable.NumericPageIndicator_showChangePageButtons,
            defaultShowChangePageButtons);
    mShowStartEndButtons = a.getBoolean(R.styleable.NumericPageIndicator_showStartEndButtons,
            defaultShowStartEndButtons);

    mPaintButtonBackground.setColor(mColorPressedButton);
    final float textSize = a.getDimension(R.styleable.NumericPageIndicator_android_textSize, defaultTextSize);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);

    mPaintPageNumberText.setColor(mColorPageNumberText);
    mPaintPageNumberText.setTextSize(textSize);
    mPaintPageNumberText.setAntiAlias(true);
    if (mPageNumberTextBold) {
        mPaintPageNumberText.setTypeface(Typeface.DEFAULT_BOLD);
    }

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

    a.recycle();
}

From source file:de.schildbach.wallet.ui.TransactionsAdapter.java

public TransactionsAdapter(final Context context, final Wallet wallet, final int maxConnectedPeers,
        final @Nullable OnClickListener onClickListener) {
    this.context = context;
    inflater = LayoutInflater.from(context);

    this.wallet = wallet;
    this.maxConnectedPeers = maxConnectedPeers;
    this.onClickListener = onClickListener;

    final Resources res = context.getResources();
    colorBackground = res.getColor(R.color.bg_bright);
    colorBackgroundSelected = res.getColor(R.color.bg_panel);
    colorSignificant = res.getColor(R.color.fg_significant);
    colorLessSignificant = res.getColor(R.color.fg_less_significant);
    colorInsignificant = res.getColor(R.color.fg_insignificant);
    colorValuePositve = res.getColor(R.color.fg_value_positive);
    colorValueNegative = res.getColor(R.color.fg_value_negative);
    colorError = res.getColor(R.color.fg_error);
    textCoinBase = context.getString(R.string.wallet_transactions_fragment_coinbase);
    textInternal = context.getString(R.string.symbol_internal) + " "
            + context.getString(R.string.wallet_transactions_fragment_internal);
    textSizeNormal = res.getDimension(R.dimen.font_size_normal);

    setHasStableIds(true);//from w w  w  . j  a  v  a  2  s. c o  m
}

From source file:com.viewsforandroid.foundry.sample.indicators.NumericPageIndicator.java

@SuppressWarnings("deprecation")
public NumericPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) {
        return;//from   ww w.ja va2s.c  o m
    }

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultTextColor = res.getColor(R.color.default_page_number_indicator_text_color);
    final int defaultPageNumberTextColor = res
            .getColor(R.color.default_page_number_indicator_page_number_text_color);
    final boolean defaultPageNumberTextBold = res
            .getBoolean(R.bool.default_page_number_indicator_page_number_text_bold);
    final int defaultButtonPressedColor = res
            .getColor(R.color.default_page_number_indicator_pressed_button_color);
    final float defaultTopPadding = res.getDimension(R.dimen.default_page_number_indicator_top_padding);
    final float defaultBottomPadding = res.getDimension(R.dimen.default_page_number_indicator_bottom_padding);
    final float defaultTextSize = res.getDimension(R.dimen.default_page_number_indicator_text_size);
    final boolean defaultShowChangePageButtons = res
            .getBoolean(R.bool.default_page_number_indicator_show_change_page_buttons);
    final boolean defaultShowStartEndButtons = res
            .getBoolean(R.bool.default_page_number_indicator_show_start_end_buttons);

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

    mTextTemplate = a.getString(R.styleable.NumericPageIndicator_textTemplate);
    if (mTextTemplate == null) {
        mTextTemplate = res.getString(R.string.default_page_number_indicator_text_template);
        ;
    }
    parseTextTemplate();

    mTextStartButton = a.getString(R.styleable.NumericPageIndicator_startButtonText);
    if (mTextStartButton == null) {
        mTextStartButton = res.getString(R.string.default_page_number_indicator_start_button_text);
    }
    mTextEndButton = a.getString(R.styleable.NumericPageIndicator_endButtonText);
    if (mTextEndButton == null) {
        mTextEndButton = res.getString(R.string.default_page_number_indicator_end_button_text);
    }
    mTextPreviousButton = a.getString(R.styleable.NumericPageIndicator_previousButtonText);
    if (mTextPreviousButton == null) {
        mTextPreviousButton = res.getString(R.string.default_page_number_indicator_previous_button_text);
    }
    mTextNextButton = a.getString(R.styleable.NumericPageIndicator_nextButtonText);
    if (mTextNextButton == null) {
        mTextNextButton = res.getString(R.string.default_page_number_indicator_next_button_text);
    }

    mColorText = a.getColor(R.styleable.NumericPageIndicator_android_textColor, defaultTextColor);
    mColorPageNumberText = a.getColor(R.styleable.NumericPageIndicator_pageNumberTextColor,
            defaultPageNumberTextColor);
    mPageNumberTextBold = a.getBoolean(R.styleable.NumericPageIndicator_pageNumberTextBold,
            defaultPageNumberTextBold);
    mColorPressedButton = a.getColor(R.styleable.NumericPageIndicator_pressedButtonColor,
            defaultButtonPressedColor);
    mPaddingTop = a.getDimension(R.styleable.NumericPageIndicator_android_paddingTop, defaultTopPadding);
    mPaddingBottom = a.getDimension(R.styleable.NumericPageIndicator_android_paddingBottom,
            defaultBottomPadding);
    mPaintText.setColor(mColorText);
    mShowChangePageButtons = a.getBoolean(R.styleable.NumericPageIndicator_showChangePageButtons,
            defaultShowChangePageButtons);
    mShowStartEndButtons = a.getBoolean(R.styleable.NumericPageIndicator_showStartEndButtons,
            defaultShowStartEndButtons);

    mPaintButtonBackground.setColor(mColorPressedButton);
    final float textSize = a.getDimension(R.styleable.NumericPageIndicator_android_textSize, defaultTextSize);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);

    mPaintPageNumberText.setColor(mColorPageNumberText);
    mPaintPageNumberText.setTextSize(textSize);
    mPaintPageNumberText.setAntiAlias(true);
    if (mPageNumberTextBold) {
        mPaintPageNumberText.setTypeface(Typeface.DEFAULT_BOLD);
    }

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

    a.recycle();
}

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

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

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

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

    // Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(getResources().getIdentifier("TitlePageIndicator_footerLineHeight",
            "styleable", context.getPackageName()), defaultFooterLineHeight);
    // mFooterLineHeight = a.getDimension(
    // R.styleable.TitlePageIndicator_footerLineHeight,
    // defaultFooterLineHeight);
    mFooterIndicatorStyle = IndicatorStyle
            .fromValue(a.getInteger(getResources().getIdentifier("TitlePageIndicator_footerIndicatorStyle",
                    "styleable", context.getPackageName()), defaultFooterIndicatorStyle));
    // mFooterIndicatorStyle = IndicatorStyle.fromValue(a.getInteger(
    // R.styleable.TitlePageIndicator_footerIndicatorStyle,
    // defaultFooterIndicatorStyle));
    mFooterIndicatorHeight = a.getDimension(getResources()
            .getIdentifier("TitlePageIndicator_footerIndicatorHeight", "styleable", context.getPackageName()),
            defaultFooterIndicatorHeight);
    // mFooterIndicatorHeight = a.getDimension(
    // R.styleable.TitlePageIndicator_footerIndicatorHeight,
    // defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a
            .getDimension(getResources().getIdentifier("TitlePageIndicator_footerIndicatorUnderlinePadding",
                    "styleable", context.getPackageName()), defaultFooterIndicatorUnderlinePadding);
    // mFooterIndicatorUnderlinePadding = a.getDimension(
    // R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
    // defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_footerPadding",
            "styleable", context.getPackageName()), defaultFooterPadding);
    // mFooterPadding = a.getDimension(
    // R.styleable.TitlePageIndicator_footerPadding,
    // defaultFooterPadding);
    mLinePosition = LinePosition
            .fromValue(a.getInteger(getResources().getIdentifier("TitlePageIndicator_linePosition", "styleable",
                    context.getPackageName()), defaultLinePosition));
    // mLinePosition = LinePosition.fromValue(a.getInteger(
    // R.styleable.TitlePageIndicator_linePosition,
    // defaultLinePosition));
    mTopPadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_topPadding", "styleable",
            context.getPackageName()), defaultTopPadding);
    // mTopPadding =
    // a.getDimension(R.styleable.TitlePageIndicator_topPadding,
    // defaultTopPadding);
    mTitlePadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_titlePadding", "styleable",
            context.getPackageName()), defaultTitlePadding);
    // mTitlePadding = a.getDimension(
    // R.styleable.TitlePageIndicator_titlePadding,
    // defaultTitlePadding);
    mClipPadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_clipPadding", "styleable",
            context.getPackageName()), defaultClipPadding);
    // mClipPadding = a.getDimension(
    // R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
    mColorSelected = a.getColor(getResources().getIdentifier("TitlePageIndicator_selectedColor", "styleable",
            context.getPackageName()), defaultSelectedColor);
    // mColorSelected = a.getColor(
    // R.styleable.TitlePageIndicator_selectedColor,
    // defaultSelectedColor);
    mColorText = a.getColor(getResources().getIdentifier("TitlePageIndicator_android_textColor", "styleable",
            context.getPackageName()), defaultTextColor);
    // mColorText = a.getColor(
    // R.styleable.TitlePageIndicator_android_textColor,
    // defaultTextColor);
    mBoldText = a.getBoolean(getResources().getIdentifier("TitlePageIndicator_selectedBold", "styleable",
            context.getPackageName()), defaultSelectedBold);
    // mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold,
    // defaultSelectedBold);

    final float textSize = a.getDimension(getResources().getIdentifier("TitlePageIndicator_android_textSize",
            "styleable", context.getPackageName()), defaultTextSize);
    // final float textSize = a.getDimension(
    // R.styleable.TitlePageIndicator_android_textSize,
    // defaultTextSize);
    final int footerColor = a.getColor(getResources().getIdentifier("TitlePageIndicator_footerColor",
            "styleable", context.getPackageName()), defaultFooterColor);
    // final int footerColor = a.getColor(
    // R.styleable.TitlePageIndicator_footerColor, defaultFooterColor);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
    mPaintFooterLine.setColor(footerColor);
    mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterIndicator.setColor(footerColor);

    Drawable background = a.getDrawable(getResources().getIdentifier("TitlePageIndicator_android_background",
            "styleable", context.getPackageName()));
    // Drawable background = a
    // .getDrawable(R.styleable.TitlePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

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

From source file:cx.ring.service.LocalService.java

public void updateTextNotifications() {
    Log.d(TAG, "updateTextNotifications()");

    for (Conversation c : conversations.values()) {
        TreeMap<Long, TextMessage> texts = c.getUnreadTextMessages();
        if (texts.isEmpty() || texts.lastEntry().getValue().isNotified()) {
            continue;
        } else//from  w  w w .  jav a2s .  co  m
            notificationManager.cancel(c.notificationId);

        CallContact contact = c.getContact();
        if (c.notificationBuilder == null) {
            c.notificationBuilder = new NotificationCompat.Builder(getApplicationContext());
            c.notificationBuilder.setCategory(NotificationCompat.CATEGORY_MESSAGE)
                    .setPriority(NotificationCompat.PRIORITY_HIGH).setDefaults(NotificationCompat.DEFAULT_ALL)
                    .setSmallIcon(R.drawable.ic_launcher).setContentTitle(contact.getDisplayName());
        }
        NotificationCompat.Builder noti = c.notificationBuilder;
        Intent c_intent = new Intent(Intent.ACTION_VIEW).setClass(this, ConversationActivity.class)
                .setData(Uri.withAppendedPath(ConversationActivity.CONTENT_URI, contact.getIds().get(0)));
        Intent d_intent = new Intent(ACTION_CONV_READ).setClass(this, LocalService.class)
                .setData(Uri.withAppendedPath(ConversationActivity.CONTENT_URI, contact.getIds().get(0)));
        noti.setContentIntent(PendingIntent.getActivity(this, new Random().nextInt(), c_intent, 0))
                .setDeleteIntent(PendingIntent.getService(this, new Random().nextInt(), d_intent, 0));

        if (contact.getPhoto() != null) {
            Resources res = getResources();
            int height = (int) res.getDimension(android.R.dimen.notification_large_icon_height);
            int width = (int) res.getDimension(android.R.dimen.notification_large_icon_width);
            noti.setLargeIcon(Bitmap.createScaledBitmap(contact.getPhoto(), width, height, false));
        }
        if (texts.size() == 1) {
            TextMessage txt = texts.firstEntry().getValue();
            txt.setNotified(true);
            noti.setContentText(txt.getMessage());
            noti.setStyle(null);
            noti.setWhen(txt.getTimestamp());
        } else {
            NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
            for (TextMessage s : texts.values()) {
                inboxStyle.addLine(Html.fromHtml("<b>"
                        + DateUtils.formatDateTime(this, s.getTimestamp(),
                                DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_ABBREV_ALL)
                        + "</b> " + s.getMessage()));
                s.setNotified(true);
            }
            noti.setContentText(texts.lastEntry().getValue().getMessage());
            noti.setStyle(inboxStyle);
            noti.setWhen(texts.lastEntry().getValue().getTimestamp());
        }
        notificationManager.notify(c.notificationId, noti.build());
    }
}

From source file:com.google.corp.productivity.specialprojects.android.samples.fft.AnalyzeActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    //  Debug.startMethodTracing("calc");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//  w  ww .  ja v  a2  s  .  c o  m

    DPRatio = getResources().getDisplayMetrics().density;

    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    Log.i(TAG, " max mem = " + maxMemory + "k");

    // set and get preferences in PreferenceActivity
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    // Set variable according to the preferences
    updatePreferenceSaved();

    textRMSChar = new char[getString(R.string.textview_RMS_text).length()];
    textCurChar = new char[getString(R.string.textview_cur_text).length()];
    textRecChar = new char[getString(R.string.textview_rec_text).length()];
    textPeakChar = new char[getString(R.string.textview_peak_text).length()];

    graphView = (AnalyzeView) findViewById(R.id.plot);

    // travel Views, and attach ClickListener to the views that contain android:tag="select"  
    visit((ViewGroup) graphView.getRootView(), new Visit() {
        @Override
        public void exec(View view) {
            view.setOnLongClickListener(AnalyzeActivity.this);
            view.setOnClickListener(AnalyzeActivity.this);
            ((TextView) view).setFreezesText(true);
        }
    }, "select");

    Resources res = getResources();
    getAudioSourceNameFromIdPrepare(res);

    listItemTextSize = res.getDimension(R.dimen.button_text_fontsize);
    listItemTitleTextSize = res.getDimension(R.dimen.button_text_small_fontsize);

    /// initialize pop up window items list
    // http://www.codeofaninja.com/2013/04/show-listview-as-drop-down-android.html
    popupMenuSampleRate = popupMenuCreate(validateAudioRates(res.getStringArray(R.array.sample_rates)),
            R.id.button_sample_rate);
    popupMenuFFTLen = popupMenuCreate(res.getStringArray(R.array.fft_len), R.id.button_fftlen);
    popupMenuAverage = popupMenuCreate(res.getStringArray(R.array.fft_ave_num), R.id.button_average);

    mDetector = new GestureDetectorCompat(this, new AnalyzerGestureListener());

    setTextViewFontSize();
}