Example usage for android.content.res TypedArray getInt

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

Introduction

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

Prototype

public int getInt(@StyleableRes int index, int defValue) 

Source Link

Document

Retrieve the integer value for the attribute at index.

Usage

From source file:android.support.design.widget.CollapsingToolbarLayout.java

public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    ThemeUtils.checkAppCompatTheme(context);

    mCollapsingTextHelper = new CollapsingTextHelper(this);
    mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr,
            R.style.Widget_Design_CollapsingToolbar);

    mCollapsingTextHelper.setExpandedTextGravity(a.getInt(
            R.styleable.CollapsingToolbarLayout_expandedTitleGravity, GravityCompat.START | Gravity.BOTTOM));
    mCollapsingTextHelper//from w  ww.  j a v a 2 s  .  c  o  m
            .setCollapsedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_collapsedTitleGravity,
                    GravityCompat.START | Gravity.CENTER_VERTICAL));

    mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a
            .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMargin, 0);

    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart)) {
        mExpandedMarginStart = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart, 0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd)) {
        mExpandedMarginEnd = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd,
                0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop)) {
        mExpandedMarginTop = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop,
                0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom)) {
        mExpandedMarginBottom = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom, 0);
    }

    mCollapsingTitleEnabled = a.getBoolean(R.styleable.CollapsingToolbarLayout_titleEnabled, true);
    setTitle(a.getText(R.styleable.CollapsingToolbarLayout_title));

    // First load the default text appearances
    mCollapsingTextHelper.setExpandedTextAppearance(R.style.TextAppearance_Design_CollapsingToolbar_Expanded);
    mCollapsingTextHelper.setCollapsedTextAppearance(
            android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);

    // Now overlay any custom text appearances
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance)) {
        mCollapsingTextHelper.setExpandedTextAppearance(
                a.getResourceId(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance, 0));
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance)) {
        mCollapsingTextHelper.setCollapsedTextAppearance(
                a.getResourceId(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance, 0));
    }

    mScrimVisibleHeightTrigger = a
            .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_scrimVisibleHeightTrigger, -1);

    mScrimAnimationDuration = a.getInt(R.styleable.CollapsingToolbarLayout_scrimAnimationDuration,
            DEFAULT_SCRIM_ANIMATION_DURATION);

    setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_contentScrim));
    setStatusBarScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_statusBarScrim));

    mToolbarId = a.getResourceId(R.styleable.CollapsingToolbarLayout_toolbarId, -1);

    a.recycle();

    setWillNotDraw(false);

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            return onWindowInsetChanged(insets);
        }
    });
}

From source file:com.gigamole.navigationtabstrip.NavigationTabStrip.java

