@@ -172,7 +172,7 @@ public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) {
172172 }
173173
174174 /*//////////////////////////////////////////////////////////////////////////
175- // Control Views
175+ // UI Initialization and Control
176176 //////////////////////////////////////////////////////////////////////////*/
177177
178178 private void initUI() {
@@ -265,8 +265,7 @@ private void initUI() {
265265 isChecked -> {
266266 if (!isChecked) {
267267 // when unchecked, slide back to the minimum of current tempo or pitch
268- setSliders(Math.min(pitchPercent, tempo));
269- updateCallback();
268+ ensureHookIsValidAndUpdateCallBack();
270269 }
271270 });
272271
@@ -277,6 +276,8 @@ private void initUI() {
277276 });
278277 }
279278
279+ // -- General formatting --
280+
280281 private void setText(
281282 final TextView textView,
282283 final DoubleFunction<String> formatter,
@@ -285,6 +286,8 @@ private void setText(
285286 Objects.requireNonNull(textView).setText(formatter.apply(value));
286287 }
287288
289+ // -- Steps --
290+
288291 private void registerOnStepClickListener(
289292 final TextView stepTextView,
290293 final DoubleSupplier currentValueSupplier,
@@ -310,6 +313,8 @@ private void registerOnSemitoneStepClickListener(
310313 });
311314 }
312315
316+ // -- Pitch --
317+
313318 private void setupPitchControlModeTextView(
314319 final boolean semitones,
315320 final TextView textView
@@ -367,6 +372,9 @@ private void changePitchControlMode(final boolean semitones) {
367372 this.onPitchPercentSliderUpdated(newPitchPercent);
368373 updateCallback();
369374 }
375+ } else if (!binding.unhookCheckbox.isChecked()) {
376+ // When changing to percent it's possible that tempo is != pitch
377+ ensureHookIsValidAndUpdateCallBack();
370378 }
371379 }
372380
@@ -377,6 +385,8 @@ private boolean isCurrentPitchControlModeSemitone() {
377385 PITCH_CTRL_MODE_PERCENT);
378386 }
379387
388+ // -- Steps (Set) --
389+
380390 private void setupStepTextView(
381391 final double stepSizeValue,
382392 final TextView textView
@@ -430,6 +440,8 @@ private double getCurrentStepSize() {
430440 .getFloat(getString(R.string.adjustment_step_key), (float) DEFAULT_STEP);
431441 }
432442
443+ // -- Additional options --
444+
433445 private void setAndUpdateSkipSilence(final boolean newSkipSilence) {
434446 this.skipSilence = newSkipSilence;
435447 binding.skipSilenceCheckbox.setChecked(newSkipSilence);
@@ -461,6 +473,18 @@ private void bindCheckboxWithBoolPref(
461473 });
462474 }
463475
476+ /**
477+ * Ensures that the slider hook is valid and if not sets and updates the sliders accordingly.
478+ * <br/>
479+ * You have to ensure by yourself that the hooking is active.
480+ */
481+ private void ensureHookIsValidAndUpdateCallBack() {
482+ if (tempo != pitchPercent) {
483+ setSliders(Math.min(tempo, pitchPercent));
484+ updateCallback();
485+ }
486+ }
487+
464488 /*//////////////////////////////////////////////////////////////////////////
465489 // Sliders
466490 //////////////////////////////////////////////////////////////////////////*/
0 commit comments