Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor NPE fix #391

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class Button extends CustomView {
OnClickListener onClickListener;
boolean clickAfterRipple = true;
int backgroundColor = Color.parseColor("#1E88E5");
TextView textButton;


public Button(Context context, AttributeSet attrs) {
super(context, attrs);
Expand Down Expand Up @@ -181,19 +181,11 @@ public float getRippleSpeed() {
return this.rippleSpeed;
}

public void setText(String text) {
textButton.setText(text);
}
public abstract void setText(String text);

public void setTextColor(int color) {
textButton.setTextColor(color);
}
public abstract void setTextColor(int color);

public TextView getTextView() {
return textButton;
}
public abstract TextView getTextView();

public String getText() {
return textButton.getText().toString();
}
public abstract String getText();
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ protected int makePressColor(){
return Color.parseColor("#88DDDDDD");
}

public void setText(String text){
textButton.setText(text.toUpperCase());
}


// Set color of background
public void setBackgroundColor(int color){
backgroundColor = color;
Expand All @@ -117,4 +114,13 @@ public String getText(){
return textButton.getText().toString();
}

public void setText(String text){
textButton.setText(text.toUpperCase());
}

@Override
public void setTextColor(int color) {
textButton.setTextColor(color);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.Bitmap.Config;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.LayerDrawable;
import android.support.annotation.ColorInt;
import android.support.v4.view.TintableBackgroundView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.animation.BounceInterpolator;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
Expand Down Expand Up @@ -175,11 +179,6 @@ public Bitmap cropCircle(Bitmap bitmap) {
return output;
}

@Override
public TextView getTextView() {
return null;
}

public void setRippleColor(int rippleColor) {
this.rippleColor = rippleColor;
}
Expand All @@ -205,5 +204,30 @@ public void hide(){
public boolean isShow(){
return isShow;
}

@Override
public TextView getTextView() {
Log.e("ButtonFloat", "getTextView() - no text view on float button");
return null;
}

@Override
public String getText() {
Log.e("ButtonFloat", "getText() - no text view on float button");
return null;
}

@Override
public void setText(String text) {
Log.e("ButtonFloat", "ButtonFloat does not have a text");
}

@Override
public void setTextColor(int color) {
if (drawableIcon != null){
Log.w("ButtonFloat", "ButtonFloat does not have a text, will try to tint image, but make sure this is what you want");
drawableIcon.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,25 @@ protected void onDraw(Canvas canvas) {
invalidate();
}
}

@Override
public void setText(String text) {
textButton.setText(text);
}

@Override
public void setTextColor(int color) {
textButton.setTextColor(color);
}

@Override
public TextView getTextView() {
return textButton;
}

@Override
public String getText() {
return textButton.getText().toString();
}

}
2 changes: 1 addition & 1 deletion MaterialDesignLibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.+'
classpath 'com.android.tools.build:gradle:2.2.0'
// COMMENT TO DEVELOPER MODE / UNCOMMENT TO UPLOAD TO BINTARRAY
// classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'
// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Aug 22 18:02:59 CEST 2015
#Sun Sep 25 06:58:35 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip