diff --git a/app/src/main/java/com/codigoparallevar/minicards/parts/strings/ConvertToString.java b/app/src/main/java/com/codigoparallevar/minicards/parts/strings/ConvertToString.java index 27d1d59..9cf3c69 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/parts/strings/ConvertToString.java +++ b/app/src/main/java/com/codigoparallevar/minicards/parts/strings/ConvertToString.java @@ -3,9 +3,10 @@ package com.codigoparallevar.minicards.parts.strings; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; -import androidx.annotation.NonNull; import android.util.Log; +import androidx.annotation.NonNull; + import com.codigoparallevar.minicards.PartInstantiator; import com.codigoparallevar.minicards.ScrolledCanvas; import com.codigoparallevar.minicards.parts.connectors.AnyRoundInputConnector; @@ -15,10 +16,10 @@ import com.codigoparallevar.minicards.types.Moveable; import com.codigoparallevar.minicards.types.Part; import com.codigoparallevar.minicards.types.PartConnection; import com.codigoparallevar.minicards.types.PartGrid; -import com.codigoparallevar.minicards.types.functional.Tuple2; import com.codigoparallevar.minicards.types.connectors.input.AnyInputConnector; import com.codigoparallevar.minicards.types.connectors.input.InputConnector; import com.codigoparallevar.minicards.types.connectors.output.OutputConnector; +import com.codigoparallevar.minicards.types.functional.Tuple2; import com.codigoparallevar.minicards.types.wireData.StringSignal; import com.codigoparallevar.minicards.types.wireData.WireDataType; import com.codigoparallevar.minicards.utils.Serializations; @@ -250,7 +251,6 @@ public class ConvertToString implements Part { public void send(InputConnector roundInputConnector, WireDataType signal) { String encoded = "null"; Object value = signal.get(); - if (value != null){ encoded = value.toString(); } diff --git a/app/src/main/java/com/programaker/api/data/ProgramakerCustomBlockArgument.kt b/app/src/main/java/com/programaker/api/data/ProgramakerCustomBlockArgument.kt index 4cf2d0b..6ce8b79 100644 --- a/app/src/main/java/com/programaker/api/data/ProgramakerCustomBlockArgument.kt +++ b/app/src/main/java/com/programaker/api/data/ProgramakerCustomBlockArgument.kt @@ -12,7 +12,11 @@ class ProgramakerCustomBlockArgument( val callback: String? ) { fun serialize(): JSONObject { - val serialized = hashMapOf() + val serialized = hashMapOf( + "type" to type, + "default_value" to default_value, + "callback" to callback + ) return JSONObject(serialized as Map<*, *>) } @@ -42,19 +46,9 @@ class ProgramakerCustomBlockArgument( } private fun deserialize(arguments: JSONObject): ProgramakerCustomBlockArgument { - var type: String? = null - var default_value: String? = null - var callback: String? = null - - if (arguments.has("type")) { - type = arguments.getString("type") - } - if (arguments.has("default_value")) { - default_value = arguments.getString("default_value") - } - if (arguments.has("callback")) { - callback = arguments.getString("callback") - } + val type: String? = arguments.optString("type") + val default_value: String? = arguments.optString("default_value") + val callback: String? = arguments.optString("callback") return ProgramakerCustomBlockArgument(type, default_value, callback) }