aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005/dsub/view/UpdateView2.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/view/UpdateView2.java')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/UpdateView2.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/view/UpdateView2.java b/app/src/main/java/github/daneren2005/dsub/view/UpdateView2.java
new file mode 100644
index 00000000..0f0b5455
--- /dev/null
+++ b/app/src/main/java/github/daneren2005/dsub/view/UpdateView2.java
@@ -0,0 +1,47 @@
+package github.daneren2005.dsub.view;
+
+import android.content.Context;
+
+public abstract class UpdateView2<T1, T2> extends UpdateView<T1> {
+ protected T2 item2;
+
+ public UpdateView2(Context context) {
+ super(context);
+ }
+
+ public UpdateView2(Context context, boolean autoUpdate) {
+ super(context, autoUpdate);
+ }
+
+ public final void setObject(T1 obj1) {
+ setObject(obj1, null);
+ }
+ @Override
+ public void setObject(T1 obj1, Object obj2) {
+ item = obj1;
+ item2 = (T2) obj2;
+ if(imageTask != null) {
+ imageTask.cancel();
+ imageTask = null;
+ }
+
+ setObjectImpl(item, item2);
+ backgroundHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ updateBackground();
+ uiHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ update();
+ }
+ });
+ }
+ });
+ }
+
+ protected final void setObjectImpl(T1 obj1) {
+ setObjectImpl(obj1, null);
+ }
+ protected abstract void setObjectImpl(T1 obj1, T2 obj2);
+}