Example usage for android.content.res TypedArray getDimension

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

Introduction

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

Prototype

public float getDimension(@StyleableRes int index, float defValue) 

Source Link

Document

Retrieve a dimensional unit attribute at index.

Usage

From source file:com.mozhuowen.widget.autoscrollviewpager.indicator.LinePageIndicator.java

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

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

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

    //        mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
    //        mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
    //        mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
    mCentered = defaultCentered;
    mLineWidth = defaultLineWidth;
    mGapWidth = defaultGapWidth;
    setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintUnselected
            .setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));

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

    a.recycle();

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

From source file:com.github.pedrovgs.DraggableView.java

/**
 * Initialize Transformer with a scalable or change width/height implementation.
 *
 * @param attributes//w  w  w  . j a v a 2  s.  com
 */
private void initializeTransformer(TypedArray attributes) {
    topViewResize = attributes.getBoolean(R.styleable.draggable_view_top_view_resize, DEFAULT_TOP_VIEW_RESIZE);
    TransformerFactory transformerFactory = new TransformerFactory();
    transformer = transformerFactory.getTransformer(topViewResize, dragView, this);
    transformer.setViewHeight(
            attributes.getDimension(R.styleable.draggable_view_top_view_height, DEFAULT_TOP_VIEW_HEIGHT));
    transformer.setXScaleFactor(
            attributes.getFloat(R.styleable.draggable_view_top_view_x_scale_factor, DEFAULT_SCALE_FACTOR));
    transformer.setYScaleFactor(
            attributes.getFloat(R.styleable.draggable_view_top_view_y_scale_factor, DEFAULT_SCALE_FACTOR));
    transformer.setMarginRight(
            attributes.getDimension(R.styleable.draggable_view_top_view_margin_right, DEFAULT_TOP_VIEW_MARGIN));
    transformer.setMarginBottom(attributes.getDimension(R.styleable.draggable_view_top_view_margin_bottom,
            DEFAULT_TOP_VIEW_MARGIN));
}

From source file:com.viewpagerindicator.TitlePageIndicatorEx1.java

public TitlePageIndicatorEx1(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 .jav  a  2s .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.hippo.widget.Slider.java

@SuppressWarnings("deprecation")
private void init(Context context, AttributeSet attrs) {
    mContext = context;/*  ww  w .  j  a  v  a2 s.  c o m*/
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextAlign(Paint.Align.CENTER);

    Resources resources = context.getResources();
    mBubbleMinWidth = resources.getDimensionPixelOffset(R.dimen.slider_bubble_width);
    mBubbleMinHeight = resources.getDimensionPixelOffset(R.dimen.slider_bubble_height);

    mBubble = new BubbleView(context, textPaint);
    mBubble.setScaleX(0.0f);
    mBubble.setScaleY(0.0f);
    AbsoluteLayout absoluteLayout = new AbsoluteLayout(context);
    absoluteLayout.addView(mBubble);
    absoluteLayout.setBackgroundDrawable(null);
    mPopup = new PopupWindow(absoluteLayout);
    mPopup.setOutsideTouchable(false);
    mPopup.setTouchable(false);
    mPopup.setFocusable(false);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Slider);
    textPaint.setColor(a.getColor(R.styleable.Slider_textColor, Color.WHITE));
    textPaint.setTextSize(a.getDimensionPixelSize(R.styleable.Slider_textSize, 12));

    updateTextSize();

    setRange(a.getInteger(R.styleable.Slider_start, 0), a.getInteger(R.styleable.Slider_end, 0));
    setProgress(a.getInteger(R.styleable.Slider_slider_progress, 0));
    mThickness = a.getDimension(R.styleable.Slider_thickness, 2);
    mRadius = a.getDimension(R.styleable.Slider_radius, 6);
    setColor(a.getColor(R.styleable.Slider_color, Color.BLACK));

    mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBgPaint.setColor(a.getBoolean(R.styleable.Slider_dark, false) ? 0x4dffffff : 0x42000000);

    a.recycle();

    mProgressAnimation = new ValueAnimator();
    mProgressAnimation.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
    mProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            mDrawPercent = value;
            mDrawProgress = Math.round(MathUtils.lerp((float) mStart, mEnd, value));
            updateBubblePosition();
            mBubble.setProgress(mDrawProgress);
            invalidate();
        }
    });

    mBubbleScaleAnimation = new ValueAnimator();
    mBubbleScaleAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            mDrawBubbleScale = value;
            mBubble.setScaleX(value);
            mBubble.setScaleY(value);
            invalidate();
        }
    });
}

From source file:com.ex.english.viewpagerindicator.TitlePageIndicator.java

public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/* w w  w . j  ava 2s.  co  m*/

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

    a.recycle();

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

