Merge "sysui: update wallet card widths on configuration changes" into sc-v2-dev am: 6be85d8ee6

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

Change-Id: Ice2f42ad2fdaa3dcce01c1a3e78f986ae2d2e627
This commit is contained in:
Thales Lima
2021-07-30 12:19:54 +00:00
committed by Automerger Merge Worker
2 changed files with 12 additions and 7 deletions

View File

@@ -189,6 +189,15 @@ public class WalletCardCarousel extends RecyclerView {
return mCardHeightPx;
}
/**
* Sets the adapter again in the RecyclerView, updating the ViewHolders children's layout.
* This is needed when changing the state of the device (eg fold/unfold) so the ViewHolders are
* recreated.
*/
void resetAdapter() {
setAdapter(mWalletCardCarouselAdapter);
}
/**
* Returns true if the data set is changed.
*/
@@ -376,8 +385,8 @@ public class WalletCardCarousel extends RecyclerView {
CardView cardView = viewHolder.mCardView;
cardView.setRadius(mCornerRadiusPx);
ViewGroup.LayoutParams layoutParams = cardView.getLayoutParams();
layoutParams.width = mCardWidthPx;
layoutParams.height = mCardHeightPx;
layoutParams.width = getCardWidthPx();
layoutParams.height = getCardHeightPx();
view.setTag(viewHolder);
return viewHolder;
}

View File

@@ -99,17 +99,13 @@ public class WalletView extends FrameLayout implements WalletCardCarousel.OnCard
mCardCarousel.setExpectedViewWidth(getWidth());
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
updateViewForOrientation(newConfig.orientation);
}
private void updateViewForOrientation(@Configuration.Orientation int orientation) {
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
renderViewPortrait();
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
renderViewLandscape();
}
mCardCarousel.resetAdapter(); // necessary to update cards width
ViewGroup.LayoutParams params = mCardCarouselContainer.getLayoutParams();
if (params instanceof MarginLayoutParams) {
((MarginLayoutParams) params).topMargin =