Make BlogController thread-safe. #555

This commit is contained in:
akwizgran
2016-08-08 17:58:27 +01:00
parent d34afa5f30
commit 98337a16ec
12 changed files with 381 additions and 292 deletions

View File

@@ -1,6 +1,7 @@
package org.briarproject.android.blogs;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import org.briarproject.api.blogs.BlogPostHeader;
import org.briarproject.api.identity.Author;
@@ -31,14 +32,11 @@ class BlogPostItem implements Comparable<BlogPostItem> {
return groupId;
}
@Nullable
public String getTitle() {
return header.getTitle();
}
public byte[] getBody() {
return body;
}
public long getTimestamp() {
return header.getTimestamp();
}
@@ -55,18 +53,22 @@ class BlogPostItem implements Comparable<BlogPostItem> {
return header.getAuthorStatus();
}
public void setRead(boolean read) {
this.read = read;
public byte[] getBody() {
return body;
}
public boolean isRead() {
return read;
}
public void setRead(boolean read) {
this.read = read;
}
@Override
public int compareTo(@NonNull BlogPostItem other) {
if (this == other) return 0;
// The blog with the newest message comes first
// The newest post comes first
long aTime = getTimeReceived(), bTime = other.getTimeReceived();
if (aTime > bTime) return -1;
if (aTime < bTime) return 1;