Merge "Only call layout during layout pass" into sc-v2-dev
This commit is contained in:
@@ -34,7 +34,11 @@ class QSSquishinessController @Inject constructor(
|
|||||||
* Change the height of all tiles and repositions their siblings.
|
* Change the height of all tiles and repositions their siblings.
|
||||||
*/
|
*/
|
||||||
private fun updateSquishiness() {
|
private fun updateSquishiness() {
|
||||||
// Start by updating the height of all tiles
|
// Update tile positions in the layout
|
||||||
|
val tileLayout = quickQSPanelController.tileLayout as TileLayout
|
||||||
|
tileLayout.setSquishinessFraction(squishiness)
|
||||||
|
|
||||||
|
// Adjust their heights as well
|
||||||
for (tile in qsTileHost.tiles) {
|
for (tile in qsTileHost.tiles) {
|
||||||
val tileView = quickQSPanelController.getTileView(tile)
|
val tileView = quickQSPanelController.getTileView(tile)
|
||||||
(tileView as? HeightOverrideable)?.let {
|
(tileView as? HeightOverrideable)?.let {
|
||||||
@@ -42,10 +46,6 @@ class QSSquishinessController @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update tile positions in the layout
|
|
||||||
val tileLayout = quickQSPanelController.tileLayout as TileLayout
|
|
||||||
tileLayout.setSquishinessFraction(squishiness)
|
|
||||||
|
|
||||||
// Calculate how much we should move the footer
|
// Calculate how much we should move the footer
|
||||||
val tileHeightOffset = tileLayout.height - tileLayout.tilesHeight
|
val tileHeightOffset = tileLayout.height - tileLayout.tilesHeight
|
||||||
val footerTopMargin = (qqsFooterActionsView.layoutParams as ViewGroup.MarginLayoutParams)
|
val footerTopMargin = (qqsFooterActionsView.layoutParams as ViewGroup.MarginLayoutParams)
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
|
|||||||
return mMaxCellHeight;
|
return mMaxCellHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void layoutTileRecords(int numRecords) {
|
private void layoutTileRecords(int numRecords, boolean forLayout) {
|
||||||
final boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
|
final boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
|
||||||
int row = 0;
|
int row = 0;
|
||||||
int column = 0;
|
int column = 0;
|
||||||
@@ -232,14 +232,18 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
|
|||||||
final int left = getColumnStart(isRtl ? mColumns - column - 1 : column);
|
final int left = getColumnStart(isRtl ? mColumns - column - 1 : column);
|
||||||
final int right = left + mCellWidth;
|
final int right = left + mCellWidth;
|
||||||
final int bottom = top + record.tileView.getMeasuredHeight();
|
final int bottom = top + record.tileView.getMeasuredHeight();
|
||||||
|
if (forLayout) {
|
||||||
record.tileView.layout(left, top, right, bottom);
|
record.tileView.layout(left, top, right, bottom);
|
||||||
|
} else {
|
||||||
|
record.tileView.setLeftTopRightBottom(left, top, right, bottom);
|
||||||
|
}
|
||||||
mLastTileBottom = bottom;
|
mLastTileBottom = bottom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||||
layoutTileRecords(mRecords.size());
|
layoutTileRecords(mRecords.size(), true /* forLayout */);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getRowTop(int row) {
|
protected int getRowTop(int row) {
|
||||||
@@ -280,6 +284,6 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mSquishinessFraction = squishinessFraction;
|
mSquishinessFraction = squishinessFraction;
|
||||||
layoutTileRecords(mRecords.size());
|
layoutTileRecords(mRecords.size(), false /* forLayout */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user