diff --git a/likebutton/src/main/java/com/like/LikeButton.java b/likebutton/src/main/java/com/like/LikeButton.java
index 9f58c18..f7e0e2f 100644
--- a/likebutton/src/main/java/com/like/LikeButton.java
+++ b/likebutton/src/main/java/com/like/LikeButton.java
@@ -42,6 +42,9 @@ public class LikeButton extends FrameLayout implements View.OnClickListener {
private int iconSize;
private boolean isChecked;
+
+
+ private boolean isEnabled;
private AnimatorSet animatorSet;
private Drawable likeDrawable;
@@ -127,6 +130,7 @@ private void init(Context context, AttributeSet attrs, int defStyle) {
}
}
+ setEnabled(array.getBoolean(R.styleable.LikeButton_enabled,true));
Boolean status = array.getBoolean(R.styleable.LikeButton_liked,false);
setLiked(status);
setEffectsViewSize();
@@ -141,6 +145,10 @@ private void init(Context context, AttributeSet attrs, int defStyle) {
*/
@Override
public void onClick(View v) {
+
+ if(!isEnabled)
+ return;
+
isChecked = !isChecked;
icon.setImageDrawable(isChecked ? likeDrawable : unLikeDrawable);
@@ -222,6 +230,9 @@ public void onAnimationCancel(Animator animation) {
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
+ if(!isEnabled)
+ return true;
+
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
icon.animate().scaleX(0.7f).scaleY(0.7f).setDuration(150).setInterpolator(DECCELERATE_INTERPOLATOR);
@@ -437,4 +448,9 @@ public void setLiked(Boolean status)
icon.setImageDrawable(unLikeDrawable);
}
}
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ isEnabled = enabled;
+ }
}
diff --git a/likebutton/src/main/res/values/attrs.xml b/likebutton/src/main/res/values/attrs.xml
index df31307..94ab12a 100644
--- a/likebutton/src/main/res/values/attrs.xml
+++ b/likebutton/src/main/res/values/attrs.xml
@@ -10,5 +10,6 @@
+
\ No newline at end of file