public NavigationTabStrip(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //Init NTS/*from  www.  ja v  a  2s .com*/

    // Always draw
    setWillNotDraw(false);
    // Speed and fix for pre 17 API
    ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, null);
    setLayerType(LAYER_TYPE_SOFTWARE, null);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabStrip);
    try {
        setStripColor(typedArray.getColor(R.styleable.NavigationTabStrip_nts_color, DEFAULT_STRIP_COLOR));
        setTitleSize(typedArray.getDimension(R.styleable.NavigationTabStrip_nts_size, DEFAULT_TITLE_SIZE));
        setStripWeight(
                typedArray.getDimension(R.styleable.NavigationTabStrip_nts_weight, DEFAULT_STRIP_WEIGHT));
        setStripFactor(typedArray.getFloat(R.styleable.NavigationTabStrip_nts_factor, DEFAULT_STRIP_FACTOR));
        setStripType(typedArray.getInt(R.styleable.NavigationTabStrip_nts_type, StripType.LINE_INDEX));
        setStripGravity(
                typedArray.getInt(R.styleable.NavigationTabStrip_nts_gravity, StripGravity.BOTTOM_INDEX));

        setTypeface(typedArray.getString(R.styleable.NavigationTabStrip_nts_typeface));
        setInactiveColor(
                typedArray.getColor(R.styleable.NavigationTabStrip_nts_inactive_color, DEFAULT_INACTIVE_COLOR));
        setActiveColor(
                typedArray.getColor(R.styleable.NavigationTabStrip_nts_active_color, DEFAULT_ACTIVE_COLOR));
        setAnimationDuration(typedArray.getInteger(R.styleable.NavigationTabStrip_nts_animation_duration,
                DEFAULT_ANIMATION_DURATION));
        setCornersRadius(typedArray.getDimension(R.styleable.NavigationTabStrip_nts_corners_radius,
                DEFAULT_CORNER_RADIUS));

        // Get titles
        String[] titles = null;
        try {
            final int titlesResId = typedArray.getResourceId(R.styleable.NavigationTabStrip_nts_titles, 0);
            titles = titlesResId == 0 ? null : typedArray.getResources().getStringArray(titlesResId);
        } catch (Exception exception) {
            titles = null;
            exception.printStackTrace();
        } finally {
            if (titles == null) {
                if (isInEditMode()) {
                    titles = new String[new Random().nextInt(5) + 1];
                    Arrays.fill(titles, PREVIEW_TITLE);
                } else
                    titles = new String[0];
            }

            setTitles(titles);
        }

        // Init animator
        mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(final ValueAnimator animation) {
                updateIndicatorPosition((Float) animation.getAnimatedValue());
            }
        });
    } finally {
        typedArray.recycle();
    }
}

From source file:com.akshay.protocol10.asplayer.widget.SlidingUpPanelLayout.java

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

    if (isInEditMode()) {
        mShadowDrawable = null;/*from   ww w  .  j  a va 2s  .c o m*/
        mDragHelper = null;
        return;
    }

    if (attrs != null) {
        TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS);

        if (defAttrs != null) {
            int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY);
            if (gravity != Gravity.TOP && gravity != Gravity.BOTTOM) {
                throw new IllegalArgumentException("gravity must be set to either top or bottom");
            }
            mIsSlidingUp = gravity == Gravity.BOTTOM;
        }

        defAttrs.recycle();

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

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

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

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

            mOverlayContent = ta.getBoolean(R.styleable.SlidingUpPanelLayout_overlay, DEFAULT_OVERLAY_FLAG);

            mAnchorPoint = ta.getFloat(R.styleable.SlidingUpPanelLayout_anchorPoint, DEFAULT_ANCHOR_POINT);

            mSlideState = SlideState.values()[ta.getInt(R.styleable.SlidingUpPanelLayout_initialState,
                    DEFAULT_SLIDE_STATE.ordinal())];
        }

        ta.recycle();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    if (mPanelHeight == -1) {
        mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f);
    }
    if (mShadowHeight == -1) {
        mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);
    }
    if (mParallaxOffset == -1) {
        mParallaxOffset = (int) (DEFAULT_PARALAX_OFFSET * density);
    }
    // If the shadow height is zero, don't show the shadow
    if (mShadowHeight > 0) {
        if (mIsSlidingUp) {
            mShadowDrawable = getResources().getDrawable(R.drawable.above_shadow);
        } else {
            mShadowDrawable = getResources().getDrawable(R.drawable.below_shadow);
        }

    } else {
        mShadowDrawable = null;
    }

    setWillNotDraw(false);

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

    mIsSlidingEnabled = true;
}

From source file:com.muzakki.ahmad.widget.CollapsingToolbarLayout.java

