com.gc.materialdesign.R Java Examples

The following examples show how to use com.gc.materialdesign.R. 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: ProgressWheel.java    From meiShi with Apache License 2.0 6 votes vote down vote up
/**
 * Parse the attributes passed to the view from the XML
 *
 * @param a the attributes to parse
 */
private void parseAttributes(TypedArray a) {
    barWidth = (int) a.getDimension(R.styleable.ProgressWheel_pwBarWidth, barWidth);
    rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_pwRimWidth, rimWidth);
    spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_pwSpinSpeed, spinSpeed);
    barLength = (int) a.getDimension(R.styleable.ProgressWheel_pwBarLength, barLength);

    delayMillis = a.getInteger(R.styleable.ProgressWheel_pwDelayMillis, delayMillis);
    if (delayMillis < 0) { delayMillis = 10; }

    // Only set the text if it is explicitly defined
    if (a.hasValue(R.styleable.ProgressWheel_pwText)) {
        setText(a.getString(R.styleable.ProgressWheel_pwText));
    }

    barColor = a.getColor(R.styleable.ProgressWheel_pwBarColor, barColor);
    textColor = a.getColor(R.styleable.ProgressWheel_pwTextColor, textColor);
    rimColor = a.getColor(R.styleable.ProgressWheel_pwRimColor, rimColor);
    circleColor = a.getColor(R.styleable.ProgressWheel_pwCircleColor, circleColor);
    contourColor = a.getColor(R.styleable.ProgressWheel_pwContourColor, contourColor);

    textSize = (int) a.getDimension(R.styleable.ProgressWheel_pwTextSize, textSize);
    contourSize = a.getDimension(R.styleable.ProgressWheel_pwContourSize, contourSize);

    a.recycle();
}
 
Example #2
Source File: Slider.java    From meiShi with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.number_indicator_spinner);
    setCanceledOnTouchOutside(false);
    RelativeLayout content = (RelativeLayout) this
            .findViewById(R.id.number_indicator_spinner_content);
    indicator = new Indicator(this.getContext());
    content.addView(indicator);
    numberIndicator = new TextView(getContext());
    numberIndicator.setTextColor(Color.WHITE);
    numberIndicator.setGravity(Gravity.CENTER);
    content.addView(numberIndicator);
    indicator.setLayoutParams(new RelativeLayout.LayoutParams(
            LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT));
}
 
Example #3
Source File: Card.java    From MoeGallery with GNU General Public License v3.0 6 votes vote down vote up
protected void setAttributes(AttributeSet attrs){
	
	setBackgroundResource(R.drawable.background_button_rectangle);
	//Set background Color
	// Color by resource
	int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1);
	if(bacgroundColor != -1){
		setBackgroundColor(getResources().getColor(bacgroundColor));
	}else{
		// Color by hexadecimal
		String background = attrs.getAttributeValue(ANDROIDXML,"background");
		if(background != null)
			setBackgroundColor(Color.parseColor(background));
		else
			setBackgroundColor(this.backgroundColor);
	}
}
 
Example #4
Source File: ButtonFloat.java    From MoeGallery with GNU General Public License v3.0 6 votes vote down vote up
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 #5
Source File: Slider.java    From MoeGallery with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.number_indicator_spinner);
    setCanceledOnTouchOutside(false);

    RelativeLayout content = (RelativeLayout) this
            .findViewById(R.id.number_indicator_spinner_content);
    indicator = new Indicator(this.getContext());
    content.addView(indicator);

    numberIndicator = new TextView(getContext());
    numberIndicator.setTextColor(Color.WHITE);
    numberIndicator.setGravity(Gravity.CENTER);
    content.addView(numberIndicator);

    indicator.setLayoutParams(new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT,
            RelativeLayout.LayoutParams.FILL_PARENT));
}
 
Example #6
Source File: ButtonFloat.java    From meiShi with Apache License 2.0 6 votes vote down vote up
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 #7
Source File: Slider.java    From MaterialDesignLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.number_indicator_spinner);
    setCanceledOnTouchOutside(false);

    RelativeLayout content = (RelativeLayout) this
            .findViewById(R.id.number_indicator_spinner_content);
    indicator = new Indicator(this.getContext());
    content.addView(indicator);

    numberIndicator = new TextView(getContext());
    numberIndicator.setTextColor(Color.WHITE);
    numberIndicator.setGravity(Gravity.CENTER);
    content.addView(numberIndicator);

    indicator.setLayoutParams(new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT,
            RelativeLayout.LayoutParams.FILL_PARENT));
}
 
