當前位置: 首頁>>代碼示例>>Java>>正文


Java GroupUtil類代碼示例

本文整理匯總了Java中org.thoughtcrime.securesms.util.GroupUtil的典型用法代碼示例。如果您正苦於以下問題:Java GroupUtil類的具體用法?Java GroupUtil怎麽用?Java GroupUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GroupUtil類屬於org.thoughtcrime.securesms.util包,在下文中一共展示了GroupUtil類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initializeExistingGroup

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
private void initializeExistingGroup() {
  final String encodedGroupId = RecipientFactory.getRecipientForId(this, getIntent().getLongExtra(GROUP_RECIPIENT_EXTRA, -1), true)
                                                .getNumber();
  byte[] groupId;
  try {
    groupId = GroupUtil.getDecodedId(encodedGroupId);
  } catch (IOException ioe) {
    Log.w(TAG, "Couldn't decode the encoded groupId passed in via intent", ioe);
    groupId = null;
  }
  if (groupId != null) {
    new FillExistingGroupInfoAsyncTask(this).execute(groupId);
  } else {
    groupName.setEnabled(true);
    avatar.setEnabled(true);
    recipientsEditor.setVisibility(View.VISIBLE);
    contactsButton.setVisibility(View.VISIBLE);
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:20,代碼來源:GroupCreateActivity.java

示例2: create

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
public void create(byte[] groupId, String title, List<String> members, String owner,
                   List<String> admins, SignalServiceAttachmentPointer avatar, String relay)
{
  ContentValues contentValues = new ContentValues();
  contentValues.put(GROUP_ID, GroupUtil.getEncodedId(groupId));
  contentValues.put(TITLE, title);
  contentValues.put(MEMBERS, Util.join(members, ","));
  contentValues.put(OWNER, owner);
  contentValues.put(ADMINS, Util.join(admins, ","));

  if (avatar != null) {
    contentValues.put(AVATAR_ID, avatar.getId());
    contentValues.put(AVATAR_KEY, avatar.getKey());
    contentValues.put(AVATAR_CONTENT_TYPE, avatar.getContentType());
  }

  contentValues.put(AVATAR_RELAY, relay);
  contentValues.put(TIMESTAMP, System.currentTimeMillis());
  contentValues.put(ACTIVE, 1);

  databaseHelper.getWritableDatabase().insert(TABLE_NAME, null, contentValues);
  notifyConversationListListeners();
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:24,代碼來源:GroupDatabase.java

示例3: update

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
public void update(byte[] groupId, String title, SignalServiceAttachmentPointer avatar) {
  ContentValues contentValues = new ContentValues();
  if (title != null) contentValues.put(TITLE, title);

  if (avatar != null) {
    contentValues.put(AVATAR_ID, avatar.getId());
    contentValues.put(AVATAR_CONTENT_TYPE, avatar.getContentType());
    contentValues.put(AVATAR_KEY, avatar.getKey());
  }

  databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues,
                                              GROUP_ID + " = ?",
                                              new String[] {GroupUtil.getEncodedId(groupId)});

  RecipientFactory.clearCache(context);
  notifyDatabaseListeners();
  notifyConversationListListeners();
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:19,代碼來源:GroupDatabase.java

示例4: getCurrentMembers

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
private List<String> getCurrentMembers(byte[] id) {
  Cursor cursor = null;

  try {
    cursor = databaseHelper.getReadableDatabase().query(TABLE_NAME, new String[] {MEMBERS},
                                                        GROUP_ID + " = ?",
                                                        new String[] {GroupUtil.getEncodedId(id)},
                                                        null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Util.split(cursor.getString(cursor.getColumnIndexOrThrow(MEMBERS)), ",");
    }

    return new LinkedList<>();
  } finally {
    if (cursor != null)
      cursor.close();
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:20,代碼來源:GroupDatabase.java

示例5: getCurrentAdmins

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
private List<String> getCurrentAdmins(byte[] id) {
  Cursor cursor = null;

  try {
    cursor = databaseHelper.getReadableDatabase().query(TABLE_NAME, new String[] {ADMINS},
            GROUP_ID + " = ?",
            new String[] {GroupUtil.getEncodedId(id)},
            null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Util.split(cursor.getString(cursor.getColumnIndexOrThrow(ADMINS)), ",");
    }

    return new LinkedList<>();
  } finally {
    if (cursor != null)
      cursor.close();
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:20,代碼來源:GroupDatabase.java

示例6: toNumberStringArray

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
public @NonNull String[] toNumberStringArray(boolean scrub) {
  String[] recipientsArray     = new String[recipients.size()];
  Iterator<Recipient> iterator = recipients.iterator();
  int i                        = 0;

  while (iterator.hasNext()) {
    String number = iterator.next().getNumber();

    if (scrub && number != null &&
        !Patterns.EMAIL_ADDRESS.matcher(number).matches() &&
        !GroupUtil.isEncodedGroup(number))
    {
      number = number.replaceAll("[^0-9+]", "");
    }

    recipientsArray[i++] = number;
  }

  return recipientsArray;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:21,代碼來源:Recipients.java

示例7: getGroupRecipientDetails

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的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

示例8: IncomingTextMessage

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
public IncomingTextMessage(String sender, int senderDeviceId, long sentTimestampMillis,
                           String encodedBody, Optional<SignalServiceGroup> group,
                           long expiresInMillis)
{
  this.message              = encodedBody;
  this.sender               = sender;
  this.senderDeviceId       = senderDeviceId;
  this.protocol             = 31337;
  this.serviceCenterAddress = "GCM";
  this.replyPathPresent     = true;
  this.pseudoSubject        = "";
  this.sentTimestampMillis  = sentTimestampMillis;
  this.push                 = true;
  this.subscriptionId       = -1;
  this.expiresInMillis      = expiresInMillis;

  if (group.isPresent()) {
    this.groupId = GroupUtil.getEncodedId(group.get().getGroupId());
  } else {
    this.groupId = null;
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:23,代碼來源:IncomingTextMessage.java

示例9: IncomingMediaMessage

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
public IncomingMediaMessage(MasterSecretUnion masterSecret,
                            String from,
                            String to,
                            long sentTimeMillis,
                            int subscriptionId,
                            long expiresIn,
                            boolean expirationUpdate,
                            Optional<String> relay,
                            Optional<String> body,
                            Optional<SignalServiceGroup> group,
                            Optional<List<SignalServiceAttachment>> attachments)
{
  this.push             = true;
  this.from             = from;
  this.sentTimeMillis   = sentTimeMillis;
  this.body             = body.orNull();
  this.subscriptionId   = subscriptionId;
  this.expiresIn        = expiresIn;
  this.expirationUpdate = expirationUpdate;

  if (group.isPresent()) this.groupId = GroupUtil.getEncodedId(group.get().getGroupId());
  else                   this.groupId = null;

  this.to.add(to);
  this.attachments.addAll(PointerAttachment.forPointers(masterSecret, attachments));
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:27,代碼來源:IncomingMediaMessage.java

示例10: create

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
public void create(byte[] groupId, String title, List<String> members,
                   SignalServiceAttachmentPointer avatar, String relay)
{
  ContentValues contentValues = new ContentValues();
  contentValues.put(GROUP_ID, GroupUtil.getEncodedId(groupId));
  contentValues.put(TITLE, title);
  contentValues.put(MEMBERS, Util.join(members, ","));

  if (avatar != null) {
    contentValues.put(AVATAR_ID, avatar.getId());
    contentValues.put(AVATAR_KEY, avatar.getKey());
    contentValues.put(AVATAR_CONTENT_TYPE, avatar.getContentType());
    contentValues.put(AVATAR_DIGEST, avatar.getDigest().orNull());
  }

  contentValues.put(AVATAR_RELAY, relay);
  contentValues.put(TIMESTAMP, System.currentTimeMillis());
  contentValues.put(ACTIVE, 1);

  databaseHelper.getWritableDatabase().insert(TABLE_NAME, null, contentValues);
  RecipientFactory.clearCache(context);
  notifyConversationListListeners();
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:24,代碼來源:GroupDatabase.java

示例11: update

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
public void update(byte[] groupId, String title, SignalServiceAttachmentPointer avatar) {
  ContentValues contentValues = new ContentValues();
  if (title != null) contentValues.put(TITLE, title);

  if (avatar != null) {
    contentValues.put(AVATAR_ID, avatar.getId());
    contentValues.put(AVATAR_CONTENT_TYPE, avatar.getContentType());
    contentValues.put(AVATAR_KEY, avatar.getKey());
    contentValues.put(AVATAR_DIGEST, avatar.getDigest().orNull());
  }

  databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues,
                                              GROUP_ID + " = ?",
                                              new String[] {GroupUtil.getEncodedId(groupId)});

  RecipientFactory.clearCache(context);
  notifyDatabaseListeners();
  notifyConversationListListeners();
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:20,代碼來源:GroupDatabase.java

示例12: getGroupRecipientDetails

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的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

示例13: handlePushOperation

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
private Pair<Long, Recipients> handlePushOperation(byte[] groupId, String groupName, byte[] avatar,
                                                   Set<String> e164numbers)
    throws InvalidNumberException
{

  try {
    String     groupRecipientId = GroupUtil.getEncodedId(groupId);
    Recipients groupRecipient   = RecipientFactory.getRecipientsFromString(this, groupRecipientId, false);

    GroupContext context = GroupContext.newBuilder()
                                       .setId(ByteString.copyFrom(groupId))
                                       .setType(GroupContext.Type.UPDATE)
                                       .setName(groupName)
                                       .addAllMembers(e164numbers)
                                       .build();

    OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(this, groupRecipient, context, avatar);
    long                      threadId        = MessageSender.send(this, masterSecret, outgoingMessage, -1, false);

    return new Pair<>(threadId, groupRecipient);
  } catch (RecipientFormattingException e) {
    throw new AssertionError(e);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:25,代碼來源:GroupCreateActivity.java

示例14: create

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
public void create(byte[] groupId, String title, List<String> members,
                   TextSecureAttachmentPointer avatar, String relay)
{
  ContentValues contentValues = new ContentValues();
  contentValues.put(GROUP_ID, GroupUtil.getEncodedId(groupId));
  contentValues.put(TITLE, title);
  contentValues.put(MEMBERS, Util.join(members, ","));

  if (avatar != null) {
    contentValues.put(AVATAR_ID, avatar.getId());
    contentValues.put(AVATAR_KEY, avatar.getKey());
    contentValues.put(AVATAR_CONTENT_TYPE, avatar.getContentType());
  }

  contentValues.put(AVATAR_RELAY, relay);
  contentValues.put(TIMESTAMP, System.currentTimeMillis());
  contentValues.put(ACTIVE, 1);

  databaseHelper.getWritableDatabase().insert(TABLE_NAME, null, contentValues);
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:21,代碼來源:GroupDatabase.java

示例15: update

import org.thoughtcrime.securesms.util.GroupUtil; //導入依賴的package包/類
public void update(byte[] groupId, String title, TextSecureAttachmentPointer avatar) {
  ContentValues contentValues = new ContentValues();
  if (title != null) contentValues.put(TITLE, title);

  if (avatar != null) {
    contentValues.put(AVATAR_ID, avatar.getId());
    contentValues.put(AVATAR_CONTENT_TYPE, avatar.getContentType());
    contentValues.put(AVATAR_KEY, avatar.getKey());
  }

  databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues,
                                              GROUP_ID + " = ?",
                                              new String[] {GroupUtil.getEncodedId(groupId)});

  RecipientFactory.clearCache();
  notifyDatabaseListeners();
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:18,代碼來源:GroupDatabase.java


注:本文中的org.thoughtcrime.securesms.util.GroupUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。