[Android] Prevent ClassCastException
Geoffrey Métais
git at videolan.org
Fri Feb 24 18:42:01 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb 24 18:41:46 2017 +0100| [4455c1e7811d49349fe3d310377491e6fa6c2d75] | committer: Geoffrey Métais
Prevent ClassCastException
> https://code.videolan.org/videolan/vlc-android/commit/4455c1e7811d49349fe3d310377491e6fa6c2d75
---
.../src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
index 25b315c..b0bdb6b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
@@ -51,7 +51,9 @@ class StorageBrowserAdapter extends BaseBrowserAdapter {
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
final MediaViewHolder vh = (MediaViewHolder) holder;
- final MediaLibraryItem storage = getItem(position);
+ 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 += "/";
@@ -67,6 +69,8 @@ class StorageBrowserAdapter extends BaseBrowserAdapter {
public void addItem(MediaLibraryItem item, boolean top) {
if (item.getItemType() == MediaLibraryItem.TYPE_MEDIA)
item = new Storage(((MediaWrapper)item).getUri());
+ else if (item.getItemType() != MediaLibraryItem.TYPE_STORAGE)
+ return;
super.addItem(item, top);
}
More information about the Android
mailing list