Removed loading third level (in future it's will be implemented) and fixed duplication of tree nodes.
This commit is contained in:
parent
dc01b7960b
commit
bb349e6b83
@ -122,9 +122,6 @@ public class MainActivity extends AppCompatActivity
|
|||||||
firstLevelNodes.add(new TreeNode(firstLevelObjects.get(i).getName()));
|
firstLevelNodes.add(new TreeNode(firstLevelObjects.get(i).getName()));
|
||||||
firstLevelNodes.get(i).setLevel(0);
|
firstLevelNodes.get(i).setLevel(0);
|
||||||
firstLevelNodes.get(i).setChildren(getSecondLevelNodesByParentID(firstLevelObjects.get(i).getID()));
|
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);
|
rootNode.setChildren(firstLevelNodes);
|
||||||
@ -174,18 +171,9 @@ public class MainActivity extends AppCompatActivity
|
|||||||
private void getTreeData(final boolean clean) throws IllegalStateException {
|
private void getTreeData(final boolean clean) throws IllegalStateException {
|
||||||
mSwipeRefreshLayout.setRefreshing(true);
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
if(clean) {
|
if(clean) {
|
||||||
for (int i = 0; i < firstLevelNodes.size(); i++) {
|
firstLevelNodes.removeAll(firstLevelNodes);
|
||||||
firstLevelNodes.remove(i);
|
firstLevelObjects.removeAll(firstLevelObjects);
|
||||||
}
|
secondLevelObjects.removeAll(secondLevelObjects);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
String baseURL = sharedPreferences.getString("addressOfServer", "");
|
String baseURL = sharedPreferences.getString("addressOfServer", "");
|
||||||
@ -210,14 +198,6 @@ public class MainActivity extends AppCompatActivity
|
|||||||
return 2;
|
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 {
|
} else {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user