Exemplo n.º 1
0
 public void setSubtitles(List<String> artistList) {
   subtitlePanel.clear();
   for (String artistId : artistList) {
     final Hyperlink artistLink = new Hyperlink();
     Label commaLabel = new Label(",");
     commaLabel.getElement().addClassName(style.space());
     Cache<String, ArtistInfo> artistCache = Controller.INSTANCE.getModel().getArtistCache();
     artistCache.addHandler(
         artistId,
         new CacheHandler<String, ArtistInfo>() {
           @Override
           public void onCacheUpdated(String k, ArtistInfo v) {
             artistLink.setText(v.getName());
             artistLink.setTargetHistoryToken(v.getTargetHistoryToken());
           }
         });
     artistCache.obtain(artistId);
     subtitlePanel.add(artistLink);
     subtitlePanel.add(commaLabel);
   }
   subtitlePanel.remove(subtitlePanel.getWidgetCount() - 1);
   subtitlePanel.setVisible(true);
 }
Exemplo n.º 2
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();
  }