diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-11-04 17:26:41 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-11-04 17:26:41 -0800 |
commit | a0dd3b2c03b2fcb9d603d752db3ab46ad5d2f42b (patch) | |
tree | cee209d60aaaea18df8dc96ee5a4b4c42389af1b /app/src | |
parent | 5d58db060279bef27c7d73b40c1edbd8fac15975 (diff) | |
download | dsub-a0dd3b2c03b2fcb9d603d752db3ab46ad5d2f42b.tar.gz dsub-a0dd3b2c03b2fcb9d603d752db3ab46ad5d2f42b.tar.bz2 dsub-a0dd3b2c03b2fcb9d603d752db3ab46ad5d2f42b.zip |
Wrap crash in try/catch
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/fragments/EqualizerFragment.java | 90 |
1 files changed, 47 insertions, 43 deletions
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 6ca2da4f..9ee98cb4 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/EqualizerFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/EqualizerFragment.java @@ -193,56 +193,60 @@ public class EqualizerFragment extends SubsonicFragment { } private void updateBars(boolean changedEnabled) { - boolean isEnabled = equalizer.getEnabled(); - short minEQLevel = equalizer.getBandLevelRange()[0]; - short maxEQLevel = equalizer.getBandLevelRange()[1]; - for (Map.Entry<Short, SeekBar> entry : bars.entrySet()) { - short band = entry.getKey(); - SeekBar bar = entry.getValue(); - bar.setEnabled(isEnabled); - if(band >= (short)0) { - short setLevel; - if(changedEnabled) { - setLevel = (short)(equalizer.getBandLevel(band) - masterLevel); - if(isEnabled) { - bar.setProgress(equalizer.getBandLevel(band) - minEQLevel); + try { + boolean isEnabled = equalizer.getEnabled(); + short minEQLevel = equalizer.getBandLevelRange()[0]; + short maxEQLevel = equalizer.getBandLevelRange()[1]; + for (Map.Entry<Short, SeekBar> entry : bars.entrySet()) { + short band = entry.getKey(); + SeekBar bar = entry.getValue(); + bar.setEnabled(isEnabled); + if (band >= (short) 0) { + short setLevel; + if (changedEnabled) { + setLevel = (short) (equalizer.getBandLevel(band) - masterLevel); + if (isEnabled) { + bar.setProgress(equalizer.getBandLevel(band) - minEQLevel); + } else { + bar.setProgress(-minEQLevel); + } } else { - bar.setProgress(-minEQLevel); + bar.setProgress(equalizer.getBandLevel(band) - minEQLevel); + setLevel = (short) (equalizer.getBandLevel(band) + masterLevel); } - } else { - bar.setProgress(equalizer.getBandLevel(band) - minEQLevel); - setLevel = (short)(equalizer.getBandLevel(band) + masterLevel); - } - if(setLevel < minEQLevel) { - setLevel = minEQLevel; - } else if(setLevel > maxEQLevel) { - setLevel = maxEQLevel; + if (setLevel < minEQLevel) { + setLevel = minEQLevel; + } else if (setLevel > maxEQLevel) { + setLevel = maxEQLevel; + } + equalizer.setBandLevel(band, setLevel); + } else if (!isEnabled) { + bar.setProgress(-minEQLevel); } - equalizer.setBandLevel(band, setLevel); - } else if(!isEnabled) { - bar.setProgress(-minEQLevel); } - } - bassBar.setEnabled(isEnabled); - if(loudnessBar != null) { - loudnessBar.setEnabled(isEnabled); - } - if(changedEnabled && !isEnabled) { - bass.setStrength((short) 0); - bassBar.setProgress(0); - if(loudnessBar != null) { - loudnessEnhancer.setGain(0); - loudnessBar.setProgress(0); + bassBar.setEnabled(isEnabled); + if (loudnessBar != null) { + loudnessBar.setEnabled(isEnabled); + } + if (changedEnabled && !isEnabled) { + bass.setStrength((short) 0); + bassBar.setProgress(0); + if (loudnessBar != null) { + loudnessEnhancer.setGain(0); + loudnessBar.setProgress(0); + } } - } - if(!isEnabled) { - masterLevel = 0; - SharedPreferences prefs = Util.getPreferences(context); - SharedPreferences.Editor editor = prefs.edit(); - editor.putInt(Constants.PREFERENCES_EQUALIZER_SETTINGS, masterLevel); - editor.commit(); + if (!isEnabled) { + masterLevel = 0; + SharedPreferences prefs = Util.getPreferences(context); + SharedPreferences.Editor editor = prefs.edit(); + editor.putInt(Constants.PREFERENCES_EQUALIZER_SETTINGS, masterLevel); + editor.commit(); + } + } catch(Exception e) { + Log.e(TAG, "Failed to update bars"); } } |