aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-06-24 18:32:20 -0700
committerScott Jackson <daneren2005@gmail.com>2015-06-24 18:32:20 -0700
commit302dd4b2e8ea0514cd489295f403edd4bfba33f1 (patch)
tree27b1fe51eaeedcdbced4b845c8e7dfc540b18ffb /app/src/main/java/github/daneren2005/dsub/view/UpdateView.java
parent87a29fb6bb39453f491933cb60e4ac8766ad2f0b (diff)
downloaddsub-302dd4b2e8ea0514cd489295f403edd4bfba33f1.tar.gz
dsub-302dd4b2e8ea0514cd489295f403edd4bfba33f1.tar.bz2
dsub-302dd4b2e8ea0514cd489295f403edd4bfba33f1.zip
Make UpdateView be template based for easier use
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/view/UpdateView.java')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/UpdateView.java43
1 files changed, 11 insertions, 32 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java b/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java
index 44831c60..8e1029df 100644
--- a/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java
+++ b/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java
@@ -20,7 +20,6 @@ package github.daneren2005.dsub.view;
import android.content.Context;
import android.content.res.TypedArray;
-import android.graphics.Color;
import android.os.Handler;
import android.os.Looper;
import android.support.v7.widget.RecyclerView;
@@ -38,20 +37,20 @@ import java.util.List;
import java.util.WeakHashMap;
import github.daneren2005.dsub.domain.MusicDirectory;
-import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.util.SilentBackgroundTask;
-public class UpdateView extends LinearLayout {
+public abstract class UpdateView<T> extends LinearLayout {
private static final String TAG = UpdateView.class.getSimpleName();
private static final WeakHashMap<UpdateView, ?> INSTANCES = new WeakHashMap<UpdateView, Object>();
- private static Handler backgroundHandler;
- private static Handler uiHandler;
+ protected static Handler backgroundHandler;
+ protected static Handler uiHandler;
private static Runnable updateRunnable;
private static int activeActivities = 0;
protected Context context;
+ protected T item;
protected RatingBar ratingBar;
protected ImageButton starButton;
protected ImageView moreButton;
@@ -91,37 +90,16 @@ public class UpdateView extends LinearLayout {
}
- public void setObject(Object obj) {
+ public void setObject(T obj) {
+ item = obj;
setObjectImpl(obj);
updateBackground();
update();
}
- public void setObject(Object obj1, Object obj2) {
- if(imageTask != null) {
- imageTask.cancel();
- imageTask = null;
- }
-
- setObjectImpl(obj1, obj2);
- backgroundHandler.post(new Runnable() {
- @Override
- public void run() {
- updateBackground();
- uiHandler.post(new Runnable() {
- @Override
- public void run() {
- update();
- }
- });
- }
- });
- }
- protected void setObjectImpl(Object obj) {
-
- }
- protected void setObjectImpl(Object obj1, Object obj2) {
-
+ public void setObject(T obj1, Object obj2) {
+ setObject(obj1, null);
}
+ protected abstract void setObjectImpl(T obj);
private static synchronized void startUpdater() {
if(uiHandler != null) {
@@ -310,7 +288,7 @@ public class UpdateView extends LinearLayout {
this.view = view;
}
- public UpdateView getUpdateView() {
+ public UpdateView<T> getUpdateView() {
return updateView;
}
public View getView() {
@@ -324,3 +302,4 @@ public class UpdateView extends LinearLayout {
}
}
}
+