aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-05-20 12:02:33 -0600
committerdaneren2005 <daneren2005@gmail.com>2013-05-20 12:02:33 -0600
commit6219116b1b707510ee66b810ea280a0f4c8b59f8 (patch)
treef5dc9c7f7efffa4dd2a16bfef05b738eb4f62b39
parentec670db9b3e71af2a644e8c7cbc8e1565c3cf0a8 (diff)
downloaddsub-6219116b1b707510ee66b810ea280a0f4c8b59f8.tar.gz
dsub-6219116b1b707510ee66b810ea280a0f4c8b59f8.tar.bz2
dsub-6219116b1b707510ee66b810ea280a0f4c8b59f8.zip
Cap the min/max level for the EQ
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java12
1 files changed, 10 insertions, 2 deletions
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<Short, SeekBar> 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);
}