From 6219116b1b707510ee66b810ea280a0f4c8b59f8 Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Mon, 20 May 2013 12:02:33 -0600 Subject: Cap the min/max level for the EQ --- .../github/daneren2005/dsub/activity/EqualizerActivity.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'subsonic-android/src/github/daneren2005') diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java index e5de3858..d9605fc5 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java @@ -142,18 +142,26 @@ public class EqualizerActivity extends Activity { private void updateBars(boolean changedEnabled) { boolean isEnabled = equalizer.getEnabled(); short minEQLevel = equalizer.getBandLevelRange()[0]; + short maxEQLevel = equalizer.getBandLevelRange()[1]; for (Map.Entry entry : bars.entrySet()) { short band = entry.getKey(); SeekBar bar = entry.getValue(); bar.setEnabled(isEnabled); if(band >= (short)0) { + short setLevel; if(changedEnabled) { - equalizer.setBandLevel(band, (short)(equalizer.getBandLevel(band) - masterLevel)); + setLevel = (short)(equalizer.getBandLevel(band) - masterLevel); bar.setProgress(equalizer.getBandLevel(band) - minEQLevel); } else { bar.setProgress(equalizer.getBandLevel(band) - minEQLevel); - equalizer.setBandLevel(band, (short)(equalizer.getBandLevel(band) + masterLevel)); + setLevel = (short)(equalizer.getBandLevel(band) + masterLevel); } + if(setLevel < minEQLevel) { + setLevel = minEQLevel; + } else if(setLevel > maxEQLevel) { + setLevel = maxEQLevel; + } + equalizer.setBandLevel(band, setLevel); } else if(!isEnabled) { bar.setProgress(-minEQLevel); } -- cgit v1.2.3