1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 02:53:09 +01:00

Create stub implementation for OnSeekBarChangeListener

This commit is contained in:
TacoTheDank 2022-03-17 21:49:04 -04:00
parent 102204e293
commit 86f335b01f
3 changed files with 25 additions and 47 deletions

View File

@ -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();

View File

@ -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.
}
};
}

View File

@ -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) {}
}