From 86f335b01f974eac688583d775b15ae1dca55229 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 17 Mar 2022 21:49:04 -0400 Subject: [PATCH] Create stub implementation for OnSeekBarChangeListener --- .../newpipe/download/DownloadDialog.java | 11 ++--- .../helper/PlaybackParameterDialog.java | 49 ++++--------------- .../util/SimpleOnSeekBarChangeListener.kt | 12 +++++ 3 files changed, 25 insertions(+), 47 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/util/SimpleOnSeekBarChangeListener.kt diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index 87bfbd12e..f5c226908 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -61,6 +61,7 @@ import org.schabi.newpipe.util.FilenameUtils; import org.schabi.newpipe.util.ListHelper; import org.schabi.newpipe.util.PermissionHelper; import org.schabi.newpipe.util.SecondaryStreamHelper; +import org.schabi.newpipe.util.SimpleOnSeekBarChangeListener; import org.schabi.newpipe.util.StreamItemAdapter; import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper; import org.schabi.newpipe.util.ThemeHelper; @@ -321,21 +322,15 @@ public class DownloadDialog extends DialogFragment final int threads = prefs.getInt(getString(R.string.default_download_threads), 3); dialogBinding.threadsCount.setText(String.valueOf(threads)); dialogBinding.threads.setProgress(threads - 1); - dialogBinding.threads.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + dialogBinding.threads.setOnSeekBarChangeListener(new SimpleOnSeekBarChangeListener() { @Override - public void onProgressChanged(final SeekBar seekbar, final int progress, + public void onProgressChanged(@NonNull final SeekBar seekbar, final int progress, final boolean fromUser) { final int newProgress = progress + 1; prefs.edit().putInt(getString(R.string.default_download_threads), newProgress) .apply(); dialogBinding.threadsCount.setText(String.valueOf(newProgress)); } - - @Override - public void onStartTrackingTouch(final SeekBar p1) { } - - @Override - public void onStopTrackingTouch(final SeekBar p1) { } }); fetchStreamsSize(); diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java index 2834b93ae..31eff4daf 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java @@ -20,6 +20,7 @@ import androidx.fragment.app.DialogFragment; import androidx.preference.PreferenceManager; import org.schabi.newpipe.R; +import org.schabi.newpipe.util.SimpleOnSeekBarChangeListener; import org.schabi.newpipe.util.SliderStrategy; public class PlaybackParameterDialog extends DialogFragment { @@ -495,10 +496,10 @@ public class PlaybackParameterDialog extends DialogFragment { // Sliders //////////////////////////////////////////////////////////////////////////*/ - private SeekBar.OnSeekBarChangeListener getOnTempoChangedListener() { - return new SeekBar.OnSeekBarChangeListener() { + private SimpleOnSeekBarChangeListener getOnTempoChangedListener() { + return new SimpleOnSeekBarChangeListener() { @Override - public void onProgressChanged(final SeekBar seekBar, final int progress, + public void onProgressChanged(@NonNull final SeekBar seekBar, final int progress, final boolean fromUser) { final double currentTempo = strategy.valueOf(progress); if (fromUser) { @@ -506,23 +507,13 @@ public class PlaybackParameterDialog extends DialogFragment { setCurrentPlaybackParameters(); } } - - @Override - public void onStartTrackingTouch(final SeekBar seekBar) { - // Do Nothing. - } - - @Override - public void onStopTrackingTouch(final SeekBar seekBar) { - // Do Nothing. - } }; } - private SeekBar.OnSeekBarChangeListener getOnPitchChangedListener() { - return new SeekBar.OnSeekBarChangeListener() { + private SimpleOnSeekBarChangeListener getOnPitchChangedListener() { + return new SimpleOnSeekBarChangeListener() { @Override - public void onProgressChanged(final SeekBar seekBar, final int progress, + public void onProgressChanged(@NonNull final SeekBar seekBar, final int progress, final boolean fromUser) { final double currentPitch = strategy.valueOf(progress); if (fromUser) { // this change is first in chain @@ -530,23 +521,13 @@ public class PlaybackParameterDialog extends DialogFragment { setCurrentPlaybackParameters(); } } - - @Override - public void onStartTrackingTouch(final SeekBar seekBar) { - // Do Nothing. - } - - @Override - public void onStopTrackingTouch(final SeekBar seekBar) { - // Do Nothing. - } }; } - private SeekBar.OnSeekBarChangeListener getOnSemitoneChangedListener() { - return new SeekBar.OnSeekBarChangeListener() { + private SimpleOnSeekBarChangeListener getOnSemitoneChangedListener() { + return new SimpleOnSeekBarChangeListener() { @Override - public void onProgressChanged(final SeekBar seekBar, final int progress, + public void onProgressChanged(@NonNull final SeekBar seekBar, final int progress, final boolean fromUser) { // semitone slider supplies values 0 to 24, subtraction by 12 is required final int currentSemitones = progress - 12; @@ -557,16 +538,6 @@ public class PlaybackParameterDialog extends DialogFragment { setCurrentPlaybackParameters(); } } - - @Override - public void onStartTrackingTouch(final SeekBar seekBar) { - // Do Nothing. - } - - @Override - public void onStopTrackingTouch(final SeekBar seekBar) { - // Do Nothing. - } }; } diff --git a/app/src/main/java/org/schabi/newpipe/util/SimpleOnSeekBarChangeListener.kt b/app/src/main/java/org/schabi/newpipe/util/SimpleOnSeekBarChangeListener.kt new file mode 100644 index 000000000..a79085fc0 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/util/SimpleOnSeekBarChangeListener.kt @@ -0,0 +1,12 @@ +package org.schabi.newpipe.util + +import android.widget.SeekBar + +/** + * Why the hell didn't they make a stub implementation for this? + */ +abstract class SimpleOnSeekBarChangeListener : SeekBar.OnSeekBarChangeListener { + override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {} + override fun onStartTrackingTouch(seekBar: SeekBar) {} + override fun onStopTrackingTouch(seekBar: SeekBar) {} +}