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; }