From aee0d616e5e6a8102fb43207c81f79bd74eebd77 Mon Sep 17 00:00:00 2001 From: Faisal Hameed Date: Sun, 13 Mar 2016 23:49:47 +0500 Subject: [PATCH] Fixing squid:S2864 - Iterating entrySet insteadof keySet. --- .../nutomic/syncthingandroid/syncthing/RestApi.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java index a969e825..25ac33eb 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java @@ -568,9 +568,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener, } } Map connections = new HashMap<>(); - for (String deviceId : jsonConnections.keySet()) { + for (Map.Entry jsonConnection : jsonConnections.entrySet()) { + String deviceId = jsonConnection.getKey(); Connection c = new Connection(); - JSONObject conn = jsonConnections.get(deviceId); + JSONObject conn = jsonConnection.getValue(); c.address = deviceId; c.at = conn.getString("at"); c.inBytesTotal = conn.getLong("inBytesTotal"); @@ -607,7 +608,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener, private int getDeviceCompletion(String deviceId) { int folderCount = 0; float percentageSum = 0; - for (String id : mCachedModelInfo.keySet()) { + for (Map.Entry modelInfo : mCachedModelInfo.entrySet()) { boolean isShared = false; outerloop: for (Folder r : getFolders()) { @@ -620,8 +621,8 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener, } } if (isShared) { - long global = mCachedModelInfo.get(id).globalBytes; - long local = mCachedModelInfo.get(id).inSyncBytes; + long global = modelInfo.getValue().globalBytes; + long local = modelInfo.getValue().inSyncBytes; percentageSum += (global != 0) ? (local * 100f) / global : 100f;