Remove classes
This commit is contained in:
@@ -4,26 +4,21 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import jscl.math.function.CustomFunction;
|
||||
import jscl.math.function.IFunction;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.solovyev.android.Check;
|
||||
import org.solovyev.android.calculator.json.Json;
|
||||
import org.solovyev.android.calculator.json.Jsonable;
|
||||
import org.solovyev.common.JBuilder;
|
||||
import org.solovyev.common.text.Strings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import jscl.math.function.CustomFunction;
|
||||
import jscl.math.function.Function;
|
||||
import jscl.math.function.IFunction;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class CppFunction implements Jsonable, Parcelable {
|
||||
@@ -185,7 +180,7 @@ public class CppFunction implements Jsonable, Parcelable {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public JBuilder<? extends Function> toJsclBuilder() {
|
||||
public CustomFunction.Builder toJsclBuilder() {
|
||||
final CustomFunction.Builder builder = new CustomFunction.Builder(name, parameters, body);
|
||||
builder.setDescription(description);
|
||||
if (id != NO_ID) {
|
||||
|
@@ -57,7 +57,7 @@ public class EditFunctionFragment extends BaseFunctionFragment {
|
||||
protected boolean applyData(@Nonnull @NonNull CppFunction function) {
|
||||
try {
|
||||
final Function oldFunction = isNewFunction() ? null : functionsRegistry.getById(function.id);
|
||||
functionsRegistry.add(function.toJsclBuilder(), oldFunction);
|
||||
functionsRegistry.addOrUpdate(function.toJsclBuilder().create(), oldFunction);
|
||||
return true;
|
||||
} catch (RuntimeException e) {
|
||||
setError(bodyLabel, e.getLocalizedMessage());
|
||||
|
@@ -36,7 +36,6 @@ import org.solovyev.android.calculator.entities.Entities;
|
||||
import org.solovyev.android.calculator.json.Json;
|
||||
import org.solovyev.android.calculator.json.Jsonable;
|
||||
import org.solovyev.android.io.FileSaver;
|
||||
import org.solovyev.common.JBuilder;
|
||||
import org.solovyev.common.text.Strings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -63,8 +62,8 @@ public class FunctionsRegistry extends BaseEntitiesRegistry<Function> {
|
||||
super(mathEngine.getFunctionsRegistry(), "c_fun_description_");
|
||||
}
|
||||
|
||||
public void add(@NonNull JBuilder<? extends Function> builder, @Nullable Function oldFunction) {
|
||||
final Function function = add(builder);
|
||||
public void addOrUpdate(@Nonnull Function newFunction, @Nullable Function oldFunction) {
|
||||
final Function function = addOrUpdate(newFunction);
|
||||
if (oldFunction == null) {
|
||||
bus.post(new AddedEvent(function));
|
||||
} else {
|
||||
@@ -92,6 +91,15 @@ public class FunctionsRegistry extends BaseEntitiesRegistry<Function> {
|
||||
setInitialized();
|
||||
}
|
||||
}
|
||||
@Nullable
|
||||
protected Function addSafely(@Nonnull CustomFunction.Builder builder) {
|
||||
try {
|
||||
return addSafely(builder.create());
|
||||
} catch (Exception e) {
|
||||
errorReporter.onException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(@Nonnull Function function) {
|
||||
|
Reference in New Issue
Block a user