public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    ThemeUtils.checkAppCompatTheme(context);

    mCollapsingTextHelper = new CollapsingTextHelper(this);
    mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr,
            R.style.Widget_Design_CollapsingToolbar);

    mCollapsingTextHelper.setExpandedTextGravity(a.getInt(
            R.styleable.CollapsingToolbarLayout_expandedTitleGravity, GravityCompat.START | Gravity.BOTTOM));
    mCollapsingTextHelper/*www  . ja  va2  s .  c  om*/
            .setCollapsedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_collapsedTitleGravity,
                    GravityCompat.START | Gravity.CENTER_VERTICAL));

    mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a
            .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMargin, 0);

    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart)) {
        mExpandedMarginStart = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart, 0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd)) {
        mExpandedMarginEnd = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd,
                0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop)) {
        mExpandedMarginTop = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop,
                0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom)) {
        mExpandedMarginBottom = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom, 0);
    }

    mCollapsingTitleEnabled = a.getBoolean(R.styleable.CollapsingToolbarLayout_titleEnabled, true);
    setTitle(a.getText(R.styleable.CollapsingToolbarLayout_title));

    // begin modification
    TypedArray mStyle = context.obtainStyledAttributes(attrs, R.styleable.SubtitleCollapsingToolbar,
            defStyleAttr, R.style.SubtitleCollapsingToolbar);
    if (mStyle.hasValue(R.styleable.SubtitleCollapsingToolbar_subtitle))
        setSubtitle(mStyle.getText(R.styleable.SubtitleCollapsingToolbar_subtitle).toString());

    //load default appearances first
    mCollapsingTextHelper.setCollapsedSubAppearance(R.style.CollapsedSubtitleAppearance);
    mCollapsingTextHelper.setExpandedSubAppearance(R.style.ExpandedSubtitleAppearance);

    // now apply custom sub appearance
    if (mStyle.hasValue(R.styleable.SubtitleCollapsingToolbar_collapsedSubtitleAppearance)) {
        mCollapsingTextHelper.setCollapsedSubAppearance(
                mStyle.getResourceId(R.styleable.SubtitleCollapsingToolbar_collapsedSubtitleAppearance, 0));
    }

    if (mStyle.hasValue(R.styleable.SubtitleCollapsingToolbar_expandedSubtitleAppearance)) {
        mCollapsingTextHelper.setExpandedSubAppearance(
                mStyle.getResourceId(R.styleable.SubtitleCollapsingToolbar_expandedSubtitleAppearance, 0));
    }
    // end

    // First load the default text appearances
    mCollapsingTextHelper.setExpandedTextAppearance(R.style.TextAppearance_Design_CollapsingToolbar_Expanded);
    mCollapsingTextHelper.setCollapsedTextAppearance(
            android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);

    // Now overlay any custom text appearances
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance)) {
        mCollapsingTextHelper.setExpandedTextAppearance(
                a.getResourceId(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance, 0));
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance)) {
        mCollapsingTextHelper.setCollapsedTextAppearance(
                a.getResourceId(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance, 0));
    }

    mScrimVisibleHeightTrigger = a
            .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_scrimVisibleHeightTrigger, -1);

    mScrimAnimationDuration = a.getInt(R.styleable.CollapsingToolbarLayout_scrimAnimationDuration,
            DEFAULT_SCRIM_ANIMATION_DURATION);

    setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_contentScrim));
    setStatusBarScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_statusBarScrim));

    mToolbarId = a.getResourceId(R.styleable.CollapsingToolbarLayout_toolbarId, -1);

    a.recycle();

    setWillNotDraw(false);

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            return onWindowInsetChanged(insets);
        }
    });
}

From source file:com.hb.hkm.slidinglayer.SlidLayer.java

