Commit 95ec1882 authored by Geoffrey Métais's avatar Geoffrey Métais

Avoid NPE in MediaInfoFragment

parent edf73f54
...@@ -173,10 +173,11 @@ public class MediaInfoFragment extends ListFragment { ...@@ -173,10 +173,11 @@ public class MediaInfoFragment extends ListFragment {
@Override @Override
public void run() { public void run() {
File itemFile = new File(Uri.decode(mItem.getLocation().substring(5))); File itemFile = new File(Uri.decode(mItem.getLocation().substring(5)));
if (!itemFile.canWrite()) if (!itemFile.canWrite() && mHandler != null)
mHandler.obtainMessage(HIDE_DELETE).sendToTarget(); mHandler.obtainMessage(HIDE_DELETE).sendToTarget();
long length = itemFile.length(); long length = itemFile.length();
mHandler.obtainMessage(NEW_SIZE, Long.valueOf(length)).sendToTarget(); if (mHandler != null)
mHandler.obtainMessage(NEW_SIZE, Long.valueOf(length)).sendToTarget();
if (mItem.getType() == MediaWrapper.TYPE_VIDEO) if (mItem.getType() == MediaWrapper.TYPE_VIDEO)
checkSubtitles(itemFile); checkSubtitles(itemFile);
} }
...@@ -214,10 +215,8 @@ public class MediaInfoFragment extends ListFragment { ...@@ -214,10 +215,8 @@ public class MediaInfoFragment extends ListFragment {
if (!Extensions.SUBTITLES.contains(extension)) if (!Extensions.SUBTITLES.contains(extension))
continue; continue;
if (mHandler == null || Thread.interrupted()) { if (mHandler == null || Thread.interrupted())
return; return;
}
if (filename.startsWith(videoName)) { if (filename.startsWith(videoName)) {
mHandler.obtainMessage(SHOW_SUBTITLES).sendToTarget(); mHandler.obtainMessage(SHOW_SUBTITLES).sendToTarget();
return; return;
...@@ -245,7 +244,8 @@ public class MediaInfoFragment extends ListFragment { ...@@ -245,7 +244,8 @@ public class MediaInfoFragment extends ListFragment {
mMedia = new Media(libVlc, mItem.getUri()); mMedia = new Media(libVlc, mItem.getUri());
mMedia.parse(); mMedia.parse();
mHandler.sendEmptyMessage(NEW_TEXT); if (mHandler != null)
mHandler.sendEmptyMessage(NEW_TEXT);
DisplayMetrics screen = new DisplayMetrics(); DisplayMetrics screen = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(screen); getActivity().getWindowManager().getDefaultDisplay().getMetrics(screen);
...@@ -272,10 +272,8 @@ public class MediaInfoFragment extends ListFragment { ...@@ -272,10 +272,8 @@ public class MediaInfoFragment extends ListFragment {
} else } else
return; return;
if (mHandler == null || Thread.interrupted()) { if (mHandler == null || Thread.interrupted())
return; return;
}
mHandler.sendEmptyMessage(NEW_IMAGE); mHandler.sendEmptyMessage(NEW_IMAGE);
} }
}; };
...@@ -308,7 +306,7 @@ public class MediaInfoFragment extends ListFragment { ...@@ -308,7 +306,7 @@ public class MediaInfoFragment extends ListFragment {
mAdapter.add(track); mAdapter.add(track);
} }
if (hasSubs) if (hasSubs && mHandler != null)
mHandler.obtainMessage(SHOW_SUBTITLES).sendToTarget(); mHandler.obtainMessage(SHOW_SUBTITLES).sendToTarget();
} }
...@@ -324,7 +322,8 @@ public class MediaInfoFragment extends ListFragment { ...@@ -324,7 +322,8 @@ public class MediaInfoFragment extends ListFragment {
public void run() { public void run() {
FileUtils.deleteFile(mItem.getUri().getPath()); FileUtils.deleteFile(mItem.getUri().getPath());
MediaDatabase.getInstance().removeMedia(mItem.getUri()); MediaDatabase.getInstance().removeMedia(mItem.getUri());
mHandler.sendEmptyMessage(EXIT); if (mHandler != null)
mHandler.sendEmptyMessage(EXIT);
} }
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment