Merge "[Output Switcher] Dismiss dialog when play state change to STOP" into tm-qpr-dev
This commit is contained in:
@@ -1174,6 +1174,7 @@
|
|||||||
|
|
||||||
<!-- Output switcher panel related dimensions -->
|
<!-- Output switcher panel related dimensions -->
|
||||||
<dimen name="media_output_dialog_list_max_height">355dp</dimen>
|
<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_album_icon_size">72dp</dimen>
|
||||||
<dimen name="media_output_dialog_header_back_icon_size">32dp</dimen>
|
<dimen name="media_output_dialog_header_back_icon_size">32dp</dimen>
|
||||||
<dimen name="media_output_dialog_header_icon_padding">16dp</dimen>
|
<dimen name="media_output_dialog_header_icon_padding">16dp</dimen>
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
|||||||
private Button mStopButton;
|
private Button mStopButton;
|
||||||
private Button mAppButton;
|
private Button mAppButton;
|
||||||
private int mListMaxHeight;
|
private int mListMaxHeight;
|
||||||
|
private int mItemHeight;
|
||||||
private WallpaperColors mWallpaperColors;
|
private WallpaperColors mWallpaperColors;
|
||||||
private Executor mExecutor;
|
private Executor mExecutor;
|
||||||
private boolean mShouldLaunchLeBroadcastDialog;
|
private boolean mShouldLaunchLeBroadcastDialog;
|
||||||
@@ -106,10 +107,12 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
|||||||
MediaOutputBaseAdapter mAdapter;
|
MediaOutputBaseAdapter mAdapter;
|
||||||
|
|
||||||
private final ViewTreeObserver.OnGlobalLayoutListener mDeviceListLayoutListener = () -> {
|
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
|
// Set max height for list
|
||||||
if (mDeviceListLayout.getHeight() > mListMaxHeight) {
|
if (correctHeight != params.height) {
|
||||||
ViewGroup.LayoutParams params = mDeviceListLayout.getLayoutParams();
|
params.height = correctHeight;
|
||||||
params.height = mListMaxHeight;
|
|
||||||
mDeviceListLayout.setLayoutParams(params);
|
mDeviceListLayout.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -212,6 +215,8 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
|||||||
mLayoutManager = new LayoutManagerWrapper(mContext);
|
mLayoutManager = new LayoutManagerWrapper(mContext);
|
||||||
mListMaxHeight = context.getResources().getDimensionPixelSize(
|
mListMaxHeight = context.getResources().getDimensionPixelSize(
|
||||||
R.dimen.media_output_dialog_list_max_height);
|
R.dimen.media_output_dialog_list_max_height);
|
||||||
|
mItemHeight = context.getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.media_output_dialog_list_item_height);
|
||||||
mExecutor = Executors.newSingleThreadExecutor();
|
mExecutor = Executors.newSingleThreadExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,8 +251,10 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
|||||||
mDeviceListLayout.getViewTreeObserver().addOnGlobalLayoutListener(
|
mDeviceListLayout.getViewTreeObserver().addOnGlobalLayoutListener(
|
||||||
mDeviceListLayoutListener);
|
mDeviceListLayoutListener);
|
||||||
// Init device list
|
// Init device list
|
||||||
|
mLayoutManager.setAutoMeasureEnabled(true);
|
||||||
mDevicesRecyclerView.setLayoutManager(mLayoutManager);
|
mDevicesRecyclerView.setLayoutManager(mLayoutManager);
|
||||||
mDevicesRecyclerView.setAdapter(mAdapter);
|
mDevicesRecyclerView.setAdapter(mAdapter);
|
||||||
|
mDevicesRecyclerView.setHasFixedSize(false);
|
||||||
// Init header icon
|
// Init header icon
|
||||||
mHeaderIcon.setOnClickListener(v -> onHeaderIconClick());
|
mHeaderIcon.setOnClickListener(v -> onHeaderIconClick());
|
||||||
// Init bottom buttons
|
// Init bottom buttons
|
||||||
|
|||||||
@@ -1013,7 +1013,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newState == PlaybackState.STATE_STOPPED || newState == PlaybackState.STATE_PAUSED) {
|
if (newState == PlaybackState.STATE_STOPPED) {
|
||||||
mCallback.onMediaStoppedOrPaused();
|
mCallback.onMediaStoppedOrPaused();
|
||||||
}
|
}
|
||||||
mCurrentState = newState;
|
mCurrentState = newState;
|
||||||
|
|||||||
Reference in New Issue
Block a user