From 8f60d4b2d36130bff8779ebcc258e7a0776c188c Mon Sep 17 00:00:00 2001 From: Pete Date: Sat, 4 Feb 2017 23:38:29 +0000 Subject: [PATCH 1/2] Added methods Allow inactive & active image changes at runtime --- .../java/com/varunest/sparkbutton/SparkButton.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sparkbutton/src/main/java/com/varunest/sparkbutton/SparkButton.java b/sparkbutton/src/main/java/com/varunest/sparkbutton/SparkButton.java index c0ee7bc..a4b4596 100644 --- a/sparkbutton/src/main/java/com/varunest/sparkbutton/SparkButton.java +++ b/sparkbutton/src/main/java/com/varunest/sparkbutton/SparkButton.java @@ -206,6 +206,16 @@ public void setChecked(boolean flag) { imageView.setImageResource(isChecked ? imageResourceIdActive : imageResourceIdInactive); imageView.setColorFilter(isChecked ? activeImageTint : inActiveImageTint, PorterDuff.Mode.SRC_ATOP); } + + public void setInactiveImage(int inactiveResource){ + this.imageResourceIdInactive = inactiveResource; + imageView.setImageResource(imageResourceIdInactive); + } + + public void setActiveImage(int activeResource){ + this.imageResourceIdActive = activeResource; + imageView.setImageResource(imageResourceIdActive); + } public void setEventListener(SparkEventListener listener) { this.listener = listener; @@ -291,4 +301,4 @@ private void getStuffFromXML(AttributeSet attr) { // recycle typedArray a.recycle(); } -} \ No newline at end of file +} From 1a16c7d7f637b61d9e8112cd290e482dfd48b5e8 Mon Sep 17 00:00:00 2001 From: Pete Date: Sat, 4 Feb 2017 23:45:58 +0000 Subject: [PATCH 2/2] Fix initial commit --- .../src/main/java/com/varunest/sparkbutton/SparkButton.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sparkbutton/src/main/java/com/varunest/sparkbutton/SparkButton.java b/sparkbutton/src/main/java/com/varunest/sparkbutton/SparkButton.java index a4b4596..60b035d 100644 --- a/sparkbutton/src/main/java/com/varunest/sparkbutton/SparkButton.java +++ b/sparkbutton/src/main/java/com/varunest/sparkbutton/SparkButton.java @@ -209,12 +209,12 @@ public void setChecked(boolean flag) { public void setInactiveImage(int inactiveResource){ this.imageResourceIdInactive = inactiveResource; - imageView.setImageResource(imageResourceIdInactive); + imageView.setImageResource(isChecked ? imageResourceIdActive : imageResourceIdInactive);; } public void setActiveImage(int activeResource){ this.imageResourceIdActive = activeResource; - imageView.setImageResource(imageResourceIdActive); + imageView.setImageResource(isChecked ? imageResourceIdActive : imageResourceIdInactive);; } public void setEventListener(SparkEventListener listener) {