Example #8
Source File: ProgressDialog.java    From meiShi with Apache License 2.0 5 votes vote down vote up
@Override
  protected void onCreate(Bundle savedInstanceState) {
	requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.progress_dialog);
    
	view = (RelativeLayout)findViewById(R.id.contentDialog);
	backView = (RelativeLayout)findViewById(R.id.dialog_rootView);
	backView.setOnTouchListener(new OnTouchListener() {
		
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			if (event.getX() < view.getLeft() 
					|| event.getX() >view.getRight()
					|| event.getY() > view.getBottom() 
					|| event.getY() < view.getTop()) {
				dismiss();
			}
			return false;
		}
	});
	
    this.titleTextView = (TextView) findViewById(R.id.title);
    setTitle(title);
    if(progressColor != -1){
    	ProgressBarCircularIndeterminate progressBarCircularIndeterminate = (ProgressBarCircularIndeterminate) findViewById(R.id.progressBarCircularIndetermininate);
    	progressBarCircularIndeterminate.setBackgroundColor(progressColor);
    }
    
    
}
 
Example #9
Source File: Dialog.java    From MaterialDesignLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public void show() {
	// TODO 自动生成的方法存根
	super.show();
	// set dialog enter animations
	view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_main_show_amination));
	backView.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_root_show_amin));
}
 
Example #10
Source File: Switch.java    From MaterialDesignLibrary with Apache License 2.0 5 votes vote down vote up
@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 #11
Source File: Switch.java    From MaterialDesignLibrary with Apache License 2.0 5 votes vote down vote up
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 #12
Source File: Dialog.java    From meiShi with Apache License 2.0 5 votes vote down vote up
@Override
public void show() {
	// TODO 自动生成的方法存根
	super.show();
	// set dialog enter animations
	view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_main_show_amination));
	backView.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_root_show_amin));
}
 
Example #13
Source File: SnackBar.java    From meiShi with Apache License 2.0 5 votes vote down vote up
@Override
public void show() {
	super.show();
	view.setVisibility(View.VISIBLE);
	view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.snackbar_show_animation));
	if (!mIndeterminate) {
	    dismissTimer.start();
	}
}
 
Example #14
Source File: SnackBar.java    From MaterialDesignLibrary with Apache License 2.0 5 votes vote down vote up
@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.snackbar);
    setCanceledOnTouchOutside(false);
    ((TextView)findViewById(R.id.text)).setText(text); 
    ((TextView)findViewById(R.id.text)).setTextSize(textSize); //set textSize
	button = (ButtonFlat) findViewById(R.id.buttonflat);
	if(text == null || onClickListener == null){
		button.setVisibility(View.GONE);
	}else{
		button.setText(buttonText);
		button.setBackgroundColor(backgroundButton);
		
		button.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				dismiss();
				onClickListener.onClick(v);
			}
		});
	}
	view = findViewById(R.id.snackbar);
	view.setBackgroundColor(backgroundSnackBar);
}
 
Example #15
Source File: SnackBar.java    From meiShi with Apache License 2.0 5 votes vote down vote up
public SnackBar(Activity activity, String text, String buttonText, View.OnClickListener onClickListener) {
	super(activity, android.R.style.Theme_Translucent);
	this.activity = activity;
	this.text = text;
	this.buttonText = buttonText;
	this.onClickListener = onClickListener;
}
 
Example #16
Source File: CheckBox.java    From meiShi with Apache License 2.0 5 votes vote down vote up
public void setChecked(boolean check) {
	invalidate();
	this.check = check;
	setPressed(false);
	changeBackgroundColor(getResources().getColor(
			android.R.color.transparent));
	if (check) {
		step = 0;
	}
	if (check)
		checkView.changeBackground();

}
 
Example #17
Source File: CheckBox.java    From meiShi with Apache License 2.0 5 votes vote down vote up
public void changeBackground() {
	if (check) {
		setBackgroundResource(R.drawable.background_checkbox_check);
		LayerDrawable layer = (LayerDrawable) getBackground();
		GradientDrawable shape = (GradientDrawable) layer
				.findDrawableByLayerId(R.id.shape_bacground);
		shape.setColor(backgroundColor);
	} else {
		setBackgroundResource(R.drawable.background_checkbox_uncheck);
	}
}
 
Example #18
Source File: Switch.java    From MaterialDesignLibrary with Apache License 2.0 5 votes vote down vote up
public void changeBackground() {
	if (eventCheck) {
		setBackgroundResource(R.drawable.background_checkbox);
		LayerDrawable layer = (LayerDrawable) getBackground();
		GradientDrawable shape = (GradientDrawable) layer
				.findDrawableByLayerId(R.id.shape_bacground);
		shape.setColor(backgroundColor);
	} else {
		setBackgroundResource(R.drawable.background_switch_ball_uncheck);
	}
}
 
