Last round of addressing review issues

This commit is contained in:
Torsten Grote
2016-10-19 14:38:11 -02:00
parent 8f882dc910
commit 5a0fa5dcc7
5 changed files with 14 additions and 11 deletions

View File

@@ -36,6 +36,7 @@ import org.briarproject.api.plugins.ConnectionRegistry;
import org.briarproject.api.plugins.PluginManager; import org.briarproject.api.plugins.PluginManager;
import org.briarproject.api.privategroup.PrivateGroupManager; import org.briarproject.api.privategroup.PrivateGroupManager;
import org.briarproject.api.settings.SettingsManager; import org.briarproject.api.settings.SettingsManager;
import org.briarproject.api.system.Clock;
import org.briarproject.plugins.AndroidPluginsModule; import org.briarproject.plugins.AndroidPluginsModule;
import org.briarproject.system.AndroidSystemModule; import org.briarproject.system.AndroidSystemModule;
@@ -121,6 +122,8 @@ public interface AndroidComponent extends CoreEagerSingletons {
FeedManager feedManager(); FeedManager feedManager();
Clock clock();
@IoExecutor @IoExecutor
Executor ioExecutor(); Executor ioExecutor();

View File

@@ -19,6 +19,7 @@ import org.briarproject.api.identity.IdentityManager;
import org.briarproject.api.identity.LocalAuthor; import org.briarproject.api.identity.LocalAuthor;
import org.briarproject.api.lifecycle.LifecycleManager; import org.briarproject.api.lifecycle.LifecycleManager;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
import org.briarproject.api.system.Clock;
import org.briarproject.util.StringUtils; import org.briarproject.util.StringUtils;
import java.util.Collection; import java.util.Collection;
@@ -41,9 +42,9 @@ public class ForumControllerImpl
LifecycleManager lifecycleManager, IdentityManager identityManager, LifecycleManager lifecycleManager, IdentityManager identityManager,
@CryptoExecutor Executor cryptoExecutor, @CryptoExecutor Executor cryptoExecutor,
ForumManager forumManager, EventBus eventBus, ForumManager forumManager, EventBus eventBus,
AndroidNotificationManager notificationManager) { AndroidNotificationManager notificationManager, Clock clock) {
super(dbExecutor, lifecycleManager, identityManager, cryptoExecutor, super(dbExecutor, lifecycleManager, identityManager, cryptoExecutor,
eventBus, notificationManager); eventBus, notificationManager, clock);
this.forumManager = forumManager; this.forumManager = forumManager;
} }

View File

@@ -19,6 +19,7 @@ import org.briarproject.api.privategroup.GroupMessageHeader;
import org.briarproject.api.privategroup.PrivateGroup; import org.briarproject.api.privategroup.PrivateGroup;
import org.briarproject.api.privategroup.PrivateGroupManager; import org.briarproject.api.privategroup.PrivateGroupManager;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
import org.briarproject.api.system.Clock;
import java.util.Collection; import java.util.Collection;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
@@ -40,9 +41,9 @@ public class GroupControllerImpl
LifecycleManager lifecycleManager, IdentityManager identityManager, LifecycleManager lifecycleManager, IdentityManager identityManager,
@CryptoExecutor Executor cryptoExecutor, @CryptoExecutor Executor cryptoExecutor,
PrivateGroupManager privateGroupManager, EventBus eventBus, PrivateGroupManager privateGroupManager, EventBus eventBus,
AndroidNotificationManager notificationManager) { AndroidNotificationManager notificationManager, Clock clock) {
super(dbExecutor, lifecycleManager, identityManager, cryptoExecutor, super(dbExecutor, lifecycleManager, identityManager, cryptoExecutor,
eventBus, notificationManager); eventBus, notificationManager, clock);
this.privateGroupManager = privateGroupManager; this.privateGroupManager = privateGroupManager;
} }

View File

@@ -52,8 +52,6 @@ class GroupViewHolder extends RecyclerView.ViewHolder {
void bindView(final Context ctx, final GroupItem group, void bindView(final Context ctx, final GroupItem group,
@NotNull final OnGroupRemoveClickListener listener) { @NotNull final OnGroupRemoveClickListener listener) {
if (group == null) return;
// Avatar // Avatar
avatar.setText(group.getName().substring(0, 1)); avatar.setText(group.getName().substring(0, 1));
avatar.setBackgroundBytes(group.getId().getBytes()); avatar.setBackgroundBytes(group.getId().getBytes());

View File

@@ -22,6 +22,7 @@ import org.briarproject.api.identity.LocalAuthor;
import org.briarproject.api.lifecycle.LifecycleManager; import org.briarproject.api.lifecycle.LifecycleManager;
import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
import org.briarproject.api.system.Clock;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -46,6 +47,7 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
private final Executor cryptoExecutor; private final Executor cryptoExecutor;
protected final AndroidNotificationManager notificationManager; protected final AndroidNotificationManager notificationManager;
private final EventBus eventBus; private final EventBus eventBus;
private final Clock clock;
private final Map<MessageId, String> bodyCache = private final Map<MessageId, String> bodyCache =
new ConcurrentHashMap<>(); new ConcurrentHashMap<>();
@@ -57,12 +59,13 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
protected ThreadListControllerImpl(@DatabaseExecutor Executor dbExecutor, protected ThreadListControllerImpl(@DatabaseExecutor Executor dbExecutor,
LifecycleManager lifecycleManager, IdentityManager identityManager, LifecycleManager lifecycleManager, IdentityManager identityManager,
@CryptoExecutor Executor cryptoExecutor, EventBus eventBus, @CryptoExecutor Executor cryptoExecutor, EventBus eventBus,
AndroidNotificationManager notificationManager) { AndroidNotificationManager notificationManager, Clock clock) {
super(dbExecutor, lifecycleManager); super(dbExecutor, lifecycleManager);
this.identityManager = identityManager; this.identityManager = identityManager;
this.cryptoExecutor = cryptoExecutor; this.cryptoExecutor = cryptoExecutor;
this.eventBus = eventBus; this.eventBus = eventBus;
this.notificationManager = notificationManager; this.notificationManager = notificationManager;
this.clock = clock;
} }
@Override @Override
@@ -250,7 +253,7 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
LocalAuthor author = identityManager.getLocalAuthor(); LocalAuthor author = identityManager.getLocalAuthor();
long timestamp = getLatestTimestamp(); long timestamp = getLatestTimestamp();
timestamp = timestamp =
Math.max(timestamp, System.currentTimeMillis()); Math.max(timestamp, clock.currentTimeMillis());
createMessage(body, timestamp, parentId, author, createMessage(body, timestamp, parentId, author,
handler); handler);
} catch (DbException e) { } catch (DbException e) {
@@ -343,9 +346,6 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
return entries; return entries;
} }
/**
* When building the item, the body can be assumed to be cached
*/
protected abstract I buildItem(H header, String body); protected abstract I buildItem(H header, String body);
protected GroupId getGroupId() { protected GroupId getGroupId() {