aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-07-31 16:36:55 -0700
committerdaneren2005 <daneren2005@gmail.com>2013-07-31 16:36:55 -0700
commit52f99c62d2048c881eaf33b4bb9ffccfc2c021cb (patch)
tree62ccf1164876c02fb07a65bb9cb43d090d4d9a4f
parentd18cd8364e885a353bca894a96a4c4a60c038239 (diff)
downloaddsub-52f99c62d2048c881eaf33b4bb9ffccfc2c021cb.tar.gz
dsub-52f99c62d2048c881eaf33b4bb9ffccfc2c021cb.tar.bz2
dsub-52f99c62d2048c881eaf33b4bb9ffccfc2c021cb.zip
Move a lot of common use cases into abstraction
-rw-r--r--src/github/daneren2005/dsub/view/UpdateView.java48
1 files changed, 43 insertions, 5 deletions
diff --git a/src/github/daneren2005/dsub/view/UpdateView.java b/src/github/daneren2005/dsub/view/UpdateView.java
index 7ce27f06..ced92ad6 100644
--- a/src/github/daneren2005/dsub/view/UpdateView.java
+++ b/src/github/daneren2005/dsub/view/UpdateView.java
@@ -37,6 +37,14 @@ public class UpdateView extends LinearLayout {
private static Handler uiHandler;
private static Runnable updateRunnable;
+ protected ImageButton starButton;
+ protected ImageView moreButton;
+
+ protected boolean exists = false;
+ protected boolean shaded = false;
+ protected boolean starred = true;
+ protected boolean isStarred = false;
+
public UpdateView(Context context) {
super(context);
@@ -45,11 +53,6 @@ public class UpdateView extends LinearLayout {
ViewGroup.LayoutParams.WRAP_CONTENT));
INSTANCES.put(this, null);
- int instanceCount = INSTANCES.size();
- if (instanceCount > 50) {
- Log.w(TAG, instanceCount + " live UpdateView instances");
- }
-
startUpdater();
}
@@ -58,6 +61,15 @@ public class UpdateView extends LinearLayout {
}
+ public void setObject(Object obj) {
+ setObjectImpl(obj);
+ updateBackground();
+ update();
+ }
+ protected void setObjectImpl(Object obj) {
+
+ }
+
private static synchronized void startUpdater() {
if(uiHandler != null) {
return;
@@ -128,6 +140,32 @@ public class UpdateView extends LinearLayout {
}
protected void update() {
+ if(moreButton != null) {
+ if(exists) {
+ if(!shaded) {
+ moreButton.setImageResource(R.drawable.list_item_more_shaded);
+ shaded = true;
+ }
+ } else {
+ if(shaded) {
+ moreButton.setImageResource(R.drawable.list_item_more);
+ shaded = false;
+ }
+ }
+ }
+ if(starButton != null) {
+ if(isStarred) {
+ if(!starred) {
+ starButton.setVisibility(View.VISIBLE);
+ starred = true;
+ }
+ } else {
+ if(starred) {
+ starButton.setVisibility(View.GONE);
+ starred = false;
+ }
+ }
+ }
}
}