Remove dependency from NumeralBaseButton

This commit is contained in:
serso 2016-02-28 13:50:02 +01:00
parent b40b82574e
commit 467789d323
2 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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) {
if (this.numeralBase == numeralBase) {
return;
}
this.numeralBase = numeralBase;
invalidate();
}
}
}