Loading packages/SystemUI/multivalentTests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.kt +3 −1 Original line number Diff line number Diff line Loading @@ -321,13 +321,15 @@ class MediaOutputAdapterTest : SysuiTestCase() { @Test fun onBindViewHolder_bindDeselectableDevice_verifyView() { mMediaSwitchingController.stub { on { isGroupListCollapsed } doReturn false } mMediaSwitchingController.stub { on { selectedMediaDevice } doReturn listOf(mMediaDevice1, mMediaDevice2) on { deselectableMediaDevice } doReturn listOf(mMediaDevice1, mMediaDevice2) } updateAdapterWithDevices(listOf(mMediaDevice1, mMediaDevice2)) createAndBindDeviceViewHolder(position = 1).apply { // positions: 0 - collapsible drop down, 1 - device1, 2 - device2. createAndBindDeviceViewHolder(position = 2).apply { assertThat(mGroupButton.visibility).isEqualTo(VISIBLE) assertThat(mGroupButton.contentDescription) .isEqualTo(mContext.getString(R.string.accessibility_remove_device_from_group)) Loading packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.kt +7 −2 Original line number Diff line number Diff line Loading @@ -51,10 +51,15 @@ import com.google.android.material.slider.Slider /** A RecyclerView adapter for the legacy UI media output dialog device list. */ class MediaOutputAdapter(controller: MediaSwitchingController) : MediaOutputAdapterBase(controller) { private val mGroupSelectedItems = mController.selectedMediaDevice.size > 1 private var mGroupSelectedItems: Boolean? = null // Unset until the first render. /** Refreshes the RecyclerView dataset and forces re-render. */ override fun updateItems() { if (mGroupSelectedItems == null) { // Decide whether to group devices only during the initial render. mGroupSelectedItems = mController.selectedMediaDevice.size > 1 } val newList = mController.getMediaItemList(false /* addConnectNewDeviceButton */).toMutableList() Loading Loading @@ -83,7 +88,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : private fun coalesceSelectedDevices(newList: MutableList<MediaItem>) { val selectedDevices = newList.filter { this.isSelectedDevice(it) } if (mGroupSelectedItems && selectedDevices.size > 1) { if (mGroupSelectedItems == true && selectedDevices.size > 1) { newList.removeAll(selectedDevices.toSet()) if (mController.isGroupListCollapsed) { newList.add(0, MediaItem.createDeviceGroupMediaItem()) Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.kt +3 −1 Original line number Diff line number Diff line Loading @@ -321,13 +321,15 @@ class MediaOutputAdapterTest : SysuiTestCase() { @Test fun onBindViewHolder_bindDeselectableDevice_verifyView() { mMediaSwitchingController.stub { on { isGroupListCollapsed } doReturn false } mMediaSwitchingController.stub { on { selectedMediaDevice } doReturn listOf(mMediaDevice1, mMediaDevice2) on { deselectableMediaDevice } doReturn listOf(mMediaDevice1, mMediaDevice2) } updateAdapterWithDevices(listOf(mMediaDevice1, mMediaDevice2)) createAndBindDeviceViewHolder(position = 1).apply { // positions: 0 - collapsible drop down, 1 - device1, 2 - device2. createAndBindDeviceViewHolder(position = 2).apply { assertThat(mGroupButton.visibility).isEqualTo(VISIBLE) assertThat(mGroupButton.contentDescription) .isEqualTo(mContext.getString(R.string.accessibility_remove_device_from_group)) Loading
packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.kt +7 −2 Original line number Diff line number Diff line Loading @@ -51,10 +51,15 @@ import com.google.android.material.slider.Slider /** A RecyclerView adapter for the legacy UI media output dialog device list. */ class MediaOutputAdapter(controller: MediaSwitchingController) : MediaOutputAdapterBase(controller) { private val mGroupSelectedItems = mController.selectedMediaDevice.size > 1 private var mGroupSelectedItems: Boolean? = null // Unset until the first render. /** Refreshes the RecyclerView dataset and forces re-render. */ override fun updateItems() { if (mGroupSelectedItems == null) { // Decide whether to group devices only during the initial render. mGroupSelectedItems = mController.selectedMediaDevice.size > 1 } val newList = mController.getMediaItemList(false /* addConnectNewDeviceButton */).toMutableList() Loading Loading @@ -83,7 +88,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : private fun coalesceSelectedDevices(newList: MutableList<MediaItem>) { val selectedDevices = newList.filter { this.isSelectedDevice(it) } if (mGroupSelectedItems && selectedDevices.size > 1) { if (mGroupSelectedItems == true && selectedDevices.size > 1) { newList.removeAll(selectedDevices.toSet()) if (mController.isGroupListCollapsed) { newList.add(0, MediaItem.createDeviceGroupMediaItem()) Loading