From bb0c32e1e66e2acf7d319151868663dbce87aa4c Mon Sep 17 00:00:00 2001 From: serso Date: Mon, 26 Jan 2015 11:12:06 +0100 Subject: [PATCH] Lint issues fixed --- .../calculator/AndroidCalculatorNotifier.java | 8 ++-- .../calculator/CalculatorActivity.java | 8 +++- .../CalculatorActivityHelperImpl.java | 10 ++--- .../calculator/CalculatorDisplayMenuItem.java | 8 ++-- .../CalculatorFragmentHelperImpl.java | 4 +- .../calculator/DigitButtonDragProcessor.java | 7 ++-- .../about/CalculatorReleaseNotesFragment.java | 2 +- .../function/FunctionParamsView.java | 7 ++-- .../AbstractCalculatorHistoryFragment.java | 2 +- .../history/AndroidCalculatorHistory.java | 2 +- .../math/edit/CalculatorVarsFragment.java | 12 ++---- .../math/edit/VarEditDialogFragment.java | 2 +- .../calculator/math/edit/VarEditorSaver.java | 9 ++--- .../model/AndroidMathEntityDao.java | 2 +- .../onscreen/CalculatorOnscreenView.java | 3 +- .../plot/AbstractCalculatorPlotFragment.java | 4 +- .../plot/CalculatorPlotFragment.java | 2 +- .../plot/CalculatorPlotFunctionsActivity.java | 7 +--- .../AbstractCalculatorWidgetProvider.java | 39 +++++++++++-------- .../main/res/layout/display_error_message.xml | 10 ++--- .../res/layout/drag_button_calibration.xml | 1 - .../src/main/res/layout/history_edit.xml | 4 +- .../main/res/layout/matrix_edit_fragment.xml | 2 +- .../src/main/res/values-large/arrays.xml | 6 +-- android-app/src/main/res/values/arrays.xml | 6 +-- .../calculator/CalculatorEditorImpl.java | 2 +- .../calculator/CalculatorKeyboardImpl.java | 2 +- .../calculator/ToJsclTextProcessor.java | 6 +-- .../plot/CalculatorPlotterImpl.java | 4 +- .../plot/MapPlotResourceManager.java | 4 +- 30 files changed, 91 insertions(+), 94 deletions(-) diff --git a/android-app/src/main/java/org/solovyev/android/calculator/AndroidCalculatorNotifier.java b/android-app/src/main/java/org/solovyev/android/calculator/AndroidCalculatorNotifier.java index 809f41ce..ba83fecb 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/AndroidCalculatorNotifier.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/AndroidCalculatorNotifier.java @@ -25,15 +25,13 @@ package org.solovyev.android.calculator; import android.app.Application; import android.os.Handler; import android.widget.Toast; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import org.solovyev.android.Threads; import org.solovyev.android.msg.AndroidMessage; import org.solovyev.common.msg.Message; import org.solovyev.common.msg.MessageType; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.List; /** @@ -56,7 +54,7 @@ public class AndroidCalculatorNotifier implements CalculatorNotifier { } public AndroidCalculatorNotifier(@Nonnull Application application, boolean showDebugMessages) { - assert Threads.isUiThread(); + if (!Threads.isUiThread()) throw new AssertionError(); this.application = application; this.showDebugMessages = showDebugMessages; diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java index 4993a487..e39f0a58 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java @@ -22,6 +22,7 @@ package org.solovyev.android.calculator; +import android.annotation.TargetApi; import android.app.AlertDialog; import android.content.Context; import android.content.SharedPreferences; @@ -96,7 +97,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar activityHelper.addTab(this, CalculatorPlotActivity.getPlotterFragmentType(), null, R.id.main_second_pane); } else { final ActionBar actionBar = getSupportActionBar(); - if (Build.VERSION.SDK_INT <= GINGERBREAD_MR1 || (Build.VERSION.SDK_INT >= ICE_CREAM_SANDWICH && ViewConfiguration.get(this).hasPermanentMenuKey())) { + if (Build.VERSION.SDK_INT <= GINGERBREAD_MR1 || (Build.VERSION.SDK_INT >= ICE_CREAM_SANDWICH && hasPermanentMenuKey())) { actionBar.hide(); } else { actionBar.setDisplayShowTitleEnabled(false); @@ -126,6 +127,11 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar } } + @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) + private boolean hasPermanentMenuKey() { + return ViewConfiguration.get(this).hasPermanentMenuKey(); + } + private boolean isMultiPane() { return findViewById(R.id.main_second_pane) != null; } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java index 0b567a40..98356ecd 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java @@ -36,17 +36,15 @@ import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; - import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.SherlockFragmentActivity; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import org.solovyev.android.Activities; import org.solovyev.android.Views; import org.solovyev.android.sherlock.tabs.ActionBarFragmentTabListener; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * User: serso * Date: 9/25/12 @@ -187,7 +185,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); final SharedPreferences.Editor editor = preferences.edit(); editor.putInt(getSavedTabPreferenceName(activity), selectedNavigationIndex); - editor.commit(); + editor.apply(); } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorDisplayMenuItem.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorDisplayMenuItem.java index cf3f1108..5adcff22 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorDisplayMenuItem.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorDisplayMenuItem.java @@ -24,15 +24,13 @@ package org.solovyev.android.calculator; import android.content.Context; import jscl.math.Generic; - -import javax.annotation.Nonnull; - -import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.plot.CalculatorPlotter; import org.solovyev.android.calculator.view.NumeralBaseConverterDialog; import org.solovyev.android.menu.LabeledMenuItem; +import javax.annotation.Nonnull; + /** * User: Solovyev_S * Date: 21.09.12 @@ -102,7 +100,7 @@ public enum CalculatorDisplayMenuItem implements LabeledMenuItem
"); } else { diff --git a/android-app/src/main/java/org/solovyev/android/calculator/function/FunctionParamsView.java b/android-app/src/main/java/org/solovyev/android/calculator/function/FunctionParamsView.java index 79db19f6..7d564b6c 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/function/FunctionParamsView.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/function/FunctionParamsView.java @@ -22,7 +22,9 @@ package org.solovyev.android.calculator.function; +import android.annotation.TargetApi; import android.content.Context; +import android.os.Build; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; @@ -31,12 +33,10 @@ import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import jscl.text.MutableInt; +import org.solovyev.android.calculator.R; import javax.annotation.Nonnull; import javax.annotation.Nullable; - -import org.solovyev.android.calculator.R; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -59,6 +59,7 @@ public class FunctionParamsView extends LinearLayout { super(context, attrs); } + @TargetApi(Build.VERSION_CODES.HONEYCOMB) public FunctionParamsView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java index 13d6d320..3fd1a722 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java @@ -245,7 +245,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag } public static boolean isAlreadySaved(@Nonnull CalculatorHistoryState historyState) { - assert !historyState.isSaved(); + if (historyState.isSaved()) throw new AssertionError(); boolean result = false; try { diff --git a/android-app/src/main/java/org/solovyev/android/calculator/history/AndroidCalculatorHistory.java b/android-app/src/main/java/org/solovyev/android/calculator/history/AndroidCalculatorHistory.java index 1102127c..e9df8a6b 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/history/AndroidCalculatorHistory.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/history/AndroidCalculatorHistory.java @@ -70,7 +70,7 @@ public class AndroidCalculatorHistory implements CalculatorHistory { editor.putString("org.solovyev.android.calculator.CalculatorModel_history", calculatorHistory.toXml()); - editor.commit(); + editor.apply(); } public void clearSavedHistory() { diff --git a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java index 82f289a2..f7308c73 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java @@ -25,17 +25,11 @@ package org.solovyev.android.calculator.math.edit; import android.content.Context; import android.os.Bundle; import android.view.View; - import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem; - import jscl.math.function.IConstant; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.menu.AMenuItem; @@ -44,6 +38,8 @@ import org.solovyev.common.JPredicate; import org.solovyev.common.collections.Collections; import org.solovyev.common.text.Strings; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -269,7 +265,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment implements View.OnClickListene if (!Strings.isEmpty(name)) { try { - assert name != null; + if (name == null) throw new AssertionError(); Identifier.parser.parse(Parser.Parameters.newInstance(name, new MutableInt(0), Locator.getInstance().getEngine().getMathEngine0()), null); result = true; } catch (ParseException e) { diff --git a/android-app/src/main/java/org/solovyev/android/calculator/model/AndroidMathEntityDao.java b/android-app/src/main/java/org/solovyev/android/calculator/model/AndroidMathEntityDao.java index 041e8f9b..f1af8b66 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/model/AndroidMathEntityDao.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/model/AndroidMathEntityDao.java @@ -81,7 +81,7 @@ public class AndroidMathEntityDao implements Ma editor.putString(preferenceString, sw.toString()); - editor.commit(); + editor.apply(); } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/onscreen/CalculatorOnscreenView.java b/android-app/src/main/java/org/solovyev/android/calculator/onscreen/CalculatorOnscreenView.java index b8f91cbd..00d40d77 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/onscreen/CalculatorOnscreenView.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/onscreen/CalculatorOnscreenView.java @@ -38,6 +38,7 @@ import org.solovyev.android.prefs.Preference; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import java.util.Locale; /** * User: serso @@ -530,7 +531,7 @@ public class CalculatorOnscreenView { if (value >= 0) { return "+" + String.format("%.2f", value); } else { - return String.format("%.2f", value); + return String.format(Locale.ENGLISH, "%.2f", value); } } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java index 344e8d2c..a04c0859 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java @@ -165,7 +165,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment case plot_data_changed: final CalculatorEventHolder.Result result = this.lastEventHolder.apply(calculatorEventData); if (result.isNewAfter()) { - assert data != null; + if (data == null) throw new AssertionError(); onNewPlotData((PlotData) data); } break; @@ -191,7 +191,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment createGraphicalView(view, plotData); } - assert activity != null; + if (activity == null) throw new AssertionError(); activity.invalidateOptionsMenu(); } }); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java index 24c7ad6b..44f30788 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java @@ -95,7 +95,7 @@ public class CalculatorPlotFragment extends AbstractCalculatorPlotFragment { @Nonnull @Override protected Bitmap getScreehshot() { - assert this.graphView != null; + if (this.graphView == null) throw new AssertionError(); return this.graphView.captureScreenshot(); } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionsActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionsActivity.java index ed29cd5e..8aff1bc4 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionsActivity.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionsActivity.java @@ -23,13 +23,9 @@ package org.solovyev.android.calculator.plot; import android.os.Bundle; - import com.actionbarsherlock.app.SherlockFragmentActivity; import com.google.common.base.Function; import com.google.common.collect.Lists; - -import javax.annotation.Nullable; - import org.solovyev.android.calculator.CalculatorFragmentType; import org.solovyev.android.calculator.CalculatorListFragment; import org.solovyev.android.calculator.Locator; @@ -37,6 +33,7 @@ import org.solovyev.android.calculator.R; import org.solovyev.android.fragments.FragmentUtils; import org.solovyev.android.list.ListItemAdapter; +import javax.annotation.Nullable; import java.util.List; /** @@ -68,7 +65,7 @@ public class CalculatorPlotFunctionsActivity extends SherlockFragmentActivity { final List items = Lists.transform(Locator.getInstance().getPlotter().getFunctions(), new Function() { @Override public PlotFunctionListItem apply(@javax.annotation.Nullable PlotFunction input) { - assert input != null; + if (input == null) throw new AssertionError(); return new PlotFunctionListItem(input); } }); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/widget/AbstractCalculatorWidgetProvider.java b/android-app/src/main/java/org/solovyev/android/calculator/widget/AbstractCalculatorWidgetProvider.java index ae492696..f80ea8b0 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/widget/AbstractCalculatorWidgetProvider.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/widget/AbstractCalculatorWidgetProvider.java @@ -22,6 +22,7 @@ package org.solovyev.android.calculator.widget; +import android.annotation.TargetApi; import android.app.PendingIntent; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; @@ -147,24 +148,30 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider { private int getLayout(@Nonnull AppWidgetManager appWidgetManager, int appWidgetId, @Nonnull Resources resources) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - final Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId); + return getLayoutJellyBean(appWidgetManager, appWidgetId, resources); + } + return R.layout.widget_layout; + } - if (options != null) { - // Get the value of OPTION_APPWIDGET_HOST_CATEGORY - final int category = options.getInt(OPTION_APPWIDGET_HOST_CATEGORY, -1); + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + private int getLayoutJellyBean(AppWidgetManager appWidgetManager, int appWidgetId, Resources resources) { + final Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId); - if (category != -1) { - // If the value is WIDGET_CATEGORY_KEYGUARD, it's a lockscreen widget - final boolean keyguard = category == WIDGET_CATEGORY_KEYGUARD; - if(keyguard) { - final int minHeightDp = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, -1); - final int minHeight = resources.getDimensionPixelSize(R.dimen.min_expanded_height_lock_screen); - final boolean expanded = (minHeightDp >= minHeight / resources.getDisplayMetrics().density); - if (expanded) { - return R.layout.widget_layout_lockscreen; - } else { - return R.layout.widget_layout_lockscreen_collapsed; - } + if (options != null) { + // Get the value of OPTION_APPWIDGET_HOST_CATEGORY + final int category = options.getInt(OPTION_APPWIDGET_HOST_CATEGORY, -1); + + if (category != -1) { + // If the value is WIDGET_CATEGORY_KEYGUARD, it's a lockscreen widget + final boolean keyguard = category == WIDGET_CATEGORY_KEYGUARD; + if(keyguard) { + final int minHeightDp = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, -1); + final int minHeight = resources.getDimensionPixelSize(R.dimen.min_expanded_height_lock_screen); + final boolean expanded = (minHeightDp >= minHeight / resources.getDisplayMetrics().density); + if (expanded) { + return R.layout.widget_layout_lockscreen; + } else { + return R.layout.widget_layout_lockscreen_collapsed; } } } diff --git a/android-app/src/main/res/layout/display_error_message.xml b/android-app/src/main/res/layout/display_error_message.xml index ad6ad982..04a61f8b 100644 --- a/android-app/src/main/res/layout/display_error_message.xml +++ b/android-app/src/main/res/layout/display_error_message.xml @@ -26,15 +26,13 @@ a:layout_width="fill_parent" a:layout_height="fill_parent"> - - diff --git a/android-app/src/main/res/layout/history_edit.xml b/android-app/src/main/res/layout/history_edit.xml index 2829897b..a05806e5 100644 --- a/android-app/src/main/res/layout/history_edit.xml +++ b/android-app/src/main/res/layout/history_edit.xml @@ -29,8 +29,8 @@ diff --git a/android-app/src/main/res/layout/matrix_edit_fragment.xml b/android-app/src/main/res/layout/matrix_edit_fragment.xml index b49ee31b..c5ad2114 100644 --- a/android-app/src/main/res/layout/matrix_edit_fragment.xml +++ b/android-app/src/main/res/layout/matrix_edit_fragment.xml @@ -74,7 +74,7 @@ diff --git a/android-app/src/main/res/values-large/arrays.xml b/android-app/src/main/res/values-large/arrays.xml index 4d508828..ed45a52f 100644 --- a/android-app/src/main/res/values-large/arrays.xml +++ b/android-app/src/main/res/values-large/arrays.xml @@ -20,15 +20,15 @@ ~ Site: http://se.solovyev.org --> - + - + @string/p_layout_calculator @string/p_layout_calculator_mobile @string/p_layout_simple @string/p_layout_simple_mobile - + main_calculator main_calculator_mobile simple diff --git a/android-app/src/main/res/values/arrays.xml b/android-app/src/main/res/values/arrays.xml index ee30e48f..68877d61 100644 --- a/android-app/src/main/res/values/arrays.xml +++ b/android-app/src/main/res/values/arrays.xml @@ -20,7 +20,7 @@ ~ Site: http://se.solovyev.org --> - + @string/p_default_theme @string/p_violet_theme @@ -55,11 +55,11 @@ "∙" - + @string/p_layout_calculator @string/p_layout_simple - + main_calculator simple diff --git a/core/src/main/java/org/solovyev/android/calculator/CalculatorEditorImpl.java b/core/src/main/java/org/solovyev/android/calculator/CalculatorEditorImpl.java index 4004cf17..8b68eeb4 100644 --- a/core/src/main/java/org/solovyev/android/calculator/CalculatorEditorImpl.java +++ b/core/src/main/java/org/solovyev/android/calculator/CalculatorEditorImpl.java @@ -120,7 +120,7 @@ public class CalculatorEditorImpl implements CalculatorEditor { } private void fireStateChangedEvent(boolean majorChanges, @Nonnull CalculatorEditorViewState oldViewState, @Nonnull CalculatorEditorViewState newViewState) { - assert Thread.holdsLock(viewLock); + if (!Thread.holdsLock(viewLock)) throw new AssertionError(); if (majorChanges) { calculator.fireCalculatorEvent(editor_state_changed, newChangeEventData(oldViewState, newViewState)); diff --git a/core/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardImpl.java b/core/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardImpl.java index bc3d6432..b3516a71 100644 --- a/core/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardImpl.java +++ b/core/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardImpl.java @@ -46,7 +46,7 @@ public class CalculatorKeyboardImpl implements CalculatorKeyboard { public void buttonPressed(@Nullable final String text) { if (!Strings.isEmpty(text)) { - assert text != null; + if (text == null) throw new AssertionError(); // process special buttons boolean processed = processSpecialButtons(text); diff --git a/core/src/main/java/org/solovyev/android/calculator/ToJsclTextProcessor.java b/core/src/main/java/org/solovyev/android/calculator/ToJsclTextProcessor.java index 947827df..56751303 100644 --- a/core/src/main/java/org/solovyev/android/calculator/ToJsclTextProcessor.java +++ b/core/src/main/java/org/solovyev/android/calculator/ToJsclTextProcessor.java @@ -24,15 +24,13 @@ package org.solovyev.android.calculator; import jscl.math.function.Function; import jscl.math.function.IConstant; - -import javax.annotation.Nonnull; - import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.text.TextProcessor; import org.solovyev.common.collections.Collections; import org.solovyev.common.msg.MessageType; import org.solovyev.common.search.StartsWithFinder; +import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; @@ -135,7 +133,7 @@ public class ToJsclTextProcessor implements TextProcessor variables = new ArrayList(CalculatorUtils.getNotSystemConstants(expression)); - assert variables.size() <= 2; + if (variables.size() > 2) throw new AssertionError(); final Constant xVariable; if (variables.size() > 0) { @@ -316,7 +316,7 @@ public class CalculatorPlotterImpl implements CalculatorPlotter { // NOTE: this method must be called from synchronized block private void onFunctionsChanged() { - assert Thread.holdsLock(functions); + if (!Thread.holdsLock(functions)) throw new AssertionError(); int maxArity = 0; for (PlotFunction function : functions) { diff --git a/core/src/main/java/org/solovyev/android/calculator/plot/MapPlotResourceManager.java b/core/src/main/java/org/solovyev/android/calculator/plot/MapPlotResourceManager.java index d3523fb5..e8112fd6 100644 --- a/core/src/main/java/org/solovyev/android/calculator/plot/MapPlotResourceManager.java +++ b/core/src/main/java/org/solovyev/android/calculator/plot/MapPlotResourceManager.java @@ -69,7 +69,7 @@ public class MapPlotResourceManager implements PlotResourceManager { } private void addLineDef(@Nonnull final PlotLineDef toBeAdded) { - assert Thread.holdsLock(this); + if (!Thread.holdsLock(this)) throw new AssertionError(); List registeredLineDefs = registeredLineDefsMap.get(toBeAdded); if (registeredLineDefs == null) { @@ -94,7 +94,7 @@ public class MapPlotResourceManager implements PlotResourceManager { } private void removeLineDef(@Nonnull final PlotLineDef toBeRemoved) { - assert Thread.holdsLock(this); + if (!Thread.holdsLock(this)) throw new AssertionError(); List registeredLineDefs = registeredLineDefsMap.get(toBeRemoved);