use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.
the class GiphyLoader method loadPage.
@NonNull
public List<GiphyImage> loadPage(int offset) {
try {
String url;
if (TextUtils.isEmpty(searchString))
url = String.format(getTrendingUrl(), offset);
else
url = String.format(getSearchUrl(), offset, Uri.encode(searchString));
Request request = new Request.Builder().url(url).build();
Response response = client.newCall(request).execute();
if (!response.isSuccessful()) {
throw new IOException("Unexpected code " + response);
}
GiphyResponse giphyResponse = JsonUtils.fromJson(response.body().byteStream(), GiphyResponse.class);
List<GiphyImage> results = giphyResponse.getData();
if (results == null)
return new LinkedList<>();
else
return results;
} catch (IOException e) {
Log.w(TAG, e);
return new LinkedList<>();
}
}
use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.
the class GroupManager method createGroup.
@NonNull
public static 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);
}
use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.
the class RecipientProvider method getIndividualRecipientDetails.
@NonNull
private RecipientDetails getIndividualRecipientDetails(Context context, long recipientId, @NonNull String number) {
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(new long[] { recipientId });
MaterialColor color = preferences.isPresent() ? preferences.get().getColor() : null;
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
Cursor cursor = context.getContentResolver().query(uri, CALLER_ID_PROJECTION, null, null, null);
try {
if (cursor != null && cursor.moveToFirst()) {
final String resultNumber = cursor.getString(3);
if (resultNumber != null) {
Uri contactUri = Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
String name = resultNumber.equals(cursor.getString(0)) ? null : cursor.getString(0);
ContactPhoto contactPhoto = ContactPhotoFactory.getContactPhoto(context, Uri.withAppendedPath(Contacts.CONTENT_URI, cursor.getLong(2) + ""), name);
return new RecipientDetails(cursor.getString(0), resultNumber, contactUri, contactPhoto, color);
} else {
Log.w(TAG, "resultNumber is null");
}
}
} finally {
if (cursor != null)
cursor.close();
}
if (STATIC_DETAILS.containsKey(number))
return STATIC_DETAILS.get(number);
else
return new RecipientDetails(null, number, null, ContactPhotoFactory.getDefaultContactPhoto(null), color);
}
use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.
the class WebRtcCallService method getRemoteRecipient.
///
@NonNull
private Recipient getRemoteRecipient(Intent intent) {
String remoteNumber = intent.getStringExtra(EXTRA_REMOTE_NUMBER);
if (TextUtils.isEmpty(remoteNumber))
throw new AssertionError("No recipient in intent!");
Recipients recipients = RecipientFactory.getRecipientsFromString(this, remoteNumber, true);
Recipient result = recipients.getPrimaryRecipient();
if (result == null)
throw new AssertionError("Recipient lookup failed!");
else
return result;
}
use of android.support.annotation.NonNull in project actor-platform by actorapp.
the class AndroidPeerConnection method getMediaConstraints.
@NonNull
public MediaConstraints getMediaConstraints() {
MediaConstraints constraints = new MediaConstraints();
constraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"));
constraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true"));
return constraints;
}
Aggregations