Code cleanup
This commit is contained in:
parent
51ced42d8e
commit
3797f26330
@ -23,19 +23,16 @@
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import jscl.NumeralBase;
|
||||
import org.solovyev.android.calculator.units.CalculatorNumeralBase;
|
||||
import org.solovyev.android.views.dragbutton.DirectionDragButton;
|
||||
import org.solovyev.android.views.dragbutton.DragDirection;
|
||||
import org.solovyev.android.calculator.units.CalculatorNumeralBase;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import jscl.NumeralBase;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 4/21/12
|
||||
@ -95,7 +92,7 @@ public enum AndroidNumeralBase {
|
||||
@Nonnull
|
||||
private final CalculatorNumeralBase calculatorNumeralBase;
|
||||
|
||||
private AndroidNumeralBase(@Nonnull CalculatorNumeralBase calculatorNumeralBase) {
|
||||
AndroidNumeralBase(@Nonnull CalculatorNumeralBase calculatorNumeralBase) {
|
||||
this.calculatorNumeralBase = calculatorNumeralBase;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public interface CalculatorEventContainer {
|
||||
|
||||
void fireCalculatorEvents(@Nonnull List<CalculatorEvent> calculatorEvents);
|
||||
|
||||
public static class CalculatorEvent {
|
||||
class CalculatorEvent {
|
||||
|
||||
@Nonnull
|
||||
private CalculatorEventData calculatorEventData;
|
||||
|
@ -75,10 +75,7 @@ class CalculatorEventDataImpl implements CalculatorEventData {
|
||||
if (this.sequenceId == NO_SEQUENCE) {
|
||||
return false;
|
||||
}
|
||||
if (this.sequenceId == that.getSequenceId()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.sequenceId == that.getSequenceId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,10 +83,7 @@ class CalculatorEventDataImpl implements CalculatorEventData {
|
||||
if (this.sequenceId == NO_SEQUENCE) {
|
||||
return false;
|
||||
}
|
||||
if (this.sequenceId > that.getSequenceId()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.sequenceId > that.getSequenceId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,9 +94,8 @@ class CalculatorEventDataImpl implements CalculatorEventData {
|
||||
CalculatorEventDataImpl that = (CalculatorEventDataImpl) o;
|
||||
|
||||
if (eventId != that.eventId) return false;
|
||||
if (sequenceId != that.sequenceId) return false;
|
||||
return sequenceId == that.sequenceId;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,7 +75,7 @@ public enum CalculatorFragmentType {
|
||||
private Class<? extends Fragment> fragmentClass;
|
||||
private int defaultTitleResId;
|
||||
|
||||
private CalculatorFragmentType(@Nonnull Class<? extends Fragment> fragmentClass,
|
||||
CalculatorFragmentType(@Nonnull Class<? extends Fragment> fragmentClass,
|
||||
int defaultLayoutId,
|
||||
int defaultTitleResId) {
|
||||
this.fragmentClass = fragmentClass;
|
||||
|
@ -87,7 +87,7 @@ enum CalculatorMenu implements LabeledMenuItem<MenuItem> {
|
||||
|
||||
private final int captionResId;
|
||||
|
||||
private CalculatorMenu(int captionResId) {
|
||||
CalculatorMenu(int captionResId) {
|
||||
this.captionResId = captionResId;
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,11 @@ import javax.annotation.Nullable;
|
||||
public interface MathEntityBuilder<T extends MathEntity> extends JBuilder<T> {
|
||||
|
||||
@Nonnull
|
||||
public MathEntityBuilder<T> setName(@Nonnull String name);
|
||||
MathEntityBuilder<T> setName(@Nonnull String name);
|
||||
|
||||
@Nonnull
|
||||
public MathEntityBuilder<T> setDescription(@Nullable String description);
|
||||
MathEntityBuilder<T> setDescription(@Nullable String description);
|
||||
|
||||
@Nonnull
|
||||
public MathEntityBuilder<T> setValue(@Nullable String value);
|
||||
MathEntityBuilder<T> setValue(@Nullable String value);
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
|
||||
return super.onOptionsItemSelected(item) || fragmentMenu.onOptionsItemSelected(this.getActivity(), item);
|
||||
}
|
||||
|
||||
private static enum PlotMenu implements IdentifiableMenuItem<MenuItem> {
|
||||
private enum PlotMenu implements IdentifiableMenuItem<MenuItem> {
|
||||
|
||||
functions(R.id.menu_plot_functions) {
|
||||
@Override
|
||||
@ -425,7 +425,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
|
||||
|
||||
private final int itemId;
|
||||
|
||||
private PlotMenu(int itemId) {
|
||||
PlotMenu(int itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
|
@ -325,11 +325,7 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
|
||||
maxArity = Math.max(maxArity, xyFunction.getArity());
|
||||
}
|
||||
|
||||
if (maxArity > 1) {
|
||||
plot3d = true;
|
||||
} else {
|
||||
plot3d = false;
|
||||
}
|
||||
plot3d = maxArity > 1;
|
||||
|
||||
if (functions.isEmpty()) {
|
||||
// no functions => new plot => default boundaries
|
||||
|
@ -31,21 +31,21 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public interface GraphView extends ZoomButtonsController.OnZoomListener, TouchHandler.TouchHandlerListener {
|
||||
|
||||
public void init(@Nonnull PlotViewDef plotViewDef);
|
||||
void init(@Nonnull PlotViewDef plotViewDef);
|
||||
|
||||
@Nonnull
|
||||
public List<PlotFunction> getPlotFunctions();
|
||||
List<PlotFunction> getPlotFunctions();
|
||||
|
||||
public void setPlotFunctions(@Nonnull List<PlotFunction> plotFunctions);
|
||||
void setPlotFunctions(@Nonnull List<PlotFunction> plotFunctions);
|
||||
|
||||
public void onDestroy();
|
||||
void onDestroy();
|
||||
|
||||
public void onPause();
|
||||
void onPause();
|
||||
|
||||
public void onResume();
|
||||
void onResume();
|
||||
|
||||
@Nonnull
|
||||
public Bitmap captureScreenshot();
|
||||
Bitmap captureScreenshot();
|
||||
|
||||
void setXRange(float xMin, float xMax);
|
||||
|
||||
|
@ -109,9 +109,8 @@ public final class PlotBoundaries implements Serializable {
|
||||
if (Float.compare(that.xMax, xMax) != 0) return false;
|
||||
if (Float.compare(that.xMin, xMin) != 0) return false;
|
||||
if (Float.compare(that.yMax, yMax) != 0) return false;
|
||||
if (Float.compare(that.yMin, yMin) != 0) return false;
|
||||
return Float.compare(that.yMin, yMin) == 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,9 +124,8 @@ public class PlotFunction {
|
||||
|
||||
PlotFunction that = (PlotFunction) o;
|
||||
|
||||
if (!xyFunction.equals(that.xyFunction)) return false;
|
||||
return xyFunction.equals(that.xyFunction);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +47,7 @@ public enum PlotLineColor {
|
||||
|
||||
private final int color;
|
||||
|
||||
private PlotLineColor(int color) {
|
||||
PlotLineColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
@ -30,5 +30,5 @@ package org.solovyev.android.calculator.plot;
|
||||
public enum PlotLineColorType {
|
||||
|
||||
monochrome,
|
||||
color_map;
|
||||
color_map
|
||||
}
|
||||
|
@ -171,9 +171,8 @@ public class PlotLineDef {
|
||||
if (lineColor != that.lineColor) return false;
|
||||
if (Float.compare(that.lineWidth, lineWidth) != 0) return false;
|
||||
if (lineColorType != that.lineColorType) return false;
|
||||
if (lineStyle != that.lineStyle) return false;
|
||||
return lineStyle == that.lineStyle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,6 +33,6 @@ public enum PlotLineStyle {
|
||||
solid,
|
||||
dashed,
|
||||
dotted,
|
||||
dash_dotted;
|
||||
dash_dotted
|
||||
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class TouchHandler {
|
||||
return velocityTracker.getYVelocity();
|
||||
}
|
||||
|
||||
static interface TouchHandlerListener {
|
||||
interface TouchHandlerListener {
|
||||
void onTouchDown(float x, float y);
|
||||
|
||||
void onTouchMove(float x, float y);
|
||||
|
@ -22,14 +22,13 @@
|
||||
|
||||
package org.solovyev.android.calculator.plot;
|
||||
|
||||
import jscl.math.Generic;
|
||||
import jscl.math.function.Constant;
|
||||
import org.solovyev.common.text.Strings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import jscl.math.Generic;
|
||||
import jscl.math.function.Constant;
|
||||
|
||||
public class XyFunction implements FunctionEvaluator {
|
||||
|
||||
/*
|
||||
@ -156,9 +155,8 @@ public class XyFunction implements FunctionEvaluator {
|
||||
|
||||
final XyFunction that = (XyFunction) o;
|
||||
|
||||
if (!id.equals(that.id)) return false;
|
||||
return id.equals(that.id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,7 +54,7 @@ public enum CalculatorNumeralBase implements UnitType<String> {
|
||||
@Nonnull
|
||||
private final NumeralBase numeralBase;
|
||||
|
||||
private CalculatorNumeralBase(@Nonnull NumeralBase numeralBase) {
|
||||
CalculatorNumeralBase(@Nonnull NumeralBase numeralBase) {
|
||||
this.numeralBase = numeralBase;
|
||||
}
|
||||
|
||||
|
@ -132,9 +132,8 @@ public class CppVariable implements Jsonable, Parcelable {
|
||||
CppVariable that = (CppVariable) o;
|
||||
|
||||
if (id != that.id) return false;
|
||||
if (!name.equals(that.name)) return false;
|
||||
return name.equals(that.name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -232,7 +232,7 @@ public class UnitConverterViewBuilder implements ViewBuilder<View> {
|
||||
spinner.setAdapter(adapter);
|
||||
}
|
||||
|
||||
public static interface CustomButtonOnClickListener {
|
||||
public interface CustomButtonOnClickListener {
|
||||
void onClick(@Nonnull Unit<String> fromUnits, @Nonnull Unit<String> toUnits);
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ public class DragButtonWizardStep extends WizardFragment {
|
||||
}
|
||||
}
|
||||
|
||||
private static enum DragButtonAction {
|
||||
private enum DragButtonAction {
|
||||
center(R.string.cpp_wizard_dragbutton_action_center, null),
|
||||
up(R.string.cpp_wizard_dragbutton_action_up, DragDirection.up),
|
||||
down(R.string.cpp_wizard_dragbutton_action_down, DragDirection.down),
|
||||
|
@ -33,7 +33,7 @@ import javax.annotation.Nonnull;
|
||||
*/
|
||||
public interface FragmentItem {
|
||||
|
||||
public void onSelected(@Nonnull FragmentTransaction ft);
|
||||
void onSelected(@Nonnull FragmentTransaction ft);
|
||||
|
||||
public void onUnselected(@Nonnull FragmentTransaction ft);
|
||||
void onUnselected(@Nonnull FragmentTransaction ft);
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ public interface Wizards {
|
||||
Class<? extends Activity> getActivityClassName();
|
||||
|
||||
@Nonnull
|
||||
public Wizard getWizard(@Nullable String name, @Nullable Bundle arguments) throws IllegalArgumentException;
|
||||
Wizard getWizard(@Nullable String name, @Nullable Bundle arguments) throws IllegalArgumentException;
|
||||
|
||||
@Nonnull
|
||||
public Wizard getWizard(@Nullable String name) throws IllegalArgumentException;
|
||||
Wizard getWizard(@Nullable String name) throws IllegalArgumentException;
|
||||
}
|
||||
|
@ -55,9 +55,8 @@ public abstract class AbstractJsclArithmeticException extends ArithmeticExceptio
|
||||
|
||||
AbstractJsclArithmeticException that = (AbstractJsclArithmeticException) o;
|
||||
|
||||
if (!message.equals(that.message)) return false;
|
||||
return message.equals(that.message);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,9 +108,8 @@ public class ExtendedConstant implements Comparable<ExtendedConstant>, IConstant
|
||||
|
||||
ExtendedConstant that = (ExtendedConstant) o;
|
||||
|
||||
if (!constant.equals(that.constant)) return false;
|
||||
return constant.equals(that.constant);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -196,7 +196,7 @@ public class Pow extends Algebraic {
|
||||
}
|
||||
|
||||
public Generic selfNumeric() {
|
||||
return ((NumericWrapper) parameters[0]).pow((NumericWrapper) parameters[1]);
|
||||
return ((NumericWrapper) parameters[0]).pow(parameters[1]);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
@ -144,7 +144,7 @@ final class TreePolynomial extends Polynomial {
|
||||
Iterator it = content.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry e = (Map.Entry) it.next();
|
||||
p.content.put(((Monomial) e.getKey()).multiply(monomial), (Generic) e.getValue());
|
||||
p.content.put(((Monomial) e.getKey()).multiply(monomial), e.getValue());
|
||||
}
|
||||
p.degree = degree + monomial.degree();
|
||||
p.sugar = sugar + monomial.degree();
|
||||
@ -171,7 +171,7 @@ final class TreePolynomial extends Polynomial {
|
||||
Iterator it = content.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry e = (Map.Entry) it.next();
|
||||
p.content.put(((Monomial) e.getKey()).divide(monomial), (Generic) e.getValue());
|
||||
p.content.put(((Monomial) e.getKey()).divide(monomial), e.getValue());
|
||||
}
|
||||
p.degree = degree + monomial.degree();
|
||||
p.sugar = sugar + monomial.degree();
|
||||
|
@ -130,7 +130,7 @@ public class ParserUtils {
|
||||
}
|
||||
|
||||
public static <T, U> T[] copyOf(U[] array, int newLength, Class<? extends T[]> newType) {
|
||||
T[] copy = ((Object) newType == (Object) Object[].class)
|
||||
T[] copy = (newType == Object[].class)
|
||||
? (T[]) new Object[newLength]
|
||||
: (T[]) Array.newInstance(newType.getComponentType(), newLength);
|
||||
|
||||
|
@ -48,7 +48,7 @@ public abstract class AbstractExpressionGenerator<T> {
|
||||
return Math.random() * MAX_VALUE;
|
||||
}
|
||||
|
||||
protected static enum Operation {
|
||||
protected enum Operation {
|
||||
addition(0, "+"),
|
||||
subtraction(1, "-"),
|
||||
multiplication(2, "*"),
|
||||
@ -79,7 +79,7 @@ public abstract class AbstractExpressionGenerator<T> {
|
||||
}
|
||||
}
|
||||
|
||||
protected static enum Function {
|
||||
protected enum Function {
|
||||
sin(0, "sin"),
|
||||
cos(1, "cos"),
|
||||
sqrt(2, "√"),
|
||||
|
Loading…
Reference in New Issue
Block a user