user exceptions fixed

This commit is contained in:
Sergey Solovyev 2012-12-05 12:31:49 +04:00
parent dc25f1897c
commit 552e23b8c0
2 changed files with 5 additions and 15 deletions

View File

@ -544,7 +544,7 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener {
varBuilder.setName(CalculatorVarsRegistry.ANS); varBuilder.setName(CalculatorVarsRegistry.ANS);
varBuilder.setValue(result); varBuilder.setValue(result);
varBuilder.setDescription(CalculatorMessages.getBundle().getString("ans_description")); varBuilder.setDescription(CalculatorMessages.getBundle().getString(CalculatorMessages.ans_description));
CalculatorVarsRegistry.saveVariable(varsRegistry, varBuilder, ansVar, this, false); CalculatorVarsRegistry.saveVariable(varsRegistry, varBuilder, ansVar, this, false);
} }

View File

@ -2,9 +2,7 @@ package org.solovyev.android.calculator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle; import java.util.ResourceBundle;
/** /**
@ -14,9 +12,6 @@ import java.util.ResourceBundle;
*/ */
public final class CalculatorMessages { public final class CalculatorMessages {
@NotNull
private static final Map<Locale, ResourceBundle> bundlesByLocale = new HashMap<Locale, ResourceBundle>();
private CalculatorMessages() { private CalculatorMessages() {
throw new AssertionError(); throw new AssertionError();
@ -29,15 +24,7 @@ public final class CalculatorMessages {
@NotNull @NotNull
public static ResourceBundle getBundle(@NotNull Locale locale) { public static ResourceBundle getBundle(@NotNull Locale locale) {
synchronized (bundlesByLocale) { return ResourceBundle.getBundle("org/solovyev/android/calculator/messages", locale);
ResourceBundle result = bundlesByLocale.get(locale);
if (result == null) {
result = ResourceBundle.getBundle("org/solovyev/android/calculator/messages", locale);
bundlesByLocale.put(locale, result);
}
return result;
}
} }
/* Arithmetic error occurred: {0} */ /* Arithmetic error occurred: {0} */
@ -63,4 +50,7 @@ public final class CalculatorMessages {
/* Result copied to clipboard! */ /* Result copied to clipboard! */
public static final String result_copied = "result_copied"; public static final String result_copied = "result_copied";
/* Last calculated value */
public static final String ans_description = "ans_description";
} }