/**
 * Constructor for the sliding layer.<br>
 * By default this panel will/*from  www .  ja  va  2  s.  c  om*/
 * <ol>
 * <li>{@link #setStickTo(int)} with param {@link #STICK_TO_RIGHT}</li>
 * <li>Use no shadow drawable. (i.e. with size of 0)</li>
 * <li>Close when the panel is tapped</li>
 * <li>Open when the offset is tapped, but will have an offset of 0</li>
 * </ol>
 *
 * @param context  a reference to an existing context
 * @param attrs    attribute set constructed from attributes set in android .xml file
 * @param defStyle style res id
 */
public SlidLayer(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Style
    final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidLayer);

    // Set the side of the screen
    setStickTo(ta.getInt(R.styleable.SlidLayer_stickTo, STICK_TO_RIGHT));

    // Sets the shadow drawable
    int shadowRes = ta.getResourceId(R.styleable.SlidLayer_shadowDrawable, INVALID_VALUE);
    if (shadowRes != INVALID_VALUE) {
        setShadowDrawable(shadowRes);
    }

    // Sets the shadow size
    mShadowSize = (int) ta.getDimension(R.styleable.SlidLayer_shadowSize, 0);

    // Sets the ability to open or close the layer by tapping in any empty space
    changeStateOnTap = ta.getBoolean(R.styleable.SlidLayer_changeStateOnTap, true);

    // How much of the view sticks out when closed
    mOffsetDistance = ta.getDimensionPixelOffset(R.styleable.SlidLayer_offsetDistance, 0);

    // Sets the size of the preview summary, if any
    mPreviewOffsetDistance = ta.getDimensionPixelOffset(R.styleable.SlidLayer_previewOffsetDistance,
            INVALID_VALUE);

    // If showing offset is greater than preview mode offset dimension, exception is thrown
    checkPreviewModeConsistency();

    ta.recycle();

    init();
}

From source file:com.pt.treasuretrash.widget.SlidingLayer.java

/**
 * Constructor for the sliding layer.<br>
 * By default this panel will/*w  ww  .j  a  v a2  s . c  o m*/
 * <ol>
 * <li>{@link #setStickTo(int)} with param {@link #STICK_TO_AUTO}</li>
 * <li>Use no shadow drawable. (i.e. with width of 0)</li>
 * <li>Close when the panel is tapped</li>
 * <li>Open when the offset is tapped, but will have an offset of 0</li>
 * </ol>
 * 
 * @param context
 *            a reference to an existing context
 * @param attrs
 *            attribute set constructed from attributes set in android .xml
 *            file
 * @param defStyle
 *            style res id
 */
public SlidingLayer(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Style
    final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingLayer);

    // Set the side of the screen
    setStickTo(ta.getInt(R.styleable.SlidingLayer_stickTo, STICK_TO_AUTO));

    // Sets the shadow drawable
    int shadowRes = ta.getResourceId(R.styleable.SlidingLayer_shadowDrawable, -1);
    if (shadowRes != -1) {
        setShadowDrawable(shadowRes);
    }

    // Sets the shadow width
    setShadowWidth((int) ta.getDimension(R.styleable.SlidingLayer_shadowWidth, 0));

    // Sets the ability to close the layer by tapping in any empty space
    closeOnTapEnabled = ta.getBoolean(R.styleable.SlidingLayer_closeOnTapEnabled, true);
    // Sets the ability to open the layout by tapping on any of the exposed
    // closed layer
    openOnTapEnabled = ta.getBoolean(R.styleable.SlidingLayer_openOnTapEnabled, true);

    // How much of the view sticks out when closed
    setOffsetWidth(ta.getDimensionPixelOffset(R.styleable.SlidingLayer_offsetWidth, 0));

    ta.recycle();

    init();
}

