本文整理汇总了Java中org.thoughtcrime.securesms.database.GroupDatabase.update方法的典型用法代码示例。如果您正苦于以下问题:Java GroupDatabase.update方法的具体用法?Java GroupDatabase.update怎么用?Java GroupDatabase.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.thoughtcrime.securesms.database.GroupDatabase
的用法示例。
在下文中一共展示了GroupDatabase.update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleGroupUpdate
import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
private static @Nullable Long handleGroupUpdate(@NonNull Context context,
@NonNull MasterSecretUnion masterSecret,
@NonNull SignalServiceEnvelope envelope,
@NonNull SignalServiceGroup group,
@NonNull GroupRecord groupRecord,
boolean outgoing)
{
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
byte[] id = group.getGroupId();
Set<String> recordMembers = new HashSet<>(groupRecord.getMembers());
Set<String> messageMembers = new HashSet<>(group.getMembers().get());
// Set<String> addedMembers = new HashSet<>(messageMembers);
// addedMembers.removeAll(recordMembers);
Set<String> missingMembers = new HashSet<>(recordMembers);
missingMembers.removeAll(messageMembers);
GroupContext.Builder builder = createGroupContext(group);
builder.setType(GroupContext.Type.UPDATE);
database.updateMembers(id, group.getMembers().or(Collections.<String>emptyList()));
builder.clearMembers().addAllMembers(new HashSet<>(group.getMembers().or(Collections.<String>emptyList())));
// if (addedMembers.size() > 0) {
// Set<String> unionMembers = new HashSet<>(recordMembers);
// unionMembers.addAll(messageMembers);
// database.updateMembers(id, new LinkedList<>(unionMembers));
//
// builder.clearMembers().addAllMembers(addedMembers);
// } else {
// builder.clearMembers();
// }
if(group.getOwner().isPresent()) {
List<String> messageListAdmins = group.getAdmins().or(Collections.<String>emptyList());
Set<String> messageAdmins = new HashSet<>(messageListAdmins);
database.updateAdmins(id, messageListAdmins);
builder.clearAdmins().addAllAdmins(messageAdmins);
}
if (group.getName().isPresent() || group.getAvatar().isPresent()) {
SignalServiceAttachment avatar = group.getAvatar().orNull();
database.update(id, group.getName().orNull(), avatar != null ? avatar.asPointer() : null);
}
if (group.getName().isPresent() && group.getName().get().equals(groupRecord.getTitle())) {
builder.clearName();
}
if (missingMembers.size() > 0) {
for (String missingMember : missingMembers) {
if(missingMember.equals(TextSecurePreferences.getLocalNumber(context))) {
database.setActive(id, false);
break;
}
}
} else if (!groupRecord.isActive()) database.setActive(id, true);
return storeMessage(context, masterSecret, envelope, group, builder.build(), outgoing);
}
示例2: handleGroupUpdate
import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
private static @Nullable Long handleGroupUpdate(@NonNull Context context,
@NonNull MasterSecretUnion masterSecret,
@NonNull SignalServiceEnvelope envelope,
@NonNull SignalServiceGroup group,
@NonNull GroupRecord groupRecord,
boolean outgoing)
{
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
byte[] id = group.getGroupId();
Set<String> recordMembers = new HashSet<>(groupRecord.getMembers());
Set<String> messageMembers = new HashSet<>(group.getMembers().get());
Set<String> addedMembers = new HashSet<>(messageMembers);
addedMembers.removeAll(recordMembers);
Set<String> missingMembers = new HashSet<>(recordMembers);
missingMembers.removeAll(messageMembers);
GroupContext.Builder builder = createGroupContext(group);
builder.setType(GroupContext.Type.UPDATE);
if (addedMembers.size() > 0) {
Set<String> unionMembers = new HashSet<>(recordMembers);
unionMembers.addAll(messageMembers);
database.updateMembers(id, new LinkedList<>(unionMembers));
builder.clearMembers().addAllMembers(addedMembers);
} else {
builder.clearMembers();
}
if (missingMembers.size() > 0) {
// TODO We should tell added and missing about each-other.
}
if (group.getName().isPresent() || group.getAvatar().isPresent()) {
SignalServiceAttachment avatar = group.getAvatar().orNull();
database.update(id, group.getName().orNull(), avatar != null ? avatar.asPointer() : null);
}
if (group.getName().isPresent() && group.getName().get().equals(groupRecord.getTitle())) {
builder.clearName();
}
if (!groupRecord.isActive()) database.setActive(id, true);
return storeMessage(context, masterSecret, envelope, group, builder.build(), outgoing);
}
示例3: handleGroupUpdate
import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
private static void handleGroupUpdate(Context context,
MasterSecret masterSecret,
TextSecureEnvelope envelope,
TextSecureGroup group,
GroupRecord groupRecord)
{
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
byte[] id = group.getGroupId();
Set<String> recordMembers = new HashSet<>(groupRecord.getMembers());
Set<String> messageMembers = new HashSet<>(group.getMembers().get());
Set<String> addedMembers = new HashSet<>(messageMembers);
addedMembers.removeAll(recordMembers);
Set<String> missingMembers = new HashSet<>(recordMembers);
missingMembers.removeAll(messageMembers);
GroupContext.Builder builder = createGroupContext(group);
builder.setType(GroupContext.Type.UPDATE);
if (addedMembers.size() > 0) {
Set<String> unionMembers = new HashSet<>(recordMembers);
unionMembers.addAll(messageMembers);
database.updateMembers(id, new LinkedList<>(unionMembers));
builder.clearMembers().addAllMembers(addedMembers);
} else {
builder.clearMembers();
}
if (missingMembers.size() > 0) {
// TODO We should tell added and missing about each-other.
}
if (group.getName().isPresent() || group.getAvatar().isPresent()) {
TextSecureAttachment avatar = group.getAvatar().orNull();
database.update(id, group.getName().orNull(), avatar != null ? avatar.asPointer() : null);
}
if (group.getName().isPresent() && group.getName().get().equals(groupRecord.getTitle())) {
builder.clearName();
}
if (!groupRecord.isActive()) database.setActive(id, true);
storeMessage(context, masterSecret, envelope, group, builder.build());
}