Example #19
Source File: Switch.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
@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 #20
Source File: Button.java    From meiShi with Apache License 2.0 5 votes vote down vote up
public void setBackgroundColor(int color) {
	this.backgroundColor = color;
	if (isEnabled())
		beforeBackground = backgroundColor;
	try {
		LayerDrawable layer = (LayerDrawable) getBackground();
		GradientDrawable shape = (GradientDrawable) layer
				.findDrawableByLayerId(R.id.shape_bacground);
		shape.setColor(backgroundColor);
		rippleColor = makePressColor();
	} catch (Exception ex) {
		// Without bacground
	}
}
 
Example #21
Source File: CheckBox.java    From meiShi with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
	invalidate();
	if (isEnabled()) {
		isLastTouch = true;
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			changeBackgroundColor((check) ? makePressColor() : Color
					.parseColor("#446D6D6D"));
		} else if (event.getAction() == MotionEvent.ACTION_UP) {
			changeBackgroundColor(getResources().getColor(
					android.R.color.transparent));
			press = false;
			if ((event.getX() <= getWidth() && event.getX() >= 0)
					&& (event.getY() <= getHeight() && event.getY() >= 0)) {
				isLastTouch = false;
				check = !check;
				if (onCheckListener != null)
					onCheckListener.onCheck(CheckBox.this, check);
				if (check) {
					step = 0;
				}
				if (check)
					checkView.changeBackground();
			}
		}
	}
	return true;
}
 
Example #22
Source File: Slider.java    From meiShi with Apache License 2.0 5 votes vote down vote up
public void changeBackground() {
    if (value != min) {
        setBackgroundResource(R.drawable.background_checkbox);
        LayerDrawable layer = (LayerDrawable) getBackground();
        GradientDrawable shape = (GradientDrawable) layer
                .findDrawableByLayerId(R.id.shape_bacground);
        shape.setColor(backgroundColor);
    } else {
        setBackgroundResource(R.drawable.background_switch_ball_uncheck);
    }
}
 
Example #23
Source File: CheckBox.java    From MaterialDesignLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
	invalidate();
	if (isEnabled()) {
		isLastTouch = true;
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			changeBackgroundColor((check) ? makePressColor() : Color
					.parseColor("#446D6D6D"));
		} else if (event.getAction() == MotionEvent.ACTION_UP) {
			changeBackgroundColor(getResources().getColor(
					android.R.color.transparent));
			press = false;
			if ((event.getX() <= getWidth() && event.getX() >= 0)
					&& (event.getY() <= getHeight() && event.getY() >= 0)) {
				isLastTouch = false;
				check = !check;
				if (onCheckListener != null)
					onCheckListener.onCheck(CheckBox.this, check);
				if (check) {
					step = 0;
				}
				if (check)
					checkView.changeBackground();
			}
		}
	}
	return true;
}
 
Example #24
Source File: ButtonFlat.java    From meiShi with Apache License 2.0 5 votes vote down vote up
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 #25
Source File: Switch.java    From meiShi with Apache License 2.0 5 votes vote down vote up
public void changeBackground() {
	if (eventCheck) {
		setBackgroundResource(R.drawable.background_checkbox);
		LayerDrawable layer = (LayerDrawable) getBackground();
		GradientDrawable shape = (GradientDrawable) layer
				.findDrawableByLayerId(R.id.shape_bacground);
		shape.setColor(backgroundColor);
	} else {
		setBackgroundResource(R.drawable.background_switch_ball_uncheck);
	}
}
 
Example #26
Source File: SnackBar.java    From MaterialDesignLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public void show() {
	super.show();
	view.setVisibility(View.VISIBLE);
	view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.snackbar_show_animation));
	if (!mIndeterminate) {
	    dismissTimer.start();
	}
}
 
Example #27
Source File: Switch.java    From meiShi with Apache License 2.0 5 votes vote down vote up
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 #28
Source File: ColorSelector.java    From MaterialDesignLibrary with Apache License 2.0 5 votes vote down vote up
public ColorSelector(Context context,Integer color, OnColorSelectedListener onColorSelectedListener) {
	super(context, android.R.style.Theme_Translucent);
	this.context = context;
	this.onColorSelectedListener = onColorSelectedListener;
	if(color != null)
		this.color = color;
	setOnDismissListener(new OnDismissListener() {
		
		@Override
		public void onDismiss(DialogInterface dialog) {
			if(ColorSelector.this.onColorSelectedListener != null)
				ColorSelector.this.onColorSelectedListener.onColorSelected(ColorSelector.this.color);
		}
	});
}
 
Example #29
Source File: SnackBar.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void show() {
	super.show();
	view.setVisibility(View.VISIBLE);
	view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.snackbar_show_animation));
	if (!mIndeterminate) {
	    dismissTimer.start();
	}
}
 
Example #30
Source File: ButtonFloat.java    From MaterialDesignLibrary with Apache License 2.0 5 votes vote down vote up
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();
	}