com.gc.materialdesign.utils.Utils Java Examples
The following examples show how to use
com.gc.materialdesign.utils.Utils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProgressBarCircularIndeterminate.java From MaterialDesignLibrary with Apache License 2.0 | 6 votes |
protected void setAttributes(AttributeSet attrs){ setMinimumHeight(Utils.dpToPx(32, getResources())); setMinimumWidth(Utils.dpToPx(32, getResources())); //Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1); if(bacgroundColor != -1){ setBackgroundColor(getResources().getColor(bacgroundColor)); }else{ // Color by hexadecimal int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); else setBackgroundColor(Color.parseColor("#1E88E5")); } setMinimumHeight(Utils.dpToPx(3, getResources())); }
Example #2
Source File: ProgressBarCircularIndeterminate.java From meiShi with Apache License 2.0 | 6 votes |
protected void setAttributes(AttributeSet attrs){ setMinimumHeight(Utils.dpToPx(32, getResources())); setMinimumWidth(Utils.dpToPx(32, getResources())); //Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1); if(bacgroundColor != -1){ setBackgroundColor(getResources().getColor(bacgroundColor)); }else{ // Color by hexadecimal int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); else setBackgroundColor(Color.parseColor("#1E88E5")); } setMinimumHeight(Utils.dpToPx(3, getResources())); }
Example #3
Source File: Button.java From Social with Apache License 2.0 | 6 votes |
public Bitmap makeCircle() { Bitmap output = Bitmap.createBitmap( getWidth() - Utils.dpToPx(6, getResources()), getHeight() - Utils.dpToPx(7, getResources()), Config.ARGB_8888); Canvas canvas = new Canvas(output); canvas.drawARGB(0, 0, 0, 0); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(rippleColor); canvas.drawCircle(x, y, radius, paint); if (radius > getHeight() / rippleSize) radius += rippleSpeed; if (radius >= getWidth()) { x = -1; y = -1; radius = getHeight() / rippleSize; if (onClickListener != null && clickAfterRipple) onClickListener.onClick(this); } return output; }
Example #4
Source File: ButtonFloat.java From MaterialDesignLibrary with Apache License 2.0 | 6 votes |
public ButtonFloat(Context context, AttributeSet attrs) { super(context, attrs); setBackgroundResource(R.drawable.background_button_float); setBackgroundColor(backgroundColor); sizeRadius = 28; setDefaultProperties(); icon = new ImageView(context); icon.setAdjustViewBounds(true); icon.setScaleType(ScaleType.CENTER_CROP); if(drawableIcon != null) { icon.setImageDrawable(drawableIcon); } LayoutParams params = new LayoutParams(Utils.dpToPx(sizeIcon, getResources()),Utils.dpToPx(sizeIcon, getResources())); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); icon.setLayoutParams(params); addView(icon); }
Example #5
Source File: ButtonFloat.java From Social with Apache License 2.0 | 6 votes |
public ButtonFloat(Context context, AttributeSet attrs) { super(context, attrs); setBackgroundResource(R.drawable.background_button_float); setBackgroundColor(backgroundColor); sizeRadius = 28; setDefaultProperties(); icon = new ImageView(context); icon.setAdjustViewBounds(true); icon.setScaleType(ScaleType.CENTER_CROP); if(drawableIcon != null) { icon.setImageDrawable(drawableIcon); } LayoutParams params = new LayoutParams(Utils.dpToPx(sizeIcon, getResources()), Utils.dpToPx(sizeIcon, getResources())); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); icon.setLayoutParams(params); addView(icon); }
Example #6
Source File: Button.java From MoeGallery with GNU General Public License v3.0 | 6 votes |
public Bitmap makeCircle() { Bitmap output = Bitmap.createBitmap( getWidth() - Utils.dpToPx(6, getResources()), getHeight() - Utils.dpToPx(7, getResources()), Config.ARGB_8888); Canvas canvas = new Canvas(output); canvas.drawARGB(0, 0, 0, 0); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(rippleColor); canvas.drawCircle(x, y, radius, paint); if (radius > getHeight() / rippleSize) radius += rippleSpeed; if (radius >= getWidth()) { x = -1; y = -1; radius = getHeight() / rippleSize; if (onClickListener != null && clickAfterRipple) onClickListener.onClick(this); } return output; }
Example #7
Source File: Button.java From MaterialDesignLibrary with Apache License 2.0 | 6 votes |
public Bitmap makeCircle() { Bitmap output = Bitmap.createBitmap( getWidth() - Utils.dpToPx(6, getResources()), getHeight() - Utils.dpToPx(7, getResources()), Config.ARGB_8888); Canvas canvas = new Canvas(output); canvas.drawARGB(0, 0, 0, 0); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(rippleColor); canvas.drawCircle(x, y, radius, paint); if (radius > getHeight() / rippleSize) radius += rippleSpeed; if (radius >= getWidth()) { x = -1; y = -1; radius = getHeight() / rippleSize; if (onClickListener != null && clickAfterRipple) onClickListener.onClick(this); } return output; }
Example #8
Source File: Button.java From meiShi with Apache License 2.0 | 6 votes |
public Bitmap makeCircle() { Bitmap output = Bitmap.createBitmap( getWidth() - Utils.dpToPx(6, getResources()), getHeight() - Utils.dpToPx(7, getResources()), Config.ARGB_8888); Canvas canvas = new Canvas(output); canvas.drawARGB(0, 0, 0, 0); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(rippleColor); canvas.drawCircle(x, y, radius, paint); if (radius > getHeight() / rippleSize) radius += rippleSpeed; if (radius >= getWidth()) { x = -1; y = -1; radius = getHeight() / rippleSize; if (onClickListener != null && clickAfterRipple) onClickListener.onClick(this); } return output; }
Example #9
Source File: ProgressBarCircularIndeterminate.java From MoeGallery with GNU General Public License v3.0 | 6 votes |
protected void setAttributes(AttributeSet attrs){ setMinimumHeight(Utils.dpToPx(32, getResources())); setMinimumWidth(Utils.dpToPx(32, getResources())); //Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1); if(bacgroundColor != -1){ setBackgroundColor(getResources().getColor(bacgroundColor)); }else{ // Color by hexadecimal int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); else setBackgroundColor(Color.parseColor("#1E88E5")); } setMinimumHeight(Utils.dpToPx(3, getResources())); }
Example #10
Source File: ButtonFloat.java From meiShi with Apache License 2.0 | 6 votes |
public ButtonFloat(Context context, AttributeSet attrs) { super(context, attrs); setBackgroundResource(R.drawable.background_button_float); setBackgroundColor(backgroundColor); sizeRadius = 28; setDefaultProperties(); icon = new ImageView(context); icon.setAdjustViewBounds(true); icon.setScaleType(ScaleType.CENTER_CROP); if(drawableIcon != null) { icon.setImageDrawable(drawableIcon); } LayoutParams params = new LayoutParams(Utils.dpToPx(sizeIcon, getResources()),Utils.dpToPx(sizeIcon, getResources())); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); icon.setLayoutParams(params); addView(icon); }
Example #11
Source File: ButtonFloat.java From MoeGallery with GNU General Public License v3.0 | 6 votes |
public ButtonFloat(Context context, AttributeSet attrs) { super(context, attrs); setBackgroundResource(R.drawable.background_button_float); setBackgroundColor(backgroundColor); sizeRadius = 28; setDefaultProperties(); icon = new ImageView(context); icon.setAdjustViewBounds(true); icon.setScaleType(ScaleType.CENTER_CROP); if (drawableIcon != null) { icon.setImageDrawable(drawableIcon); } RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(Utils.dpToPx(sizeIcon, getResources()), Utils.dpToPx(sizeIcon, getResources())); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); icon.setLayoutParams(params); addView(icon); }
Example #12
Source File: ButtonFloat.java From MaterialDesignLibrary with Apache License 2.0 | 5 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (x != -1) { Rect src = new Rect(0, 0, getWidth(), getHeight()); Rect dst = new Rect(Utils.dpToPx(1, getResources()), Utils.dpToPx(2, getResources()), getWidth()-Utils.dpToPx(1, getResources()), getHeight()-Utils.dpToPx(2, getResources())); canvas.drawBitmap(cropCircle(makeCircle()), src, dst, null); invalidate(); } }
Example #13
Source File: ButtonFloat.java From meiShi with Apache License 2.0 | 5 votes |
protected void setDefaultProperties(){ rippleSpeed = Utils.dpToPx(2, getResources()); rippleSize = Utils.dpToPx(5, getResources()); setMinimumWidth(Utils.dpToPx(sizeRadius*2, getResources())); setMinimumHeight(Utils.dpToPx(sizeRadius*2, getResources())); super.background = R.drawable.background_button_float; // super.setDefaultProperties(); }
Example #14
Source File: ButtonFloat.java From MaterialDesignLibrary with Apache License 2.0 | 5 votes |
protected void setDefaultProperties(){ rippleSpeed = Utils.dpToPx(2, getResources()); rippleSize = Utils.dpToPx(5, getResources()); setMinimumWidth(Utils.dpToPx(sizeRadius*2, getResources())); setMinimumHeight(Utils.dpToPx(sizeRadius*2, getResources())); super.background = R.drawable.background_button_float; // super.setDefaultProperties(); }
Example #15
Source File: ButtonIcon.java From MaterialDesignLibrary with Apache License 2.0 | 5 votes |
public ButtonIcon(Context context, AttributeSet attrs) { super(context, attrs); try { setBackground(new ColorDrawable(getResources().getColor(R.color.transparent))); } catch (NoSuchMethodError e) { setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparent))); } rippleSpeed = Utils.dpToPx(2, getResources()); rippleSize = Utils.dpToPx(5, getResources()); }
Example #16
Source File: Button.java From MaterialDesignLibrary with Apache License 2.0 | 5 votes |
protected void setDefaultProperties() { // Min size setMinimumHeight(Utils.dpToPx(minHeight, getResources())); setMinimumWidth(Utils.dpToPx(minWidth, getResources())); // Background shape setBackgroundResource(background); setBackgroundColor(backgroundColor); }
Example #17
Source File: Slider.java From MaterialDesignLibrary with Apache License 2.0 | 5 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (numberIndicatorResize == false) { LayoutParams params = (LayoutParams) numberIndicator.numberIndicator .getLayoutParams(); params.height = (int) finalSize * 2; params.width = (int) finalSize * 2; numberIndicator.numberIndicator.setLayoutParams(params); } Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(backgroundColor); if (animate) { if (y == 0) y = finalY + finalSize * 2; y -= Utils.dpToPx(6, getResources()); size += Utils.dpToPx(2, getResources()); } canvas.drawCircle( ViewHelper.getX(ball) + Utils.getRelativeLeft((View) ball.getParent()) + ball.getWidth() / 2, y, size, paint); if (animate && size >= finalSize) animate = false; if (animate == false) { ViewHelper .setX(numberIndicator.numberIndicator, (ViewHelper.getX(ball) + Utils.getRelativeLeft((View) ball .getParent()) + ball.getWidth() / 2) - size); ViewHelper.setY(numberIndicator.numberIndicator, y - size); numberIndicator.numberIndicator.setText(value + ""); } invalidate(); }
Example #18
Source File: ButtonFlat.java From MaterialDesignLibrary with Apache License 2.0 | 5 votes |
protected void setDefaultProperties(){ minHeight = 36; minWidth = 88; rippleSize = 3; // Min size setMinimumHeight(Utils.dpToPx(minHeight, getResources())); setMinimumWidth(Utils.dpToPx(minWidth, getResources())); setBackgroundResource(R.drawable.background_transparent); }
Example #19
Source File: Switch.java From MaterialDesignLibrary with Apache License 2.0 | 5 votes |
protected void setAttributes(AttributeSet attrs) { setBackgroundResource(R.drawable.background_transparent); // Set size of view setMinimumHeight(Utils.dpToPx(48, getResources())); setMinimumWidth(Utils.dpToPx(80, getResources())); // Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML, "background", -1); if (bacgroundColor != -1) { setBackgroundColor(getResources().getColor(bacgroundColor)); } else { // Color by hexadecimal int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); } check = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "check", false); eventCheck = check; ball = new Ball(getContext()); RelativeLayout.LayoutParams params = new LayoutParams(Utils.dpToPx(20, getResources()), Utils.dpToPx(20, getResources())); params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); ball.setLayoutParams(params); addView(ball); }
Example #20
Source File: ButtonFloatSmall.java From meiShi with Apache License 2.0 | 5 votes |
protected void setDefaultProperties(){ rippleSpeed = Utils.dpToPx(2, getResources()); rippleSize = 10; // Min size setMinimumHeight(Utils.dpToPx(sizeRadius*2, getResources())); setMinimumWidth(Utils.dpToPx(sizeRadius*2, getResources())); // Background shape setBackgroundResource(R.drawable.background_button_float); // setBackgroundColor(backgroundColor); }
Example #21
Source File: ProgressBarCircularIndeterminate.java From meiShi with Apache License 2.0 | 5 votes |
/** * Draw second animation of view * @param canvas */ private void drawSecondAnimation(Canvas canvas){ if(arcO == limite) arcD+=6; if(arcD >= 290 || arcO > limite){ arcO+=6; arcD-=6; } if(arcO > limite + 290){ limite = arcO; arcO = limite; arcD = 1; } rotateAngle += 4; canvas.rotate(rotateAngle,getWidth()/2, getHeight()/2); Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888); Canvas temp = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(backgroundColor); // temp.drawARGB(0, 0, 0, 255); temp.drawArc(new RectF(0, 0, getWidth(), getHeight()), arcO, arcD, true, paint); Paint transparentPaint = new Paint(); transparentPaint.setAntiAlias(true); transparentPaint.setColor(getResources().getColor(android.R.color.transparent)); transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); temp.drawCircle(getWidth()/2, getHeight()/2, (getWidth()/2)-Utils.dpToPx(4, getResources()), transparentPaint); canvas.drawBitmap(bitmap, 0, 0, new Paint()); }
Example #22
Source File: ProgressBarCircularIndeterminate.java From MaterialDesignLibrary with Apache License 2.0 | 5 votes |
/** * Draw second animation of view * @param canvas */ private void drawSecondAnimation(Canvas canvas){ if(arcO == limite) arcD+=6; if(arcD >= 290 || arcO > limite){ arcO+=6; arcD-=6; } if(arcO > limite + 290){ limite = arcO; arcO = limite; arcD = 1; } rotateAngle += 4; canvas.rotate(rotateAngle,getWidth()/2, getHeight()/2); Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888); Canvas temp = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(backgroundColor); // temp.drawARGB(0, 0, 0, 255); temp.drawArc(new RectF(0, 0, getWidth(), getHeight()), arcO, arcD, true, paint); Paint transparentPaint = new Paint(); transparentPaint.setAntiAlias(true); transparentPaint.setColor(getResources().getColor(android.R.color.transparent)); transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); temp.drawCircle(getWidth()/2, getHeight()/2, (getWidth()/2)-Utils.dpToPx(4, getResources()), transparentPaint); canvas.drawBitmap(bitmap, 0, 0, new Paint()); }
Example #23
Source File: ButtonRectangle.java From MaterialDesignLibrary with Apache License 2.0 | 5 votes |
@Override protected void onDraw(Canvas canvas) { // if(!txtCenter) // centrarTexto(); super.onDraw(canvas); if (x != -1) { Rect src = new Rect(0, 0, getWidth()-Utils.dpToPx(6, getResources()), getHeight()-Utils.dpToPx(7, getResources())); Rect dst = new Rect(Utils.dpToPx(6, getResources()), Utils.dpToPx(6, getResources()), getWidth()-Utils.dpToPx(6, getResources()), getHeight()-Utils.dpToPx(7, getResources())); canvas.drawBitmap(makeCircle(), src, dst, null); invalidate(); } }
Example #24
Source File: ButtonFloat.java From meiShi with Apache License 2.0 | 5 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (x != -1) { Rect src = new Rect(0, 0, getWidth(), getHeight()); Rect dst = new Rect(Utils.dpToPx(1, getResources()), Utils.dpToPx(2, getResources()), getWidth()-Utils.dpToPx(1, getResources()), getHeight()-Utils.dpToPx(2, getResources())); canvas.drawBitmap(cropCircle(makeCircle()), src, dst, null); invalidate(); } }
Example #25
Source File: Switch.java From MaterialDesignLibrary with Apache License 2.0 | 5 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (!placedBall) { placeBall(); } // Crop line to transparent effect if(null == bitmap) { bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888); } Canvas temp = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor((eventCheck) ? backgroundColor : Color.parseColor("#B0B0B0")); paint.setStrokeWidth(Utils.dpToPx(2, getResources())); temp.drawLine(getHeight() / 2, getHeight() / 2, getWidth() - getHeight() / 2, getHeight() / 2, paint); Paint transparentPaint = new Paint(); transparentPaint.setAntiAlias(true); transparentPaint.setColor(getResources().getColor( android.R.color.transparent)); transparentPaint.setXfermode(new PorterDuffXfermode( PorterDuff.Mode.CLEAR)); temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2, ViewHelper.getY(ball) + ball.getHeight() / 2, ball.getWidth() / 2, transparentPaint); canvas.drawBitmap(bitmap, 0, 0, new Paint()); if (press) { paint.setColor((check) ? makePressColor() : Color .parseColor("#446D6D6D")); canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2, getHeight() / 2, getHeight() / 2, paint); } invalidate(); }
Example #26
Source File: ButtonIcon.java From meiShi with Apache License 2.0 | 5 votes |
public ButtonIcon(Context context, AttributeSet attrs) { super(context, attrs); try { setBackground(new ColorDrawable(getResources().getColor(R.color.transparent))); } catch (NoSuchMethodError e) { setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparent))); } rippleSpeed = Utils.dpToPx(2, getResources()); rippleSize = Utils.dpToPx(5, getResources()); }
Example #27
Source File: Button.java From meiShi with Apache License 2.0 | 5 votes |
protected void setDefaultProperties() { // Min size setMinimumHeight(Utils.dpToPx(minHeight, getResources())); setMinimumWidth(Utils.dpToPx(minWidth, getResources())); // Background shape setBackgroundResource(background); setBackgroundColor(backgroundColor); }
Example #28
Source File: Slider.java From meiShi with Apache License 2.0 | 5 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (numberIndicatorResize == false) { LayoutParams params = (LayoutParams) numberIndicator.numberIndicator .getLayoutParams(); params.height = (int) finalSize * 2; params.width = (int) finalSize * 2; numberIndicator.numberIndicator.setLayoutParams(params); } Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(backgroundColor); if (animate) { if (y == 0) y = finalY + finalSize * 2; y -= Utils.dpToPx(6, getResources()); size += Utils.dpToPx(2, getResources()); } canvas.drawCircle( ViewHelper.getX(ball) + Utils.getRelativeLeft((View) ball.getParent()) + ball.getWidth() / 2, y, size, paint); if (animate && size >= finalSize) animate = false; if (animate == false) { ViewHelper .setX(numberIndicator.numberIndicator, (ViewHelper.getX(ball) + Utils.getRelativeLeft((View) ball .getParent()) + ball.getWidth() / 2) - size); ViewHelper.setY(numberIndicator.numberIndicator, y - size); numberIndicator.numberIndicator.setText(getNumberIndicatorValue(value)); } invalidate(); }
Example #29
Source File: ButtonRectangle.java From meiShi with Apache License 2.0 | 5 votes |
@Override protected void onDraw(Canvas canvas) { // if(!txtCenter) // centrarTexto(); super.onDraw(canvas); if (x != -1) { Rect src = new Rect(0, 0, getWidth()-Utils.dpToPx(6, getResources()), getHeight()-Utils.dpToPx(7, getResources())); Rect dst = new Rect(Utils.dpToPx(6, getResources()), Utils.dpToPx(6, getResources()), getWidth()-Utils.dpToPx(6, getResources()), getHeight()-Utils.dpToPx(7, getResources())); canvas.drawBitmap(makeCircle(), src, dst, null); invalidate(); } }
Example #30
Source File: Switch.java From Social with Apache License 2.0 | 5 votes |
protected void setAttributes(AttributeSet attrs) { setBackgroundResource(R.drawable.background_transparent); // Set size of view setMinimumHeight(Utils.dpToPx(48, getResources())); setMinimumWidth(Utils.dpToPx(80, getResources())); // Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML, "background", -1); if (bacgroundColor != -1) { setBackgroundColor(getResources().getColor(bacgroundColor)); } else { // Color by hexadecimal int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); } check = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "check", false); eventCheck = check; ball = new Ball(getContext()); RelativeLayout.LayoutParams params = new LayoutParams(Utils.dpToPx(20, getResources()), Utils.dpToPx(20, getResources())); params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); ball.setLayoutParams(params); addView(ball); }