From 467789d3238cb509f9ab6912126a1bea776f410f Mon Sep 17 00:00:00 2001 From: serso Date: Sun, 28 Feb 2016 13:50:02 +0100 Subject: [PATCH] Remove dependency from NumeralBaseButton --- .../calculator/keyboard/PartialKeyboardUi.java | 3 +++ .../android/calculator/view/NumeralBasesButton.java | 11 +++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/solovyev/android/calculator/keyboard/PartialKeyboardUi.java b/app/src/main/java/org/solovyev/android/calculator/keyboard/PartialKeyboardUi.java index cef3250b..571298fe 100644 --- a/app/src/main/java/org/solovyev/android/calculator/keyboard/PartialKeyboardUi.java +++ b/app/src/main/java/org/solovyev/android/calculator/keyboard/PartialKeyboardUi.java @@ -68,6 +68,9 @@ public class PartialKeyboardUi extends BaseKeyboardUi { prepareButton(leftButton); prepareButton(equalsButton); prepareButton(clearButton); + if (clearButton != null) { + clearButton.setNumeralBase(numeralBase.getPreference(preferences)); + } if (eraseButton != null) { Check.isTrue(IMAGE_SCALE == 0.6f); // backspace button is too big, scale it more diff --git a/app/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java b/app/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java index 42b5f80f..ba00edda 100644 --- a/app/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java +++ b/app/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java @@ -28,7 +28,6 @@ import android.support.v4.content.ContextCompat; import android.text.TextPaint; import android.util.AttributeSet; import jscl.NumeralBase; -import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.R; import org.solovyev.android.views.dragbutton.DirectionDragButton; @@ -37,11 +36,10 @@ import javax.annotation.Nonnull; public class NumeralBasesButton extends DirectionDragButton { @Nonnull - private NumeralBase numeralBase; + private NumeralBase numeralBase = NumeralBase.dec; public NumeralBasesButton(Context context, @Nonnull AttributeSet attrs) { super(context, attrs); - this.numeralBase = Locator.getInstance().getEngine().getMathEngine().getNumeralBase(); } @Override @@ -70,9 +68,10 @@ public class NumeralBasesButton extends DirectionDragButton { } public void setNumeralBase(@Nonnull NumeralBase numeralBase) { - if (this.numeralBase != numeralBase) { - this.numeralBase = numeralBase; - invalidate(); + if (this.numeralBase == numeralBase) { + return; } + this.numeralBase = numeralBase; + invalidate(); } }