[Android] Prevent NPE
Geoffrey Métais
git at videolan.org
Tue Nov 29 19:18:28 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Nov 29 19:18:10 2016 +0100| [12700edfa7de49ab934ca653ee6107d25598e496] | committer: Geoffrey Métais
Prevent NPE
> https://code.videolan.org/videolan/vlc-android/commit/12700edfa7de49ab934ca653ee6107d25598e496
---
.../src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java | 2 +-
.../src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
index 3de9380..c19c213 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -109,7 +109,7 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<BaseBrowserAdapter.
private void onBindMediaViewHolder(final MediaViewHolder vh, int position) {
final MediaWrapper media = (MediaWrapper) getItem(position);
if (media.observableDescription == null)
- media.observableDescription = new ObservableField<>(media.getDescription());
+ media.observableDescription = new ObservableField<>();
vh.binding.setItem(media);
vh.binding.setHasContextMenu(true);
if (fragment instanceof NetworkBrowserFragment && fragment.isRootDirectory())
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index 64a0285..8966779 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -23,6 +23,7 @@
package org.videolan.vlc.gui.browser;
import android.annotation.TargetApi;
+import android.databinding.ObservableField;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -612,7 +613,11 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
MediaWrapper mw = null;
if (!TextUtils.equals(holderText, "")) {
- mAdapter.getItem(mCurrentParsedPosition).observableDescription.set(holderText);
+ MediaLibraryItem item = mAdapter.getItem(mCurrentParsedPosition);
+ if (item.observableDescription == null)
+ item.observableDescription = new ObservableField<>(holderText);
+ else
+ item.observableDescription.set(holderText);
directories.addAll(files);
mFoldersContentLists.put(mCurrentParsedPosition, new ArrayList<>(directories));
}
More information about the Android
mailing list