mirror of
https://github.com/memen45/SubMusic.git
synced 2026-12-05 23:43:56 +01:00
42 lines
1.0 KiB
MonkeyC
42 lines
1.0 KiB
MonkeyC
using Toybox.Media;
|
|
using Toybox.WatchUi;
|
|
|
|
// Delegate for playback menu
|
|
class SubMusicConfigurePlaybackMenuDelegate extends WatchUi.Menu2InputDelegate {
|
|
|
|
// Constructor
|
|
function initialize() {
|
|
Menu2InputDelegate.initialize();
|
|
|
|
System.println("Constructing PlaybackMenuDelegate");
|
|
}
|
|
|
|
// When an item is selected, add or remove it from the system playlist
|
|
function onSelect(item) {
|
|
|
|
System.println("onSelect PlaybackMenuDelegate");
|
|
var playlist = Application.Storage.getValue(Storage.PLAYLIST);
|
|
|
|
if (playlist == null) {
|
|
playlist = [];
|
|
}
|
|
|
|
if (item.isChecked()) {
|
|
playlist.add(item.getId());
|
|
} else {
|
|
playlist.remove(item.getId());
|
|
}
|
|
|
|
Application.Storage.setValue(Storage.PLAYLIST, playlist);
|
|
}
|
|
|
|
// Pop the view when done
|
|
function onDone() {
|
|
Media.startPlayback(null);
|
|
}
|
|
|
|
// Pop the view when back is pushed
|
|
function onBack() {
|
|
WatchUi.popView(WatchUi.SLIDE_IMMEDIATE);
|
|
}
|
|
} |