blob: 79a37b6f948efa31ffab2025659fe9deb2907ba6 (
plain) (
tree)
|
|
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();
}
|