Merge "[Output Switcher] Improve volume control" into udc-qpr-dev
This commit is contained in:
@@ -157,6 +157,7 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
private String mDeviceId;
|
||||
private ValueAnimator mCornerAnimator;
|
||||
private ValueAnimator mVolumeAnimator;
|
||||
private int mLatestUpdateVolume = -1;
|
||||
|
||||
MediaDeviceBaseViewHolder(View view) {
|
||||
super(view);
|
||||
@@ -314,7 +315,11 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
mSeekBar.setMaxVolume(device.getMaxVolume());
|
||||
final int currentVolume = device.getCurrentVolume();
|
||||
if (!mIsDragging) {
|
||||
if (mSeekBar.getVolume() != currentVolume) {
|
||||
if (mSeekBar.getVolume() != currentVolume && (mLatestUpdateVolume == -1
|
||||
|| currentVolume == mLatestUpdateVolume)) {
|
||||
// Update only if volume of device and value of volume bar doesn't match.
|
||||
// Check if response volume match with the latest request, to ignore obsolete
|
||||
// response
|
||||
if (isCurrentSeekbarInvisible && !mIsInitVolumeFirstTime) {
|
||||
updateTitleIcon(currentVolume == 0 ? R.drawable.media_output_icon_volume_off
|
||||
: R.drawable.media_output_icon_volume,
|
||||
@@ -330,12 +335,16 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
updateUnmutedVolumeIcon();
|
||||
}
|
||||
mSeekBar.setVolume(currentVolume);
|
||||
mLatestUpdateVolume = -1;
|
||||
}
|
||||
}
|
||||
} else if (currentVolume == 0) {
|
||||
mSeekBar.resetVolume();
|
||||
updateMutedVolumeIcon();
|
||||
}
|
||||
if (currentVolume == mLatestUpdateVolume) {
|
||||
mLatestUpdateVolume = -1;
|
||||
}
|
||||
}
|
||||
if (mIsInitVolumeFirstTime) {
|
||||
mIsInitVolumeFirstTime = false;
|
||||
@@ -360,6 +369,7 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
mStartFromMute = false;
|
||||
}
|
||||
if (progressToVolume != deviceVolume) {
|
||||
mLatestUpdateVolume = progressToVolume;
|
||||
mController.adjustVolume(device, progressToVolume);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user