예제 #1
0
 public void fillView(final Album album, Collection collection) {
   if (collection == null) {
     collection = CollectionManager.getInstance().getCollection(TomahawkApp.PLUGINNAME_HATCHET);
   }
   TextView textView1 = (TextView) findViewById(R.id.textview1);
   textView1.setText(album.getPrettyName());
   TextView textView2 = (TextView) findViewById(R.id.textview2);
   textView2.setText(album.getArtist().getPrettyName());
   ImageView imageView1 = (ImageView) findViewById(R.id.imageview1);
   TomahawkUtils.loadImageIntoImageView(
       TomahawkApp.getContext(), imageView1, album.getImage(), Image.getSmallImageSize(), false);
   final TextView textView3 = (TextView) findViewById(R.id.textview3);
   textView3.setVisibility(View.INVISIBLE);
   collection
       .getAlbumTracks(album)
       .done(
           new DoneCallback<CollectionCursor<Query>>() {
             @Override
             public void onDone(CollectionCursor<Query> cursor) {
               int size = 0;
               if (cursor != null) {
                 size = cursor.size();
                 cursor.close();
               }
               textView3.setVisibility(View.VISIBLE);
               textView3.setText(
                   TomahawkApp.getContext()
                       .getResources()
                       .getQuantityString(R.plurals.songs_with_count, size, size));
             }
           });
 }
  private void setupAlbumArt(View view) {
    if (mAlbum != null
        || (mQuery != null && !TextUtils.isEmpty(mQuery.getAlbum().getName()))
        || (mPlaylistEntry != null
            && !TextUtils.isEmpty(mPlaylistEntry.getQuery().getAlbum().getName()))) {
      View v =
          ViewUtils.ensureInflation(
              view, R.id.context_menu_albumart_stub, R.id.context_menu_albumart);

      // load albumart image
      ImageView albumImageView = (ImageView) v.findViewById(R.id.album_imageview);
      Album album;
      String cacheKey;
      if (mAlbum != null) {
        album = mAlbum;
        cacheKey = mAlbum.getCacheKey();
      } else if (mQuery != null) {
        album = mQuery.getAlbum();
        cacheKey = mQuery.getAlbum().getCacheKey();
      } else {
        album = mPlaylistEntry.getAlbum();
        cacheKey = mPlaylistEntry.getAlbum().getCacheKey();
      }
      if (album.getImage() != null) {
        ImageUtils.loadImageIntoImageView(
            TomahawkApp.getContext(),
            albumImageView,
            album.getImage(),
            Image.getLargeImageSize(),
            true,
            false);
      } else {
        String requestId = InfoSystem.get().resolve(album);
        if (requestId != null) {
          mCorrespondingRequestIds.add(requestId);
        }
      }

      // set text on "view album"-button and set up click listener
      View viewAlbumButton = view.findViewById(R.id.view_album_button);
      TextView viewAlbumButtonText = (TextView) viewAlbumButton.findViewById(R.id.textview);
      viewAlbumButtonText.setText(
          TomahawkApp.getContext().getString(R.string.view_album).toUpperCase());
      viewAlbumButton.setOnClickListener(constructAlbumNameClickListener(cacheKey));
    }
  }
 @SuppressWarnings("unused")
 public void onEventMainThread(InfoSystem.ResultsEvent event) {
   if (mCorrespondingRequestIds.contains(event.mInfoRequestData.getRequestId())
       && getView() != null) {
     ImageView albumImageView = (ImageView) getView().findViewById(R.id.album_imageview);
     Album album;
     if (mAlbum != null) {
       album = mAlbum;
     } else if (mQuery != null) {
       album = mQuery.getAlbum();
     } else {
       album = mPlaylistEntry.getAlbum();
     }
     ImageUtils.loadImageIntoImageView(
         TomahawkApp.getContext(),
         albumImageView,
         album.getImage(),
         Image.getLargeImageSize(),
         true,
         false);
   }
 }