Beispiel #1
0
 /**
  * Returns the {@link Artist} with the given id. If none exists in our static {@link
  * ConcurrentHashMap} yet, construct and add it.
  *
  * @return {@link Artist} with the given id
  */
 public static Artist get(String artistName) {
   Artist artist = new Artist(artistName);
   String key = TomahawkUtils.getCacheKey(artist);
   if (!sArtists.containsKey(key)) {
     sArtists.put(key, artist);
   }
   return sArtists.get(key);
 }
Beispiel #2
0
 /**
  * Add an {@link Album} to this object
  *
  * @param album the {@link Album} to be added
  */
 public void addAlbum(Album album, boolean isLocalAlbum) {
   String key = TomahawkUtils.getCacheKey(album);
   synchronized (this) {
     if (!mAlbums.containsKey(key)) {
       mAlbums.put(key, album);
       if (isLocalAlbum) {
         mLocalAlbums.put(key, album);
       }
     }
   }
 }
Beispiel #3
0
 /** @param query the {@link org.tomahawk.libtomahawk.resolver.Query} to be added */
 public void addQuery(Query query) {
   String key = TomahawkUtils.getCacheKey(query);
   synchronized (this) {
     if (!mQueries.containsKey(key)) {
       mQueries.put(key, query);
       boolean isLocalQuery =
           query.getPreferredTrackResult() != null
               && query.getPreferredTrackResult().getResolvedBy() instanceof DataBaseResolver;
       if (isLocalQuery) {
         mLocalQueries.put(key, query);
       }
     }
   }
 }