Taking snapshots of volume view no longer needed
This commit is contained in:
@@ -58,10 +58,9 @@ public class VolumeView extends View {
|
|||||||
final int height = canvas.getHeight();
|
final int height = canvas.getHeight();
|
||||||
final int width = canvas.getWidth();
|
final int width = canvas.getWidth();
|
||||||
|
|
||||||
final VolumeHistory history = volumeHistory.getSnapshot(width);
|
final int size = volumeHistory.size(); // Size is at most width
|
||||||
final int size = history.size(); // Size is at most width
|
final double volumeNorm = volumeHistory.getVolumeNorm();
|
||||||
final double volumeNorm = history.getVolumeNorm();
|
final double normalizedVolume = volumeHistory.get(size - 1);
|
||||||
final double normalizedVolume = history.get(size - 1);
|
|
||||||
final double relativeBrightness = Math.max(0.3, normalizedVolume);
|
final double relativeBrightness = Math.max(0.3, normalizedVolume);
|
||||||
int blue;
|
int blue;
|
||||||
int rest;
|
int rest;
|
||||||
@@ -76,11 +75,14 @@ public class VolumeView extends View {
|
|||||||
canvas.drawColor(rgb);
|
canvas.drawColor(rgb);
|
||||||
final double margins = height * 0.1;
|
final double margins = height * 0.1;
|
||||||
final double graphHeight = height - 2.0 * margins;
|
final double graphHeight = height - 2.0 * margins;
|
||||||
|
int leftMost = Math.max(0, volumeHistory.size() - width);
|
||||||
final double graphScale = graphHeight * volumeNorm;
|
final double graphScale = graphHeight * volumeNorm;
|
||||||
|
|
||||||
int xPrev = 0;
|
int xPrev = 0;
|
||||||
int yPrev = ((int) (margins + graphHeight - history.get(0) * graphScale));
|
int yPrev = ((int) (margins + graphHeight - volumeHistory.get(leftMost) * graphScale));
|
||||||
for (int xNext = 1; xNext < size; ++xNext) {
|
int length = Math.min(size, width);
|
||||||
int yNext = (int) (margins + graphHeight - history.get(xNext) * graphScale);
|
for (int xNext = 1; xNext < length-1; ++xNext) {
|
||||||
|
int yNext = (int) (margins + graphHeight - volumeHistory.get(leftMost + xNext) * graphScale);
|
||||||
canvas.drawLine(xPrev, yPrev, xNext, yNext, paint);
|
canvas.drawLine(xPrev, yPrev, xNext, yNext, paint);
|
||||||
xPrev = xNext;
|
xPrev = xNext;
|
||||||
yPrev = yNext;
|
yPrev = yNext;
|
||||||
|
|||||||
Reference in New Issue
Block a user