mirror of
https://github.com/memen45/SubMusic.git
synced 2026-12-02 10:09:04 +01:00
added software version number in settings rewrite of sync engine rewrite of menu structure added experimental podcast support (newest file only) added artwork support for podcasts fixed "remove all" option in menu in case cache was already removed
59 lines
1.2 KiB
MonkeyC
59 lines
1.2 KiB
MonkeyC
/*
|
|
* Store number of items in a Dictionary by id
|
|
* Item class should have a function id()
|
|
* Item class should have a function toStorage()
|
|
*/
|
|
class ObjectStore extends Store {
|
|
|
|
function initialize(key) {
|
|
Store.initialize(key, {}); // initialize with empty object
|
|
}
|
|
|
|
// returns a connected item
|
|
function get(id) {
|
|
// System.println("ObjectStore::get( id : " + id + " )");
|
|
|
|
var items = Store.value();
|
|
if (id == null) {
|
|
return null;
|
|
}
|
|
return items.get(id);
|
|
}
|
|
|
|
function getIds() {
|
|
// System.println("ObjectStore::getIds()");
|
|
|
|
return Store.value().keys();
|
|
}
|
|
|
|
function getValues() {
|
|
return Store.value().values();
|
|
}
|
|
|
|
function save(item) {
|
|
System.println("ObjectStore::save( item : " + item.toStorage() + " )");
|
|
|
|
// return false if failed save
|
|
var id = item.id();
|
|
if (id == null) {
|
|
return false;
|
|
}
|
|
|
|
// save details of the item
|
|
Store.value().put(id, item.toStorage());
|
|
return Store.update();
|
|
}
|
|
|
|
// returns true if item id entry removed from storage or is not in storage
|
|
function remove(item) {
|
|
System.println("ObjectStore::remove( " + item.toStorage() + " )");
|
|
|
|
var id = item.id();
|
|
if (id == null) {
|
|
return true;
|
|
}
|
|
|
|
Store.value().remove(id);
|
|
return Store.update();
|
|
}
|
|
} |