commit be56ea1cb0c137b58b11cb4d31735adb5aa26128
parent 5eefc34a0b3e41974123fcd705cfd6265fb18265
Author: gstraube <gstraube@mailbox.org>
Date: Mon, 10 Jul 2017 06:28:12 +0200
Extract method
Diffstat:
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/app/src/main/java/com/github/cythara/TunerView.java b/app/src/main/java/com/github/cythara/TunerView.java
@@ -31,19 +31,23 @@ public class TunerView extends View {
paint.setColor(Color.BLACK);
paint.setTextSize(120F);
- float x = canvas.getWidth() / 2F;
- float y = canvas.getHeight() / 2F;
-
if (pitchDifference != null) {
setBackground(canvas);
- String note = pitchDifference.closest.name();
- float offset = paint.measureText(note) / 2F;
-
- canvas.drawText(note, x - offset, y, paint);
+ drawText(canvas);
}
}
+ private void drawText(Canvas canvas) {
+ float x = canvas.getWidth() / 2F;
+ float y = canvas.getHeight() / 2F;
+
+ String note = pitchDifference.closest.name();
+ float offset = paint.measureText(note) / 2F;
+
+ canvas.drawText(note, x - offset, y, paint);
+ }
+
private void setBackground(Canvas canvas) {
int color = Color.RED;
if (pitchDifference.deviation <= MAX_ALLOWED_DEVIATION) {