public void fillView(Playlist playlist) {
   if (findViewById(R.id.imageview_create_playlist) != null) {
     findViewById(R.id.imageview_create_playlist).setVisibility(View.GONE);
   }
   ArrayList<Image> artistImages = new ArrayList<>();
   String topArtistsString = "";
   String[] artists = playlist.getTopArtistNames();
   if (artists != null) {
     for (int i = 0; i < artists.length && i < 5 && artistImages.size() < 3; i++) {
       Artist artist = Artist.get(artists[i]);
       topArtistsString += artists[i];
       if (i != artists.length - 1) {
         topArtistsString += ", ";
       }
       if (artist.getImage() != null) {
         artistImages.add(artist.getImage());
       }
     }
   }
   fillView(mRootView, artistImages, 0, false);
   TextView textView1 = (TextView) findViewById(R.id.textview1);
   if (textView1 != null) {
     textView1.setText(playlist.getName());
   }
   TextView textView2 = (TextView) findViewById(R.id.textview2);
   if (textView2 != null) {
     textView2.setText(topArtistsString);
     textView2.setVisibility(View.VISIBLE);
   }
   TextView textView3 = (TextView) findViewById(R.id.textview3);
   if (textView3 != null) {
     textView3.setVisibility(View.VISIBLE);
     textView3.setText(
         TomahawkApp.getContext()
             .getResources()
             .getQuantityString(
                 R.plurals.songs_with_count, (int) playlist.getCount(), playlist.getCount()));
   }
 }
 private void setupTextViews(View view) {
   if (mAlbum != null) {
     View v = ViewUtils.ensureInflation(view, R.id.album_name_button_stub, R.id.album_name_button);
     TextView textView = (TextView) v.findViewById(R.id.textview);
     textView.setText(mAlbum.getName());
     v.setOnClickListener(constructAlbumNameClickListener(mAlbum.getCacheKey()));
   } else if (mQuery != null || mPlaylistEntry != null || mPlaylist != null) {
     View v = ViewUtils.ensureInflation(view, R.id.track_name_stub, R.id.track_name);
     TextView textView = (TextView) v;
     if (mQuery != null) {
       textView.setText(mQuery.getName());
     } else if (mPlaylistEntry != null) {
       textView.setText(mPlaylistEntry.getName());
     } else if (mPlaylist != null) {
       textView.setText(mPlaylist.getName());
     }
   }
   if (mAlbum != null || mQuery != null || mPlaylistEntry != null || mArtist != null) {
     View v =
         ViewUtils.ensureInflation(view, R.id.artist_name_button_stub, R.id.artist_name_button);
     TextView textView = (TextView) v.findViewById(R.id.textview);
     String cacheKey;
     if (mQuery != null) {
       textView.setText(mQuery.getArtist().getPrettyName());
       cacheKey = mQuery.getArtist().getCacheKey();
     } else if (mAlbum != null) {
       textView.setText(mAlbum.getArtist().getPrettyName());
       cacheKey = mAlbum.getArtist().getCacheKey();
     } else if (mPlaylistEntry != null) {
       textView.setText(mPlaylistEntry.getArtist().getPrettyName());
       cacheKey = mPlaylistEntry.getArtist().getCacheKey();
     } else {
       textView.setText(mArtist.getPrettyName());
       cacheKey = mArtist.getCacheKey();
     }
     v.setOnClickListener(constructArtistNameClickListener(cacheKey));
   }
 }
  /**
   * Update this {@link org.tomahawk.tomahawk_android.fragments.TomahawkFragment}'s {@link
   * org.tomahawk.tomahawk_android.adapters.TomahawkListAdapter} content
   */
  @Override
  protected void updateAdapter() {
    if (!mIsResumed) {
      return;
    }

    if (mAlbum != null) {
      showContentHeader(mAlbum);
      if (mContainerFragmentClass == null) {
        showAlbumFancyDropDown();
      }
      mCollection
          .getAlbumTracks(mAlbum)
          .done(
              new DoneCallback<Playlist>() {
                @Override
                public void onDone(Playlist playlist) {
                  mCurrentPlaylist = playlist;
                  Segment.Builder builder =
                      new Segment.Builder(playlist)
                          .headerLayout(R.layout.single_line_list_header)
                          .headerString(mAlbum.getArtist().getPrettyName());
                  if (playlist != null && playlist.allFromOneArtist()) {
                    builder.hideArtistName(true);
                    builder.showDuration(true);
                  }
                  builder.showNumeration(true, 1);
                  fillAdapter(builder.build());
                }
              });
    } else if (mUser != null || mPlaylist != null) {
      if (mUser != null) {
        if (mShowMode == SHOW_MODE_PLAYBACKLOG) {
          mCurrentPlaylist = mUser.getPlaybackLog();
        } else if (mShowMode == SHOW_MODE_LOVEDITEMS) {
          mCurrentPlaylist = mUser.getFavorites();
        }
      }
      if (mPlaylist != null) {
        mCurrentPlaylist = mPlaylist;
      }
      if (!mCurrentPlaylist.isFilled()) {
        User.getSelf()
            .done(
                new DoneCallback<User>() {
                  @Override
                  public void onDone(User user) {
                    if (mShowMode < 0) {
                      if (mUser != user) {
                        String requestId = InfoSystem.get().resolve(mCurrentPlaylist);
                        if (requestId != null) {
                          mCorrespondingRequestIds.add(requestId);
                        }
                      } else if (mPlaylist != null) {
                        mPlaylist = DatabaseHelper.get().getPlaylist(mPlaylist.getId());
                        updateAdapter();
                      }
                    }
                  }
                });
      } else {
        Segment.Builder builder = new Segment.Builder(mCurrentPlaylist);
        if (mContainerFragmentClass == null
            || !mContainerFragmentClass.equals(SearchPagerFragment.class.getName())) {
          builder.showNumeration(true, 1);
          if (mContainerFragmentClass == null
              || !mContainerFragmentClass.equals(ChartsPagerFragment.class.getName())) {
            builder
                .headerLayout(R.layout.single_line_list_header)
                .headerString(R.string.playlist_details);
          }
        } else if (mContainerFragmentClass.equals(SearchPagerFragment.class.getName())) {
          builder.showResolverIcon(true);
        }
        Segment segment = builder.build();
        fillAdapter(segment);
        showContentHeader(mCurrentPlaylist);
        showFancyDropDown(0, mCurrentPlaylist.getName(), null, null);
        ThreadManager.get()
            .execute(
                new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_INFOSYSTEM_LOW) {
                  @Override
                  public void run() {
                    if (mCurrentPlaylist.getTopArtistNames() == null
                        || mCurrentPlaylist.getTopArtistNames().length == 0) {
                      boolean isFavorites =
                          mUser != null && mCurrentPlaylist == mUser.getFavorites();
                      mCurrentPlaylist.updateTopArtistNames(isFavorites);
                    } else {
                      for (int i = 0;
                          i < mCurrentPlaylist.getTopArtistNames().length && i < 5;
                          i++) {
                        String artistName = mCurrentPlaylist.getTopArtistNames()[i];
                        if (!mResolvingTopArtistNames.contains(artistName)) {
                          String requestId =
                              InfoSystem.get().resolve(Artist.get(artistName), false);
                          if (requestId != null) {
                            mCorrespondingRequestIds.add(requestId);
                          }
                          mResolvingTopArtistNames.add(artistName);
                        }
                      }
                    }
                  }
                });
      }
    } else {
      mCollection
          .getQueries(getSortMode())
          .done(
              new DoneCallback<Playlist>() {
                @Override
                public void onDone(final Playlist playlist) {
                  new Thread(
                          new Runnable() {
                            @Override
                            public void run() {
                              mCurrentPlaylist = playlist;
                              String id = mCollection.getId();
                              Segment segment =
                                  new Segment.Builder(playlist)
                                      .headerLayout(R.layout.dropdown_header)
                                      .headerStrings(constructDropdownItems())
                                      .spinner(
                                          constructDropdownListener(
                                              COLLECTION_TRACKS_SPINNER_POSITION + id),
                                          getDropdownPos(COLLECTION_TRACKS_SPINNER_POSITION + id))
                                      .build();
                              fillAdapter(segment);
                            }
                          })
                      .start();
                }
              });
    }
  }