Refactor Forum Activity and adapters to be re-used for private groups

This commit is contained in:
Torsten Grote
2016-10-10 10:04:28 -03:00
parent 9d2c56e75f
commit 9ce95d6de7
13 changed files with 895 additions and 699 deletions

View File

@@ -1,51 +0,0 @@
package org.briarproject.android.util;
import android.support.annotation.UiThread;
import org.briarproject.api.clients.MessageTree;
import org.briarproject.clients.MessageTreeImpl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@UiThread
public class NestedTreeList<T extends MessageTree.MessageNode>
implements Iterable<T> {
private final MessageTree<T> tree = new MessageTreeImpl<>();
private List<T> depthFirstCollection = new ArrayList<>();
public void addAll(Collection<T> collection) {
tree.add(collection);
depthFirstCollection = new ArrayList<>(tree.depthFirstOrder());
}
public void add(T elem) {
tree.add(elem);
depthFirstCollection = new ArrayList<>(tree.depthFirstOrder());
}
public void clear() {
tree.clear();
depthFirstCollection.clear();
}
public T get(int index) {
return depthFirstCollection.get(index);
}
public int indexOf(T elem) {
return depthFirstCollection.indexOf(elem);
}
public int size() {
return depthFirstCollection.size();
}
@Override
public Iterator<T> iterator() {
return depthFirstCollection.iterator();
}
}