Refactor existing adapters into a generic superclass

This commit also moves various blog classes into their own packages and
makes the required visibility changes.
This commit is contained in:
Torsten Grote
2016-10-03 19:29:14 -03:00
parent 9112d17a4b
commit b2fa039474
29 changed files with 305 additions and 615 deletions

View File

@@ -1,40 +1,14 @@
package org.briarproject.android.blogs;
import org.briarproject.api.blogs.Blog;
import org.briarproject.api.blogs.BlogPostHeader;
import java.util.Collection;
class BlogItem {
private final Blog blog;
private final int postCount;
private final long timestamp;
private final int unread;
private final boolean ours, removable;
BlogItem(Blog blog, Collection<BlogPostHeader> headers, boolean ours,
boolean removable) {
BlogItem(Blog blog, boolean ours, boolean removable) {
this.blog = blog;
if (headers.isEmpty()) {
postCount = 0;
timestamp = 0;
unread = 0;
} else {
BlogPostHeader newest = null;
long timestamp = -1;
int unread = 0;
for (BlogPostHeader h : headers) {
if (h.getTimestamp() > timestamp) {
timestamp = h.getTimestamp();
newest = h;
}
if (!h.isRead()) unread++;
}
this.postCount = headers.size();
this.timestamp = newest.getTimestamp();
this.unread = unread;
}
this.ours = ours;
this.removable = removable;
}
@@ -47,22 +21,6 @@ class BlogItem {
return blog.getName();
}
boolean isEmpty() {
return postCount == 0;
}
int getPostCount() {
return postCount;
}
long getTimestamp() {
return timestamp;
}
int getUnreadCount() {
return unread;
}
boolean isOurs() {
return ours;
}