Esempio n. 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 showAlbumFancyDropDown() {
    if (mAlbum != null) {
      CollectionManager.get()
          .getAvailableCollections(mAlbum)
          .done(
              new DoneCallback<List<Collection>>() {
                @Override
                public void onDone(final List<Collection> result) {
                  int initialSelection = 0;
                  for (int i = 0; i < result.size(); i++) {
                    if (result.get(i) == mCollection) {
                      initialSelection = i;
                      break;
                    }
                  }
                  showFancyDropDown(
                      initialSelection,
                      mAlbum.getPrettyName(),
                      FancyDropDown.convertToDropDownItemInfo(result),
                      new FancyDropDown.DropDownListener() {
                        @Override
                        public void onDropDownItemSelected(int position) {
                          mCollection = result.get(position);
                          updateAdapter();
                        }

                        @Override
                        public void onCancel() {}
                      });
                }
              });
    }
  }
 private void unpackArgs() {
   if (getArguments() != null) {
     if (getArguments().containsKey(TomahawkFragment.HIDE_REMOVE_BUTTON)) {
       mHideRemoveButton = getArguments().getBoolean(TomahawkFragment.HIDE_REMOVE_BUTTON);
     }
     if (getArguments().containsKey(TomahawkFragment.FROM_PLAYBACKFRAGMENT)) {
       mFromPlaybackFragment = getArguments().getBoolean(TomahawkFragment.FROM_PLAYBACKFRAGMENT);
     }
     if (getArguments().containsKey(TomahawkFragment.TOMAHAWKLISTITEM_TYPE)
         && getArguments().containsKey(TomahawkFragment.TOMAHAWKLISTITEM)) {
       String type = getArguments().getString(TomahawkFragment.TOMAHAWKLISTITEM_TYPE);
       String key = getArguments().getString(TomahawkFragment.TOMAHAWKLISTITEM);
       switch (type) {
         case TomahawkFragment.ALBUM:
           mAlbum = Album.getByKey(key);
           break;
         case TomahawkFragment.PLAYLIST:
           mPlaylist = Playlist.getByKey(key);
           break;
         case TomahawkFragment.ARTIST:
           mArtist = Artist.getByKey(key);
           break;
         case TomahawkFragment.QUERY:
           mQuery = Query.getByKey(key);
           break;
         case TomahawkFragment.SOCIALACTION:
           SocialAction socialAction = SocialAction.getByKey(key);
           Object targetObject = socialAction.getTargetObject();
           if (targetObject instanceof Artist) {
             mArtist = (Artist) targetObject;
           } else if (targetObject instanceof Album) {
             mAlbum = (Album) targetObject;
           } else if (targetObject instanceof Query) {
             mQuery = (Query) targetObject;
           } else if (targetObject instanceof Playlist) {
             mPlaylist = (Playlist) targetObject;
           }
           break;
         case TomahawkFragment.PLAYLISTENTRY:
           mPlaylistEntry = PlaylistEntry.getByKey(key);
           break;
       }
     }
     if (getArguments().containsKey(TomahawkFragment.COLLECTION_ID)) {
       mCollection =
           CollectionManager.get()
               .getCollection(getArguments().getString(TomahawkFragment.COLLECTION_ID));
     }
   }
 }