From source file:co.codecrunch.musicplayerlite.slidinguppanelhelper.SlidingUpPanelLayout.java

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

    if (isInEditMode()) {
        mShadowDrawable = null;/*from  ww w  . j  ava  2  s. c  o m*/
        mDragHelper = null;
        return;
    }

    if (attrs != null) {
        TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS);

        if (defAttrs != null) {
            int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY);
            setGravity(gravity);
        }

        defAttrs.recycle();

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

        if (ta != null) {
            mPanelHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_umanoPanelHeight, -1);
            mShadowHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_umanoShadowHeight, -1);
            mParallaxOffset = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_umanoParalaxOffset, -1);

            mMinFlingVelocity = ta.getInt(R.styleable.SlidingUpPanelLayout_umanoFlingVelocity,
                    DEFAULT_MIN_FLING_VELOCITY);
            mCoveredFadeColor = ta.getColor(R.styleable.SlidingUpPanelLayout_umanoFadeColor,
                    DEFAULT_FADE_COLOR);

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

            mOverlayContent = ta.getBoolean(R.styleable.SlidingUpPanelLayout_umanoOverlay,
                    DEFAULT_OVERLAY_FLAG);
            mClipPanel = ta.getBoolean(R.styleable.SlidingUpPanelLayout_umanoClipPanel,
                    DEFAULT_CLIP_PANEL_FLAG);

            mAnchorPoint = ta.getFloat(R.styleable.SlidingUpPanelLayout_umanoAnchorPoint, DEFAULT_ANCHOR_POINT);

            mSlideState = PanelState.values()[ta.getInt(R.styleable.SlidingUpPanelLayout_umanoInitialState,
                    DEFAULT_SLIDE_STATE.ordinal())];
        }

        ta.recycle();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    if (mPanelHeight == -1) {
        mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f);
    }
    if (mShadowHeight == -1) {
        mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);
    }
    if (mParallaxOffset == -1) {
        mParallaxOffset = (int) (DEFAULT_PARALAX_OFFSET * density);
    }
    // If the shadow height is zero, don't show the shadow
    if (mShadowHeight > 0) {
        if (mIsSlidingUp) {
            mShadowDrawable = getResources().getDrawable(R.drawable.above_shadow);
        } else {
            mShadowDrawable = getResources().getDrawable(R.drawable.below_shadow);
        }

    } else {
        mShadowDrawable = null;
    }

    setWillNotDraw(false);

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

    mIsTouchEnabled = true;
}

From source file:com.dirkgassen.wator.ui.view.RollingGraphView.java

/**
 * Read out the attributes from the given attribute set and initialize whatever they represent.
 *
 * @param attributeArray typed array containing the attribute values from the XML file
 */// w w w.  jav  a  2  s  . c  om
private void setupAttributes(TypedArray attributeArray) {
    String series1Name = attributeArray.getString(R.styleable.RollingGraphView_series1name);
    if (series1Name == null) {
        seriesNames = null;
    } else {
        String series2Name = attributeArray.getString(R.styleable.RollingGraphView_series2name);
        if (series2Name == null) {
            seriesNames = new String[] { series1Name };
        } else {
            String series3Name = attributeArray.getString(R.styleable.RollingGraphView_series3name);
            if (series3Name == null) {
                seriesNames = new String[] { series1Name, series2Name };
            } else {
                String series4Name = attributeArray.getString(R.styleable.RollingGraphView_series4name);
                if (series4Name == null) {
                    seriesNames = new String[] { series1Name, series2Name, series3Name };
                } else {
                    seriesNames = new String[] { series1Name, series2Name, series3Name, series4Name };
                }
            }
        }

        maxValues = attributeArray.getInt(R.styleable.RollingGraphView_maxValues, -1);
        seriesPaints = new Paint[seriesNames.length];

        seriesPaints[0] = new Paint(Paint.ANTI_ALIAS_FLAG);
        seriesPaints[0]
                .setColor(attributeArray.getColor(R.styleable.RollingGraphView_series1color, 0xFFFF0000));
        seriesPaints[0].setStrokeWidth(attributeArray
                .getDimension(R.styleable.RollingGraphView_series1thickness, 1 /* dp */ * displayDensity));
        seriesPaints[0].setTextSize(
                attributeArray.getDimension(R.styleable.RollingGraphView_label1textSize, 14 * displayDensity));
        if (seriesPaints.length > 1) {
            seriesPaints[1] = new Paint(Paint.ANTI_ALIAS_FLAG);
            seriesPaints[1]
                    .setColor(attributeArray.getColor(R.styleable.RollingGraphView_series2color, 0xFFFF0000));
            seriesPaints[1].setStrokeWidth(attributeArray
                    .getDimension(R.styleable.RollingGraphView_series2thickness, 1 /* dp */ * displayDensity));
            seriesPaints[1].setTextSize(attributeArray.getDimension(R.styleable.RollingGraphView_label2textSize,
                    14 * displayDensity));
            if (seriesPaints.length > 2) {
                seriesPaints[2] = new Paint(Paint.ANTI_ALIAS_FLAG);
                seriesPaints[2].setColor(
                        attributeArray.getColor(R.styleable.RollingGraphView_series3color, 0xFFFF0000));
                seriesPaints[2].setStrokeWidth(attributeArray.getDimension(
                        R.styleable.RollingGraphView_series3thickness, 1 /* dp */ * displayDensity));
                seriesPaints[2].setTextSize(attributeArray
                        .getDimension(R.styleable.RollingGraphView_label3textSize, 14 * displayDensity));
                if (seriesPaints.length > 3) {
                    seriesPaints[3] = new Paint(Paint.ANTI_ALIAS_FLAG);
                    seriesPaints[3].setColor(
                            attributeArray.getColor(R.styleable.RollingGraphView_series4color, 0xFFFF0000));
                    seriesPaints[3].setStrokeWidth(attributeArray.getDimension(
                            R.styleable.RollingGraphView_series4thickness, 1 /* dp */ * displayDensity));
                    seriesPaints[3].setTextSize(attributeArray
                            .getDimension(R.styleable.RollingGraphView_label4textSize, 14 * displayDensity));
                }
            }
        }
        background = getBackground();
        if (background == null) {
            background = new ColorDrawable(ContextCompat.getColor(getContext(), android.R.color.white));
        }
    }

    horizontal = attributeArray.getInt(R.styleable.RollingGraphView_android_orientation, 0) == 0;
}

