Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We found some opportunities to use the multi-catch construc of Java 7 and refactor the code. #463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
return;
}
retriever.setDataSource(path);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
}catch(IllegalArgumentException | IllegalStateException | IOException e) /*multi-catch refactor*/ {
e.printStackTrace();
}
long durationMs = Long.parseLong(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void playAudio(Integer media) {
}
tx.setText("Playing audio...");

} catch (Exception e) {
}catch (Exception e) {
Log.e(TAG, "error: " + e.getMessage(), e);
}

Expand All @@ -98,13 +98,7 @@ public MediaPlayer createMediaPlayer(Context context, int resid) {
afd.close();
mp.prepare();
return mp;
} catch (IOException ex) {
Log.d(TAG, "create failed:", ex);
// fall through
} catch (IllegalArgumentException ex) {
Log.d(TAG, "create failed:", ex);
// fall through
} catch (SecurityException ex) {
}catch(IOException | IllegalArgumentException | SecurityException ex) /*multi-catch refactor*/ {
Log.d(TAG, "create failed:", ex);
// fall through
}
Expand Down
11 changes: 1 addition & 10 deletions vitamio-sample/src/io/vov/vitamio/demo/MediaPlayerSubtitle.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,7 @@ private void playVideo() {
mediaPlayer.setOnTimedTextListener(this);

// TODO Auto-generated catch block
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
}catch(IllegalArgumentException | IllegalStateException | SecurityException | IOException e) /*multi-catch refactor*/ {
// TODO Auto-generated catch block
e.printStackTrace();
}
Expand Down
6 changes: 1 addition & 5 deletions vitamio/src/io/vov/vitamio/provider/MediaStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,7 @@ private static Bitmap getMiniThumbFromFile(Cursor c, Uri baseUri, ContentResolve
ParcelFileDescriptor pfdInput = cr.openFileDescriptor(thumbUri, "r");
bitmap = BitmapFactory.decodeFileDescriptor(pfdInput.getFileDescriptor(), null, options);
pfdInput.close();
} catch (FileNotFoundException ex) {
Log.e("getMiniThumbFromFile", ex);
} catch (IOException ex) {
Log.e("getMiniThumbFromFile", ex);
} catch (OutOfMemoryError ex) {
}catch(FileNotFoundException | IOException | OutOfMemoryError ex) /*multi-catch refactor*/ {
Log.e("getMiniThumbFromFile", ex);
}
return bitmap;
Expand Down
8 changes: 1 addition & 7 deletions vitamio/src/io/vov/vitamio/widget/VideoView.java
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,7 @@ private void openVideo() {
mMediaPlayer.prepareAsync();
mCurrentState = STATE_PREPARING;
attachMediaController();
} catch (IOException ex) {
Log.e("Unable to open content: " + mUri, ex);
mCurrentState = STATE_ERROR;
mTargetState = STATE_ERROR;
mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
return;
} catch (IllegalArgumentException ex) {
}catch(IOException | IllegalArgumentException ex) /*multi-catch refactor*/ {
Log.e("Unable to open content: " + mUri, ex);
mCurrentState = STATE_ERROR;
mTargetState = STATE_ERROR;
Expand Down