From d3df8e9a883dee8e415c6462f34476b017999d6b Mon Sep 17 00:00:00 2001 From: Deepu Eswarath Ganapathiyadan Date: Fri, 14 Sep 2018 10:38:10 -0700 Subject: [PATCH] fix toBundle logic in apiGen. --- .../android/libraries/ern/apidatamodel.mustache | 16 ++++++++-------- .../ComplexApi/ern/api/TestMultiArgsData.java | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ern-api-gen/resources/android/libraries/ern/apidatamodel.mustache b/ern-api-gen/resources/android/libraries/ern/apidatamodel.mustache index 271522cc7..d3143786b 100644 --- a/ern-api-gen/resources/android/libraries/ern/apidatamodel.mustache +++ b/ern-api-gen/resources/android/libraries/ern/apidatamodel.mustache @@ -154,16 +154,16 @@ public class {{requestDataType}} implements Parcelable, Bridgeable { {{/isListContainer}} {{^isListContainer}} {{#isString}} - this.{{baseName}} = bundle.getString("{{baseName}}"); + bundle.putString("{{baseName}}", this.{{baseName}}); {{/isString}} {{#isInteger}} - this.{{baseName}} = getNumberValue(bundle, "{{baseName}}") == null ? null : getNumberValue(bundle, "{{baseName}}").intValue(); + bundle.putInt("{{baseName}}", this.{{baseName}}); {{/isInteger}} {{#isBoolean}} - this.{{baseName}} = bundle.containsKey("{{baseName}}") ? bundle.getBoolean("{{baseName}}") : null; + bundle.putBoolean("{{baseName}}", this.{{baseName}}); {{/isBoolean}} {{^isPrimitiveType}} - this.{{baseName}} = bundle.containsKey("{{baseName}}") ? new {{{dataType}}}(bundle.getBundle("{{baseName}}")) : null; + bundle.putBundle("{{baseName}}", this.{{baseName}}.toBundle()); {{/isPrimitiveType}} {{/isListContainer}} {{/requiredParams}} @@ -176,22 +176,22 @@ public class {{requestDataType}} implements Parcelable, Bridgeable { {{^isListContainer}} {{#isString}} if({{baseName}} != null) { - this.{{baseName}} = bundle.getString("{{baseName}}"); + bundle.putString("{{baseName}}", this.{{baseName}} ); } {{/isString}} {{#isInteger}} if({{baseName}} != null) { - this.{{baseName}} = getNumberValue(bundle, "{{baseName}}") == null ? null : getNumberValue(bundle, "{{baseName}}").intValue(); + bundle.putInt("{{baseName}}", this.{{baseName}}); } {{/isInteger}} {{#isBoolean}} if({{baseName}} != null) { - this.{{baseName}} = bundle.containsKey("{{baseName}}") ? bundle.getBoolean("{{baseName}}") : null; + bundle.putBoolean("{{baseName}}", this.{{baseName}}); } {{/isBoolean}} {{^isPrimitiveType}} if({{baseName}} != null) { - this.{{baseName}} = bundle.containsKey("{{baseName}}") ? new {{{dataType}}}(bundle.getBundle("{{baseName}}")) : null; + bundle.putBundle("{{baseName}}", this.{{baseName}}.toBundle()); } {{/isPrimitiveType}} {{/isListContainer}} diff --git a/system-tests/fixtures/api/ComplexApi/android/lib/src/main/java/com/ComplexApi/ern/api/TestMultiArgsData.java b/system-tests/fixtures/api/ComplexApi/android/lib/src/main/java/com/ComplexApi/ern/api/TestMultiArgsData.java index 088316d49..aa83a7ee7 100644 --- a/system-tests/fixtures/api/ComplexApi/android/lib/src/main/java/com/ComplexApi/ern/api/TestMultiArgsData.java +++ b/system-tests/fixtures/api/ComplexApi/android/lib/src/main/java/com/ComplexApi/ern/api/TestMultiArgsData.java @@ -97,8 +97,8 @@ public void writeToParcel(Parcel dest, int flags) { @Override public Bundle toBundle() { Bundle bundle = new Bundle(); - this.key1 = bundle.getString("key1"); - this.key2 = getNumberValue(bundle, "key2") == null ? null : getNumberValue(bundle, "key2").intValue(); + bundle.putString("key1", this.key1); + bundle.putInt("key2", this.key2); return bundle; }