public void setSong(MusicDirectory.Entry song, boolean checkable) { this.song = song; StringBuilder artist = new StringBuilder(40); String bitRate = null; if (song.getBitRate() != null) { bitRate = String.format(getContext().getString(R.string.song_details_kbps), song.getBitRate()); } String fileFormat = null; if (song.getTranscodedSuffix() != null && !song.getTranscodedSuffix().equals(song.getSuffix())) { fileFormat = String.format("%s > %s", song.getSuffix(), song.getTranscodedSuffix()); } else { fileFormat = song.getSuffix(); } if (!song.isVideo()) { artist .append(song.getArtist()) .append(" (") .append( String.format( getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate, fileFormat)) .append(")"); } else { artist.append( String.format( getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate, fileFormat)); } titleTextView.setText(song.getTitle()); artistTextView.setText(artist); durationTextView.setText(Util.formatDuration(song.getDuration())); checkedTextView.setVisibility(checkable && !song.isVideo() ? View.VISIBLE : View.GONE); starButton.setVisibility( (Util.isOffline(getContext()) || !song.isStarred()) ? View.GONE : View.VISIBLE); starButton.setFocusable(false); moreButton = (ImageView) findViewById(R.id.artist_more); moreButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { v.showContextMenu(); } }); update(); }
@Override public boolean isChecked() { return checkedTextView.isChecked(); }
@Override public void toggle() { checkedTextView.toggle(); }
@Override public void setChecked(boolean b) { checkedTextView.setChecked(b); }