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


Java GroupDatabase.GroupRecord方法代码示例

本文整理汇总了Java中org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord方法的典型用法代码示例。如果您正苦于以下问题:Java GroupDatabase.GroupRecord方法的具体用法?Java GroupDatabase.GroupRecord怎么用?Java GroupDatabase.GroupRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.thoughtcrime.securesms.database.GroupDatabase的用法示例。


在下文中一共展示了GroupDatabase.GroupRecord方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getGroupRecipientDetails

import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
private @NonNull RecipientDetails getGroupRecipientDetails(Context context, String groupId) {
  try {
    GroupDatabase.GroupRecord record = DatabaseFactory.getGroupDatabase(context)
                                                      .getGroup(GroupUtil.getDecodedId(groupId));

    if (record != null) {
      ContactPhoto contactPhoto = ContactPhotoFactory.getGroupContactPhoto(record.getAvatar());
      String       title        = record.getTitle();

      if (title == null) {
        title = context.getString(R.string.RecipientProvider_unnamed_group);;
      }

      return new RecipientDetails(title, groupId, null, contactPhoto, null);
    }

    return new RecipientDetails(context.getString(R.string.RecipientProvider_unnamed_group), groupId, null, ContactPhotoFactory.getDefaultGroupPhoto(), null);
  } catch (IOException e) {
    Log.w("RecipientProvider", e);
    return new RecipientDetails(context.getString(R.string.RecipientProvider_unnamed_group), groupId, null, ContactPhotoFactory.getDefaultGroupPhoto(), null);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:23,代码来源:RecipientProvider.java

示例2: getGroupRecipientDetails

import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
private @NonNull RecipientDetails getGroupRecipientDetails(Context context, String groupId) {
  try {
    GroupDatabase.GroupRecord record = DatabaseFactory.getGroupDatabase(context)
                                                      .getGroup(GroupUtil.getDecodedId(groupId));

    if (record != null) {
      ContactPhoto contactPhoto = ContactPhotoFactory.getGroupContactPhoto(record.getAvatar());
      String       title        = record.getTitle();

      if (title == null) {
        title = context.getString(R.string.RecipientProvider_unnamed_group);;
      }

      return new RecipientDetails(title, groupId, null, null, contactPhoto, null);
    }

    return new RecipientDetails(context.getString(R.string.RecipientProvider_unnamed_group), groupId, null, null, ContactPhotoFactory.getDefaultGroupPhoto(), null);
  } catch (IOException e) {
    Log.w("RecipientProvider", e);
    return new RecipientDetails(context.getString(R.string.RecipientProvider_unnamed_group), groupId, null, null, ContactPhotoFactory.getDefaultGroupPhoto(), null);
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:23,代码来源:RecipientProvider.java

示例3: doInBackground

import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... voids) {
  final GroupDatabase db = DatabaseFactory.getGroupDatabase(GroupCreateActivity.this);
  final Recipients recipients = db.getGroupMembers(groupId, false);
  if (recipients != null) {
    final List<Recipient> recipientList = recipients.getRecipientsList();
    if (recipientList != null) {
      if (existingContacts == null)
        existingContacts = new HashSet<>(recipientList.size());
      existingContacts.addAll(recipientList);
    }
  }
  GroupDatabase.GroupRecord group = db.getGroup(groupId);
  if (group != null) {
    existingTitle = group.getTitle();
    final byte[] existingAvatar = group.getAvatar();
    if (existingAvatar != null) {
      existingAvatarBmp = BitmapUtil.getCircleCroppedBitmap(
          BitmapFactory.decodeByteArray(existingAvatar, 0, existingAvatar.length));
    }
  }
  return null;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:24,代码来源:GroupCreateActivity.java

示例4: getGroupRecipientDetails

import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
private RecipientDetails getGroupRecipientDetails(Context context, String groupId) {
  try {
    GroupDatabase.GroupRecord record  = DatabaseFactory.getGroupDatabase(context)
                                                       .getGroup(GroupUtil.getDecodedId(groupId));

    if (record != null) {
      byte[] avatarBytes = record.getAvatar();
      Bitmap avatar;

      if (avatarBytes == null) avatar = ContactPhotoFactory.getDefaultGroupPhoto(context);
      else                     avatar = BitmapFactory.decodeByteArray(avatarBytes, 0, avatarBytes.length);

      return new RecipientDetails(record.getTitle(), groupId, null, avatar, BitmapUtil.getCircleCroppedBitmap(avatar));
    }

    return null;
  } catch (IOException e) {
    Log.w("RecipientProvider", e);
    return null;
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:22,代码来源:RecipientProvider.java

示例5: 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

示例6: onRun

import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws Exception {
  SignalServiceMessageSender messageSender = messageSenderFactory.create();
  File                    contactDataFile  = createTempFile("multidevice-contact-update");
  GroupDatabase.Reader    reader           = null;

  GroupDatabase.GroupRecord record;

  try {
    DeviceGroupsOutputStream out = new DeviceGroupsOutputStream(new FileOutputStream(contactDataFile));

    reader = DatabaseFactory.getGroupDatabase(context).getGroups();

    while ((record = reader.getNext()) != null) {
      out.write(new DeviceGroup(record.getId(), Optional.fromNullable(record.getTitle()),
                                record.getMembers(), getAvatar(record.getAvatar()),
                                record.isActive()));
    }

    out.close();

    if (contactDataFile.exists() && contactDataFile.length() > 0) {
      sendUpdate(messageSender, contactDataFile);
    } else {
      Log.w(TAG, "No groups present for sync message...");
    }

  } finally {
    if (contactDataFile != null) contactDataFile.delete();
    if (reader != null)          reader.close();
  }

}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:34,代码来源:MultiDeviceGroupUpdateJob.java

示例7: onRun

import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws IOException {
  GroupDatabase             database   = DatabaseFactory.getGroupDatabase(context);
  GroupDatabase.GroupRecord record     = database.getGroup(groupId);
  File                      attachment = null;

  try {
    if (record != null) {
      long   avatarId    = record.getAvatarId();
      String contentType = record.getAvatarContentType();
      byte[] key         = record.getAvatarKey();
      String relay       = record.getRelay();

      if (avatarId == -1 || key == null) {
        return;
      }



      attachment = File.createTempFile("avatar", "tmp", context.getCacheDir());
      attachment.deleteOnExit();

      SignalServiceAttachmentPointer pointer     = new SignalServiceAttachmentPointer(avatarId, contentType, null, key, relay, Optional.<byte[]>absent());
      InputStream                    inputStream = receiver.retrieveAttachment(pointer, attachment, 0);
      Bitmap                         avatar      = BitmapUtil.createScaledBitmap(context, new AttachmentModel(attachment, key), 500, 500);

      database.updateAvatar(groupId, avatar);
      inputStream.close();
    }
  } catch (BitmapDecodingException | NonSuccessfulResponseCodeException | InvalidMessageException e) {
    Log.w(TAG, e);
  } finally {
    if (attachment != null)
      attachment.delete();
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:37,代码来源:AvatarDownloadJob.java

示例8: onRun

import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws IOException {
  GroupDatabase             database   = DatabaseFactory.getGroupDatabase(context);
  GroupDatabase.GroupRecord record     = database.getGroup(groupId);
  File                      attachment = null;

  try {
    if (record != null) {
      long             avatarId    = record.getAvatarId();
      String           contentType = record.getAvatarContentType();
      byte[]           key         = record.getAvatarKey();
      String           relay       = record.getRelay();
      Optional<byte[]> digest      = Optional.fromNullable(record.getAvatarDigest());
      Optional<String> fileName    = Optional.absent();

      if (avatarId == -1 || key == null) {
        return;
      }

      if (digest.isPresent()) {
        Log.w(TAG, "Downloading group avatar with digest: " + Hex.toString(digest.get()));
      }

      attachment = File.createTempFile("avatar", "tmp", context.getCacheDir());
      attachment.deleteOnExit();

      SignalServiceAttachmentPointer pointer     = new SignalServiceAttachmentPointer(avatarId, contentType, key, relay, digest, fileName, false);
      InputStream                    inputStream = receiver.retrieveAttachment(pointer, attachment, MAX_AVATAR_SIZE);
      Bitmap                         avatar      = BitmapUtil.createScaledBitmap(context, new AttachmentModel(attachment, key), 500, 500);

      database.updateAvatar(groupId, avatar);
      inputStream.close();
    }
  } catch (BitmapDecodingException | NonSuccessfulResponseCodeException | InvalidMessageException e) {
    Log.w(TAG, e);
  } finally {
    if (attachment != null)
      attachment.delete();
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:41,代码来源:AvatarDownloadJob.java


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