当前位置: 首页>>代码示例>>Java>>正文


Java GroupDatabase.updateMembers方法代码示例

本文整理汇总了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);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:20,代码来源:GroupManager.java

示例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);
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:18,代码来源:GroupCreateActivity.java

示例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);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:38,代码来源:GroupManager.java

示例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);
  }
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:64,代码来源:GroupMessageProcessor.java

示例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);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:51,代码来源:GroupMessageProcessor.java

示例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());
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:50,代码来源:GroupMessageProcessor.java


注:本文中的org.thoughtcrime.securesms.database.GroupDatabase.updateMembers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。