Remove unsed code

This commit is contained in:
serso 2016-02-11 16:32:06 +01:00
parent 7350a9ed0c
commit bc43fa91c3
7 changed files with 25 additions and 187 deletions

View File

@ -127,12 +127,6 @@ public class Calculator implements SharedPreferences.OnSharedPreferenceChangeLis
return CalculatorEventDataImpl.newInstance(eventId, eventId); return CalculatorEventDataImpl.newInstance(eventId, eventId);
} }
@Nonnull
private CalculatorEventData nextEventData(@Nonnull Long sequenceId) {
long eventId = nextSequence();
return CalculatorEventDataImpl.newInstance(eventId, sequenceId);
}
public void evaluate() { public void evaluate() {
final EditorState state = editor.getState(); final EditorState state = editor.getState();
evaluate(JsclOperation.numeric, state.getTextString()); evaluate(JsclOperation.numeric, state.getTextString());
@ -143,34 +137,21 @@ public class Calculator implements SharedPreferences.OnSharedPreferenceChangeLis
evaluate(JsclOperation.simplify, state.getTextString()); evaluate(JsclOperation.simplify, state.getTextString());
} }
@Nonnull public long evaluate(@Nonnull final JsclOperation operation,
public CalculatorEventData evaluate(@Nonnull final JsclOperation operation, @Nonnull final String expression) {
@Nonnull final String expression) { return evaluate(operation, expression, nextSequence());
final CalculatorEventData eventDataId = nextEventData();
background.execute(new Runnable() {
@Override
public void run() {
evaluateAsync(eventDataId.getSequenceId(), operation, expression);
}
});
return eventDataId;
} }
@Nonnull public long evaluate(@Nonnull final JsclOperation operation, @Nonnull final String expression,
public CalculatorEventData evaluate(@Nonnull final JsclOperation operation, @Nonnull final String expression, long sequenceId) { final long sequence) {
final CalculatorEventData eventDataId = nextEventData(sequenceId);
background.execute(new Runnable() { background.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
evaluateAsync(eventDataId.getSequenceId(), operation, expression); evaluateAsync(sequence, operation, expression);
} }
}); });
return eventDataId; return sequence;
} }
public void init(@Nonnull Executor init) { public void init(@Nonnull Executor init) {

View File

@ -44,11 +44,6 @@ class CalculatorEventDataImpl implements CalculatorEventData {
return new CalculatorEventDataImpl(id, sequenceId, null); return new CalculatorEventDataImpl(id, sequenceId, null);
} }
@Nonnull
static CalculatorEventData newInstance(long id, long sequenceId, @Nonnull Object source) {
return new CalculatorEventDataImpl(id, sequenceId, source);
}
@Override @Override
public long getEventId() { public long getEventId() {
return this.eventId; return this.eventId;

View File

@ -22,42 +22,8 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import javax.annotation.Nonnull;
/**
* User: Solovyev_S
* Date: 20.09.12
* Time: 16:40
*/
public enum CalculatorEventType { public enum CalculatorEventType {
/*
**********************************************************************
*
* CONVERSION
* CalculatorConversionEventData
*
**********************************************************************
*/
// @Nonnull String conversion result
conversion_result,
// @Nonnull ConversionFailure
conversion_failed,
conversion_finished,
/*
**********************************************************************
*
* OTHER
*
**********************************************************************
*/
// List<Message>
calculation_messages,
show_create_var_dialog, show_create_var_dialog,
show_create_matrix_dialog, show_create_matrix_dialog,
show_create_function_dialog, show_create_function_dialog,
@ -69,14 +35,4 @@ public enum CalculatorEventType {
*/ */
plot_data_changed; plot_data_changed;
public boolean isOfType(@Nonnull CalculatorEventType... types) {
for (CalculatorEventType type : types) {
if (this == type) {
return true;
}
}
return false;
}
} }

View File

@ -1,41 +0,0 @@
/*
* Copyright 2013 serso aka se.solovyev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Contact details
*
* Email: se.solovyev@gmail.com
* Site: http://se.solovyev.org
*/
package org.solovyev.android.calculator;
import org.solovyev.android.calculator.jscl.JsclOperation;
import javax.annotation.Nonnull;
/**
* User: serso
* Date: 9/20/12
* Time: 7:25 PM
*/
public interface CalculatorInput {
@Nonnull
String getExpression();
@Nonnull
JsclOperation getOperation();
}

View File

@ -1,58 +0,0 @@
/*
* Copyright 2013 serso aka se.solovyev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Contact details
*
* Email: se.solovyev@gmail.com
* Site: http://se.solovyev.org
*/
package org.solovyev.android.calculator;
import org.solovyev.android.calculator.jscl.JsclOperation;
import javax.annotation.Nonnull;
/**
* User: serso
* Date: 9/20/12
* Time: 7:26 PM
*/
public class CalculatorInputImpl implements CalculatorInput {
@Nonnull
private String expression;
@Nonnull
private JsclOperation operation;
public CalculatorInputImpl(@Nonnull String expression, @Nonnull JsclOperation operation) {
this.expression = expression;
this.operation = operation;
}
@Override
@Nonnull
public String getExpression() {
return expression;
}
@Override
@Nonnull
public JsclOperation getOperation() {
return operation;
}
}

View File

@ -26,10 +26,11 @@ import jscl.math.Generic;
import jscl.math.function.Constant; import jscl.math.function.Constant;
import jscl.math.function.IConstant; import jscl.math.function.IConstant;
import javax.annotation.Nonnull;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import javax.annotation.Nonnull;
/** /**
* User: serso * User: serso
* Date: 9/22/12 * Date: 9/22/12
@ -41,11 +42,6 @@ public final class CalculatorUtils {
throw new AssertionError(); throw new AssertionError();
} }
@Nonnull
public static CalculatorEventData createFirstEventDataId() {
return CalculatorEventDataImpl.newInstance(Calculator.NO_SEQUENCE, Calculator.NO_SEQUENCE);
}
@Nonnull @Nonnull
public static Set<Constant> getNotSystemConstants(@Nonnull Generic expression) { public static Set<Constant> getNotSystemConstants(@Nonnull Generic expression) {
final Set<Constant> notSystemConstants = new HashSet<Constant>(); final Set<Constant> notSystemConstants = new HashSet<Constant>();

View File

@ -22,10 +22,13 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import static org.mockito.Mockito.mock;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import com.squareup.otto.Bus; import com.squareup.otto.Bus;
import jscl.JsclMathEngine;
import org.junit.Assert; import org.junit.Assert;
import org.robolectric.fakes.RoboSharedPreferences; import org.robolectric.fakes.RoboSharedPreferences;
import org.solovyev.android.calculator.functions.FunctionsRegistry; import org.solovyev.android.calculator.functions.FunctionsRegistry;
@ -35,9 +38,14 @@ import org.solovyev.android.calculator.operators.OperatorsRegistry;
import org.solovyev.android.calculator.operators.PostfixFunctionsRegistry; import org.solovyev.android.calculator.operators.PostfixFunctionsRegistry;
import org.solovyev.android.calculator.plot.CalculatorPlotter; import org.solovyev.android.calculator.plot.CalculatorPlotter;
import javax.annotation.Nonnull; import jscl.JsclMathEngine;
import javax.annotation.Nullable;
import java.io.*; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -45,7 +53,8 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static org.mockito.Mockito.mock; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* User: serso * User: serso
@ -118,7 +127,7 @@ public class CalculatorTestUtils {
try { try {
calculator.addCalculatorEventListener(calculatorEventListener); calculator.addCalculatorEventListener(calculatorEventListener);
calculatorEventListener.setCalculatorEventData(calculator.evaluate(operation, expression)); //calculatorEventListener.setCalculatorEventData(calculator.evaluate(operation, expression));
if (latch.await(TIMEOUT, TimeUnit.SECONDS)) { if (latch.await(TIMEOUT, TimeUnit.SECONDS)) {
Assert.assertNotNull(calculatorEventListener.getResult()); Assert.assertNotNull(calculatorEventListener.getResult());
@ -173,7 +182,7 @@ public class CalculatorTestUtils {
final TestCalculatorEventListener calculatorEventListener = new TestCalculatorEventListener(latch); final TestCalculatorEventListener calculatorEventListener = new TestCalculatorEventListener(latch);
try { try {
calculator.addCalculatorEventListener(calculatorEventListener); calculator.addCalculatorEventListener(calculatorEventListener);
calculatorEventListener.setCalculatorEventData(calculator.evaluate(operation, expression)); //calculatorEventListener.setCalculatorEventData(calculator.evaluate(operation, expression));
if (latch.await(TIMEOUT, TimeUnit.SECONDS)) { if (latch.await(TIMEOUT, TimeUnit.SECONDS)) {
Assert.assertNotNull(calculatorEventListener.getResult()); Assert.assertNotNull(calculatorEventListener.getResult());