本文整理汇总了Java中org.thoughtcrime.securesms.database.GroupDatabase.getGroup方法的典型用法代码示例。如果您正苦于以下问题:Java GroupDatabase.getGroup方法的具体用法?Java GroupDatabase.getGroup怎么用?Java GroupDatabase.getGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.thoughtcrime.securesms.database.GroupDatabase
的用法示例。
在下文中一共展示了GroupDatabase.getGroup方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
@Override
protected Optional<GroupData> doInBackground(byte[]... groupIds) {
final GroupDatabase db = DatabaseFactory.getGroupDatabase(activity);
final Recipients recipients = db.getGroupMembers(groupIds[0], true);
final GroupRecord group = db.getGroup(groupIds[0]);
final Set<Recipient> existingContacts = new HashSet<>(recipients.getRecipientsList().size());
final Set<String> existingAdmins = db.getGroupAdmins(groupIds[0]);
existingContacts.addAll(recipients.getRecipientsList());
if (group != null) {
return Optional.of(new GroupData(groupIds[0],
existingContacts,
group.getOwner(),
existingAdmins,
BitmapUtil.fromByteArray(group.getAvatar()),
group.getAvatar(),
group.getTitle()));
} else {
return Optional.absent();
}
}
示例2: doInBackground
import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
@Override
protected Optional<GroupData> doInBackground(byte[]... groupIds) {
final GroupDatabase db = DatabaseFactory.getGroupDatabase(activity);
final Recipients recipients = db.getGroupMembers(groupIds[0], false);
final GroupRecord group = db.getGroup(groupIds[0]);
final Set<Recipient> existingContacts = new HashSet<>(recipients.getRecipientsList().size());
existingContacts.addAll(recipients.getRecipientsList());
if (group != null) {
return Optional.of(new GroupData(groupIds[0],
existingContacts,
BitmapUtil.fromByteArray(group.getAvatar()),
group.getAvatar(),
group.getTitle()));
} else {
return Optional.absent();
}
}
示例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;
}
示例4: process
import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
public static @Nullable Long process(@NonNull Context context,
@NonNull MasterSecretUnion masterSecret,
@NonNull SignalServiceEnvelope envelope,
@NonNull SignalServiceDataMessage message,
boolean outgoing)
{
if (!message.getGroupInfo().isPresent() || message.getGroupInfo().get().getGroupId() == null) {
Log.w(TAG, "Received group message with no id! Ignoring...");
return null;
}
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
SignalServiceGroup group = message.getGroupInfo().get();
byte[] id = group.getGroupId();
GroupRecord record = database.getGroup(id);
if (record != null && group.getType() == Type.UPDATE) {
return handleGroupUpdate(context, masterSecret, envelope, group, record, outgoing);
} else if (record == null && group.getType() == Type.UPDATE) {
return handleGroupCreate(context, masterSecret, envelope, group, outgoing);
} else if (record != null && group.getType() == Type.QUIT) {
return handleGroupLeave(context, masterSecret, envelope, group, record, outgoing);
} else if (record != null && group.getType() == Type.REQUEST_INFO) {
return handleGroupInfoRequest(context, envelope, group, record);
} else {
Log.w(TAG, "Received unknown type, ignoring...");
return null;
}
}
示例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);
}
示例6: onRun
import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
@Override
public void onRun() throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = messageSenderFactory.create();
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
GroupRecord record = groupDatabase.getGroup(groupId);
SignalServiceAttachment avatar = null;
if (record == null) {
Log.w(TAG, "No information for group record info request: " + new String(groupId));
return;
}
if (record.getAvatar() != null) {
avatar = SignalServiceAttachmentStream.newStreamBuilder()
.withContentType("image/jpeg")
.withStream(new ByteArrayInputStream(record.getAvatar()))
.withLength(record.getAvatar().length)
.build();
}
SignalServiceGroup groupContext = SignalServiceGroup.newBuilder(Type.UPDATE)
.withAvatar(avatar)
.withId(groupId)
.withMembers(record.getMembers())
.withName(record.getTitle())
.withOwner(record.getOwner())
.withAdmins(record.getAdmins())
.build();
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
.asGroupMessage(groupContext)
.withTimestamp(System.currentTimeMillis())
.build();
messageSender.sendMessage(new SignalServiceAddress(source), message);
}
示例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();
}
}
示例8: onRun
import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
@Override
public void onRun() throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = messageSenderFactory.create();
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
GroupRecord record = groupDatabase.getGroup(groupId);
SignalServiceAttachment avatar = null;
if (record == null) {
Log.w(TAG, "No information for group record info request: " + new String(groupId));
return;
}
if (record.getAvatar() != null) {
avatar = SignalServiceAttachmentStream.newStreamBuilder()
.withContentType("image/jpeg")
.withStream(new ByteArrayInputStream(record.getAvatar()))
.withLength(record.getAvatar().length)
.build();
}
SignalServiceGroup groupContext = SignalServiceGroup.newBuilder(Type.UPDATE)
.withAvatar(avatar)
.withId(groupId)
.withMembers(record.getMembers())
.withName(record.getTitle())
.build();
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
.asGroupMessage(groupContext)
.withTimestamp(System.currentTimeMillis())
.build();
messageSender.sendMessage(new SignalServiceAddress(source), message);
}
示例9: 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();
}
}
示例10: process
import org.thoughtcrime.securesms.database.GroupDatabase; //导入方法依赖的package包/类
public static void process(Context context,
MasterSecret masterSecret,
TextSecureEnvelope envelope,
TextSecureMessage message)
{
if (!message.getGroupInfo().isPresent() || message.getGroupInfo().get().getGroupId() == null) {
Log.w(TAG, "Received group message with no id! Ignoring...");
return;
}
if (!message.isSecure()) {
Log.w(TAG, "Received insecure group push action! Ignoring...");
return;
}
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
TextSecureGroup group = message.getGroupInfo().get();
byte[] id = group.getGroupId();
GroupRecord record = database.getGroup(id);
if (record != null && group.getType() == TextSecureGroup.Type.UPDATE) {
handleGroupUpdate(context, masterSecret, envelope, group, record);
} else if (record == null && group.getType() == TextSecureGroup.Type.UPDATE) {
handleGroupCreate(context, masterSecret, envelope, group);
} else if (record != null && group.getType() == TextSecureGroup.Type.QUIT) {
handleGroupLeave(context, masterSecret, envelope, group, record);
} else {
Log.w(TAG, "Received unknown type, ignoring...");
}
}