Removed loading third level (in future it's will be implemented) and fixed duplication of tree nodes.

This commit is contained in:
ChronosX88 2019-01-03 22:01:22 +04:00
parent dc01b7960b
commit bb349e6b83
No known key found for this signature in database
GPG Key ID: 8F92E090A87804AA

View File

@ -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<List<ThirdLevelModel>> thirdLevelResponse = vrApi.getDetails(secondLevelObjects.get(i).getID()).execute();
if(thirdLevelResponse.isSuccessful()) {
thirdLevelObjects.addAll(thirdLevelResponse.body());
} else {
return 2;
}
}
} else {
return 2;
}