1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 06:37:30 +00:00
This commit is contained in:
Ammar Githam 2021-04-09 19:13:59 +09:00
parent a2f73eeb2d
commit abd6fa1c28
2 changed files with 9 additions and 5 deletions

View File

@ -112,6 +112,7 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple
} }
public void bind(final int position, final DirectItem item) { public void bind(final int position, final DirectItem item) {
if (item == null) return;
this.item = item; this.item = item;
messageDirection = isSelf(item) ? MessageDirection.OUTGOING : MessageDirection.INCOMING; messageDirection = isSelf(item) ? MessageDirection.OUTGOING : MessageDirection.INCOMING;
// Asynchronous binding causes some weird behaviour // Asynchronous binding causes some weird behaviour
@ -123,7 +124,7 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple
setupLongClickListener(position, messageDirection); setupLongClickListener(position, messageDirection);
} }
private void bindBase(final DirectItem item, final MessageDirection messageDirection, final int position) { private void bindBase(@NonNull final DirectItem item, final MessageDirection messageDirection, final int position) {
final FrameLayout.LayoutParams containerLayoutParams = (FrameLayout.LayoutParams) binding.container.getLayoutParams(); final FrameLayout.LayoutParams containerLayoutParams = (FrameLayout.LayoutParams) binding.container.getLayoutParams();
final DirectItemType itemType = item.getItemType(); final DirectItemType itemType = item.getItemType();
setMessageDirectionGravity(messageDirection, containerLayoutParams); setMessageDirectionGravity(messageDirection, containerLayoutParams);
@ -188,7 +189,7 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple
containerLayoutParams.gravity = Gravity.CENTER; containerLayoutParams.gravity = Gravity.CENTER;
} }
private void setMessageInfo(final DirectItem item, final MessageDirection messageDirection) { private void setMessageInfo(@NonNull final DirectItem item, final MessageDirection messageDirection) {
if (showMessageInfo()) { if (showMessageInfo()) {
binding.messageInfo.setVisibility(View.VISIBLE); binding.messageInfo.setVisibility(View.VISIBLE);
binding.deliveryStatus.setVisibility(messageDirection == MessageDirection.OUTGOING ? View.VISIBLE : View.GONE); binding.deliveryStatus.setVisibility(messageDirection == MessageDirection.OUTGOING ? View.VISIBLE : View.GONE);

View File

@ -23,18 +23,21 @@ import awais.instagrabber.repositories.responses.directmessages.DirectThreadLast
import awais.instagrabber.repositories.responses.directmessages.RavenExpiringMediaActionSummary; import awais.instagrabber.repositories.responses.directmessages.RavenExpiringMediaActionSummary;
public final class DMUtils { public final class DMUtils {
public static boolean isRead(final DirectItem item, public static boolean isRead(@NonNull final DirectItem item,
@NonNull final Map<Long, DirectThreadLastSeenAt> lastSeenAt, @NonNull final Map<Long, DirectThreadLastSeenAt> lastSeenAt,
final List<Long> userIdsToCheck) { @NonNull final List<Long> userIdsToCheck) {
// Further check if directStory exists // Further check if directStory exists
// if (read && directStory != null) { // if (read && directStory != null) {
// read = false; // read = false;
// } // }
if (item == null) return false;
return lastSeenAt.entrySet() return lastSeenAt.entrySet()
.stream() .stream()
.filter(entry -> userIdsToCheck.contains(entry.getKey())) .filter(entry -> userIdsToCheck.contains(entry.getKey()))
.anyMatch(entry -> { .anyMatch(entry -> {
final String userLastSeenTsString = entry.getValue().getTimestamp(); final DirectThreadLastSeenAt threadLastSeenAt = entry.getValue();
if (threadLastSeenAt == null) return false;
final String userLastSeenTsString = threadLastSeenAt.getTimestamp();
if (userLastSeenTsString == null) return false; if (userLastSeenTsString == null) return false;
final long userTs = Long.parseLong(userLastSeenTsString); final long userTs = Long.parseLong(userLastSeenTsString);
final long itemTs = item.getTimestamp(); final long itemTs = item.getTimestamp();