Search in sources :

Example 1 with Storage

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);
}
Also used : Storage(org.videolan.medialibrary.media.Storage) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem)

Example 2 with Storage

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);
}
Also used : Storage(org.videolan.medialibrary.media.Storage)

Example 3 with Storage

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);
}
Also used : Storage(org.videolan.medialibrary.media.Storage)

Example 4 with Storage

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);
}
Also used : AudioPlayerContainerActivity(org.videolan.vlc.gui.AudioPlayerContainerActivity) Storage(org.videolan.medialibrary.media.Storage)

Example 5 with Storage

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);
}
Also used : Storage(org.videolan.medialibrary.media.Storage) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

Storage (org.videolan.medialibrary.media.Storage)7 MediaLibraryItem (org.videolan.medialibrary.media.MediaLibraryItem)3 AudioPlayerContainerActivity (org.videolan.vlc.gui.AudioPlayerContainerActivity)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1