本文整理汇总了Java中org.thoughtcrime.securesms.database.GroupDatabase.updateMembers方法的典型用法代码示例。如果您正苦于以下问题:Java GroupDatabase.updateMembers方法的具体用法?Java GroupDatabase.updateMembers怎么用?Java GroupDatabase.updateMembers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.thoughtcrime.securesms.database.GroupDatabase
的用法示例。
在下文中一共展示了GroupDatabase.updateMembers方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateGroup
import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
public static GroupActionResult updateGroup(@NonNull Context context,
@NonNull MasterSecret masterSecret,
@NonNull byte[] groupId,
@NonNull Set<Recipient> members,
@Nullable Bitmap avatar,
@Nullable String name)
throws InvalidNumberException
{
final GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
final Set<String> memberE164Numbers = getE164Numbers(context, members);
final byte[] avatarBytes = BitmapUtil.toByteArray(avatar);
memberE164Numbers.add(TextSecurePreferences.getLocalNumber(context));
groupDatabase.updateMembers(groupId, new LinkedList<>(memberE164Numbers));
groupDatabase.updateTitle(groupId, name);
groupDatabase.updateAvatar(groupId, avatarBytes);
return sendGroupUpdate(context, masterSecret, groupId, memberE164Numbers, name, avatarBytes);
}
示例2: handleUpdatePushGroup
import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
private Pair<Long, Recipients> handleUpdatePushGroup(byte[] groupId, String groupName,
byte[] avatar, Set<Recipient> members)
throws InvalidNumberException, MmsException
{
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(this);
Set<String> memberE164Numbers = getE164Numbers(members);
memberE164Numbers.add(TextSecurePreferences.getLocalNumber(this));
for (String number : memberE164Numbers)
Log.w(TAG, "Updating: " + number);
groupDatabase.updateMembers(groupId, new LinkedList<String>(memberE164Numbers));
groupDatabase.updateTitle(groupId, groupName);
groupDatabase.updateAvatar(groupId, avatar);
return handlePushOperation(groupId, groupName, avatar, memberE164Numbers);
}
示例3: updateGroup
import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
public static GroupActionResult updateGroup(@NonNull Context context,
@NonNull MasterSecret masterSecret,
@NonNull byte[] groupId,
@NonNull Set<Recipient> members,
@Nullable Set<String> admins,
@Nullable Bitmap avatar,
@Nullable String name)
throws InvalidNumberException
{
final GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
final GroupDatabase.GroupRecord groupRecord = groupDatabase.getGroup(groupId);
final Set<String> memberE164Numbers = getE164Numbers(context, members);
final String ownerNumber = groupRecord.getOwner();
final String ownerE164Number = Util.canonicalizeNumber(context, ownerNumber, ownerNumber);
final Set<String> adminE164Numbers = getE164FromNumbers(context, admins);
final byte[] avatarBytes = BitmapUtil.toByteArray(avatar);
removeLocalRecipient(context, members);
List<Recipient> missingMembers = groupDatabase.getGroupMembers(groupId, false).getRecipientsList();
missingMembers.removeAll(members);
Recipients destRecipients = null;
if(missingMembers.size() > 0) {
missingMembers.addAll(members);
destRecipients = RecipientFactory.getRecipientsFor(context, missingMembers, false);
}
memberE164Numbers.add(TextSecurePreferences.getLocalNumber(context));
groupDatabase.updateMembers(groupId, new LinkedList<>(memberE164Numbers));
groupDatabase.updateAdmins(groupId, new LinkedList<>(adminE164Numbers));
groupDatabase.updateTitle(groupId, name);
groupDatabase.updateAvatar(groupId, avatarBytes);
return sendGroupUpdate(context, masterSecret, groupId, memberE164Numbers, ownerE164Number,
adminE164Numbers, name, avatarBytes, destRecipients);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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());
}