From ec0fbf498e1506368a057a594d89a8fcbc6503ce Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 12 May 2015 08:35:10 -0700 Subject: Fix a couple of EQ related crashes --- .../dsub/fragments/EqualizerFragment.java | 36 +++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/EqualizerFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/EqualizerFragment.java index b7080a8e..ea61f2c7 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/EqualizerFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/EqualizerFragment.java @@ -274,11 +274,15 @@ public class EqualizerFragment extends SubsonicFragment { bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { - short level = (short) (progress + minEQLevel); - if (fromUser) { - equalizer.setBandLevel(band, (short)(level + masterLevel)); + try { + short level = (short) (progress + minEQLevel); + if (fromUser) { + equalizer.setBandLevel(band, (short) (level + masterLevel)); + } + updateLevelText(levelTextView, level); + } catch(Exception e) { + Log.e(TAG, "Failed to change equalizer", e); } - updateLevelText(levelTextView, level); } @Override @@ -410,18 +414,22 @@ public class EqualizerFragment extends SubsonicFragment { bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { - masterLevel = (short) (progress + minEQLevel); - if (fromUser) { - SharedPreferences prefs = Util.getPreferences(context); - SharedPreferences.Editor editor = prefs.edit(); - editor.putInt(Constants.PREFERENCES_EQUALIZER_SETTINGS, masterLevel); - editor.commit(); - for (short i = 0; i < equalizer.getNumberOfBands(); i++) { - short level = (short) ((bars.get(i).getProgress() + minEQLevel) + masterLevel); - equalizer.setBandLevel(i, level); + try { + masterLevel = (short) (progress + minEQLevel); + if (fromUser) { + SharedPreferences prefs = Util.getPreferences(context); + SharedPreferences.Editor editor = prefs.edit(); + editor.putInt(Constants.PREFERENCES_EQUALIZER_SETTINGS, masterLevel); + editor.commit(); + for (short i = 0; i < equalizer.getNumberOfBands(); i++) { + short level = (short) ((bars.get(i).getProgress() + minEQLevel) + masterLevel); + equalizer.setBandLevel(i, level); + } } + updateLevelText(levelTextView, masterLevel); + } catch(Exception e) { + Log.e(TAG, "Failed to change equalizer", e); } - updateLevelText(levelTextView, masterLevel); } @Override -- cgit v1.2.3