From c3622852bf4af7e4d05d160f42c7ba56c4dd0080 Mon Sep 17 00:00:00 2001 From: Varun Talwar Date: Wed, 21 Dec 2016 17:01:20 -0500 Subject: [PATCH] Addressed Comments - code reuse - BundleSceneUpdate private method bundles list of scene updates as an array of strings alternating scene yaml path and corresponding value --- .../src/com/mapzen/tangram/MapController.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/android/tangram/src/com/mapzen/tangram/MapController.java b/android/tangram/src/com/mapzen/tangram/MapController.java index ce26203ff5..c8bd874758 100644 --- a/android/tangram/src/com/mapzen/tangram/MapController.java +++ b/android/tangram/src/com/mapzen/tangram/MapController.java @@ -234,16 +234,7 @@ public void loadSceneFile(String path) { */ public void loadSceneFile(String path, List sceneUpdates) { - String[] updateStrings = null; - - if (sceneUpdates != null) { - updateStrings = new String[sceneUpdates.size() * 2]; - int index = 0; - for (SceneUpdate sceneUpdate : sceneUpdates) { - updateStrings[index++] = sceneUpdate.getPath(); - updateStrings[index++] = sceneUpdate.getValue(); - } - } + String[] updateStrings = bundleSceneUpdates(sceneUpdates); scenePath = path; checkPointer(mapPointer); nativeLoadScene(mapPointer, path, updateStrings); @@ -773,13 +764,7 @@ public void queueSceneUpdate(SceneUpdate sceneUpdate) { */ public void queueSceneUpdate(List sceneUpdates) { checkPointer(mapPointer); - String[] updateStrings = new String[sceneUpdates.size() * 2]; - - int index = 0; - for (SceneUpdate sceneUpdate : sceneUpdates) { - updateStrings[index++] = sceneUpdate.getPath(); - updateStrings[index++] = sceneUpdate.getValue(); - } + String[] updateStrings = bundleSceneUpdates(sceneUpdates); nativeQueueSceneUpdates(mapPointer, updateStrings); } @@ -841,6 +826,22 @@ void checkId(long id) { } } + private String[] bundleSceneUpdates(List sceneUpdates) { + + String[] updateStrings = null; + + if (sceneUpdates != null) { + updateStrings = new String[sceneUpdates.size() * 2]; + int index = 0; + for (SceneUpdate sceneUpdate : sceneUpdates) { + updateStrings[index++] = sceneUpdate.getPath(); + updateStrings[index++] = sceneUpdate.getValue(); + } + } + + return updateStrings; + } + boolean setMarkerStyling(long markerId, String styleStr) { checkPointer(mapPointer); checkId(markerId);