[Android] Prevent NPEs
Geoffrey Métais
git at videolan.org
Wed Jul 26 11:33:10 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jul 26 11:07:46 2017 +0200| [daa32d3cc4d409c1ef46a92aff2a11ee282ebbf8] | committer: Geoffrey Métais
Prevent NPEs
> https://code.videolan.org/videolan/vlc-android/commit/daa32d3cc4d409c1ef46a92aff2a11ee282ebbf8
---
.../src/org/videolan/vlc/gui/dialogs/VlcDialog.java | 7 ++++---
.../vlc/gui/tv/MediaItemDetailsFragment.java | 20 +++++++++++---------
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/VlcDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/VlcDialog.java
index e8e1a9c43..b09260168 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/VlcDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/VlcDialog.java
@@ -59,12 +59,13 @@ public abstract class VlcDialog<T extends Dialog, B extends android.databinding.
@NonNull
@Override
public android.app.Dialog onCreateDialog(Bundle savedInstanceState) {
- mVlcDialog.setContext(this);
AppCompatDialog dialog = new AppCompatDialog(getActivity(), getTheme());
- dialog.setTitle(mVlcDialog.getTitle());
-
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
+ if (mVlcDialog != null) {
+ mVlcDialog.setContext(this);
+ dialog.setTitle(mVlcDialog.getTitle());
+ }
return dialog;
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java
index a1753af4d..a7e4c4b36 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java
@@ -164,15 +164,17 @@ public class MediaItemDetailsFragment extends DetailsFragment implements Playbac
MediaUtils.getSubs(getActivity(), media);
break;
case ID_PLAY_ALL:
- int position = -1;
- for (int i= 0; i < mediaList.size(); ++i)
- if (media.equals(mediaList.get(i)))
- position = i;
- Activity activity = getActivity();
- MediaUtils.openList(activity, mediaList, position);
- if (media.getType() == MediaWrapper.TYPE_AUDIO)
- getActivity().startActivity(new Intent(activity, AudioPlayerActivity.class));
- getActivity().finish();
+ if (mediaList != null) {
+ int position = -1;
+ for (int i= 0; i < mediaList.size(); ++i)
+ if (media.equals(mediaList.get(i)))
+ position = i;
+ Activity activity = getActivity();
+ MediaUtils.openList(activity, mediaList, position);
+ if (media.getType() == MediaWrapper.TYPE_AUDIO)
+ getActivity().startActivity(new Intent(activity, AudioPlayerActivity.class));
+ getActivity().finish();
+ }
break;
case ID_PLAY_FROM_START:
VideoPlayerActivity.start(getActivity(), media.getUri(), true);
More information about the Android
mailing list