Merge "Refine layout for output switcher panel" into rvc-dev
This commit is contained in:
@@ -95,6 +95,7 @@ public class PanelFragment extends Fragment {
|
||||
private ImageView mTitleIcon;
|
||||
private TextView mHeaderTitle;
|
||||
private TextView mHeaderSubtitle;
|
||||
private int mMaxHeight;
|
||||
|
||||
private final Map<Uri, LiveData<Slice>> mSliceLiveData = new LinkedHashMap<>();
|
||||
|
||||
@@ -105,6 +106,18 @@ public class PanelFragment extends Fragment {
|
||||
return false;
|
||||
};
|
||||
|
||||
private final ViewTreeObserver.OnGlobalLayoutListener mPanelLayoutListener =
|
||||
new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
if (mLayoutView.getHeight() > mMaxHeight) {
|
||||
final ViewGroup.LayoutParams params = mLayoutView.getLayoutParams();
|
||||
params.height = mMaxHeight;
|
||||
mLayoutView.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final ViewTreeObserver.OnGlobalLayoutListener mOnGlobalLayoutListener =
|
||||
new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
@@ -123,6 +136,9 @@ public class PanelFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
mLayoutView = inflater.inflate(R.layout.panel_layout, container, false);
|
||||
mLayoutView.getViewTreeObserver()
|
||||
.addOnGlobalLayoutListener(mPanelLayoutListener);
|
||||
mMaxHeight = getResources().getDimensionPixelSize(R.dimen.output_switcher_slice_max_height);
|
||||
createPanelContent();
|
||||
return mLayoutView;
|
||||
}
|
||||
@@ -159,6 +175,9 @@ public class PanelFragment extends Fragment {
|
||||
if (mLayoutView == null) {
|
||||
activity.finish();
|
||||
}
|
||||
final ViewGroup.LayoutParams params = mLayoutView.getLayoutParams();
|
||||
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
mLayoutView.setLayoutParams(params);
|
||||
|
||||
mPanelSlices = mLayoutView.findViewById(R.id.panel_parent_layout);
|
||||
mSeeMoreButton = mLayoutView.findViewById(R.id.see_more);
|
||||
@@ -214,6 +233,12 @@ public class PanelFragment extends Fragment {
|
||||
mHeaderSubtitle.setText(mPanel.getSubTitle());
|
||||
if (mPanel.getHeaderIconIntent() != null) {
|
||||
mTitleIcon.setOnClickListener(getHeaderIconListener());
|
||||
mTitleIcon.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
} else {
|
||||
final int size = getResources().getDimensionPixelSize(
|
||||
R.dimen.output_switcher_panel_icon_size);
|
||||
mTitleIcon.setLayoutParams(new LinearLayout.LayoutParams(size, size));
|
||||
}
|
||||
}
|
||||
mSeeMoreButton.setOnClickListener(getSeeMoreListener());
|
||||
@@ -378,6 +403,9 @@ public class PanelFragment extends Fragment {
|
||||
mPanelClosedKey = PanelClosedKeys.KEY_OTHERS;
|
||||
}
|
||||
|
||||
if (mLayoutView != null) {
|
||||
mLayoutView.getViewTreeObserver().removeOnGlobalLayoutListener(mPanelLayoutListener);
|
||||
}
|
||||
mMetricsProvider.action(
|
||||
0 /* attribution */,
|
||||
SettingsEnums.PAGE_HIDE,
|
||||
|
Reference in New Issue
Block a user