Merge "[Output Switcher] Dismiss dialog when play state change to STOP" into tm-qpr-dev

This commit is contained in:
Shaowei Shen
2022-09-23 17:03:42 +00:00
committed by Android (Google) Code Review
3 changed files with 12 additions and 4 deletions

View File

@@ -1174,6 +1174,7 @@
<!-- Output switcher panel related dimensions -->
<dimen name="media_output_dialog_list_max_height">355dp</dimen>
<dimen name="media_output_dialog_list_item_height">76dp</dimen>
<dimen name="media_output_dialog_header_album_icon_size">72dp</dimen>
<dimen name="media_output_dialog_header_back_icon_size">32dp</dimen>
<dimen name="media_output_dialog_header_icon_padding">16dp</dimen>

View File

@@ -99,6 +99,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
private Button mStopButton;
private Button mAppButton;
private int mListMaxHeight;
private int mItemHeight;
private WallpaperColors mWallpaperColors;
private Executor mExecutor;
private boolean mShouldLaunchLeBroadcastDialog;
@@ -106,10 +107,12 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
MediaOutputBaseAdapter mAdapter;
private final ViewTreeObserver.OnGlobalLayoutListener mDeviceListLayoutListener = () -> {
ViewGroup.LayoutParams params = mDeviceListLayout.getLayoutParams();
int totalItemsHeight = mAdapter.getItemCount() * mItemHeight;
int correctHeight = Math.min(totalItemsHeight, mListMaxHeight);
// Set max height for list
if (mDeviceListLayout.getHeight() > mListMaxHeight) {
ViewGroup.LayoutParams params = mDeviceListLayout.getLayoutParams();
params.height = mListMaxHeight;
if (correctHeight != params.height) {
params.height = correctHeight;
mDeviceListLayout.setLayoutParams(params);
}
};
@@ -212,6 +215,8 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
mLayoutManager = new LayoutManagerWrapper(mContext);
mListMaxHeight = context.getResources().getDimensionPixelSize(
R.dimen.media_output_dialog_list_max_height);
mItemHeight = context.getResources().getDimensionPixelSize(
R.dimen.media_output_dialog_list_item_height);
mExecutor = Executors.newSingleThreadExecutor();
}
@@ -246,8 +251,10 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
mDeviceListLayout.getViewTreeObserver().addOnGlobalLayoutListener(
mDeviceListLayoutListener);
// Init device list
mLayoutManager.setAutoMeasureEnabled(true);
mDevicesRecyclerView.setLayoutManager(mLayoutManager);
mDevicesRecyclerView.setAdapter(mAdapter);
mDevicesRecyclerView.setHasFixedSize(false);
// Init header icon
mHeaderIcon.setOnClickListener(v -> onHeaderIconClick());
// Init bottom buttons

View File

@@ -1013,7 +1013,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
return;
}
if (newState == PlaybackState.STATE_STOPPED || newState == PlaybackState.STATE_PAUSED) {
if (newState == PlaybackState.STATE_STOPPED) {
mCallback.onMediaStoppedOrPaused();
}
mCurrentState = newState;