Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide leading zeroes on int number in concatNode #698

Merged
merged 6 commits into from Apr 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,11 +1,17 @@
package com.swmansion.reanimated.nodes;

import java.text.NumberFormat;

import com.facebook.react.bridge.ReadableMap;
import com.swmansion.reanimated.NodesManager;
import com.swmansion.reanimated.Utils;

public class ConcatNode extends Node {
private final int[] mInputIDs;
private final static NumberFormat sFormatter = NumberFormat.getInstance();
static {
sFormatter.setMinimumFractionDigits(0);
}

public ConcatNode(int nodeID, ReadableMap config, NodesManager nodesManager) {
super(nodeID, config, nodesManager);
Expand All @@ -17,7 +23,11 @@ protected String evaluate() {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < mInputIDs.length; i++) {
Node inputNodes = mNodesManager.findNodeById(mInputIDs[i], Node.class);
builder.append(inputNodes.value());
Object value = inputNodes.value();
if (value instanceof Double) {
value = sFormatter.format((Double) value);
}
builder.append(value);
}
return builder.toString();
}
Expand Down