Add LibraryObserver.Values.*

This commit is contained in:
Adrian Ulrich 2018-07-06 22:18:39 +02:00
parent 474402c119
commit 629f0e0b8d
3 changed files with 14 additions and 7 deletions

View File

@ -26,8 +26,15 @@ public class LibraryObserver {
* by the receiver
*/
public enum Type {
SONG, // Change affected song entries
PLAYLIST, // Change affected playlists
SONG, // Change affected song items.
PLAYLIST, // Change affected playlists.
}
/**
* Special hint values
*/
public class Value {
public static final int UNKNOWN = -1; // The exact id of the changed object is not know, may have affected all items.
public static final int OUTDATED = -2; // Everything you know is wrong: Cached data must not be used nor trusted.
}
/**

View File

@ -362,7 +362,7 @@ public class MediaLibrary {
if (rows > 0) {
getBackend(context).cleanOrphanedEntries(true);
notifyObserver(LibraryObserver.Type.SONG, id, false);
notifyObserver(LibraryObserver.Type.PLAYLIST, -1, false);
notifyObserver(LibraryObserver.Type.PLAYLIST, LibraryObserver.Value.UNKNOWN, false);
}
return rows;
}

View File

@ -205,19 +205,19 @@ public class MediaScanner implements Handler.Callback {
switch (rpc) {
case MSG_NOTIFY_CHANGE: {
MediaLibrary.notifyObserver(LibraryObserver.Type.SONG, -1, true);
MediaLibrary.notifyObserver(LibraryObserver.Type.SONG, LibraryObserver.Value.UNKNOWN, true);
break;
}
case MSG_SCAN_FINISHED: {
if (mIsInitialScan) {
mIsInitialScan = false;
PlaylistBridge.importAndroidPlaylists(mContext);
MediaLibrary.notifyObserver(LibraryObserver.Type.PLAYLIST, LibraryObserver.Value.OUTDATED, false);
}
if (mPendingCleanup) {
mPendingCleanup = false;
mBackend.cleanOrphanedEntries(true);
// scan run possibly deleted file which may affect playlists:
MediaLibrary.notifyObserver(LibraryObserver.Type.PLAYLIST, -1, false);
MediaLibrary.notifyObserver(LibraryObserver.Type.PLAYLIST, LibraryObserver.Value.UNKNOWN, false);
}
// Send a last change notification to all observers.
@ -226,7 +226,7 @@ public class MediaScanner implements Handler.Callback {
// also signals that this will be our last update
// for this scan.
mHandler.removeMessages(MSG_NOTIFY_CHANGE);
MediaLibrary.notifyObserver(LibraryObserver.Type.SONG, -1, false);
MediaLibrary.notifyObserver(LibraryObserver.Type.SONG, LibraryObserver.Value.UNKNOWN, false);
updateNotification(false);
break;