From bb349e6b83f27e5a3e560668c72b71b8ce26c309 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Thu, 3 Jan 2019 22:01:22 +0400 Subject: [PATCH] Removed loading third level (in future it's will be implemented) and fixed duplication of tree nodes. --- .../ru/volgorobot/vrcatalog/MainActivity.java | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/MainActivity.java b/app/src/main/java/ru/volgorobot/vrcatalog/MainActivity.java index a287510..7ff9c58 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/MainActivity.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/MainActivity.java @@ -122,9 +122,6 @@ public class MainActivity extends AppCompatActivity firstLevelNodes.add(new TreeNode(firstLevelObjects.get(i).getName())); firstLevelNodes.get(i).setLevel(0); firstLevelNodes.get(i).setChildren(getSecondLevelNodesByParentID(firstLevelObjects.get(i).getID())); - for (int j = 0; j < firstLevelNodes.get(i).getChildren().size(); j++) { - firstLevelNodes.get(i).getChildren().get(j).setChildren(getThirdLevelNodesByParentName((String) firstLevelNodes.get(i).getChildren().get(j).getValue())); - } } rootNode.setChildren(firstLevelNodes); @@ -174,18 +171,9 @@ public class MainActivity extends AppCompatActivity private void getTreeData(final boolean clean) throws IllegalStateException { mSwipeRefreshLayout.setRefreshing(true); if(clean) { - for (int i = 0; i < firstLevelNodes.size(); i++) { - firstLevelNodes.remove(i); - } - for (int i = 0; i < firstLevelObjects.size(); i++) { - firstLevelObjects.remove(i); - } - for (int i = 0; i < secondLevelObjects.size(); i++) { - secondLevelObjects.remove(i); - } - for (int i = 0; i < thirdLevelObjects.size(); i++) { - thirdLevelObjects.remove(i); - } + firstLevelNodes.removeAll(firstLevelNodes); + firstLevelObjects.removeAll(firstLevelObjects); + secondLevelObjects.removeAll(secondLevelObjects); } SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); String baseURL = sharedPreferences.getString("addressOfServer", ""); @@ -210,14 +198,6 @@ public class MainActivity extends AppCompatActivity return 2; } } - for (int i = 0; i < secondLevelObjects.size(); i++) { - Response> thirdLevelResponse = vrApi.getDetails(secondLevelObjects.get(i).getID()).execute(); - if(thirdLevelResponse.isSuccessful()) { - thirdLevelObjects.addAll(thirdLevelResponse.body()); - } else { - return 2; - } - } } else { return 2; }