From 4833269e0ffc9e2a9391548e12769152c1166c75 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Thu, 22 Nov 2018 16:41:49 +0300 Subject: [PATCH] Made refresh tree view. --- .idea/caches/build_file_checksums.ser | Bin 531 -> 531 bytes .idea/misc.xml | 2 +- .../ru/volgorobot/vrcatalog/MainActivity.java | 24 ++++++------------ 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 84fb81ffdc8f80a138ab6242b13f24919e462979..104abea78f7d9bda2d7ee9eba7b650ed766d6b0c 100644 GIT binary patch delta 15 WcmbQtGMQz<3>NFeMyHK)${7JGB?W%~ delta 15 XcmbQtGMQz<3>HI{*OxZVDQ5%#EtUon diff --git a/.idea/misc.xml b/.idea/misc.xml index e0d5b93..b0c7b20 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -29,7 +29,7 @@ - + diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/MainActivity.java b/app/src/main/java/ru/volgorobot/vrcatalog/MainActivity.java index c964d8f..40e2140 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/MainActivity.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/MainActivity.java @@ -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 firstLevelObjects = new ArrayList<>(); private List 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 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); }