Example usage for android.content.res TypedArray getBoolean

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

Introduction

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

Prototype

public boolean getBoolean(@StyleableRes int index, boolean defValue) 

Source Link

Document

Retrieve the boolean value for the attribute at index.

Usage

From source file:ch.berta.fabio.fabprogress.FabProgress.java

private void init(@NonNull Context context, @NonNull AttributeSet attrs, int defStyleAttr) {
    mArcWidth = getResources().getDimensionPixelSize(R.dimen.fp_progress_arc_stroke_width);
    mFabIcon = getDrawable();//from  w  w w .  jav  a2s.  c o m
    mAccentColor = fetchAccentColor();

    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FabProgress, defStyleAttr, 0);
    try {
        mArcColor = attr.getColor(R.styleable.FabProgress_fp_arcColor,
                ContextCompat.getColor(context, R.color.green_500));
        mUseRoundedStroke = attr.getBoolean(R.styleable.FabProgress_fp_roundedStroke, false);
        mCompleteIcon = attr.getDrawable(R.styleable.FabProgress_fp_finalIcon);
        if (mCompleteIcon == null) {
            mCompleteIcon = ContextCompat.getDrawable(getContext(), R.drawable.ic_done_white_24dp);
        }
        mIsReusable = attr.getBoolean(R.styleable.FabProgress_fp_reusable, false);
    } finally {
        attr.recycle();
    }

    if (!Utils.isRunningLollipopAndHigher()) {
        setFakeShadowPadding(context, attrs, defStyleAttr);
    }

    setupPaint();
    setupAnimations();
}

From source file:android.support.designox.widget.BottomSheetBehavior.java

/**
 * Default constructor for inflating BottomSheetBehaviors from layout.
 *
 * @param context The {@link Context}.// w ww. j a v a2 s  . co  m
 * @param attrs The {@link AttributeSet}.
 */
public BottomSheetBehavior(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BottomSheetBehavior_Params);
    setPeekHeight(a.getDimensionPixelSize(R.styleable.BottomSheetBehavior_Params_behavior_peekHeight_ox, 0));
    setHideable(a.getBoolean(R.styleable.BottomSheetBehavior_Params_behavior_hideable_ox, false));
    a.recycle();
    ViewConfiguration configuration = ViewConfiguration.get(context);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}

From source file:com.dl7.commonlib.views.RippleView.java

/**
 * Method that initializes all fields and sets listeners
 *
 * @param context Context used to create this view
 * @param attrs Attribute used to initialize fields
 *//*  w w  w .j a  va 2s.c om*/
private void init(final Context context, final AttributeSet attrs) {
    if (isInEditMode())
        return;

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleView);
    rippleColor = typedArray.getColor(R.styleable.RippleView_rv_color,
            ContextCompat.getColor(context, R.color.rippelColor));
    rippleType = typedArray.getInt(R.styleable.RippleView_rv_type, 0);
    hasToZoom = typedArray.getBoolean(R.styleable.RippleView_rv_zoom, false);
    isCentered = typedArray.getBoolean(R.styleable.RippleView_rv_centered, false);
    rippleDuration = typedArray.getInteger(R.styleable.RippleView_rv_rippleDuration, rippleDuration);
    frameRate = typedArray.getInteger(R.styleable.RippleView_rv_framerate, frameRate);
    rippleAlpha = typedArray.getInteger(R.styleable.RippleView_rv_alpha, rippleAlpha);
    ripplePadding = typedArray.getDimensionPixelSize(R.styleable.RippleView_rv_ripplePadding, 0);
    canvasHandler = new Handler();
    zoomScale = typedArray.getFloat(R.styleable.RippleView_rv_zoomScale, 1.03f);
    zoomDuration = typedArray.getInt(R.styleable.RippleView_rv_zoomDuration, 200);
    isListMode = typedArray.getBoolean(R.styleable.RippleView_rv_listMode, false);
    typedArray.recycle();
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL);
    paint.setColor(rippleColor);
    paint.setAlpha(rippleAlpha);
    this.setWillNotDraw(false);

    gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public void onLongPress(MotionEvent event) {
            super.onLongPress(event);
            animateRipple(event);
            sendClickEvent(true);
            lastLongPressX = (int) event.getX();
            lastLongPressY = (int) event.getY();
            rippleStatus = RIPPLE_LONG_PRESS;
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            return true;
        }

        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            return true;
        }
    });

    this.setDrawingCacheEnabled(true);
    this.setClickable(true);
    this.touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
}

From source file:com.android.launcher3.BubbleTextView.java

public BubbleTextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mLauncher = Launcher.getLauncher(context);
    DeviceProfile grid = mLauncher.getDeviceProfile();

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BubbleTextView, defStyle, 0);
    mCustomShadowsEnabled = a.getBoolean(R.styleable.BubbleTextView_customShadows, true);
    mLayoutHorizontal = a.getBoolean(R.styleable.BubbleTextView_layoutHorizontal, false);
    mDeferShadowGenerationOnTouch = a.getBoolean(R.styleable.BubbleTextView_deferShadowGeneration, false);

    int display = a.getInteger(R.styleable.BubbleTextView_iconDisplay, DISPLAY_WORKSPACE);
    int defaultIconSize = grid.iconSizePx;
    if (display == DISPLAY_WORKSPACE) {
        setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx);
    } else if (display == DISPLAY_ALL_APPS) {
        setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
        setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx);
        defaultIconSize = grid.allAppsIconSizePx;
    } else if (display == DISPLAY_FOLDER) {
        setCompoundDrawablePadding(grid.folderChildDrawablePaddingPx);
    }/*from w w w.java2  s  .co  m*/
    mCenterVertically = a.getBoolean(R.styleable.BubbleTextView_centerVertically, false);

    if (Utilities.getIconSizePrefEnabled(context) == -1) {
        mIconSize = a.getDimensionPixelSize(R.styleable.BubbleTextView_iconSizeOverride, defaultIconSize);
        Utilities.setIconSizeValue(context, mIconSize);
        a.recycle();
    } else {
        mIconSize = Utilities.getIconSizePrefEnabled(context);
    }

    if (mCustomShadowsEnabled) {
        // Draw the background itself as the parent is drawn twice.
        mBackground = getBackground();
        setBackground(null);

        // Set shadow layer as the larger shadow to that the textView does not clip the shadow.
        float density = getResources().getDisplayMetrics().density;
        setShadowLayer(density * AMBIENT_SHADOW_RADIUS, 0, 0, AMBIENT_SHADOW_COLOR);
    } else {
        mBackground = null;
    }

    mLongPressHelper = new CheckLongPressHelper(this);
    mStylusEventHelper = new StylusEventHelper(new SimpleOnStylusPressListener(this), this);

    mOutlineHelper = HolographicOutlineHelper.obtain(getContext());
    setAccessibilityDelegate(mLauncher.getAccessibilityDelegate());

}

From source file:com.demos.support_23_2.MyBottomBehavior.java

/**
 * Default constructor for inflating BottomSheetBehaviors from layout.
 *
 * @param context The {@link Context}.//  w  w w.  j a  va2s. c  om
 * @param attrs   The {@link AttributeSet}.
 */
public MyBottomBehavior(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BottomSheetBehavior_Params);
    setPeekHeight(a.getDimensionPixelSize(R.styleable.BottomSheetBehavior_Params_behavior_peekHeight, 0));
    setHideable(a.getBoolean(R.styleable.BottomSheetBehavior_Params_behavior_hideable, false));
    a.recycle();
    ViewConfiguration configuration = ViewConfiguration.get(context);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}

From source file:com.facebook.widget.LoginTextView.java

private void parseAttributes(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.com_facebook_login_view);
    confirmLogout = a.getBoolean(R.styleable.com_facebook_login_view_confirm_logout, true);
    fetchUserInfo = a.getBoolean(R.styleable.com_facebook_login_view_fetch_user_info, true);
    a.recycle();//ww  w . j av  a 2 s  .  c o  m
}

From source file:com.adithyaupadhya.uimodule.roundcornerprogressbar.BaseRoundCornerProgressBar.java

private void setupStyleable(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RoundCornerProgress);

    radius = (int) typedArray.getDimension(R.styleable.RoundCornerProgress_rcRadius,
            dp2px(DEFAULT_PROGRESS_RADIUS));
    padding = (int) typedArray.getDimension(R.styleable.RoundCornerProgress_rcBackgroundPadding,
            dp2px(DEFAULT_BACKGROUND_PADDING));

    isReverse = typedArray.getBoolean(R.styleable.RoundCornerProgress_rcReverse, false);

    max = typedArray.getFloat(R.styleable.RoundCornerProgress_rcMax, DEFAULT_MAX_PROGRESS);
    progress = typedArray.getFloat(R.styleable.RoundCornerProgress_rcProgress, DEFAULT_PROGRESS);
    secondaryProgress = typedArray.getFloat(R.styleable.RoundCornerProgress_rcSecondaryProgress,
            DEFAULT_SECONDARY_PROGRESS);

    int colorBackgroundDefault = ContextCompat.getColor(context,
            R.color.round_corner_progress_bar_background_default);
    colorBackground = typedArray.getColor(R.styleable.RoundCornerProgress_rcBackgroundColor,
            colorBackgroundDefault);/*from  w  w  w  .ja  v  a 2 s. com*/
    int colorProgressDefault = ContextCompat.getColor(context,
            R.color.round_corner_progress_bar_progress_default);
    colorProgress = typedArray.getColor(R.styleable.RoundCornerProgress_rcProgressColor, colorProgressDefault);
    int colorSecondaryProgressDefault = ContextCompat.getColor(context,
            R.color.round_corner_progress_bar_secondary_progress_default);
    colorSecondaryProgress = typedArray.getColor(R.styleable.RoundCornerProgress_rcSecondaryProgressColor,
            colorSecondaryProgressDefault);
    typedArray.recycle();

    initStyleable(context, attrs);
}

From source file:com.cheng.animationstudy.customview.googleimitatecode.DiySwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 * @param context/* w  ww.ja v  a 2  s. com*/
 * @param attrs
 */
public DiySwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mProgressBar = new DiySwipeProgressBar(this);
    mProgressBarBottom = new DiySwipeProgressBar(this);
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();
}

From source file:com.cdwx.moka.widget.SwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context/*from   w w  w. ja v  a 2s .c o m*/
 * @param attrs
 */
public SwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mProgressBar = new SwipeProgressBar(this);
    mProgressBarBottom = new SwipeProgressBar(this);
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();
}

From source file:com.example.googleplay.view.SwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 * @param context/*from  w  ww  .j  a v  a  2  s .  c  om*/
 * @param attrs
 */
public SwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mProgressBar = new SwipeProgressBar(this);
    mProgressBarBottom = new SwipeProgressBar(this);
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT);
    System.out.println("mProgressBarHeight" + mProgressBarHeight);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();
}