Merge "[Output Switcher] Refresh list when data set changed" into sc-v2-dev
This commit is contained in:
@@ -150,6 +150,10 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
void refresh() {
|
void refresh() {
|
||||||
|
refresh(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void refresh(boolean deviceSetChanged) {
|
||||||
// Update header icon
|
// Update header icon
|
||||||
final int iconRes = getHeaderIconRes();
|
final int iconRes = getHeaderIconRes();
|
||||||
final IconCompat iconCompat = getHeaderIcon();
|
final IconCompat iconCompat = getHeaderIcon();
|
||||||
@@ -175,7 +179,8 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
if (!mAdapter.isDragging() && !mAdapter.isAnimating()) {
|
if (!mAdapter.isDragging() && !mAdapter.isAnimating()) {
|
||||||
int currentActivePosition = mAdapter.getCurrentActivePosition();
|
int currentActivePosition = mAdapter.getCurrentActivePosition();
|
||||||
if (currentActivePosition >= 0 && currentActivePosition < mAdapter.getItemCount()) {
|
if (!deviceSetChanged && currentActivePosition >= 0
|
||||||
|
&& currentActivePosition < mAdapter.getItemCount()) {
|
||||||
mAdapter.notifyItemChanged(currentActivePosition);
|
mAdapter.notifyItemChanged(currentActivePosition);
|
||||||
} else {
|
} else {
|
||||||
mAdapter.notifyDataSetChanged();
|
mAdapter.notifyDataSetChanged();
|
||||||
@@ -214,6 +219,11 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
|||||||
mMainThreadHandler.post(() -> refresh());
|
mMainThreadHandler.post(() -> refresh());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDeviceListChanged() {
|
||||||
|
mMainThreadHandler.post(() -> refresh(true));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismissDialog() {
|
public void dismissDialog() {
|
||||||
dismiss();
|
dismiss();
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback {
|
|||||||
@Override
|
@Override
|
||||||
public void onDeviceListUpdate(List<MediaDevice> devices) {
|
public void onDeviceListUpdate(List<MediaDevice> devices) {
|
||||||
buildMediaDevices(devices);
|
buildMediaDevices(devices);
|
||||||
mCallback.onRouteChanged();
|
mCallback.onDeviceListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -529,10 +529,15 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback {
|
|||||||
void onMediaStoppedOrPaused();
|
void onMediaStoppedOrPaused();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override to handle the device updating.
|
* Override to handle the device status or attributes updating.
|
||||||
*/
|
*/
|
||||||
void onRouteChanged();
|
void onRouteChanged();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override to handle the devices set updating.
|
||||||
|
*/
|
||||||
|
void onDeviceListChanged();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override to dismiss dialog.
|
* Override to dismiss dialog.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ public class MediaOutputControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
assertThat(devices.containsAll(mMediaDevices)).isTrue();
|
assertThat(devices.containsAll(mMediaDevices)).isTrue();
|
||||||
assertThat(devices.size()).isEqualTo(mMediaDevices.size());
|
assertThat(devices.size()).isEqualTo(mMediaDevices.size());
|
||||||
verify(mCb).onRouteChanged();
|
verify(mCb).onDeviceListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user