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

Fixes #2948 - updated volume control delegate to handle when ACTION_CANCELLED (which seems to get triggered in pico) for when a user drags the volume seekbar outside of the area

Fixes #2948 - updated volume control delegate to handle when ACTION_CANCELLED (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 ba9d45b commit d2d10a0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.SeekBar;

Expand Down Expand Up @@ -38,18 +40,20 @@ public VolumeControl(Context context, AttributeSet attrs, int defStyleAttr, int
initialize();
}

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

@SuppressLint("ClickableViewAccessibility")
private void initialize() {
inflate(getContext(), R.layout.volume_control, this);
mSeekBar = findViewById(R.id.volumeSeekBar);
mSeekBar.setProgress(100);
mSeekBar.setOnSeekBarChangeListener(this);
mSeekBar.setOnTouchListener((v, event) -> {
if (event.getAction() == MotionEvent.ACTION_UP) {

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

return true;
}
return false;
Expand All @@ -60,7 +64,6 @@ public void setDelegate(Delegate aDelegate) {
mDelegate = aDelegate;
}


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

public interface Delegate {
void onVolumeChange(double aVolume);
void onSeekBarActionCancelled();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,33 @@ public void onSeekPreview(String aText, double aRatio) {
}
});

mVolumeControl.setDelegate(v -> {
/* mVolumeControl.setDelegate(v -> {
mMedia.setVolume(v);
if (mMedia.isMuted()) {
mMedia.setMuted(false);
}
mVolumeControl.requestFocusFromTouch();
});
*/

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 d2d10a0

Please sign in to comment.