use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class HistoryFragment method onDestroyActionMode.
@Override
public void onDestroyActionMode(ActionMode mode) {
mActionMode = null;
int index = -1;
for (MediaWrapper media : mHistoryAdapter.getAll()) {
++index;
if (media.hasStateFlags(MediaLibraryItem.FLAG_SELECTED)) {
media.removeStateFlags(MediaLibraryItem.FLAG_SELECTED);
mHistoryAdapter.notifyItemChanged(index, media);
}
}
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class InfoActivity method updateMeta.
private void updateMeta() {
long length = 0L;
MediaWrapper[] tracks = mItem.getTracks();
int nbTracks = tracks != null ? tracks.length : 0;
if (nbTracks > 0)
for (MediaWrapper media : tracks) length += media.getLength();
if (length > 0)
mBinding.setLength(Tools.millisToText(length));
if (mItem.getItemType() == MediaLibraryItem.TYPE_MEDIA) {
MediaWrapper media = (MediaWrapper) mItem;
mBinding.setPath(Uri.decode(media.getUri().getPath()));
mBinding.setProgress(media.getLength() == 0 ? 0 : (int) ((long) 100 * media.getTime() / length));
mBinding.setSizeTitleText(getString(R.string.file_size));
} else if (mItem.getItemType() == MediaLibraryItem.TYPE_ARTIST) {
Medialibrary ml = VLCApplication.getMLInstance();
Album[] albums = ((Artist) mItem).getAlbums();
int nbAlbums = albums == null ? 0 : albums.length;
mBinding.setSizeTitleText(getString(R.string.albums));
mBinding.setSizeValueText(String.valueOf(nbAlbums));
mBinding.setExtraTitleText(getString(R.string.tracks));
mBinding.setExtraValueText(String.valueOf(nbTracks));
} else {
mBinding.setSizeTitleText(getString(R.string.tracks));
mBinding.setSizeValueText(String.valueOf(nbTracks));
}
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class PlaylistActivity method onActionItemClicked.
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
List<MediaLibraryItem> list = mAdapter.getSelection();
List<MediaWrapper> tracks = new ArrayList<>();
for (MediaLibraryItem mediaItem : list) tracks.addAll(Arrays.asList(mediaItem.getTracks()));
if (item.getItemId() == R.id.action_mode_audio_playlist_up) {
Toast.makeText(this, "UP !", Toast.LENGTH_SHORT).show();
return true;
}
if (item.getItemId() == R.id.action_mode_audio_playlist_down) {
Toast.makeText(this, "DOWN !", Toast.LENGTH_SHORT).show();
return true;
}
stopActionMode();
switch(item.getItemId()) {
case R.id.action_mode_audio_play:
mService.load(tracks, 0);
break;
case R.id.action_mode_audio_append:
mService.append(tracks);
break;
case R.id.action_mode_audio_add_playlist:
;
UiTools.addToPlaylist(this, tracks);
break;
case R.id.action_mode_audio_info:
showInfoDialog((MediaWrapper) list.get(0));
break;
case R.id.action_mode_audio_set_song:
AudioUtil.setRingtone((MediaWrapper) list.get(0), this);
break;
case R.id.action_mode_audio_delete:
removeFromPlaylist(tracks);
break;
default:
return false;
}
return true;
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class SavePlaylistDialog method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mMedialibrary = VLCApplication.getMLInstance();
mAdapter = new AudioBrowserAdapter(MediaLibraryItem.TYPE_PLAYLIST, this, false);
mTracks = (MediaWrapper[]) getArguments().getParcelableArray(KEY_TRACKS);
mNewTrack = (MediaWrapper[]) getArguments().getParcelableArray(KEY_NEW_TRACKS);
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class BaseBrowserFragment method inflate.
@Override
protected void inflate(Menu menu, int position) {
MediaWrapper mw = (MediaWrapper) mAdapter.getItem(position);
if (mw == null)
return;
int type = mw.getType();
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(type == MediaWrapper.TYPE_DIR ? R.menu.directory_view_dir : R.menu.directory_view_file, menu);
}
Aggregations