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


Java Optional.get方法代码示例

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


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

示例1: insert

import org.whispersystems.libsignal.util.guava.Optional; //导入方法依赖的package包/类
public long insert(@NonNull SignalServiceEnvelope envelope) {
  Optional<Long> messageId = find(envelope);

  if (messageId.isPresent()) {
    return messageId.get();
  } else {
    ContentValues values = new ContentValues();
    values.put(TYPE, envelope.getType());
    values.put(SOURCE, envelope.getSource());
    values.put(DEVICE_ID, envelope.getSourceDevice());
    values.put(LEGACY_MSG, envelope.hasLegacyMessage() ? Base64.encodeBytes(envelope.getLegacyMessage()) : "");
    values.put(CONTENT, envelope.hasContent() ? Base64.encodeBytes(envelope.getContent()) : "");
    values.put(TIMESTAMP, envelope.getTimestamp());

    return databaseHelper.getWritableDatabase().insert(TABLE_NAME, null, values);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:18,代码来源:PushDatabase.java

示例2: getApn

import org.whispersystems.libsignal.util.guava.Optional; //导入方法依赖的package包/类
public static Apn getApn(Context context) throws ApnUnavailableException {

    try {
      Optional<Apn> params = ApnDatabase.getInstance(context)
                                        .getMmsConnectionParameters(TelephonyUtil.getMccMnc(context),
                                                                    TelephonyUtil.getApn(context));

      if (!params.isPresent()) {
        throw new ApnUnavailableException("No parameters available from ApnDefaults.");
      }

      return params.get();
    } catch (IOException ioe) {
      throw new ApnUnavailableException("ApnDatabase threw an IOException", ioe);
    }
  }
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:17,代码来源:LegacyMmsConnection.java

示例3: forPointers

import org.whispersystems.libsignal.util.guava.Optional; //导入方法依赖的package包/类
public static List<Attachment> forPointers(@NonNull MasterSecretUnion masterSecret, Optional<List<SignalServiceAttachment>> pointers) {
  List<Attachment> results = new LinkedList<>();

  if (pointers.isPresent()) {
    for (SignalServiceAttachment pointer : pointers.get()) {
      if (pointer.isPointer()) {
        String encryptedKey = MediaKey.getEncrypted(masterSecret, pointer.asPointer().getKey());
        results.add(new PointerAttachment(pointer.getContentType(),
                                          pointer.getFilename(),
                                          AttachmentDatabase.TRANSFER_PROGRESS_AUTO_PENDING,
                                          pointer.asPointer().getSize().or(0),
                                          String.valueOf(pointer.asPointer().getId()),
                                          encryptedKey, pointer.asPointer().getRelay().orNull()));
      }
    }
  }

  return results;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:20,代码来源:PointerAttachment.java

示例4: createAttachmentPointers

import org.whispersystems.libsignal.util.guava.Optional; //导入方法依赖的package包/类
private List<AttachmentPointer> createAttachmentPointers(Optional<List<SignalServiceAttachment>> attachments) throws IOException {
  List<AttachmentPointer> pointers = new LinkedList<>();

  if (!attachments.isPresent() || attachments.get().isEmpty()) {
    Log.w(TAG, "No attachments present...");
    return pointers;
  }

  for (SignalServiceAttachment attachment : attachments.get()) {
    if (attachment.isStream()) {
      Log.w(TAG, "Found attachment, creating pointer...");
      pointers.add(createAttachmentPointer(attachment.asStream()));
    }
  }

  return pointers;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-lib,代码行数:18,代码来源:SignalServiceMessageSender.java

示例5: onPostExecute

import org.whispersystems.libsignal.util.guava.Optional; //导入方法依赖的package包/类
@Override
protected void onPostExecute(Optional<GroupData> group) {
  super.onPostExecute(group);

  if (group.isPresent() && !activity.isFinishing()) {
    activity.groupToUpdate = group;

    activity.groupName.setText(group.get().name);
    if (group.get().avatarBmp != null) {
      activity.setAvatar(group.get().avatarBytes, group.get().avatarBmp);
    }
    SelectedRecipientsAdapter adapter = new SelectedRecipientsAdapter(activity, group.get().recipients);
    adapter.setOnRecipientDeletedListener(activity);
    activity.lv.setAdapter(adapter);
    activity.updateViewState();
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:18,代码来源:GroupCreateActivity.java

示例6: forPointers

import org.whispersystems.libsignal.util.guava.Optional; //导入方法依赖的package包/类
public static List<Attachment> forPointers(@NonNull MasterSecretUnion masterSecret, Optional<List<SignalServiceAttachment>> pointers) {
  List<Attachment> results = new LinkedList<>();

  if (pointers.isPresent()) {
    for (SignalServiceAttachment pointer : pointers.get()) {
      if (pointer.isPointer()) {
        String encryptedKey = MediaKey.getEncrypted(masterSecret, pointer.asPointer().getKey());
        results.add(new PointerAttachment(pointer.getContentType(),
                                          AttachmentDatabase.TRANSFER_PROGRESS_AUTO_PENDING,
                                          pointer.asPointer().getSize().or(0),
                                          pointer.asPointer().getFileName().orNull(),
                                          String.valueOf(pointer.asPointer().getId()),
                                          encryptedKey, pointer.asPointer().getRelay().orNull(),
                                          pointer.asPointer().getDigest().orNull(),
                                          pointer.asPointer().getVoiceNote()));
      }
    }
  }

  return results;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:22,代码来源:PointerAttachment.java

示例7: getBody

import org.whispersystems.libsignal.util.guava.Optional; //导入方法依赖的package包/类
@NonNull
public String getBody() {
  String body = "";

  for (Slide slide : slides) {
    Optional<String> slideBody = slide.getBody();

    if (slideBody.isPresent()) {
      body = slideBody.get();
    }
  }

  return body;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:15,代码来源:SlideDeck.java

示例8: sendReceipt

import org.whispersystems.libsignal.util.guava.Optional; //导入方法依赖的package包/类
public void sendReceipt(String destination, long messageId, Optional<String> relay) throws IOException {
  String path = String.format(RECEIPT_PATH, destination, messageId);

  if (relay.isPresent()) {
    path += "?relay=" + relay.get();
  }

  makeRequest(path, "PUT", null);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-lib,代码行数:10,代码来源:PushServiceSocket.java

示例9: getActiveSignedPreKeyId

import org.whispersystems.libsignal.util.guava.Optional; //导入方法依赖的package包/类
public static synchronized int getActiveSignedPreKeyId(Context context) {
  Optional<SignedPreKeyIndex> index = getSignedPreKeyIndex(context);

  if (index.isPresent()) return index.get().activeSignedPreKeyId;
  else                   return -1;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:7,代码来源:PreKeyUtil.java


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