Skip to content

Commit

Permalink
Added support to change error button background color
Browse files Browse the repository at this point in the history
  • Loading branch information
vlonjat-gashi committed Feb 1, 2017
1 parent f16ab9c commit c433118
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.LightingColorFilter;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
Expand Down Expand Up @@ -74,6 +75,7 @@ public class ProgressFrameLayout extends FrameLayout {
int errorStateTitleTextColor;
int errorStateContentTextColor;
int errorStateButtonTextColor;
int errorStateButtonBackgroundColor;
int errorStateBackgroundColor;

private String state = CONTENT;
Expand Down Expand Up @@ -154,6 +156,9 @@ private void init(AttributeSet attrs) {
errorStateButtonTextColor =
typedArray.getColor(R.styleable.ProgressActivity_errorButtonTextColor, Color.BLACK);

errorStateButtonBackgroundColor =
typedArray.getColor(R.styleable.ProgressActivity_errorButtonBackgroundColor, Color.WHITE);

errorStateBackgroundColor =
typedArray.getColor(R.styleable.ProgressActivity_errorBackgroundColor, Color.TRANSPARENT);

Expand Down Expand Up @@ -498,6 +503,7 @@ private void setErrorView() {
errorStateTitleTextView.setTextColor(errorStateTitleTextColor);
errorStateContentTextView.setTextColor(errorStateContentTextColor);
errorStateButton.setTextColor(errorStateButtonTextColor);
errorStateButton.getBackground().setColorFilter(new LightingColorFilter(1, errorStateButtonBackgroundColor));

//Set background color if not TRANSPARENT
if (errorStateBackgroundColor != Color.TRANSPARENT) {
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<attr name="errorTitleTextColor" format="color"/>
<attr name="errorContentTextColor" format="color"/>
<attr name="errorButtonTextColor" format="color"/>
<attr name="errorButtonBackgroundColor" format="color"/>
<attr name="errorBackgroundColor" format="color"/>
</declare-styleable>
</resources>
1 change: 1 addition & 0 deletions sample/src/main/res/layout/activity_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
progressActivity:errorButtonTextColor="#FFFFFF"
progressActivity:errorContentTextColor="#FFFFFF"
progressActivity:errorTitleTextColor="#FFFFFF"
progressActivity:errorButtonBackgroundColor="#9C27B0"
progressActivity:loadingBackgroundColor="#FFFFFF"
progressActivity:loadingStateProgressBarColor="#9C27B0">

Expand Down

0 comments on commit c433118

Please sign in to comment.