Made refresh tree view.

This commit is contained in:
ChronosX88 2018-11-22 16:41:49 +03:00
parent f595212692
commit 4833269e0f
3 changed files with 9 additions and 17 deletions

View File

@ -29,7 +29,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -32,11 +32,9 @@ import ru.volgorobot.vrcatalog.model.FirstLevelModel;
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, SwipeRefreshLayout.OnRefreshListener {
private AndroidTreeView treeView;
private VRApi vrApi;
private List<FirstLevelModel> firstLevelObjects = new ArrayList<>();
private List<TreeNode> firstLevelNodes = new ArrayList<>();
private TreeNode root = TreeNode.root();
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -64,14 +62,6 @@ public class MainActivity extends AppCompatActivity
} catch (IllegalStateException e) {
//
}
root.addChildren(firstLevelNodes);
treeView = new AndroidTreeView(MainActivity.this, root);
treeView.setDefaultAnimation(true);
ViewGroup containerView = (ViewGroup) findViewById(R.id.treeViewContainer);
containerView.addView(treeView.getView());
}
@Override
@ -117,8 +107,14 @@ public class MainActivity extends AppCompatActivity
for (int i = 0; i < firstLevelObjects.size(); i++) {
firstLevelNodes.add(new TreeNode(firstLevelObjects.get(i).getName()));
}
SwipeRefreshLayout mSwipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);
mSwipeRefreshLayout.setRefreshing(false);
TreeNode root = TreeNode.root();
root.addChildren(firstLevelNodes);
AndroidTreeView treeView = new AndroidTreeView(MainActivity.this, root);
treeView.setDefaultAnimation(true);
treeView.setDefaultContainerStyle(R.style.TreeNodeStyle);
ViewGroup containerView = findViewById(R.id.treeViewContainer);
containerView.addView(treeView.getView());
}
@Override
@ -146,10 +142,6 @@ public class MainActivity extends AppCompatActivity
final SwipeRefreshLayout mSwipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);
mSwipeRefreshLayout.setRefreshing(true);
if(clean) {
List<TreeNode> list = new ArrayList<>(root.getChildren());
for (int i = 0; i < list.size(); i++) {
root.deleteChild(list.get(i));
}
for (int i = 0; i < firstLevelNodes.size(); i++) {
firstLevelNodes.remove(i);
}