Made refresh tree view.
This commit is contained in:
parent
f595212692
commit
4833269e0f
Binary file not shown.
@ -29,7 +29,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</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" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
@ -32,11 +32,9 @@ import ru.volgorobot.vrcatalog.model.FirstLevelModel;
|
|||||||
public class MainActivity extends AppCompatActivity
|
public class MainActivity extends AppCompatActivity
|
||||||
implements NavigationView.OnNavigationItemSelectedListener, SwipeRefreshLayout.OnRefreshListener {
|
implements NavigationView.OnNavigationItemSelectedListener, SwipeRefreshLayout.OnRefreshListener {
|
||||||
|
|
||||||
private AndroidTreeView treeView;
|
|
||||||
private VRApi vrApi;
|
private VRApi vrApi;
|
||||||
private List<FirstLevelModel> firstLevelObjects = new ArrayList<>();
|
private List<FirstLevelModel> firstLevelObjects = new ArrayList<>();
|
||||||
private List<TreeNode> firstLevelNodes = new ArrayList<>();
|
private List<TreeNode> firstLevelNodes = new ArrayList<>();
|
||||||
private TreeNode root = TreeNode.root();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -64,14 +62,6 @@ public class MainActivity extends AppCompatActivity
|
|||||||
} catch (IllegalStateException e) {
|
} 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
|
@Override
|
||||||
@ -117,8 +107,14 @@ public class MainActivity extends AppCompatActivity
|
|||||||
for (int i = 0; i < firstLevelObjects.size(); i++) {
|
for (int i = 0; i < firstLevelObjects.size(); i++) {
|
||||||
firstLevelNodes.add(new TreeNode(firstLevelObjects.get(i).getName()));
|
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
|
@Override
|
||||||
@ -146,10 +142,6 @@ public class MainActivity extends AppCompatActivity
|
|||||||
final SwipeRefreshLayout mSwipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
final SwipeRefreshLayout mSwipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
||||||
mSwipeRefreshLayout.setRefreshing(true);
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
if(clean) {
|
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++) {
|
for (int i = 0; i < firstLevelNodes.size(); i++) {
|
||||||
firstLevelNodes.remove(i);
|
firstLevelNodes.remove(i);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user