Merge "sysui: update wallet card widths on configuration changes" into sc-v2-dev
This commit is contained in:
@@ -189,6 +189,15 @@ public class WalletCardCarousel extends RecyclerView {
|
|||||||
return mCardHeightPx;
|
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.
|
* Returns true if the data set is changed.
|
||||||
*/
|
*/
|
||||||
@@ -376,8 +385,8 @@ public class WalletCardCarousel extends RecyclerView {
|
|||||||
CardView cardView = viewHolder.mCardView;
|
CardView cardView = viewHolder.mCardView;
|
||||||
cardView.setRadius(mCornerRadiusPx);
|
cardView.setRadius(mCornerRadiusPx);
|
||||||
ViewGroup.LayoutParams layoutParams = cardView.getLayoutParams();
|
ViewGroup.LayoutParams layoutParams = cardView.getLayoutParams();
|
||||||
layoutParams.width = mCardWidthPx;
|
layoutParams.width = getCardWidthPx();
|
||||||
layoutParams.height = mCardHeightPx;
|
layoutParams.height = getCardHeightPx();
|
||||||
view.setTag(viewHolder);
|
view.setTag(viewHolder);
|
||||||
return viewHolder;
|
return viewHolder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,17 +99,13 @@ public class WalletView extends FrameLayout implements WalletCardCarousel.OnCard
|
|||||||
mCardCarousel.setExpectedViewWidth(getWidth());
|
mCardCarousel.setExpectedViewWidth(getWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onConfigurationChanged(Configuration newConfig) {
|
|
||||||
updateViewForOrientation(newConfig.orientation);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateViewForOrientation(@Configuration.Orientation int orientation) {
|
private void updateViewForOrientation(@Configuration.Orientation int orientation) {
|
||||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
renderViewPortrait();
|
renderViewPortrait();
|
||||||
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
renderViewLandscape();
|
renderViewLandscape();
|
||||||
}
|
}
|
||||||
|
mCardCarousel.resetAdapter(); // necessary to update cards width
|
||||||
ViewGroup.LayoutParams params = mCardCarouselContainer.getLayoutParams();
|
ViewGroup.LayoutParams params = mCardCarouselContainer.getLayoutParams();
|
||||||
if (params instanceof MarginLayoutParams) {
|
if (params instanceof MarginLayoutParams) {
|
||||||
((MarginLayoutParams) params).topMargin =
|
((MarginLayoutParams) params).topMargin =
|
||||||
|
|||||||
Reference in New Issue
Block a user