Exemplo n.º 1
0
  public SongPanel(String albumId, String artistId, String collectionId) {
    initWidget(uiBinder.createAndBindUi(this));

    this.albumId = albumId;
    this.artistId = artistId;
    this.inCollection = collectionId;

    // Get album info (null means all songs)
    if (albumId == null && artistId == null) {
      if (inCollection != null) {
        titleLabel.setText(
            Controller.INSTANCE.getModel().getTagCache().get(inCollection).getName());
      } else {
        titleLabel.setText(Constants.I18N.allMusic());
      }
      byLabel.setVisible(false);
      subtitlePanel.setVisible(false);
      setViewLinks(true, true);
      backButton.setVisible(false);
    } else if (artistId != null) {
      Cache<String, ArtistInfo> artistCache = Controller.INSTANCE.getModel().getArtistCache();
      artistCache.addHandler(
          artistId,
          new CacheHandler<String, ArtistInfo>() {
            @Override
            public void onCacheUpdated(String k, ArtistInfo v) {
              titleLabel.setText(v.getName());
            }
          });
      artistCache.obtain(artistId);
      byLabel.setVisible(false);
      subtitlePanel.setVisible(false);
      setViewLinks(false, true);
      Utils.setBackButton(backButton, collectionId);
    } else {
      Cache<String, AlbumInfo> albumCache = Controller.INSTANCE.getModel().getAlbumCache();
      albumCache.addHandler(
          albumId,
          new CacheHandler<String, AlbumInfo>() {
            @Override
            public void onCacheUpdated(String k, AlbumInfo v) {
              titleLabel.setText(v.getName());
              byLabel.setVisible(true);
              setSubtitles(v.getArtistList());
            }
          });
      albumCache.obtain(albumId);
      setViewLinks(false, false);
      Utils.setBackButton(backButton, collectionId);
    }

    // Create button line
    createButtonLine();
  }
Exemplo n.º 2
0
 private void setViewLinks(boolean showArtist, boolean showAlbum) {
   if (showArtist) {
     String artistTarget =
         Utils.getTargetHistoryToken(artistId, albumId, inCollection, ViewKind.ARTISTS.toString());
     viewTabs.setTarget(ViewKind.ARTISTS, artistTarget);
     String albumTarget =
         Utils.getTargetHistoryToken(artistId, albumId, inCollection, ViewKind.ALBUMS.toString());
     viewTabs.setTarget(ViewKind.ALBUMS, albumTarget);
   } else if (showAlbum) {
     String albumTarget =
         Utils.getTargetHistoryToken(artistId, albumId, inCollection, ViewKind.ALBUMS.toString());
     viewTabs.setTarget(ViewKind.ALBUMS, albumTarget);
     viewTabs.hideTab(ViewKind.ARTISTS);
   } else {
     viewTabs.setVisible(false);
   }
   viewTabs.setSelected(ViewKind.SONGS);
 }