From source file:com.androtex.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 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);
    mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke/*www. j a  v a  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();
}

From source file:com.morninz.ninepinview.widget.NinePINView.java

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

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NinePINView);

    mPointColor = a.getColor(R.styleable.NinePINView_pointColor, DEFAULT_POINT_COLOR);
    mCircleColor = a.getColor(R.styleable.NinePINView_circleColor, DEFAULT_CIRCLE_COLOR);
    mLineColor = a.getColor(R.styleable.NinePINView_lineColor, DEFAULT_LINE_COLOR);
    mWrongColor = a.getColor(R.styleable.NinePINView_wrongColor, DEFAULT_WRONG_COLOR);

    mPointSize = a.getDimension(R.styleable.NinePINView_pointSize, 8.0f);
    mCircleWidth = a.getDimension(R.styleable.NinePINView_circleWidth, 5.0f);
    mLineWidth = a.getDimension(R.styleable.NinePINView_lineWidth, 5.0f);
    mCircleRadius = a.getDimension(R.styleable.NinePINView_circleRadius, 40.0f);

    a.recycle();//  w ww.ja  va 2 s. co m

    // center point
    mPointPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPointPaint.setColor(mPointColor);
    mPointPaint.setStyle(Style.FILL);

    // circle
    mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCirclePaint.setColor(mCircleColor);
    mCirclePaint.setStrokeWidth(mCircleWidth);
    mCirclePaint.setStyle(Style.STROKE);

    // connection line
    mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLinePaint.setColor(mLineColor);
    mLinePaint.setStrokeWidth(mLineWidth);
    mLinePaint.setStyle(Style.FILL);
    mLinePaint.setStrokeCap(Cap.ROUND);
    mLinePaint.setStrokeJoin(Join.ROUND);

    // wrong triangle path
    mWrongPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mWrongPaint.setColor(mWrongColor);
    mWrongPaint.setStyle(Style.FILL);

    setPadding(Math.max(getPaddingLeft(), DEFAULT_PADDING), Math.max(getPaddingTop(), DEFAULT_PADDING),
            Math.max(getPaddingRight(), DEFAULT_PADDING), Math.max(getPaddingBottom(), DEFAULT_PADDING));

    mWillDrawWrongTriangle = false;
}

From source file:com.example.marvin.familylink._UI.pager.CirclePageIndicator.java

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

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

    a.recycle();

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

From source file:com.lovebridge.library.view.viewpagerindicator.TitlePageIndicator.java

public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from   w ww .j av  a  2 s  . com*/
    // 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 defaultLinePosition = res.getInteger(R.integer.default_title_indicator_line_position);
    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, 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) {
        setBackgroundDrawable(background);
    }
    a.recycle();
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.opencabinetlabs.destinycommunityhub.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Crashlytics.start(this);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

    if (isFinishing()) {
        return;/*from ww  w.  ja  v  a2s .  c  o  m*/
    }

    setContentView(R.layout.activity_main);

    bindViews();

    // Enabling Up navigation
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setDisplayShowHomeEnabled(true);
    getActionBar().setIcon(R.drawable.action_bar_icon);

    if (savedInstanceState != null) {
        mCommunityNewsFragment = (CommunityNewsFragment) getSupportFragmentManager()
                .getFragment(savedInstanceState, CommunityNewsFragment.class.getName());
        mVideosFragment = (VideosFragment) getSupportFragmentManager().getFragment(savedInstanceState,
                VideosFragment.class.getName());
        mCommunityFragment = (CommunityFragment) getSupportFragmentManager().getFragment(savedInstanceState,
                CommunityFragment.class.getName());
        mTwitterStreamFragment = (TwitterStreamFragment) getSupportFragmentManager()
                .getFragment(savedInstanceState, TwitterStreamFragment.class.getName());
        mPodcastFragment = (PodcastFragment) getSupportFragmentManager().getFragment(savedInstanceState,
                PodcastFragment.class.getName());
    }
    if (mCommunityNewsFragment == null) {
        mCommunityNewsFragment = new CommunityNewsFragment();
    }
    if (mVideosFragment == null) {
        mVideosFragment = new VideosFragment();
    }
    if (mCommunityFragment == null) {
        mCommunityFragment = new CommunityFragment();
    }
    if (mTwitterStreamFragment == null) {
        mTwitterStreamFragment = new TwitterStreamFragment();
    }
    if (mPodcastFragment == null) {
        mPodcastFragment = new PodcastFragment();
    }

    //Initialize sharedPrefs
    mPrefs = getSharedPreferences(CommunityHubConfig.PREFS_NAME, Context.MODE_PRIVATE);

    mLastTimeApiRequestsMade = mPrefs.getLong("lastTimeApiRequestsMade", 0);

    // Instantiate a ViewPager and a PagerAdapter.
    mPager = (ViewPager) findViewById(R.id.pager);

    HomePagerAdapter mPagerAdapter = new HomePagerAdapter(getSupportFragmentManager());
    mPager.setAdapter(mPagerAdapter);
    mNumFragments = mPagerAdapter.getCount();

    mPager.setPageTransformer(true, new DepthPageTransformer());

    //mNumFragments = mPagerAdapter.getCount();

    // Getting an array of link names
    mNavDrawerLinks = getResources().getStringArray(R.array.navdrawer_links);

    // Title of the activity
    // = (String)getTitle();

    // Getting a reference to the drawer listview
    mDrawerList = (ListView) findViewById(R.id.drawer_list);
    final TypedArray styledAttributes = this.getTheme()
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    int mActionBarSize = (int) styledAttributes.getDimension(0, 0);
    styledAttributes.recycle();
    mDrawerList.setPadding(0, mActionBarSize, 0, 0);

    // Getting a reference to the sidebar drawer ( Title + ListView )
    mDrawer = (LinearLayout) findViewById(R.id.drawer);

    mList = new ArrayList<HashMap<String, String>>();
    for (int i = 0; i < 5; i++) {
        HashMap<String, String> hm = new HashMap<String, String>();
        hm.put(TITLE, mNavDrawerLinks[i]);
        hm.put(ICON, Integer.toString(mIcons[i]));
        mList.add(hm);
    }

    // Keys used in Hashmap
    String[] from = { ICON, TITLE };

    // Ids of views in listview_layout
    int[] to = { R.id.icon, R.id.title };

    // Instantiating an adapter to store each items
    // R.layout.drawer_layout defines the layout of each item
    mAdapter = new SimpleAdapter(this, mList, R.layout.drawer_layout, from, to) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = super.getView(position, convertView, parent);

            TextView textView = (TextView) view.findViewById(R.id.title);
            textView.setTextColor(Color.WHITE);

            return view;
        }
    };

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    // Creating a ToggleButton for NavigationDrawer with drawer event listener
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close) {

        /** Called when drawer is closed */
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(R.string.app_name);
            supportInvalidateOptionsMenu();
        }

        /** Called when a drawer is opened */
        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(R.string.title_nav_opened);
            supportInvalidateOptionsMenu();
        }
    };

    // Setting event listener for the drawer
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    // ItemClick event handler for the drawer items
    mDrawerList.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {

            // Increment hit count of the drawer list item
            //incrementHitCount(position);

            if (position <= mNumFragments) { // Show fragment
                showFragment(position);
            }

            // Closing the drawer
            mDrawerLayout.closeDrawer(mDrawer);
        }
    });

    // Setting the adapter to the listView
    mDrawerList.setAdapter(mAdapter);

    PagerTabStrip strip = (PagerTabStrip) findViewById(R.id.pagertitlestrip);
    strip.setDrawFullUnderline(true);
    strip.setTabIndicatorColor(Color.WHITE);
    strip.setNonPrimaryAlpha(0.5f);
    strip.setTextSpacing(25);
    strip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);

    /* Sliding Panel Layout Setup */
    mSlidingLayout.setShadowDrawable(getResources().getDrawable(R.drawable.above_shadow));
    //mSlidingLayout.setAnchorPoint(0.3f);
    mSlidingLayout.setDragView(mDraggableView);
    mSlidingLayout.setPanelSlideListener(new PanelSlideListener() {

        @Override
        public void onPanelSlide(View panel, float slideOffset) {
            if (slideOffset < 0.2) {
                if (getActionBar().isShowing()) {
                    getActionBar().hide();
                }
            } else {
                if (!getActionBar().isShowing()) {
                    getActionBar().show();
                }
            }
        }

        @Override
        public void onPanelExpanded(View panel) {

        }

        @Override
        public void onPanelCollapsed(View panel) {

        }

        @Override
        public void onPanelAnchored(View panel) {

        }
    });

    //Initially hide the podcast panel
    mPodcastPanel.setVisibility(View.GONE);

    mHasMadeCommunityNewsRequest = savedInstanceState == null ? false
            : savedInstanceState.getBoolean(KEY_HAS_MADE_COMMUNITY_NEWS_FEED_REQUEST, false);
    mHasMadeTwitterFeedRequest = savedInstanceState == null ? false
            : savedInstanceState.getBoolean(KEY_HAS_MADE_TWITTER_FEED_REQUEST, false);
    mHasMadePodcastsRequest = savedInstanceState == null ? false
            : savedInstanceState.getBoolean(KEY_HAS_MADE_PODCAST_FEED_REQUEST, false);

    boolean actionBarHidden = savedInstanceState != null
            ? savedInstanceState.getBoolean(SAVED_STATE_ACTION_BAR_HIDDEN, false)
            : false;
    if (actionBarHidden) {
        getActionBar().hide();
    }
}