Bug 15: Refactor, improve and finish the Local Storage (Preferences) implementation of Storage api
This commit is contained in:
parent
57a17492c3
commit
bf2cf7c046
@ -28,21 +28,21 @@ import com.pixelgamelibrary.api.storage.map.MapStorage;
|
|||||||
*
|
*
|
||||||
* @author robertvokac
|
* @author robertvokac
|
||||||
*/
|
*/
|
||||||
public class WebGLStorage extends MapStorage {
|
public class PreferencesStorage extends MapStorage {
|
||||||
|
|
||||||
public Platform getPlatform() {
|
public Platform getPlatform() {
|
||||||
return Platform.WEB;
|
return Platform.WEB;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebGLStorage() {
|
public PreferencesStorage() {
|
||||||
this("pixel.libgdx.webGL.Local-Storage");
|
this("pixel.libgdx.webGL.Local-Storage");
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebGLStorage(String preferencesName) {
|
public PreferencesStorage(String preferencesName) {
|
||||||
this(Gdx.app.getPreferences(preferencesName));
|
this(Gdx.app.getPreferences(preferencesName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebGLStorage(Preferences preferences) {
|
public PreferencesStorage(Preferences preferences) {
|
||||||
super(new SimpleLocalStorageMap(preferences));
|
super(new SimpleLocalStorageMap(preferences));
|
||||||
}
|
}
|
||||||
|
|
@ -39,8 +39,8 @@ public class StorageFactory {
|
|||||||
public static Storage getStorage() {
|
public static Storage getStorage() {
|
||||||
final Platform platform = Pixel.app().getPlatform();
|
final Platform platform = Pixel.app().getPlatform();
|
||||||
if (storage == null) {
|
if (storage == null) {
|
||||||
storage = new MemoryStorage();
|
storage = new PreferencesStorage();
|
||||||
}
|
}//todo fixme
|
||||||
if (storage == null) {
|
if (storage == null) {
|
||||||
|
|
||||||
if (platform.isDesktop()) {
|
if (platform.isDesktop()) {
|
||||||
@ -50,7 +50,7 @@ public class StorageFactory {
|
|||||||
storage = new AndroidStorage();
|
storage = new AndroidStorage();
|
||||||
}
|
}
|
||||||
if (platform.isWeb()) {
|
if (platform.isWeb()) {
|
||||||
storage = new WebGLStorage();
|
storage = new PreferencesStorage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (storage == null) {
|
if (storage == null) {
|
||||||
|
Reference in New Issue
Block a user