本文整理汇总了Java中org.thoughtcrime.securesms.database.GroupDatabase类的典型用法代码示例。如果您正苦于以下问题:Java GroupDatabase类的具体用法?Java GroupDatabase怎么用?Java GroupDatabase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GroupDatabase类属于org.thoughtcrime.securesms.database包,在下文中一共展示了GroupDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleGroupCreate
import org.thoughtcrime.securesms.database.GroupDatabase; //导入依赖的package包/类
private static @Nullable Long handleGroupCreate(@NonNull Context context,
@NonNull MasterSecretUnion masterSecret,
@NonNull SignalServiceEnvelope envelope,
@NonNull SignalServiceGroup group,
boolean outgoing)
{
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
byte[] id = group.getGroupId();
GroupContext.Builder builder = createGroupContext(group);
builder.setType(GroupContext.Type.UPDATE);
SignalServiceAttachment avatar = group.getAvatar().orNull();
database.create(id, group.getName().orNull(), group.getMembers().orNull(), group.getOwner().orNull(),
group.getAdmins().or(Collections.<String>emptyList()),
avatar != null && avatar.isPointer() ? avatar.asPointer() : null,
envelope.getRelay());
return storeMessage(context, masterSecret, envelope, group, builder.build(), outgoing);
}
示例2: handleGroupLeave
import org.thoughtcrime.securesms.database.GroupDatabase; //导入依赖的package包/类
private static Long handleGroupLeave(@NonNull Context context,
@NonNull MasterSecretUnion masterSecret,
@NonNull SignalServiceEnvelope envelope,
@NonNull SignalServiceGroup group,
@NonNull GroupRecord record,
boolean outgoing)
{
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
byte[] id = group.getGroupId();
List<String> members = record.getMembers();
GroupContext.Builder builder = createGroupContext(group);
builder.setType(GroupContext.Type.QUIT);
if (members.contains(envelope.getSource())) {
database.remove(id, envelope.getSource());
if (outgoing) database.setActive(id, false);
return storeMessage(context, masterSecret, envelope, group, builder.build(), outgoing);
}
return null;
}
示例3: createGroup
import org.thoughtcrime.securesms.database.GroupDatabase; //导入依赖的package包/类
public static @NonNull GroupActionResult createGroup(@NonNull Context context,
@NonNull MasterSecret masterSecret,
@NonNull Set<Recipient> members,
@Nullable Bitmap avatar,
@Nullable String name)
throws InvalidNumberException
{
final byte[] avatarBytes = BitmapUtil.toByteArray(avatar);
final GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
final byte[] groupId = groupDatabase.allocateGroupId();
final Set<String> memberE164Numbers = getE164Numbers(context, members);
final String ownerE164Number = Util.canonicalizeNumber(context,
TextSecurePreferences.getLocalNumber(context));
memberE164Numbers.add(TextSecurePreferences.getLocalNumber(context));
groupDatabase.create(groupId, name, new LinkedList<>(memberE164Numbers), ownerE164Number,
Collections.<String>emptyList(), null, null);
groupDatabase.updateAvatar(groupId, avatarBytes);
return sendGroupUpdate(context, masterSecret, groupId, memberE164Numbers, ownerE164Number,
Collections.<String>emptySet(), name, avatarBytes, null);
}
示例4: 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();
}
}
示例5: 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);
}
}
示例6: initializeReceivers
import org.thoughtcrime.securesms.database.GroupDatabase; //导入依赖的package包/类
private void initializeReceivers() {
this.staleReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Recipients recipients = RecipientFactory.getRecipientsForIds(context, getIntent().getLongArrayExtra(RECIPIENTS_EXTRA), true);
recipients.addListener(RecipientPreferenceActivity.this);
onModified(recipients);
}
};
IntentFilter staleFilter = new IntentFilter();
staleFilter.addAction(GroupDatabase.DATABASE_UPDATE_ACTION);
staleFilter.addAction(RecipientFactory.RECIPIENT_CLEAR_ACTION);
registerReceiver(staleReceiver, staleFilter);
}
示例7: initializeRecipients
import org.thoughtcrime.securesms.database.GroupDatabase; //导入依赖的package包/类
private void initializeRecipients() {
this.recipients = RecipientFactory.getRecipientsForIds(getActivity(),
getArguments().getLongArray(RECIPIENTS_EXTRA),
true);
this.recipients.addListener(this);
this.staleReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
recipients.removeListener(RecipientPreferenceFragment.this);
recipients = RecipientFactory.getRecipientsForIds(getActivity(), getArguments().getLongArray(RECIPIENTS_EXTRA), true);
onModified(recipients);
}
};
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(GroupDatabase.DATABASE_UPDATE_ACTION);
intentFilter.addAction(RecipientFactory.RECIPIENT_CLEAR_ACTION);
getActivity().registerReceiver(staleReceiver, intentFilter);
}
示例8: handleGroupCreate
import org.thoughtcrime.securesms.database.GroupDatabase; //导入依赖的package包/类
private static @Nullable Long handleGroupCreate(@NonNull Context context,
@NonNull MasterSecretUnion masterSecret,
@NonNull SignalServiceEnvelope envelope,
@NonNull SignalServiceGroup group,
boolean outgoing)
{
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
byte[] id = group.getGroupId();
GroupContext.Builder builder = createGroupContext(group);
builder.setType(GroupContext.Type.UPDATE);
SignalServiceAttachment avatar = group.getAvatar().orNull();
database.create(id, group.getName().orNull(), group.getMembers().orNull(),
avatar != null && avatar.isPointer() ? avatar.asPointer() : null,
envelope.getRelay());
return storeMessage(context, masterSecret, envelope, group, builder.build(), outgoing);
}
示例9: createGroup
import org.thoughtcrime.securesms.database.GroupDatabase; //导入依赖的package包/类
public static @NonNull GroupActionResult createGroup(@NonNull Context context,
@NonNull MasterSecret masterSecret,
@NonNull Set<Recipient> members,
@Nullable Bitmap avatar,
@Nullable String name)
throws InvalidNumberException
{
final byte[] avatarBytes = BitmapUtil.toByteArray(avatar);
final GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
final byte[] groupId = groupDatabase.allocateGroupId();
final Set<String> memberE164Numbers = getE164Numbers(context, members);
memberE164Numbers.add(TextSecurePreferences.getLocalNumber(context));
groupDatabase.create(groupId, name, new LinkedList<>(memberE164Numbers), null, null);
groupDatabase.updateAvatar(groupId, avatarBytes);
return sendGroupUpdate(context, masterSecret, groupId, memberE164Numbers, name, avatarBytes);
}
示例10: 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);
}
示例11: 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();
}
}
示例12: 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);
}
}
示例13: handleGroupCreate
import org.thoughtcrime.securesms.database.GroupDatabase; //导入依赖的package包/类
private static void handleGroupCreate(Context context,
MasterSecret masterSecret,
TextSecureEnvelope envelope,
TextSecureGroup group)
{
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
byte[] id = group.getGroupId();
GroupContext.Builder builder = createGroupContext(group);
builder.setType(GroupContext.Type.UPDATE);
TextSecureAttachment avatar = group.getAvatar().orNull();
database.create(id, group.getName().orNull(), group.getMembers().orNull(),
avatar != null && avatar.isPointer() ? avatar.asPointer() : null,
envelope.getRelay());
storeMessage(context, masterSecret, envelope, group, builder.build());
}
示例14: handleGroupLeave
import org.thoughtcrime.securesms.database.GroupDatabase; //导入依赖的package包/类
private static void handleGroupLeave(Context context,
MasterSecret masterSecret,
TextSecureEnvelope envelope,
TextSecureGroup group,
GroupRecord record)
{
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
byte[] id = group.getGroupId();
List<String> members = record.getMembers();
GroupContext.Builder builder = createGroupContext(group);
builder.setType(GroupContext.Type.QUIT);
if (members.contains(envelope.getSource())) {
database.remove(id, envelope.getSource());
storeMessage(context, masterSecret, envelope, group, builder.build());
}
}
示例15: 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);
}