Data usage performance, bugfixes.
Optimize launch times by removing unneeded extra work, including reloading data and tightening chart invalidation. Fix invalidation storm when sweeps overlap. Move chart history into loader instead of blocking main thread. Disable "Split 4G" mode until telephony support is ready, and combine any existing split policies. Async loading of application details. Remove alpha transitions to speed up on some hardware. Hide menus in detail mode. Delay kicking off force-poll. Fix inset padding on large devices. Bug: 5284321, 5273918, 5263056 Change-Id: I746d79c05e2a6ea97bbdbdc5d807e208328d1373
This commit is contained in:
@@ -76,6 +76,8 @@ public class ChartSweepView extends View {
|
||||
private ChartSweepView mValidAfterDynamic;
|
||||
private ChartSweepView mValidBeforeDynamic;
|
||||
|
||||
private float mLabelOffset;
|
||||
|
||||
private Paint mOutlinePaint = new Paint();
|
||||
|
||||
public static final int HORIZONTAL = 0;
|
||||
@@ -230,12 +232,44 @@ public class ChartSweepView extends View {
|
||||
private void invalidateLabel() {
|
||||
if (mLabelTemplate != null && mAxis != null) {
|
||||
mLabelValue = mAxis.buildLabel(getResources(), mLabelTemplate, mValue);
|
||||
invalidateLabelOffset();
|
||||
invalidate();
|
||||
} else {
|
||||
mLabelValue = mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When overlapping with neighbor, split difference and push label.
|
||||
*/
|
||||
public void invalidateLabelOffset() {
|
||||
float margin;
|
||||
float labelOffset = 0;
|
||||
if (mFollowAxis == VERTICAL) {
|
||||
if (mValidAfterDynamic != null) {
|
||||
margin = getLabelTop(mValidAfterDynamic) - getLabelBottom(this);
|
||||
if (margin < 0) {
|
||||
labelOffset = margin / 2;
|
||||
}
|
||||
} else if (mValidBeforeDynamic != null) {
|
||||
margin = getLabelTop(this) - getLabelBottom(mValidBeforeDynamic);
|
||||
if (margin < 0) {
|
||||
labelOffset = -margin / 2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// TODO: implement horizontal labels
|
||||
}
|
||||
|
||||
// when offsetting label, neighbor probably needs to offset too
|
||||
if (labelOffset != mLabelOffset) {
|
||||
mLabelOffset = labelOffset;
|
||||
invalidate();
|
||||
if (mValidAfterDynamic != null) mValidAfterDynamic.invalidateLabelOffset();
|
||||
if (mValidBeforeDynamic != null) mValidBeforeDynamic.invalidateLabelOffset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jumpDrawablesToCurrentState() {
|
||||
super.jumpDrawablesToCurrentState();
|
||||
@@ -566,6 +600,12 @@ public class ChartSweepView extends View {
|
||||
mMargins.offset(-mSweepOffset.x, -mSweepOffset.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
invalidateLabelOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
final int width = getWidth();
|
||||
@@ -575,36 +615,11 @@ public class ChartSweepView extends View {
|
||||
canvas.drawRect(0, 0, width, height, mOutlinePaint);
|
||||
}
|
||||
|
||||
// when overlapping with neighbor, split difference and push label
|
||||
float margin;
|
||||
float labelOffset = 0;
|
||||
if (mFollowAxis == VERTICAL) {
|
||||
if (mValidAfterDynamic != null) {
|
||||
margin = getLabelTop(mValidAfterDynamic) - getLabelBottom(this);
|
||||
if (margin < 0) {
|
||||
labelOffset = margin / 2;
|
||||
}
|
||||
} else if (mValidBeforeDynamic != null) {
|
||||
margin = getLabelTop(this) - getLabelBottom(mValidBeforeDynamic);
|
||||
if (margin < 0) {
|
||||
labelOffset = -margin / 2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// TODO: implement horizontal labels
|
||||
}
|
||||
|
||||
// when offsetting label, neighbor probably needs to offset too
|
||||
if (labelOffset != 0) {
|
||||
if (mValidAfterDynamic != null) mValidAfterDynamic.invalidate();
|
||||
if (mValidBeforeDynamic != null) mValidBeforeDynamic.invalidate();
|
||||
}
|
||||
|
||||
final int labelSize;
|
||||
if (isEnabled() && mLabelLayout != null) {
|
||||
final int count = canvas.save();
|
||||
{
|
||||
canvas.translate(mContentOffset.left, mContentOffset.top + labelOffset);
|
||||
canvas.translate(mContentOffset.left, mContentOffset.top + mLabelOffset);
|
||||
mLabelLayout.draw(canvas);
|
||||
}
|
||||
canvas.restoreToCount(count);
|
||||
|
Reference in New Issue
Block a user