Merge "eOutput Switcher] Fix Dialog refreshing shortage" into tm-qpr-dev am: ac786fe1fb

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19716906

Change-Id: I6e67f0ac06db9516a42dd9fff2ddb8a66ec6176d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Shaowei Shen
2022-08-31 05:28:58 +00:00
committed by Automerger Merge Worker
2 changed files with 20 additions and 9 deletions

View File

@@ -356,15 +356,6 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
mHeaderSubtitle.setText(subTitle);
mHeaderTitle.setGravity(Gravity.NO_GRAVITY);
}
if (!mAdapter.isDragging()) {
int currentActivePosition = mAdapter.getCurrentActivePosition();
if (!colorSetUpdated && !deviceSetChanged && currentActivePosition >= 0
&& currentActivePosition < mAdapter.getItemCount()) {
mAdapter.notifyItemChanged(currentActivePosition);
} else {
mAdapter.notifyDataSetChanged();
}
}
// Show when remote media session is available or
// when the device supports BT LE audio + media is playing
mStopButton.setVisibility(getStopButtonVisibility());
@@ -374,6 +365,18 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
mBroadcastIcon.setVisibility(getBroadcastIconVisibility());
mBroadcastIcon.setOnClickListener(v -> onBroadcastIconClick());
if (!mAdapter.isDragging()) {
int currentActivePosition = mAdapter.getCurrentActivePosition();
if (!colorSetUpdated && !deviceSetChanged && currentActivePosition >= 0
&& currentActivePosition < mAdapter.getItemCount()) {
mAdapter.notifyItemChanged(currentActivePosition);
} else {
mAdapter.notifyDataSetChanged();
}
} else {
mMediaOutputController.setRefreshing(false);
mMediaOutputController.refreshDataSetIfNeeded();
}
}
private void updateButtonBackgroundColorFilter() {

View File

@@ -223,6 +223,14 @@ public class MediaOutputBaseDialogTest extends SysuiTestCase {
verify(mMediaOutputBaseAdapter, never()).notifyDataSetChanged();
}
@Test
public void refresh_inDragging_directSetRefreshingToFalse() {
when(mMediaOutputBaseAdapter.isDragging()).thenReturn(true);
mMediaOutputBaseDialogImpl.refresh();
assertThat(mMediaOutputController.isRefreshing()).isFalse();
}
@Test
public void refresh_notInDragging_verifyUpdateAdapter() {
when(mMediaOutputBaseAdapter.getCurrentActivePosition()).thenReturn(-1);