예제 #1
0
  @Override
  public List<Serializable> getObjects(
      MusicService musicService, boolean refresh, ProgressListener listener) throws Exception {
    List<PodcastChannel> channels = musicService.getPodcastChannels(refresh, context, listener);

    if (!Util.isOffline(context) && ServerInfo.hasNewestPodcastEpisodes(context)) {
      try {
        newestEpisodes = musicService.getNewestPodcastEpisodes(10, context, listener);

        for (MusicDirectory.Entry entry : newestEpisodes.getChildren()) {
          for (PodcastChannel channel : channels) {
            if (channel.getId().equals(entry.getParent())) {
              PodcastEpisode episode = (PodcastEpisode) entry;

              // Update with information normally done in PodcastEntryParser
              episode.setArtist(channel.getName());
              episode.setCoverArt(channel.getCoverArt());
              episode.setPath(FileUtil.getPodcastPath(context, episode));
              break;
            }
          }
        }
      } catch (Exception e) {
        Log.e(TAG, "Failed to download newest episodes", e);
        newestEpisodes = null;
      }
    } else {
      newestEpisodes = null;
    }

    List<Serializable> serializableList = new ArrayList<>();
    serializableList.addAll(channels);

    return serializableList;
  }
예제 #2
0
  private SearchResult search(String query) {
    MusicService musicService = MusicServiceFactory.getMusicService(getContext());
    if (musicService == null) {
      return null;
    }

    try {
      return musicService.search(new SearchCritera(query, 5, 10, 10), getContext(), null);
    } catch (Exception e) {
      return null;
    }
  }
예제 #3
0
    public void loadImage() {
      try {
        MusicService musicService = MusicServiceFactory.getMusicService(mContext);
        Bitmap bitmap = musicService.getCoverArt(mContext, mEntry, mSize, null);
        String key = getKey(mEntry.getCoverArt(), mSize);
        cache.put(key, bitmap);
        // Make sure key is the most recently "used"
        cache.get(key);
        if (mIsNowPlaying) {
          nowPlaying = bitmap;
        }

        final Drawable drawable = Util.createDrawableFromBitmap(mContext, bitmap);
        mTaskHandler.setDrawable(drawable);
        mHandler.post(mTaskHandler);
      } catch (Throwable x) {
        Log.e(TAG, "Failed to download album art.", x);
      }
    }
예제 #4
0
 @Override
 public List<Share> getObjects(
     MusicService musicService, boolean refresh, ProgressListener listener) throws Exception {
   return musicService.getShares(context, listener);
 }
예제 #5
0
 @Override
 public List<Artist> getObjects(
     MusicService musicService, boolean refresh, ProgressListener listener) throws Exception {
   info = musicService.getArtistInfo(artistId, refresh, true, context, listener);
   return info.getSimilarArtists();
 }