Search in sources :

Example 26 with NonNull

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<>();
    }
}
Also used : GiphyResponse(org.thoughtcrime.securesms.giph.model.GiphyResponse) Response(okhttp3.Response) GiphyResponse(org.thoughtcrime.securesms.giph.model.GiphyResponse) GiphyImage(org.thoughtcrime.securesms.giph.model.GiphyImage) Request(okhttp3.Request) IOException(java.io.IOException) NonNull(android.support.annotation.NonNull)

Example 27 with NonNull

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);
}
Also used : GroupDatabase(org.thoughtcrime.securesms.database.GroupDatabase) ByteString(com.google.protobuf.ByteString) NonNull(android.support.annotation.NonNull)

Example 28 with NonNull

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);
}
Also used : MaterialColor(org.thoughtcrime.securesms.color.MaterialColor) RecipientsPreferences(org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences) Cursor(android.database.Cursor) ContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ContactPhoto) Uri(android.net.Uri) NonNull(android.support.annotation.NonNull)

Example 29 with NonNull

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;
}
Also used : Recipients(org.thoughtcrime.securesms.recipients.Recipients) Recipient(org.thoughtcrime.securesms.recipients.Recipient) NonNull(android.support.annotation.NonNull)

Example 30 with NonNull

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;
}
Also used : MediaConstraints(org.webrtc.MediaConstraints) NonNull(android.support.annotation.NonNull)

Aggregations

NonNull (android.support.annotation.NonNull)610 TextView (android.widget.TextView)65 View (android.view.View)64 ArrayList (java.util.ArrayList)57 Test (org.junit.Test)45 Intent (android.content.Intent)38 Cursor (android.database.Cursor)35 ContentValues (android.content.ContentValues)32 Bundle (android.os.Bundle)32 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)29 IOException (java.io.IOException)27 DialogAction (com.afollestad.materialdialogs.DialogAction)25 AlertDialog (android.support.v7.app.AlertDialog)24 Override (java.lang.Override)24 DialogInterface (android.content.DialogInterface)22 File (java.io.File)21 WorkerThread (android.support.annotation.WorkerThread)19 RecyclerView (android.support.v7.widget.RecyclerView)19 ImageView (android.widget.ImageView)19 HashMap (java.util.HashMap)19