public class LoadoutManager
extends java.lang.Object
implements android.content.SharedPreferences.OnSharedPreferenceChangeListener
Modifier and Type | Class and Description |
---|---|
static interface |
LoadoutManager.OnLoadoutChangedListener
Loadout event listener
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_LOADOUT_UID |
static java.lang.String |
LOADOUT_PREFIX |
static java.lang.String |
PREF_SELECTED_LOADOUT |
Constructor and Description |
---|
LoadoutManager(android.content.Context appContext) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(LoadoutManager.OnLoadoutChangedListener l)
Add a listener to the manager
|
void |
addLoadout(LoadoutItemModel loadout)
Add a loadout to the list of available
|
LoadoutItemModel |
getCurrentLoadout()
Get the currently active loadout
|
static LoadoutManager |
getInstance() |
LoadoutItemModel |
getLoadout(java.lang.String uid)
Get a loadout given its UID
|
java.util.List<LoadoutItemModel> |
getLoadouts()
Get the list of available loadouts
|
void |
notifyLoadoutChanged(LoadoutItemModel loadout)
Notify listeners a loadout has been modified
|
void |
onSharedPreferenceChanged(android.content.SharedPreferences prefs,
java.lang.String key) |
void |
persistLoadout(LoadoutItemModel loadout,
boolean notify)
Persists a loadout to the shared preferences and notifies modification
|
void |
removeListener(LoadoutManager.OnLoadoutChangedListener l)
Remove a listener from the manager
|
void |
removeLoadout(LoadoutItemModel loadout)
Remove a loadout from the list of available
|
void |
removeLoadout(java.lang.String uid)
Remove a loadout from the list of available
|
java.lang.String |
serializeToXML(LoadoutItemModel loadout)
Serialize a loadout to preferences XML
|
void |
setCurrentLoadout(LoadoutItemModel loadout)
Set the currently selected loadout
|
void |
setCurrentLoadout(java.lang.String uid)
Set the currently selected loadout
|
public static final java.lang.String PREF_SELECTED_LOADOUT
public static final java.lang.String DEFAULT_LOADOUT_UID
public static final java.lang.String LOADOUT_PREFIX
public static LoadoutManager getInstance()
public LoadoutItemModel getCurrentLoadout()
public void setCurrentLoadout(LoadoutItemModel loadout)
loadout
- Loadout to selectpublic void setCurrentLoadout(java.lang.String uid)
uid
- Loadout UID (falls back to default if not found)public void addLoadout(LoadoutItemModel loadout)
loadout
- Loadout to addpublic void removeLoadout(java.lang.String uid)
uid
- Loadout UIDpublic void removeLoadout(LoadoutItemModel loadout)
loadout
- Loadout to removepublic LoadoutItemModel getLoadout(java.lang.String uid)
uid
- Loadout UIDpublic java.util.List<LoadoutItemModel> getLoadouts()
public void persistLoadout(LoadoutItemModel loadout, boolean notify)
loadout
- Loadout to persistnotify
- True to notify listeners of a changepublic void notifyLoadoutChanged(LoadoutItemModel loadout)
loadout
- Loadout that has been modifiedpublic void addListener(LoadoutManager.OnLoadoutChangedListener l)
l
- Loadout listenerpublic void removeListener(LoadoutManager.OnLoadoutChangedListener l)
l
- Loadout listenerpublic java.lang.String serializeToXML(LoadoutItemModel loadout)
loadout
- Loadout to serializepublic void onSharedPreferenceChanged(android.content.SharedPreferences prefs, java.lang.String key)
onSharedPreferenceChanged
in interface android.content.SharedPreferences.OnSharedPreferenceChangeListener