From source file:com.jsibbold.zoomage.ZoomageView.java

public ZoomageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    scaleDetector = new ScaleGestureDetector(context, this);
    ScaleGestureDetectorCompat.setQuickScaleEnabled(scaleDetector, false);
    startScaleType = getScaleType();/*w w  w .  j  a  va  2 s. co  m*/

    TypedArray values = context.obtainStyledAttributes(attrs, com.jsibbold.zoomage.R.styleable.ZoomageView);

    zoomable = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_zoomable, true);
    translatable = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_translatable, true);
    animateOnReset = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_animateOnReset,
            true);
    autoCenter = values.getBoolean(R.styleable.ZoomageView_zoomage_autoCenter, true);
    restrictBounds = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_restrictBounds,
            false);
    minScale = values.getFloat(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_minScale, MIN_SCALE);
    maxScale = values.getFloat(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_maxScale, MAX_SCALE);
    autoResetMode = AutoResetMode.Parser.fromInt(values
            .getInt(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_autoResetMode, AutoResetMode.UNDER));

    verifyScaleRange();

    values.recycle();
}

From source file:com.aviary.android.feather.sdk.widget.AviaryWorkspace.java

private void initWorkspace(Context context, AttributeSet attrs, int defStyle) {

    Theme theme = context.getTheme();//w w  w . j  ava 2 s .  c om

    TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.AviaryWorkspace, defStyle, 0);
    mDefaultScreen = a.getInt(R.styleable.AviaryWorkspace_aviary_defaultScreen, 0);
    int overscrollMode = a.getInt(R.styleable.AviaryWorkspace_aviary_overscroll, 0);
    a.recycle();

    setHapticFeedbackEnabled(false);

    mScrollInterpolator = new DecelerateInterpolator(1.0f);
    mScroller = new Scroller(context, mScrollInterpolator);
    mPreviousScreen = INVALID_SCREEN;

    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    mPaddingTop = getPaddingTop();
    mPaddingBottom = getPaddingBottom();
    mPaddingLeft = getPaddingLeft();
    mPaddingRight = getPaddingRight();

    setOverScroll(overscrollMode);
}