That fuck shit the fascists are using
at master 103 lines 3.8 kB view raw
1package org.tm.archive.messagedetails; 2 3import androidx.annotation.NonNull; 4 5import com.annimon.stream.ComparatorCompat; 6 7import org.tm.archive.conversation.ConversationMessage; 8import org.tm.archive.dependencies.ApplicationDependencies; 9 10import java.util.Collection; 11import java.util.Comparator; 12import java.util.List; 13import java.util.TreeSet; 14 15public final class MessageDetails { 16 private static final Comparator<RecipientDeliveryStatus> HAS_DISPLAY_NAME = (r1, r2) -> Boolean.compare(r2.getRecipient().hasAUserSetDisplayName(ApplicationDependencies.getApplication()), r1.getRecipient().hasAUserSetDisplayName(ApplicationDependencies.getApplication())); 17 private static final Comparator<RecipientDeliveryStatus> ALPHABETICAL = (r1, r2) -> r1.getRecipient().getDisplayName(ApplicationDependencies.getApplication()).compareToIgnoreCase(r2.getRecipient().getDisplayName(ApplicationDependencies.getApplication())); 18 private static final Comparator<RecipientDeliveryStatus> RECIPIENT_COMPARATOR = ComparatorCompat.chain(HAS_DISPLAY_NAME).thenComparing(ALPHABETICAL); 19 20 private final ConversationMessage conversationMessage; 21 22 private final Collection<RecipientDeliveryStatus> pending; 23 private final Collection<RecipientDeliveryStatus> sent; 24 private final Collection<RecipientDeliveryStatus> delivered; 25 private final Collection<RecipientDeliveryStatus> read; 26 private final Collection<RecipientDeliveryStatus> notSent; 27 private final Collection<RecipientDeliveryStatus> viewed; 28 private final Collection<RecipientDeliveryStatus> skipped; 29 30 MessageDetails(@NonNull ConversationMessage conversationMessage, @NonNull List<RecipientDeliveryStatus> recipients) { 31 this.conversationMessage = conversationMessage; 32 33 pending = new TreeSet<>(RECIPIENT_COMPARATOR); 34 sent = new TreeSet<>(RECIPIENT_COMPARATOR); 35 delivered = new TreeSet<>(RECIPIENT_COMPARATOR); 36 read = new TreeSet<>(RECIPIENT_COMPARATOR); 37 notSent = new TreeSet<>(RECIPIENT_COMPARATOR); 38 viewed = new TreeSet<>(RECIPIENT_COMPARATOR); 39 skipped = new TreeSet<>(RECIPIENT_COMPARATOR); 40 41 if (conversationMessage.getMessageRecord().getFromRecipient().isSelf() && conversationMessage.getMessageRecord().getToRecipient().isSelf()) { 42 read.addAll(recipients); 43 } else if (conversationMessage.getMessageRecord().isOutgoing()) { 44 for (RecipientDeliveryStatus status : recipients) { 45 switch (status.getDeliveryStatus()) { 46 case UNKNOWN: 47 notSent.add(status); 48 break; 49 case PENDING: 50 pending.add(status); 51 break; 52 case SENT: 53 sent.add(status); 54 break; 55 case DELIVERED: 56 delivered.add(status); 57 break; 58 case READ: 59 read.add(status); 60 break; 61 case VIEWED: 62 viewed.add(status); 63 break; 64 case SKIPPED: 65 skipped.add(status); 66 break; 67 } 68 } 69 } else { 70 sent.addAll(recipients); 71 } 72 } 73 74 public @NonNull ConversationMessage getConversationMessage() { 75 return conversationMessage; 76 } 77 78 public @NonNull Collection<RecipientDeliveryStatus> getPending() { 79 return pending; 80 } 81 82 public @NonNull Collection<RecipientDeliveryStatus> getSent() { 83 return sent; 84 } 85 86 public @NonNull Collection<RecipientDeliveryStatus> getSkipped() {return skipped;} 87 88 public @NonNull Collection<RecipientDeliveryStatus> getDelivered() { 89 return delivered; 90 } 91 92 public @NonNull Collection<RecipientDeliveryStatus> getRead() { 93 return read; 94 } 95 96 public @NonNull Collection<RecipientDeliveryStatus> getNotSent() { 97 return notSent; 98 } 99 100 public @NonNull Collection<RecipientDeliveryStatus> getViewed() { 101 return viewed; 102 } 103}