From 9075019daa8d8741a9fa9216dad35f57b57082ac Mon Sep 17 00:00:00 2001 From: Ivan Baranov Date: Fri, 20 Nov 2015 11:44:42 +0300 Subject: [PATCH] Basic color and type shouldn't be applied if custom resource is provided. Fixes #6. --- .../github/ivbaranov/mfb/MaterialFavoriteButton.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/materialfavoritebutton/src/main/java/com/github/ivbaranov/mfb/MaterialFavoriteButton.java b/materialfavoritebutton/src/main/java/com/github/ivbaranov/mfb/MaterialFavoriteButton.java index 6e5d5c5..bafd0ae 100644 --- a/materialfavoritebutton/src/main/java/com/github/ivbaranov/mfb/MaterialFavoriteButton.java +++ b/materialfavoritebutton/src/main/java/com/github/ivbaranov/mfb/MaterialFavoriteButton.java @@ -401,6 +401,7 @@ public static final class Builder { private int mBounceDuration = DEFAULT_BOUNCE_DURATION; private int mColor = STYLE_WHITE; private int mType = STYLE_BLACK; + private boolean mCustomRecources = false; public Builder(Context context) { this.context = context; @@ -428,11 +429,13 @@ public Builder animateUnfavorite(boolean animation) { public Builder favoriteResource(int resource) { this.mFavoriteResource = resource; + mCustomRecources = true; return this; } public Builder notFavoriteResource(int recsource) { this.mNotFavoriteResource = recsource; + mCustomRecources = true; return this; } @@ -453,11 +456,13 @@ public Builder bounceDuration(int bounceDuration) { public Builder color(int color) { this.mColor = color; + mCustomRecources = false; return this; } public Builder type(int type) { this.mType = type; + mCustomRecources = false; return this; } @@ -472,8 +477,10 @@ public MaterialFavoriteButton create() { materialFavoriteButton.setRotationDuration(mRotationDuration); materialFavoriteButton.setRotationAngle(mRotationAngle); materialFavoriteButton.setBounceDuration(mBounceDuration); - materialFavoriteButton.setColor(mColor); - materialFavoriteButton.setType(mType); + if (!mCustomRecources) { + materialFavoriteButton.setColor(mColor); + materialFavoriteButton.setType(mType); + } materialFavoriteButton.setResources(); return materialFavoriteButton;