本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}