Search in sources :

Example 1 with Consumer

use of androidx.core.util.Consumer in project Signal-Android by WhisperSystems.

the class EditGroupProfileRepository method getCurrentName.

@Override
public void getCurrentName(@NonNull Consumer<String> nameConsumer) {
    SimpleTask.run(() -> {
        RecipientId recipientId = getRecipientId();
        Recipient recipient = Recipient.resolved(recipientId);
        return SignalDatabase.groups().getGroup(recipientId).transform(groupRecord -> {
            String title = groupRecord.getTitle();
            return title == null ? "" : title;
        }).or(() -> recipient.getGroupName(context));
    }, nameConsumer::accept);
}
Also used : AvatarColor(org.thoughtcrime.securesms.conversation.colors.AvatarColor) Context(android.content.Context) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) AvatarHelper(org.thoughtcrime.securesms.profiles.AvatarHelper) NonNull(androidx.annotation.NonNull) StreamUtil(org.signal.core.util.StreamUtil) ProfileName(org.thoughtcrime.securesms.profiles.ProfileName) WorkerThread(androidx.annotation.WorkerThread) IOException(java.io.IOException) Optional(org.whispersystems.libsignal.util.guava.Optional) Consumer(androidx.core.util.Consumer) GroupChangeException(org.thoughtcrime.securesms.groups.GroupChangeException) Log(org.signal.core.util.logging.Log) GroupManager(org.thoughtcrime.securesms.groups.GroupManager) Nullable(androidx.annotation.Nullable) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) GroupId(org.thoughtcrime.securesms.groups.GroupId) Recipient(org.thoughtcrime.securesms.recipients.Recipient) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) Recipient(org.thoughtcrime.securesms.recipients.Recipient)

Example 2 with Consumer

use of androidx.core.util.Consumer in project Signal-Android by signalapp.

the class EditGroupProfileRepository method getCurrentName.

@Override
public void getCurrentName(@NonNull Consumer<String> nameConsumer) {
    SimpleTask.run(() -> {
        RecipientId recipientId = getRecipientId();
        Recipient recipient = Recipient.resolved(recipientId);
        return SignalDatabase.groups().getGroup(recipientId).transform(groupRecord -> {
            String title = groupRecord.getTitle();
            return title == null ? "" : title;
        }).or(() -> recipient.getGroupName(context));
    }, nameConsumer::accept);
}
Also used : AvatarColor(org.thoughtcrime.securesms.conversation.colors.AvatarColor) Context(android.content.Context) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) AvatarHelper(org.thoughtcrime.securesms.profiles.AvatarHelper) NonNull(androidx.annotation.NonNull) StreamUtil(org.signal.core.util.StreamUtil) ProfileName(org.thoughtcrime.securesms.profiles.ProfileName) WorkerThread(androidx.annotation.WorkerThread) IOException(java.io.IOException) Optional(org.whispersystems.libsignal.util.guava.Optional) Consumer(androidx.core.util.Consumer) GroupChangeException(org.thoughtcrime.securesms.groups.GroupChangeException) Log(org.signal.core.util.logging.Log) GroupManager(org.thoughtcrime.securesms.groups.GroupManager) Nullable(androidx.annotation.Nullable) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) GroupId(org.thoughtcrime.securesms.groups.GroupId) Recipient(org.thoughtcrime.securesms.recipients.Recipient) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) Recipient(org.thoughtcrime.securesms.recipients.Recipient)

Aggregations

Context (android.content.Context)2 NonNull (androidx.annotation.NonNull)2 Nullable (androidx.annotation.Nullable)2 WorkerThread (androidx.annotation.WorkerThread)2 Consumer (androidx.core.util.Consumer)2 IOException (java.io.IOException)2 StreamUtil (org.signal.core.util.StreamUtil)2 Log (org.signal.core.util.logging.Log)2 AvatarColor (org.thoughtcrime.securesms.conversation.colors.AvatarColor)2 SignalDatabase (org.thoughtcrime.securesms.database.SignalDatabase)2 GroupChangeException (org.thoughtcrime.securesms.groups.GroupChangeException)2 GroupId (org.thoughtcrime.securesms.groups.GroupId)2 GroupManager (org.thoughtcrime.securesms.groups.GroupManager)2 AvatarHelper (org.thoughtcrime.securesms.profiles.AvatarHelper)2 ProfileName (org.thoughtcrime.securesms.profiles.ProfileName)2 Recipient (org.thoughtcrime.securesms.recipients.Recipient)2 RecipientId (org.thoughtcrime.securesms.recipients.RecipientId)2 SimpleTask (org.thoughtcrime.securesms.util.concurrent.SimpleTask)2 Optional (org.whispersystems.libsignal.util.guava.Optional)2