Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Fixes #2948 - updated volume control delegate to handle when ACTION_C…
Browse files Browse the repository at this point in the history
…ANCELLED (which seems to get triggered in pico) for when a user drags the volume seekbar outside of the area
  • Loading branch information
daron-walters committed Jun 10, 2020
1 parent 0020e27 commit 23ff996
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ private void initialize() {
mSeekBar.setOnSeekBarChangeListener(this);
mSeekBar.setOnTouchListener((v, event) -> {

if ((event.getAction() == MotionEvent.ACTION_UP) ||(event.getAction() == MotionEvent.ACTION_CANCEL)){
if((event.getAction() == MotionEvent.ACTION_CANCEL) && (mDelegate !=null))
{
if ((event.getAction() == MotionEvent.ACTION_UP) || (event.getAction() == MotionEvent.ACTION_CANCEL)) {
if ((event.getAction() == MotionEvent.ACTION_CANCEL) && (mDelegate != null)) {
mDelegate.onSeekBarActionCancelled();
}

Expand Down Expand Up @@ -107,6 +106,7 @@ public void onStopTrackingTouch(SeekBar seekBar) {

public interface Delegate {
void onVolumeChange(double aVolume);

void onSeekBarActionCancelled();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,24 +209,23 @@ public void onSeekPreview(String aText, double aRatio) {
});
*/

mVolumeControl.setDelegate(new VolumeControl.Delegate()
{

@Override
public void onVolumeChange(double aVolume) {
mMedia.setVolume(aVolume);
if (mMedia.isMuted()) {
mMedia.setMuted(false);
}
mVolumeControl.requestFocusFromTouch();
}

@Override
public void onSeekBarActionCancelled() {
mHideVolumeSlider = true;
startVolumeCtrlHandler();
}
});
mVolumeControl.setDelegate(new VolumeControl.Delegate() {

@Override
public void onVolumeChange(double aVolume) {
mMedia.setVolume(aVolume);
if (mMedia.isMuted()) {
mMedia.setMuted(false);
}
mVolumeControl.requestFocusFromTouch();
}

@Override
public void onSeekBarActionCancelled() {
mHideVolumeSlider = true;
startVolumeCtrlHandler();
}
});


this.setOnHoverListener((v, event) -> {
Expand Down

0 comments on commit 23ff996

Please sign in to comment.