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 c8b8bfb commit cad7e37
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ public VolumeControl(Context context, AttributeSet attrs, int defStyleAttr, int
initialize();
}

public interface Delegate {
void onVolumeChange(double aVolume);
void onSeekBarActionCancelled();
}



@SuppressLint("ClickableViewAccessibility")
private void initialize() {
inflate(getContext(), R.layout.volume_control, this);
Expand All @@ -56,7 +49,7 @@ private void initialize() {
mSeekBar.setOnTouchListener((v, event) -> {

if ((event.getAction() == MotionEvent.ACTION_UP) ||(event.getAction() == MotionEvent.ACTION_CANCEL)){
if(event.getAction() == MotionEvent.ACTION_CANCEL)
if((event.getAction() == MotionEvent.ACTION_CANCEL) && (mDelegate !=null))
{
mDelegate.onSeekBarActionCancelled();
}
Expand All @@ -71,7 +64,6 @@ public void setDelegate(Delegate aDelegate) {
mDelegate = aDelegate;
}


public void setVolume(double aVolume) {
mVolume = aVolume;
if (!mTouching) {
Expand Down Expand Up @@ -112,4 +104,9 @@ public void onStartTrackingTouch(SeekBar seekBar) {
public void onStopTrackingTouch(SeekBar seekBar) {
mTouching = false;
}

public interface Delegate {
void onVolumeChange(double aVolume);
void onSeekBarActionCancelled();
}
}

0 comments on commit cad7e37

Please sign in to comment.