mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 11:20:47 +01:00
Live group update messages on conversation list and conversation.
This commit is contained in:
committed by
Greyson Parrelli
parent
7446c2096d
commit
bd1c164d57
@@ -14,7 +14,6 @@ import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.mms.MessageGroupContext;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientForeverObserver;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
@@ -67,13 +66,13 @@ public final class GroupUtil {
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
public static @NonNull GroupDescription getDescription(@NonNull Context context, @Nullable String encodedGroup, boolean isV2) {
|
||||
public static @NonNull GroupDescription getNonV2GroupDescription(@NonNull Context context, @Nullable String encodedGroup) {
|
||||
if (encodedGroup == null) {
|
||||
return new GroupDescription(context, null);
|
||||
}
|
||||
|
||||
try {
|
||||
MessageGroupContext groupContext = new MessageGroupContext(encodedGroup, isV2);
|
||||
MessageGroupContext groupContext = new MessageGroupContext(encodedGroup, false);
|
||||
return new GroupDescription(context, groupContext);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
@@ -117,7 +116,8 @@ public final class GroupUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public String toString(Recipient sender) {
|
||||
@WorkerThread
|
||||
public String toString(@NonNull Recipient sender) {
|
||||
StringBuilder description = new StringBuilder();
|
||||
description.append(context.getString(R.string.MessageRecord_s_updated_group, sender.getDisplayName(context)));
|
||||
|
||||
@@ -142,22 +142,6 @@ public final class GroupUtil {
|
||||
return description.toString();
|
||||
}
|
||||
|
||||
public void addObserver(RecipientForeverObserver listener) {
|
||||
if (this.members != null) {
|
||||
for (RecipientId member : this.members) {
|
||||
Recipient.live(member).observeForever(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeObserver(RecipientForeverObserver listener) {
|
||||
if (this.members != null) {
|
||||
for (RecipientId member : this.members) {
|
||||
Recipient.live(member).removeForeverObserver(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String toString(List<RecipientId> recipients) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@ import org.thoughtcrime.securesms.util.concurrent.SerialMonoLifoExecutor;
|
||||
import org.thoughtcrime.securesms.util.concurrent.SignalExecutors;
|
||||
import org.whispersystems.libsignal.util.guava.Function;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public final class LiveDataUtil {
|
||||
@@ -78,6 +82,34 @@ public final class LiveDataUtil {
|
||||
return new CombineLiveData<>(a, b, combine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges the supplied live data streams.
|
||||
*/
|
||||
public static <T> LiveData<T> merge(@NonNull List<LiveData<T>> liveDataList) {
|
||||
Set<LiveData<T>> set = new LinkedHashSet<>(liveDataList);
|
||||
|
||||
set.addAll(liveDataList);
|
||||
|
||||
if (set.size() == 1) {
|
||||
return liveDataList.get(0);
|
||||
}
|
||||
|
||||
MediatorLiveData<T> mergedLiveData = new MediatorLiveData<>();
|
||||
|
||||
for (LiveData<T> liveDataSource : set) {
|
||||
mergedLiveData.addSource(liveDataSource, mergedLiveData::setValue);
|
||||
}
|
||||
|
||||
return mergedLiveData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Live data with just the initial value.
|
||||
*/
|
||||
public static <T> LiveData<T> just(@NonNull T item) {
|
||||
return new MutableLiveData<>(item);
|
||||
}
|
||||
|
||||
public interface Combine<A, B, R> {
|
||||
@NonNull R apply(@NonNull A a, @NonNull B b);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user