mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 07:09:56 +01:00
Use commit action to add contacts to SharingController.
This commit is contained in:
@@ -245,20 +245,16 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadSharingContacts() {
|
public void loadSharingContacts() {
|
||||||
runOnDbThread(() -> {
|
runOnDbThread(true, txn -> {
|
||||||
try {
|
Collection<GroupMember> members =
|
||||||
Collection<GroupMember> members =
|
privateGroupManager.getMembers(txn, groupId);
|
||||||
privateGroupManager.getMembers(groupId);
|
Collection<ContactId> contactIds = new ArrayList<>();
|
||||||
Collection<ContactId> contactIds = new ArrayList<>();
|
for (GroupMember m : members) {
|
||||||
for (GroupMember m : members) {
|
if (m.getContactId() != null)
|
||||||
if (m.getContactId() != null)
|
contactIds.add(m.getContactId());
|
||||||
contactIds.add(m.getContactId());
|
|
||||||
}
|
|
||||||
sharingController.addAll(contactIds);
|
|
||||||
} catch (DbException e) {
|
|
||||||
logException(LOG, WARNING, e);
|
|
||||||
}
|
}
|
||||||
});
|
txn.attach(() -> sharingController.addAll(contactIds));
|
||||||
|
}, e -> logException(LOG, WARNING, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
void deletePrivateGroup() {
|
void deletePrivateGroup() {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.briarproject.briar.android.sharing;
|
package org.briarproject.briar.android.sharing;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
|
||||||
import org.briarproject.bramble.api.event.EventBus;
|
import org.briarproject.bramble.api.event.EventBus;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ public interface SharingController {
|
|||||||
/**
|
/**
|
||||||
* Adds a collection of contacts to be tracked.
|
* Adds a collection of contacts to be tracked.
|
||||||
*/
|
*/
|
||||||
@DatabaseExecutor
|
@UiThread
|
||||||
void addAll(Collection<ContactId> contacts);
|
void addAll(Collection<ContactId> contacts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ package org.briarproject.briar.android.sharing;
|
|||||||
|
|
||||||
import org.briarproject.bramble.api.connection.ConnectionRegistry;
|
import org.briarproject.bramble.api.connection.ConnectionRegistry;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
import org.briarproject.bramble.api.event.Event;
|
||||||
import org.briarproject.bramble.api.event.EventBus;
|
import org.briarproject.bramble.api.event.EventBus;
|
||||||
import org.briarproject.bramble.api.event.EventListener;
|
import org.briarproject.bramble.api.event.EventListener;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.plugin.event.ContactConnectedEvent;
|
import org.briarproject.bramble.api.plugin.event.ContactConnectedEvent;
|
||||||
import org.briarproject.bramble.api.plugin.event.ContactDisconnectedEvent;
|
import org.briarproject.bramble.api.plugin.event.ContactDisconnectedEvent;
|
||||||
import org.briarproject.bramble.api.system.AndroidExecutor;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -26,7 +24,6 @@ public class SharingControllerImpl implements SharingController, EventListener {
|
|||||||
|
|
||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
private final ConnectionRegistry connectionRegistry;
|
private final ConnectionRegistry connectionRegistry;
|
||||||
private final AndroidExecutor executor;
|
|
||||||
|
|
||||||
// UI thread
|
// UI thread
|
||||||
private final Set<ContactId> contacts = new HashSet<>();
|
private final Set<ContactId> contacts = new HashSet<>();
|
||||||
@@ -35,11 +32,9 @@ public class SharingControllerImpl implements SharingController, EventListener {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SharingControllerImpl(EventBus eventBus,
|
SharingControllerImpl(EventBus eventBus,
|
||||||
ConnectionRegistry connectionRegistry,
|
ConnectionRegistry connectionRegistry) {
|
||||||
AndroidExecutor executor) {
|
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.connectionRegistry = connectionRegistry;
|
this.connectionRegistry = connectionRegistry;
|
||||||
this.executor = executor;
|
|
||||||
eventBus.addListener(this);
|
eventBus.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,13 +73,11 @@ public class SharingControllerImpl implements SharingController, EventListener {
|
|||||||
return online;
|
return online;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UiThread
|
||||||
@Override
|
@Override
|
||||||
@DatabaseExecutor
|
|
||||||
public void addAll(Collection<ContactId> c) {
|
public void addAll(Collection<ContactId> c) {
|
||||||
executor.runOnUiThread(() -> {
|
contacts.addAll(c);
|
||||||
contacts.addAll(c);
|
updateLiveData();
|
||||||
updateLiveData();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
|
|||||||
Reference in New Issue
Block a user