Merge pull request #8066 from TacoTheDank/simpleSeekbarChange
Create stub implementation for OnSeekBarChangeListener
This commit is contained in:
commit
57231382a6
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package org.schabi.newpipe.views.player
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.animation.addListener
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.databinding.PlayerFastSeekSecondsViewBinding
|
||||
import org.schabi.newpipe.util.DeviceUtils
|
||||
|
@ -163,19 +163,10 @@ class SecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context
|
|||
setFloatValues(0f, 1f)
|
||||
|
||||
addUpdateListener { update(it.animatedValue as Float) }
|
||||
addListener(object : AnimatorListener {
|
||||
override fun onAnimationStart(animation: Animator?) {
|
||||
start()
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
end()
|
||||
}
|
||||
|
||||
override fun onAnimationCancel(animation: Animator?) = Unit
|
||||
|
||||
override fun onAnimationRepeat(animation: Animator?) = Unit
|
||||
})
|
||||
addListener(
|
||||
onStart = { start() },
|
||||
onEnd = { end() }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue