Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a9799b6

Browse filesBrowse files
committed
improved id generation. fix bmelnychuk#20
1 parent 1d90738 commit a9799b6
Copy full SHA for a9799b6

1 file changed

+6-2Lines changed: 6 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎library/src/main/java/com/unnamed/b/atv/model/TreeNode.java‎

Copy file name to clipboardExpand all lines: library/src/main/java/com/unnamed/b/atv/model/TreeNode.java
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class TreeNode {
2020
public static final String NODES_ID_SEPARATOR = ":";
2121

2222
private int mId;
23+
private int mLastId;
2324
private TreeNode mParent;
2425
private boolean mSelected;
2526
private boolean mSelectable = true;
@@ -36,15 +37,18 @@ public static TreeNode root() {
3637
return root;
3738
}
3839

40+
private int generateId() {
41+
return ++mLastId;
42+
}
43+
3944
public TreeNode(Object value) {
4045
children = new ArrayList<>();
4146
mValue = value;
4247
}
4348

4449
public TreeNode addChild(TreeNode childNode) {
4550
childNode.mParent = this;
46-
//TODO think about id generation
47-
childNode.mId = size();
51+
childNode.mId = generateId();
4852
children.add(childNode);
4953
return this;
5054
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.