Skip to content

Commit

Permalink
Addressed Comments - code reuse
Browse files Browse the repository at this point in the history
- BundleSceneUpdate private method bundles list of scene updates as an array of strings alternating
scene yaml path and corresponding value
  • Loading branch information
tallytalwar committed Dec 21, 2016
1 parent 4b54361 commit c362285
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions android/tangram/src/com/mapzen/tangram/MapController.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,7 @@ public void loadSceneFile(String path) {
*/
public void loadSceneFile(String path, List<SceneUpdate> 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);
Expand Down Expand Up @@ -773,13 +764,7 @@ public void queueSceneUpdate(SceneUpdate sceneUpdate) {
*/
public void queueSceneUpdate(List<SceneUpdate> 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);
}

Expand Down Expand Up @@ -841,6 +826,22 @@ void checkId(long id) {
}
}

private String[] bundleSceneUpdates(List<SceneUpdate> 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);
Expand Down

0 comments on commit c362285

Please sign in to comment.