[Android] Remove useless exception
Geoffrey Métais
git at videolan.org
Wed Feb 18 16:07:45 CET 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 18 15:34:41 2015 +0100| [62d3e5f795f6cc12549c944417ad4aaceb01e743] | committer: Geoffrey Métais
Remove useless exception
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=62d3e5f795f6cc12549c944417ad4aaceb01e743
---
libvlc/src/org/videolan/libvlc/LibVLC.java | 3 +--
.../videolan/vlc/gui/audio/EqualizerFragment.java | 21 +++++++------------
.../videolan/vlc/gui/dialogs/PickTimeFragment.java | 7 +------
.../videolan/vlc/gui/video/MediaInfoFragment.java | 8 +------
.../videolan/vlc/gui/video/VideoGridFragment.java | 4 +---
.../org/videolan/vlc/gui/tv/MainTvActivity.java | 22 ++++++++++++++------
.../vlc/gui/tv/browser/BrowserGridFragment.java | 4 +---
7 files changed, 28 insertions(+), 41 deletions(-)
diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index 1f87c7e..d0bd9e7 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -159,9 +159,8 @@ public class LibVLC {
* thumbnail and get information e.g. on the MediaLibraryActivity
*
* @return libVLC instance
- * @throws LibVlcException
*/
- public static LibVLC getInstance() throws LibVlcException {
+ public static LibVLC getInstance() {
synchronized (LibVLC.class) {
if (sInstance == null) {
/* First call */
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.java
index 10bbdb8..8cb3df2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.java
@@ -40,13 +40,11 @@ import android.widget.Spinner;
import android.widget.ToggleButton;
import org.videolan.libvlc.LibVLC;
-import org.videolan.libvlc.LibVlcException;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.interfaces.OnEqualizerBarChangeListener;
import org.videolan.vlc.util.Preferences;
import org.videolan.vlc.util.Util;
-import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.widget.EqualizerBar;
public class EqualizerFragment extends Fragment {
@@ -91,18 +89,13 @@ public class EqualizerFragment extends Fragment {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
float[] bands = null;
String[] presets = null;
- try {
- libVlc = VLCInstance.getLibVlcInstance();
- bands = libVlc.getBands();
- presets = libVlc.getPresets();
- if (equalizer == null)
- equalizer = Preferences.getFloatArray(preferences, "equalizer_values");
- if (equalizer == null)
- equalizer = new float[bands.length + 1];
- } catch (LibVlcException e) {
- e.printStackTrace();
- return;
- }
+ libVlc = LibVLC.getInstance();
+ bands = libVlc.getBands();
+ presets = libVlc.getPresets();
+ if (equalizer == null)
+ equalizer = Preferences.getFloatArray(preferences, "equalizer_values");
+ if (equalizer == null)
+ equalizer = new float[bands.length + 1];
// on/off
button.setChecked(libVlc.getEqualizer() != null);
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java
index a0066bf..8eb70fc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java
@@ -33,7 +33,6 @@ import android.widget.Button;
import android.widget.TextView;
import org.videolan.libvlc.LibVLC;
-import org.videolan.libvlc.LibVlcException;
import org.videolan.vlc.R;
public abstract class PickTimeFragment extends DialogFragment implements DialogInterface.OnKeyListener, View.OnClickListener, View.OnFocusChangeListener, TextView.OnEditorActionListener {
@@ -60,11 +59,7 @@ public abstract class PickTimeFragment extends DialogFragment implements DialogI
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- try {
- mLibVLC = LibVLC.getInstance();
- } catch (LibVlcException e) {
- getDialog().dismiss();
- }
+ mLibVLC = LibVLC.getInstance();
View view = inflater.inflate(R.layout.jump_to_time, container);
((TextView)view.findViewById(R.id.jump_dialog_title)).setText(getTitle());
mHours = (TextView) view.findViewById(R.id.jump_hours);
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
index 631118c..01fdf96 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
@@ -25,7 +25,6 @@ import java.nio.ByteBuffer;
import java.util.Locale;
import org.videolan.libvlc.LibVLC;
-import org.videolan.libvlc.LibVlcException;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.util.Extensions;
@@ -36,7 +35,6 @@ import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.util.BitmapUtil;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;
-import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.WeakHandler;
import android.content.res.Configuration;
@@ -198,11 +196,7 @@ public class MediaInfoFragment extends ListFragment {
Runnable mLoadImage = new Runnable() {
@Override
public void run() {
- try {
- mLibVlc = VLCInstance.getLibVlcInstance();
- } catch (LibVlcException e) {
- return;
- }
+ mLibVlc = LibVLC.getInstance();
mMedia = new Media(mLibVlc, mItem.getLocation());
mMedia.parse();
mMedia.release();
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index e49bfd1..246f700 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -126,9 +126,7 @@ public class VideoGridFragment extends BrowserFragment implements ISortable, IVi
FragmentActivity activity = getActivity();
if (activity != null)
mThumbnailer = new Thumbnailer(activity, activity.getWindowManager().getDefaultDisplay());
- try {
- mLibVlc = LibVLC.getInstance();
- } catch (LibVlcException e) {}
+ mLibVlc = LibVLC.getInstance();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java
index 69d5cf0..6fa1acf 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java
@@ -25,18 +25,20 @@ import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import org.videolan.libvlc.LibVLC;
+import org.videolan.libvlc.LibVlcException;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.Thumbnailer;
+import org.videolan.vlc.gui.CompatErrorActivity;
import org.videolan.vlc.gui.PreferencesActivity;
import org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity;
-import org.videolan.vlc.gui.tv.browser.GridFragment;
import org.videolan.vlc.gui.tv.browser.MusicFragment;
import org.videolan.vlc.gui.tv.browser.VerticalGridActivity;
import org.videolan.vlc.interfaces.IVideoBrowser;
import org.videolan.vlc.gui.video.VideoListHandler;
+import org.videolan.vlc.util.VLCInstance;
import android.app.Activity;
import android.app.FragmentManager;
@@ -120,12 +122,20 @@ public class MainTvActivity extends Activity implements IVideoBrowser {
/*
* skip browser and show directly Audio Player if a song is playing
*/
- if (LibVLC.getExistingInstance() != null){
- if (LibVLC.getExistingInstance().isPlaying()){
- startActivity(new Intent(this, AudioPlayerActivity.class));
- finish();
- return;
+ try {
+ if (VLCInstance.getLibVlcInstance() != null){
+ if (LibVLC.getExistingInstance().isPlaying()){
+ startActivity(new Intent(this, AudioPlayerActivity.class));
+ finish();
+ return;
+ }
}
+ } catch (LibVlcException e) {
+ Intent i = new Intent(this, CompatErrorActivity.class);
+ startActivity(i);
+ finish();
+ super.onCreate(savedInstanceState);
+ return;
}
mContext = this;
setContentView(R.layout.tv_main_fragment);
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
index 932f12e..24b425f 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
@@ -57,9 +57,7 @@ public class BrowserGridFragment extends GridFragment implements MediaBrowser.Ev
super.onResume();
if (mAdapter.size() == 0) {
if (mAdapter.size() == 0) {
- try {
- mMediaBrowser = new MediaBrowser(LibVLC.getInstance(), this);
- } catch (LibVlcException e) {}
+ mMediaBrowser = new MediaBrowser(LibVLC.getInstance(), this);
if (mMediaBrowser != null) {
mMediaList = new ArrayList<>();
if (mMrl != null)
More information about the Android
mailing list