use of org.videolan.medialibrary.media.Storage in project vlc-android by videolan.
the class StorageBrowserAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
final MediaViewHolder vh = (MediaViewHolder) holder;
MediaLibraryItem storage = getItem(position);
if (storage.getItemType() == MediaLibraryItem.TYPE_MEDIA)
storage = new Storage(((MediaWrapper) storage).getUri());
String storagePath = ((Storage) storage).getUri().getPath();
if (!storagePath.endsWith("/"))
storagePath += "/";
boolean hasContextMenu = mCustomDirsLocation.contains(storagePath);
boolean checked = ((StorageBrowserFragment) fragment).mScannedDirectory || mMediaDirsLocation.contains(storagePath);
vh.binding.setItem(storage);
vh.binding.setHasContextMenu(hasContextMenu);
if (checked)
vh.binding.browserCheckbox.setState(ThreeStatesCheckbox.STATE_CHECKED);
else if (hasDiscoveredChildren(storagePath))
vh.binding.browserCheckbox.setState(ThreeStatesCheckbox.STATE_PARTIAL);
else
vh.binding.browserCheckbox.setState(ThreeStatesCheckbox.STATE_UNCHECKED);
vh.binding.setCheckEnabled(!((StorageBrowserFragment) fragment).mScannedDirectory);
}
use of org.videolan.medialibrary.media.Storage in project vlc-android by videolan.
the class StorageBrowserFragment method setContextMenuItems.
protected void setContextMenuItems(MenuInflater inflater, Menu menu, int position) {
if (mRoot) {
Storage storage = (Storage) mAdapter.getItem(position);
boolean isCustom = CustomDirectories.contains(storage.getUri().getPath());
if (isCustom)
inflater.inflate(R.menu.directory_custom_dir, menu);
} else
super.setContextMenuItems(menu, position);
}
use of org.videolan.medialibrary.media.Storage in project vlc-android by GeoffreyMetais.
the class StorageBrowserFragment method setContextMenuItems.
protected void setContextMenuItems(MenuInflater inflater, Menu menu, int position) {
if (mRoot) {
Storage storage = (Storage) mAdapter.getItem(position);
boolean isCustom = CustomDirectories.contains(storage.getUri().getPath());
if (isCustom)
inflater.inflate(R.menu.directory_custom_dir, menu);
} else
super.setContextMenuItems(menu, position);
}
use of org.videolan.medialibrary.media.Storage in project vlc-android by videolan.
the class FileBrowserFragment method handleContextItemSelected.
@Override
protected boolean handleContextItemSelected(MenuItem item, int position) {
if (mRoot && item.getItemId() == R.id.directory_remove_custom_path) {
Storage storage = (Storage) mAdapter.getItem(position);
MediaDatabase.getInstance().recursiveRemoveDir(storage.getUri().getPath());
CustomDirectories.removeCustomDirectory(storage.getUri().getPath());
mAdapter.removeItem(position);
((AudioPlayerContainerActivity) getActivity()).updateLib();
return true;
} else
return super.handleContextItemSelected(item, position);
}
use of org.videolan.medialibrary.media.Storage in project vlc-android by videolan.
the class StorageBrowserFragment method browseRoot.
@Override
protected void browseRoot() {
String[] storages = AndroidDevices.getMediaDirectories();
String[] customDirectories = CustomDirectories.getCustomDirectories();
Storage storage;
final ArrayList<MediaLibraryItem> storagesList = new ArrayList<>();
for (String mediaDirLocation : storages) {
if (TextUtils.isEmpty(mediaDirLocation))
continue;
storage = new Storage(Uri.fromFile(new File(mediaDirLocation)));
if (TextUtils.equals(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY, mediaDirLocation))
storage.setName(getString(R.string.internal_memory));
storagesList.add(storage);
}
customLoop: for (String customDir : customDirectories) {
for (String mediaDirLocation : storages) {
if (TextUtils.isEmpty(mediaDirLocation))
continue;
if (customDir.startsWith(mediaDirLocation))
continue customLoop;
}
storage = new Storage(Uri.parse(customDir));
storagesList.add(storage);
}
VLCApplication.runOnMainThread(new Runnable() {
@Override
public void run() {
mAdapter.update(storagesList);
}
});
mHandler.sendEmptyMessage(BrowserFragmentHandler.MSG_HIDE_LOADING);
}
Aggregations