List of usage examples for android.content.res TypedArray getInteger
public int getInteger(@StyleableRes int index, int defValue)
From source file:com.android.andryyu.lifehelper.widget.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 *//*from ww w .ja v a 2 s . c o m*/ 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, Color.parseColor("#33626262")); 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.kadavelil.jossy.mapalarm.SeekArc.java
private void init(Context context, AttributeSet attrs, int defStyle) { Log.d(TAG, "Initialising SeekArc"); final Resources res = getResources(); float density = context.getResources().getDisplayMetrics().density; // Defaults, may need to link this into theme settings int arcColor = res.getColor(R.color.progress_gray); int progressColor = res.getColor(R.color.accent_700); int thumbHalfheight = 0; int thumbHalfWidth = 0; mThumb = ContextCompat.getDrawable(context, R.drawable.seek_arc_control_selector); // Convert progress width to pixels for current density mProgressWidth = (int) (mProgressWidth * density); if (attrs != null) { // Attribute initialization final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SeekArc, defStyle, 0); Drawable thumb = a.getDrawable(R.styleable.SeekArc_thumb); if (thumb != null) { mThumb = thumb;/* www . j a v a 2s. com*/ } thumbHalfheight = (int) mThumb.getIntrinsicHeight() / 2; thumbHalfWidth = (int) mThumb.getIntrinsicWidth() / 2; mThumb.setBounds(-thumbHalfWidth, -thumbHalfheight, thumbHalfWidth, thumbHalfheight); mMax = a.getInteger(R.styleable.SeekArc_max, mMax); mProgress = a.getInteger(R.styleable.SeekArc_progress, mProgress); mProgressWidth = (int) a.getDimension(R.styleable.SeekArc_progressWidth, mProgressWidth); mArcWidth = (int) a.getDimension(R.styleable.SeekArc_arcWidth, mArcWidth); mStartAngle = a.getInt(R.styleable.SeekArc_startAngle, mStartAngle); mSweepAngle = a.getInt(R.styleable.SeekArc_sweepAngle, mSweepAngle); mRotation = a.getInt(R.styleable.SeekArc_rotation, mRotation); mRoundedEdges = a.getBoolean(R.styleable.SeekArc_roundEdges, mRoundedEdges); mTouchInside = a.getBoolean(R.styleable.SeekArc_touchInside, mTouchInside); mClockwise = a.getBoolean(R.styleable.SeekArc_clockwise, mClockwise); arcColor = a.getColor(R.styleable.SeekArc_arcColor, arcColor); progressColor = a.getColor(R.styleable.SeekArc_progressColor, progressColor); a.recycle(); } mProgress = (mProgress > mMax) ? mMax : mProgress; mProgress = (mProgress < 0) ? 0 : mProgress; mSweepAngle = (mSweepAngle > 360) ? 360 : mSweepAngle; mSweepAngle = (mSweepAngle < 0) ? 0 : mSweepAngle; mStartAngle = (mStartAngle > 360) ? 0 : mStartAngle; mStartAngle = (mStartAngle < 0) ? 0 : mStartAngle; mArcPaint = new Paint(); mArcPaint.setColor(arcColor); mArcPaint.setAntiAlias(true); mArcPaint.setStyle(Paint.Style.STROKE); mArcPaint.setStrokeWidth(mArcWidth); //mArcPaint.setAlpha(45); mProgressPaint = new Paint(); mProgressPaint.setColor(progressColor); mProgressPaint.setAntiAlias(true); mProgressPaint.setStyle(Paint.Style.STROKE); mProgressPaint.setStrokeWidth(mProgressWidth); if (mRoundedEdges) { mArcPaint.setStrokeCap(Paint.Cap.ROUND); mProgressPaint.setStrokeCap(Paint.Cap.ROUND); } }
From source file:mbanje.kurt.fabbutton.FabButton.java
protected void init(Context context, AttributeSet attrs, int defStyle) { View v = View.inflate(context, R.layout.widget_fab_button, this); setClipChildren(false);//from w w w . j a v a2 s. co m circle = (CircleImageView) v.findViewById(R.id.fabbutton_circle); ring = (ProgressRingView) v.findViewById(R.id.fabbutton_ring); circle.setFabViewListener(this); ring.setFabViewListener(this); int color = Color.BLACK; int progressColor = Color.BLACK; int animDuration = 4000; int icon = -1; float maxProgress = 0; float progress = 0; if (attrs != null) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView); color = a.getColor(R.styleable.CircleImageView_android_color, Color.BLACK); progressColor = a.getColor(R.styleable.CircleImageView_fbb_progressColor, Color.BLACK); progress = a.getFloat(R.styleable.CircleImageView_android_progress, 0f); maxProgress = a.getFloat(R.styleable.CircleImageView_android_max, 100f); indeterminate = a.getBoolean(R.styleable.CircleImageView_android_indeterminate, false); autostartanim = a.getBoolean(R.styleable.CircleImageView_fbb_autoStart, true); animDuration = a.getInteger(R.styleable.CircleImageView_android_indeterminateDuration, animDuration); icon = a.getResourceId(R.styleable.CircleImageView_android_src, icon); ringWidthRatio = a.getFloat(R.styleable.CircleImageView_fbb_progressWidthRatio, ringWidthRatio); endBitmapResource = a.getResourceId(R.styleable.CircleImageView_fbb_endBitmap, R.drawable.ic_fab_complete); showEndBitmap = a.getBoolean(R.styleable.CircleImageView_fbb_showEndBitmap, false); hideProgressOnComplete = a.getBoolean(R.styleable.CircleImageView_fbb_hideProgressOnComplete, false); circle.setShowShadow(a.getBoolean(R.styleable.CircleImageView_fbb_showShadow, true)); a.recycle(); } circle.setColor(color); circle.setShowEndBitmap(showEndBitmap); circle.setRingWidthRatio(ringWidthRatio); ring.setProgressColor(progressColor); ring.setProgress(progress, true); ring.setMaxProgress(maxProgress); ring.setAutostartanim(autostartanim); ring.setAnimDuration(animDuration); ring.setRingWidthRatio(ringWidthRatio); ring.setIndeterminate(indeterminate); if (icon != -1) { circle.setIcon(icon, endBitmapResource); } }
From source file:mbanje.kurt.fabbutton.FabButton.java
protected void init(Context context, AttributeSet attrs, int defStyle) { View v = View.inflate(context, R.layout.widget_fab_button, this); setClipChildren(false);//ww w . j a v a 2 s .c o m circle = (CircleImageView) v.findViewById(R.id.fabbutton_circle); ring = (ProgressRingView) v.findViewById(R.id.fabbutton_ring); circle.setFabViewListener(this); ring.setFabViewListener(this); int color = Color.BLACK; int progressColor = Color.BLACK; int animDuration = 4000; int icon = -1; float maxProgress = 0; float progress = 0; if (attrs != null) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView); color = a.getColor(R.styleable.CircleImageView_android_color, Color.BLACK); progressColor = a.getColor(R.styleable.CircleImageView_fbb_progressColor, Color.BLACK); progress = a.getFloat(R.styleable.CircleImageView_android_progress, 0f); maxProgress = a.getFloat(R.styleable.CircleImageView_android_max, 100f); indeterminate = a.getBoolean(R.styleable.CircleImageView_android_indeterminate, false); autostartanim = a.getBoolean(R.styleable.CircleImageView_fbb_autoStart, true); animDuration = a.getInteger(R.styleable.CircleImageView_android_indeterminateDuration, animDuration); icon = a.getResourceId(R.styleable.CircleImageView_android_src, icon); ringWidthRatio = a.getFloat(R.styleable.CircleImageView_fbb_progressWidthRatio, ringWidthRatio); endBitmapResource = a.getResourceId(R.styleable.CircleImageView_fbb_endBitmap, R.drawable.ic_fab_complete); showEndBitmap = a.getBoolean(R.styleable.CircleImageView_fbb_showEndBitmap, false); hideProgressOnComplete = a.getBoolean(R.styleable.CircleImageView_fbb_hideProgressOnComplete, false); circle.setShowShadow(a.getBoolean(R.styleable.CircleImageView_fbb_showShadow, true)); a.recycle(); } circle.setColor(color); circle.setShowEndBitmap(showEndBitmap); circle.setRingWidthRatio(ringWidthRatio); ring.setProgressColor(progressColor); ring.setProgress(progress); ring.setMaxProgress(maxProgress); ring.setAutostartanim(autostartanim); ring.setAnimDuration(animDuration); ring.setRingWidthRatio(ringWidthRatio); ring.setIndeterminate(indeterminate); if (icon != -1) { circle.setIcon(icon, endBitmapResource); } }
From source file:com.github.ppamorim.dragger.DraggerView.java
private void initializeAttributes(AttributeSet attrs) { TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.dragger_layout); this.dragLimit = attributes.getFloat(R.styleable.dragger_layout_drag_limit, DEFAULT_DRAG_LIMIT); this.dragPosition = DraggerPosition.getDragPosition( attributes.getInt(R.styleable.dragger_layout_drag_position, DEFAULT_DRAG_POSITION)); this.tension = attributes.getInteger(R.styleable.dragger_layout_tension, DEFAULT_TENSION); this.friction = attributes.getInteger(R.styleable.dragger_layout_friction, DEFAULT_FRICTION); this.attributes = attributes; }
From source file:com.center.mycode.view.swipelayout.SwipeRevealLayout.java
private void init(Context context, AttributeSet attrs) { if (attrs != null && context != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, com.center.mycode.R.styleable.SwipeRevealLayout, 0, 0); mDragEdge = a.getInteger(com.center.mycode.R.styleable.SwipeRevealLayout_dragEdge, DRAG_EDGE_LEFT); mMinFlingVelocity = a.getInteger(com.center.mycode.R.styleable.SwipeRevealLayout_flingVelocity, DEFAULT_MIN_FLING_VELOCITY); mMode = a.getInteger(com.center.mycode.R.styleable.SwipeRevealLayout_mode, MODE_NORMAL); }//from w ww . j ava2s . c o m mDragHelper = ViewDragHelper.create(this, 1.0f, mDragHelperCallback); mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_ALL); mGestureDetector = new GestureDetectorCompat(context, mGestureListener); }
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 *//*from w w w.ja va 2 s . c o m*/ 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:de.mrapp.android.preference.AbstractColorPickerPreference.java
/** * Obtains the format, which should be used to print a textual representation of the * preference's color, from a specific typed array. * * @param typedArray// w ww. j a v a2 s .c o m * The typed array, the color format should be obtained from, as an instance of the * class {@link TypedArray}. The typed array may not be null */ private void obtainColorFormat(@NonNull final TypedArray typedArray) { int defaultValue = getContext().getResources() .getInteger(R.integer.color_picker_preference_default_color_format); setColorFormat(ColorFormat.fromValue( typedArray.getInteger(R.styleable.AbstractColorPickerPreference_colorFormat, defaultValue))); }
From source file:de.mrapp.android.preference.AbstractColorPickerPreference.java
/** * Obtains the shape of the preview of the preference's color from a specific typed array. * * @param typedArray/* w w w.java 2 s. co m*/ * The typed array, the shape should be obtained from, as an instance of the class * {@link TypedArray}. The typed array may not be null */ private void obtainPreviewShape(@NonNull final TypedArray typedArray) { int defaultValue = getContext().getResources() .getInteger(R.integer.color_picker_preference_default_preview_shape); setPreviewShape(PreviewShape.fromValue( typedArray.getInteger(R.styleable.AbstractColorPickerPreference_previewShape, defaultValue))); }
From source file:com.adherence.adherence.SwipeRevealLayout.java
private void init(Context context, AttributeSet attrs) { if (attrs != null && context != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SwipeRevealLayout, 0, 0); mDragEdge = a.getInteger(R.styleable.SwipeRevealLayout_dragEdge, DRAG_EDGE_LEFT); mMinFlingVelocity = a.getInteger(R.styleable.SwipeRevealLayout_flingVelocity, DEFAULT_MIN_FLING_VELOCITY); mMode = a.getInteger(R.styleable.SwipeRevealLayout_mode, MODE_NORMAL); mMinDistRequestDisallowParent = a.getDimensionPixelSize( R.styleable.SwipeRevealLayout_minDistRequestDisallowParent, dpToPx(DEFAULT_MIN_DIST_REQUEST_DISALLOW_PARENT)); }//from w w w .j a v a2s . co m mDragHelper = ViewDragHelper.create(this, 1.0f, mDragHelperCallback); mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_ALL); mGestureDetector = new GestureDetectorCompat(context, mGestureListener); }