summaryrefslogtreecommitdiffstats
path: root/src/de/animux/android/andmal/api/MalList.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/animux/android/andmal/api/MalList.java')
-rw-r--r--src/de/animux/android/andmal/api/MalList.java79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/de/animux/android/andmal/api/MalList.java b/src/de/animux/android/andmal/api/MalList.java
new file mode 100644
index 0000000..79a37b6
--- /dev/null
+++ b/src/de/animux/android/andmal/api/MalList.java
@@ -0,0 +1,79 @@
+package de.animux.android.andmal.api;
+
+import java.util.Collection;
+import java.util.Map;
+
+public abstract class MalList {
+
+ private String username;
+
+ private String password;
+
+ protected boolean needsRefresh;
+
+ private static MalList cache;
+
+ public MalList(String username, String password) {
+ this.username = username;
+ this.password = password;
+ cache = this;
+ setNeedsRefresh(true);
+ }
+
+ public MalList() {
+ if (cache != null) {
+ this.username = cache.getUsername();
+ this.password = cache.getPassword();
+ setNeedsRefresh(false);
+ }
+ }
+
+ public String getUsername() {
+ return this.username;
+ }
+
+ public void setUsername(String username) {
+ if (this.username != null && this.username.equals(username))
+ return;
+
+ this.username = username;
+ this.needsRefresh = true;
+
+ if (cache != this
+ && (cache.getUsername() == null || !cache.getUsername().equals(
+ username))) {
+ cache.setUsername(username);
+ }
+ }
+
+ protected String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(String password) {
+ if (this.password != null && this.password.equals(password))
+ return;
+
+ this.password = password;
+ this.needsRefresh = true;
+
+ if (cache != this
+ && (cache.getPassword() == null || !cache.getPassword().equals(
+ password))) {
+ cache.setPassword(password);
+ }
+ }
+
+ public void setNeedsRefresh(boolean needsRefresh) {
+ this.needsRefresh = needsRefresh;
+ }
+
+ public boolean needsRefresh() {
+ return needsRefresh;
+ }
+
+ abstract public void refresh();
+
+ abstract public Map<MalState, Collection<MalObject>> getObjects();
+
+} \ No newline at end of file