|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsk.baka.ambient.commons.AbstractFileStorage
sk.baka.ambient.library.CoverCache
public final class CoverCache
Provides covers and manages cover cache. Thread-safe. Essentially a singleton, there must be at most one instance.
| Field Summary |
|---|
| Fields inherited from class sk.baka.ambient.commons.AbstractFileStorage |
|---|
maxStorageSize, theCache |
| Constructor Summary | |
|---|---|
CoverCache()
Creates new cache. |
|
| Method Summary | |
|---|---|
void |
cleanup()
Cleans up old files. |
void |
coverLoaded(TrackMetadataBean track)
A cover for given track has been successfully downloaded. |
protected String[] |
getFilenameAndExt(URL url,
Object fetchInfo)
Retrieves target file name. |
protected boolean |
isProceedWithDownload(Object fetchInfo)
Invoked before the download process starts. |
void |
libraryUpdate(boolean updateStarted,
boolean interrupted,
boolean userNotified)
Informs that the file rescan is complete and the database is updated. |
void |
lyricsLoaded(TrackMetadataBean track,
List<LyrdbTrack> lyrics)
A lyrics event. |
protected void |
onFileDownloaded(URL url,
Object fetchInfo,
boolean success)
The file was downloaded and is already registered in the storage. |
void |
setCacheOverflowBehavior(boolean dontDownload)
Sets the cache behavior when the cache is full. |
Bitmap |
setCover(TrackMetadataBean track,
ImageView view)
Fetches a cover for a track and sets it into given view. |
protected URL |
toURL(Object fetchInfo)
Converts given fetch info to an URL object. |
| Methods inherited from class sk.baka.ambient.commons.AbstractFileStorage |
|---|
close, createFile, fetchFileAsync, getCacheFile, getCacheFileNull, getFile, getNames, isFull, purge, registerFile, removeFile, setMaxStorageSize, supportsExtension |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CoverCache()
| Method Detail |
|---|
public void setCacheOverflowBehavior(boolean dontDownload)
dontDownload - if true then new covers will not be downloaded.
If false then old covers will be purged.protected boolean isProceedWithDownload(Object fetchInfo)
AbstractFileStorage
isProceedWithDownload in class AbstractFileStoragefetchInfo - the fetch info object, never null.
false then this download is aborted.
protected String[] getFilenameAndExt(URL url,
Object fetchInfo)
AbstractFileStorageUnsupportedOperationException. Must be thread-safe as it is not
invoked from a Handler thread.
getFilenameAndExt in class AbstractFileStorageurl - the source URL. May be null - in this case the
extension is not needed and returned extension may be
null or the result may contain only the name.fetchInfo - the fetch info object
null is returned
then the object is not downloadable nor storable into the
storage.
protected void onFileDownloaded(URL url,
Object fetchInfo,
boolean success)
AbstractFileStorage
onFileDownloaded in class AbstractFileStorageurl - the source URLfetchInfo - the fetch info objectsuccess - if true then the file is available in the cache.
If false then the download process was aborted (
AbstractFileStorage.toURL(Object) returned null).
protected URL toURL(Object fetchInfo)
throws IOException
AbstractFileStorageUnsupportedOperationException. Must be thread-safe as it is not
invoked from a Handler thread.
toURL in class AbstractFileStoragefetchInfo - the fetch info object, never null.
null then this download is aborted.
IOException - if i/o error occurs
public Bitmap setCover(TrackMetadataBean track,
ImageView view)
ILibraryListener.coverLoaded(TrackMetadataBean)
is emitted.
track - the track.view - set the image to this view.
public void cleanup()
AbstractFileStorageAbstractFileStorage.setMaxStorageSize(long) method.
cleanup in class AbstractFileStoragepublic void coverLoaded(TrackMetadataBean track)
ILibraryListenertrue.
coverLoaded in interface ILibraryListenertrack - the track.
public void libraryUpdate(boolean updateStarted,
boolean interrupted,
boolean userNotified)
ILibraryListener
libraryUpdate in interface ILibraryListenerupdateStarted - if true then the library update just started. If
false then the update finished.interrupted - if true then the scan was interrupted.userNotified - if true then the user is already notified about
the library being updated.
public void lyricsLoaded(TrackMetadataBean track,
List<LyrdbTrack> lyrics)
ILibraryListener
lyricsLoaded in interface ILibraryListenertrack - the track.lyrics - if non-null then user needs to select the correct
karaoke from this list. The list may be empty - in this case
no karaoke files are available. If null then the
karaoke file is available locally. If non-null
and is empty then no karaoke files are available.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||