1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-26 00:27:30 +00:00

Convert to kotlin

This commit is contained in:
Ammar Githam 2021-05-25 01:58:37 +09:00
parent ebe6a176f1
commit 841c3bdbda
18 changed files with 193 additions and 991 deletions

View File

@ -195,7 +195,7 @@ public final class ThreadManager {
.orElse(null); .orElse(null);
if (thread != null) { if (thread != null) {
cursor = thread.getOldestCursor(); cursor = thread.getOldestCursor();
hasOlder = thread.hasOlder(); hasOlder = thread.getHasOlder();
} }
return thread; return thread;
})); }));
@ -229,7 +229,7 @@ public final class ThreadManager {
})); }));
pending = distinctUntilChanged(map(thread, t -> { pending = distinctUntilChanged(map(thread, t -> {
if (t == null) return true; if (t == null) return true;
return t.isPending(); return t.getPending();
})); }));
adminUserIds = distinctUntilChanged(map(thread, t -> { adminUserIds = distinctUntilChanged(map(thread, t -> {
if (t == null) return Collections.emptyList(); if (t == null) return Collections.emptyList();
@ -249,15 +249,15 @@ public final class ThreadManager {
})); }));
isMuted = distinctUntilChanged(map(thread, t -> { isMuted = distinctUntilChanged(map(thread, t -> {
if (t == null) return false; if (t == null) return false;
return t.isMuted(); return t.getMuted();
})); }));
isApprovalRequiredToJoin = distinctUntilChanged(map(thread, t -> { isApprovalRequiredToJoin = distinctUntilChanged(map(thread, t -> {
if (t == null) return false; if (t == null) return false;
return t.isApprovalRequiredForNewMembers(); return t.getApprovalRequiredForNewMembers();
})); }));
isMentionsMuted = distinctUntilChanged(map(thread, t -> { isMentionsMuted = distinctUntilChanged(map(thread, t -> {
if (t == null) return false; if (t == null) return false;
return t.isMentionsMuted(); return t.getMentionsMuted();
})); }));
pendingRequestsCount = distinctUntilChanged(map(pendingRequests, p -> { pendingRequestsCount = distinctUntilChanged(map(pendingRequests, p -> {
if (p == null) return 0; if (p == null) return 0;

View File

@ -1,31 +1,6 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
import java.io.Serializable; import awais.instagrabber.repositories.responses.Media
import java.util.Objects; import java.io.Serializable
import awais.instagrabber.repositories.responses.Media; data class DirectItemClip(val clip: Media? = null) : Serializable
public class DirectItemClip implements Serializable {
private final Media clip;
public DirectItemClip(final Media clip) {
this.clip = clip;
}
public Media getClip() {
return clip;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final DirectItemClip that = (DirectItemClip) o;
return Objects.equals(clip, that.clip);
}
@Override
public int hashCode() {
return Objects.hash(clip);
}
}

View File

@ -1,31 +1,6 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
import java.io.Serializable; import awais.instagrabber.repositories.responses.Media
import java.util.Objects; import java.io.Serializable
import awais.instagrabber.repositories.responses.Media; data class DirectItemFelixShare(val video: Media? = null) : Serializable
public class DirectItemFelixShare implements Serializable {
private final Media video;
public DirectItemFelixShare(final Media video) {
this.video = video;
}
public Media getVideo() {
return video;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final DirectItemFelixShare that = (DirectItemFelixShare) o;
return Objects.equals(video, that.video);
}
@Override
public int hashCode() {
return Objects.hash(video);
}
}

View File

@ -1,87 +1,15 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
import java.io.Serializable; import awais.instagrabber.repositories.responses.Media
import java.util.Objects; import java.io.Serializable
import awais.instagrabber.repositories.responses.Media; data class DirectItemReelShare(
val text: String? = null,
public class DirectItemReelShare implements Serializable { val type: String? = null,
private final String text; val reelOwnerId: Long = 0,
private final String type; val mentionedUserId: Long = 0,
private final long reelOwnerId; val isReelPersisted: Boolean = false,
private final long mentionedUserId; val reelType: String? = null,
private final boolean isReelPersisted; val media: Media? = null,
private final String reelType; val reactionInfo: DirectItemReelShareReactionInfo? = null,
private final Media media; ) : Serializable
private final DirectItemReelShareReactionInfo reactionInfo;
public DirectItemReelShare(final String text,
final String type,
final long reelOwnerId,
final long mentionedUserId,
final boolean isReelPersisted,
final String reelType,
final Media media,
final DirectItemReelShareReactionInfo reactionInfo) {
this.text = text;
this.type = type;
this.reelOwnerId = reelOwnerId;
this.mentionedUserId = mentionedUserId;
this.isReelPersisted = isReelPersisted;
this.reelType = reelType;
this.media = media;
this.reactionInfo = reactionInfo;
}
public String getText() {
return text;
}
public String getType() {
return type;
}
public long getReelOwnerId() {
return reelOwnerId;
}
public boolean isReelPersisted() {
return isReelPersisted;
}
public String getReelType() {
return reelType;
}
public Media getMedia() {
return media;
}
public DirectItemReelShareReactionInfo getReactionInfo() {
return reactionInfo;
}
public long getMentionedUserId() {
return mentionedUserId;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final DirectItemReelShare that = (DirectItemReelShare) o;
return reelOwnerId == that.reelOwnerId &&
mentionedUserId == that.mentionedUserId &&
isReelPersisted == that.isReelPersisted &&
Objects.equals(text, that.text) &&
Objects.equals(type, that.type) &&
Objects.equals(reelType, that.reelType) &&
Objects.equals(media, that.media) &&
Objects.equals(reactionInfo, that.reactionInfo);
}
@Override
public int hashCode() {
return Objects.hash(text, type, reelOwnerId, mentionedUserId, isReelPersisted, reelType, media, reactionInfo);
}
}

View File

@ -1,36 +1,8 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
import java.io.Serializable; import java.io.Serializable
import java.util.Objects;
public class DirectItemReelShareReactionInfo implements Serializable { data class DirectItemReelShareReactionInfo(
private final String emoji; val emoji: String? = null,
private final String intensity; val intensity: String? = null,
) : Serializable
public DirectItemReelShareReactionInfo(final String emoji, final String intensity) {
this.emoji = emoji;
this.intensity = intensity;
}
public String getEmoji() {
return emoji;
}
public String getIntensity() {
return intensity;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final DirectItemReelShareReactionInfo that = (DirectItemReelShareReactionInfo) o;
return Objects.equals(emoji, that.emoji) &&
Objects.equals(intensity, that.intensity);
}
@Override
public int hashCode() {
return Objects.hash(emoji, intensity);
}
}

View File

@ -1,79 +1,14 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
import java.io.Serializable; import awais.instagrabber.repositories.responses.Media
import java.util.Objects; import java.io.Serializable
import awais.instagrabber.repositories.responses.Media; data class DirectItemStoryShare(
val reelId: String? = null,
public class DirectItemStoryShare implements Serializable { val reelType: String? = null,
private final String reelId; val text: String? = null,
private final String reelType; val isReelPersisted: Boolean = false,
private final String text; val media: Media? = null,
private final boolean isReelPersisted; val title: String? = null,
private final Media media; val message: String? = null,
private final String title; ) : Serializable
private final String message;
public DirectItemStoryShare(final String reelId,
final String reelType,
final String text,
final boolean isReelPersisted,
final Media media,
final String title,
final String message) {
this.reelId = reelId;
this.reelType = reelType;
this.text = text;
this.isReelPersisted = isReelPersisted;
this.media = media;
this.title = title;
this.message = message;
}
public String getReelId() {
return reelId;
}
public String getReelType() {
return reelType;
}
public String getText() {
return text;
}
public boolean isReelPersisted() {
return isReelPersisted;
}
public Media getMedia() {
return media;
}
public String getTitle() {
return title;
}
public String getMessage() {
return message;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final DirectItemStoryShare that = (DirectItemStoryShare) o;
return isReelPersisted == that.isReelPersisted &&
Objects.equals(reelId, that.reelId) &&
Objects.equals(reelType, that.reelType) &&
Objects.equals(text, that.text) &&
Objects.equals(media, that.media) &&
Objects.equals(title, that.title) &&
Objects.equals(message, that.message);
}
@Override
public int hashCode() {
return Objects.hash(reelId, reelType, text, isReelPersisted, media, title, message);
}
}

View File

@ -1,90 +1,16 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
import java.io.Serializable; import awais.instagrabber.models.enums.RavenMediaViewMode
import java.util.List; import awais.instagrabber.repositories.responses.Media
import java.util.Objects; import java.io.Serializable
import awais.instagrabber.models.enums.RavenMediaViewMode; data class DirectItemVisualMedia(
import awais.instagrabber.repositories.responses.Media; val urlExpireAtSecs: Long = 0,
val playbackDurationSecs: Int = 0,
public class DirectItemVisualMedia implements Serializable { val seenUserIds: List<Long>? = null,
private final long urlExpireAtSecs; val viewMode: RavenMediaViewMode? = null,
private final int playbackDurationSecs; val seenCount: Int = 0,
private final List<Long> seenUserIds; val replayExpiringAtUs: Long = 0,
private final RavenMediaViewMode viewMode; val expiringMediaActionSummary: RavenExpiringMediaActionSummary? = null,
private final int seenCount; val media: Media? = null,
private final long replayExpiringAtUs; ) : Serializable
private final RavenExpiringMediaActionSummary expiringMediaActionSummary;
private final Media media;
public DirectItemVisualMedia(final long urlExpireAtSecs,
final int playbackDurationSecs,
final List<Long> seenUserIds,
final RavenMediaViewMode viewMode,
final int seenCount,
final long replayExpiringAtUs,
final RavenExpiringMediaActionSummary expiringMediaActionSummary,
final Media media) {
this.urlExpireAtSecs = urlExpireAtSecs;
this.playbackDurationSecs = playbackDurationSecs;
this.seenUserIds = seenUserIds;
this.viewMode = viewMode;
this.seenCount = seenCount;
this.replayExpiringAtUs = replayExpiringAtUs;
this.expiringMediaActionSummary = expiringMediaActionSummary;
this.media = media;
}
public long getUrlExpireAtSecs() {
return urlExpireAtSecs;
}
public int getPlaybackDurationSecs() {
return playbackDurationSecs;
}
public List<Long> getSeenUserIds() {
return seenUserIds;
}
public RavenMediaViewMode getViewMode() {
return viewMode;
}
public int getSeenCount() {
return seenCount;
}
public long getReplayExpiringAtUs() {
return replayExpiringAtUs;
}
public RavenExpiringMediaActionSummary getExpiringMediaActionSummary() {
return expiringMediaActionSummary;
}
public Media getMedia() {
return media;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final DirectItemVisualMedia media1 = (DirectItemVisualMedia) o;
return urlExpireAtSecs == media1.urlExpireAtSecs &&
playbackDurationSecs == media1.playbackDurationSecs &&
seenCount == media1.seenCount &&
replayExpiringAtUs == media1.replayExpiringAtUs &&
Objects.equals(seenUserIds, media1.seenUserIds) &&
viewMode == media1.viewMode &&
Objects.equals(expiringMediaActionSummary, media1.expiringMediaActionSummary) &&
Objects.equals(media, media1.media);
}
@Override
public int hashCode() {
return Objects
.hash(urlExpireAtSecs, playbackDurationSecs, seenUserIds, viewMode, seenCount, replayExpiringAtUs, expiringMediaActionSummary, media);
}
}

View File

@ -1,372 +1,49 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
import androidx.annotation.NonNull; import awais.instagrabber.repositories.responses.User
import androidx.annotation.Nullable; import java.io.Serializable
import java.io.Serializable; data class DirectThread(
import java.util.List; val threadId: String? = null,
import java.util.Map; val threadV2Id: String? = null,
import java.util.Objects; var users: List<User>? = null,
var leftUsers: List<User>? = null,
var adminUserIds: List<Long>? = null,
var items: List<DirectItem>? = null,
val lastActivityAt: Long = 0,
var muted: Boolean = false,
val isPin: Boolean = false,
val named: Boolean = false,
val canonical: Boolean = false,
var pending: Boolean = false,
val archived: Boolean = false,
val valuedRequest: Boolean = false,
val threadType: String? = null,
val viewerId: Long = 0,
val threadTitle: String? = null,
val pendingScore: String? = null,
val folder: Long = 0,
val vcMuted: Boolean = false,
val isGroup: Boolean = false,
var mentionsMuted: Boolean = false,
val inviter: User? = null,
val hasOlder: Boolean = false,
val hasNewer: Boolean = false,
var lastSeenAt: Map<Long, DirectThreadLastSeenAt>? = null,
val newestCursor: String? = null,
val oldestCursor: String? = null,
val isSpam: Boolean = false,
val lastPermanentItem: DirectItem? = null,
val directStory: DirectThreadDirectStory? = null,
var approvalRequiredForNewMembers: Boolean = false,
var inputMode: Int = 0,
val threadContextItems: List<ThreadContext>? = null
) : Serializable, Cloneable {
var isTemp = false
import awais.instagrabber.repositories.responses.User; val firstDirectItem: DirectItem?
get() = items?.firstNotNullOfOrNull { it }
public class DirectThread implements Serializable, Cloneable { @Throws(CloneNotSupportedException::class)
private final String threadId; public override fun clone(): Any = super.clone()
private final String threadV2Id;
private List<User> users;
private List<User> leftUsers;
private List<Long> adminUserIds;
private List<DirectItem> items;
private final long lastActivityAt;
private boolean muted;
private final boolean isPin;
private final boolean named;
private final boolean canonical;
private boolean pending;
private final boolean archived;
private final boolean valuedRequest;
private final String threadType;
private final long viewerId;
private final String threadTitle;
private final String pendingScore;
private final long folder;
private final boolean vcMuted;
private final boolean isGroup;
private boolean mentionsMuted;
private final User inviter;
private final boolean hasOlder;
private final boolean hasNewer;
private Map<Long, DirectThreadLastSeenAt> lastSeenAt;
private final String newestCursor;
private final String oldestCursor;
private final boolean isSpam;
private final DirectItem lastPermanentItem;
private final DirectThreadDirectStory directStory;
private boolean approvalRequiredForNewMembers;
private int inputMode;
private final List<ThreadContext> threadContextItems;
private boolean isTemp;
public DirectThread(final String threadId,
final String threadV2Id,
final List<User> users,
final List<User> leftUsers,
final List<Long> adminUserIds,
final List<DirectItem> items,
final long lastActivityAt,
final boolean muted,
final boolean isPin,
final boolean named,
final boolean canonical,
final boolean pending,
final boolean archived,
final boolean valuedRequest,
final String threadType,
final long viewerId,
final String threadTitle,
final String pendingScore,
final long folder,
final boolean vcMuted,
final boolean isGroup,
final boolean mentionsMuted,
final User inviter,
final boolean hasOlder,
final boolean hasNewer,
final Map<Long, DirectThreadLastSeenAt> lastSeenAt,
final String newestCursor,
final String oldestCursor,
final boolean isSpam,
final DirectItem lastPermanentItem,
final DirectThreadDirectStory directStory,
final boolean approvalRequiredForNewMembers,
final int inputMode,
final List<ThreadContext> threadContextItems) {
this.threadId = threadId;
this.threadV2Id = threadV2Id;
this.users = users;
this.leftUsers = leftUsers;
this.adminUserIds = adminUserIds;
this.items = items;
this.lastActivityAt = lastActivityAt;
this.muted = muted;
this.isPin = isPin;
this.named = named;
this.canonical = canonical;
this.pending = pending;
this.archived = archived;
this.valuedRequest = valuedRequest;
this.threadType = threadType;
this.viewerId = viewerId;
this.threadTitle = threadTitle;
this.pendingScore = pendingScore;
this.folder = folder;
this.vcMuted = vcMuted;
this.isGroup = isGroup;
this.mentionsMuted = mentionsMuted;
this.inviter = inviter;
this.hasOlder = hasOlder;
this.hasNewer = hasNewer;
this.lastSeenAt = lastSeenAt;
this.newestCursor = newestCursor;
this.oldestCursor = oldestCursor;
this.isSpam = isSpam;
this.lastPermanentItem = lastPermanentItem;
this.directStory = directStory;
this.approvalRequiredForNewMembers = approvalRequiredForNewMembers;
this.inputMode = inputMode;
this.threadContextItems = threadContextItems;
}
public String getThreadId() {
return threadId;
}
public String getThreadV2Id() {
return threadV2Id;
}
public List<User> getUsers() {
return users;
}
public void setUsers(final List<User> users) {
this.users = users;
}
public List<User> getLeftUsers() {
return leftUsers;
}
public void setLeftUsers(final List<User> leftUsers) {
this.leftUsers = leftUsers;
}
public List<Long> getAdminUserIds() {
return adminUserIds;
}
public void setAdminUserIds(final List<Long> adminUserIds) {
this.adminUserIds = adminUserIds;
}
public List<DirectItem> getItems() {
return items;
}
public void setItems(final List<DirectItem> items) {
this.items = items;
}
public long getLastActivityAt() {
return lastActivityAt;
}
public boolean isMuted() {
return muted;
}
public void setMuted(final boolean muted) {
this.muted = muted;
}
public boolean isPin() {
return isPin;
}
public boolean isNamed() {
return named;
}
public boolean isCanonical() {
return canonical;
}
public boolean isPending() {
return pending;
}
public void setPending(final boolean pending) {
this.pending = pending;
}
public boolean isArchived() {
return archived;
}
public boolean isValuedRequest() {
return valuedRequest;
}
public String getThreadType() {
return threadType;
}
public long getViewerId() {
return viewerId;
}
public String getThreadTitle() {
return threadTitle;
}
public String getPendingScore() {
return pendingScore;
}
public long getFolder() {
return folder;
}
public boolean isVcMuted() {
return vcMuted;
}
public boolean isGroup() {
return isGroup;
}
public boolean isMentionsMuted() {
return mentionsMuted;
}
public void setMentionsMuted(final boolean mentionsMuted) {
this.mentionsMuted = mentionsMuted;
}
public User getInviter() {
return inviter;
}
public boolean hasOlder() {
return hasOlder;
}
public boolean hasNewer() {
return hasNewer;
}
public Map<Long, DirectThreadLastSeenAt> getLastSeenAt() {
return lastSeenAt;
}
public void setLastSeenAt(final Map<Long, DirectThreadLastSeenAt> lastSeenAt) {
this.lastSeenAt = lastSeenAt;
}
public String getNewestCursor() {
return newestCursor;
}
public String getOldestCursor() {
return oldestCursor;
}
public boolean isSpam() {
return isSpam;
}
public DirectItem getLastPermanentItem() {
return lastPermanentItem;
}
public DirectThreadDirectStory getDirectStory() {
return directStory;
}
public boolean isApprovalRequiredForNewMembers() {
return approvalRequiredForNewMembers;
}
public void setApprovalRequiredForNewMembers(final boolean approvalRequiredForNewMembers) {
this.approvalRequiredForNewMembers = approvalRequiredForNewMembers;
}
public int getInputMode() {
return inputMode;
}
public void setInputMode(final int inputMode) {
this.inputMode = inputMode;
}
public List<ThreadContext> getThreadContextItems() {
return threadContextItems;
}
public boolean isTemp() {
return isTemp;
}
public void setTemp(final boolean isTemp) {
this.isTemp = isTemp;
}
@Nullable
public DirectItem getFirstDirectItem() {
DirectItem firstItem = null;
if (!items.isEmpty()) {
int position = 0;
while (firstItem == null && position < items.size()) {
firstItem = items.get(position);
position++;
}
}
return firstItem;
}
@NonNull
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final DirectThread that = (DirectThread) o;
return lastActivityAt == that.lastActivityAt &&
muted == that.muted &&
isPin == that.isPin &&
named == that.named &&
canonical == that.canonical &&
pending == that.pending &&
archived == that.archived &&
valuedRequest == that.valuedRequest &&
viewerId == that.viewerId &&
folder == that.folder &&
vcMuted == that.vcMuted &&
isGroup == that.isGroup &&
mentionsMuted == that.mentionsMuted &&
hasOlder == that.hasOlder &&
hasNewer == that.hasNewer &&
isSpam == that.isSpam &&
approvalRequiredForNewMembers == that.approvalRequiredForNewMembers &&
inputMode == that.inputMode &&
Objects.equals(threadId, that.threadId) &&
Objects.equals(threadV2Id, that.threadV2Id) &&
Objects.equals(users, that.users) &&
Objects.equals(leftUsers, that.leftUsers) &&
Objects.equals(adminUserIds, that.adminUserIds) &&
Objects.equals(items, that.items) &&
Objects.equals(threadType, that.threadType) &&
Objects.equals(threadTitle, that.threadTitle) &&
Objects.equals(pendingScore, that.pendingScore) &&
Objects.equals(inviter, that.inviter) &&
Objects.equals(lastSeenAt, that.lastSeenAt) &&
Objects.equals(newestCursor, that.newestCursor) &&
Objects.equals(oldestCursor, that.oldestCursor) &&
Objects.equals(lastPermanentItem, that.lastPermanentItem) &&
Objects.equals(directStory, that.directStory) &&
Objects.equals(threadContextItems, that.threadContextItems);
}
@Override
public int hashCode() {
return Objects
.hash(threadId, threadV2Id, users, leftUsers, adminUserIds, items, lastActivityAt, muted, isPin, named, canonical, pending, archived,
valuedRequest, threadType, viewerId, threadTitle, pendingScore, folder, vcMuted, isGroup, mentionsMuted, inviter, hasOlder,
hasNewer, lastSeenAt, newestCursor, oldestCursor, isSpam, lastPermanentItem, directStory, approvalRequiredForNewMembers,
inputMode, threadContextItems);
}
} }

View File

@ -1,19 +1,6 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
public class DirectThreadDetailsChangeResponse { data class DirectThreadDetailsChangeResponse(
private final DirectThread thread; val thread: DirectThread? = null,
private final String status; val status: String? = null
)
public DirectThreadDetailsChangeResponse(final DirectThread thread, final String status) {
this.thread = thread;
this.status = status;
}
public DirectThread getThread() {
return thread;
}
public String getStatus() {
return status;
}
}

View File

@ -1,37 +1,8 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
import java.io.Serializable; import java.io.Serializable
import java.util.List;
import java.util.Objects;
public class DirectThreadDirectStory implements Serializable { data class DirectThreadDirectStory(
private final List<DirectItem> items; val items: List<DirectItem>? = null,
private final int unseenCount; val unseenCount: Int = 0,
) : Serializable
public DirectThreadDirectStory(final List<DirectItem> items, final int unseenCount) {
this.items = items;
this.unseenCount = unseenCount;
}
public List<DirectItem> getItems() {
return items;
}
public int getUnseenCount() {
return unseenCount;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final DirectThreadDirectStory that = (DirectThreadDirectStory) o;
return unseenCount == that.unseenCount &&
Objects.equals(items, that.items);
}
@Override
public int hashCode() {
return Objects.hash(items, unseenCount);
}
}

View File

@ -1,70 +1,16 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
import androidx.annotation.NonNull; import awais.instagrabber.repositories.responses.User
import java.io.Serializable
import java.io.Serializable; data class DirectThreadParticipantRequestsResponse(
import java.util.List; var users: List<User>? = null,
import java.util.Map; val requesterUsernames: Map<Long, String>? = null,
val cursor: String? = null,
import awais.instagrabber.repositories.responses.User; val totalThreadParticipants: Int = 0,
var totalParticipantRequests: Int = 0,
public class DirectThreadParticipantRequestsResponse implements Serializable, Cloneable { val status: String? = null,
private List<User> users; ) : Serializable, Cloneable {
private final Map<Long, String> requesterUsernames; @Throws(CloneNotSupportedException::class)
private final String cursor; public override fun clone(): Any = super.clone()
private final int totalThreadParticipants;
private int totalParticipantRequests;
private final String status;
public DirectThreadParticipantRequestsResponse(final List<User> users,
final Map<Long, String> requesterUsernames,
final String cursor,
final int totalThreadParticipants,
final int totalParticipantRequests,
final String status) {
this.users = users;
this.requesterUsernames = requesterUsernames;
this.cursor = cursor;
this.totalThreadParticipants = totalThreadParticipants;
this.totalParticipantRequests = totalParticipantRequests;
this.status = status;
}
public List<User> getUsers() {
return users;
}
public void setUsers(final List<User> users) {
this.users = users;
}
public Map<Long, String> getRequesterUsernames() {
return requesterUsernames;
}
public String getCursor() {
return cursor;
}
public int getTotalThreadParticipants() {
return totalThreadParticipants;
}
public int getTotalParticipantRequests() {
return totalParticipantRequests;
}
public void setTotalParticipantRequests(final int totalParticipantRequests) {
this.totalParticipantRequests = totalParticipantRequests;
}
public String getStatus() {
return status;
}
@NonNull
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
} }

View File

@ -1,46 +1,21 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
import java.io.Serializable; import awais.instagrabber.repositories.responses.User
import java.util.Objects; import java.io.Serializable
import awais.instagrabber.repositories.responses.User; data class RankedRecipient(
val user: User? = null,
public class RankedRecipient implements Serializable { val thread: DirectThread? = null,
private final User user; ) : Serializable {
private final DirectThread thread; companion object {
@JvmStatic
public RankedRecipient(final User user, final DirectThread thread) { fun of(user: User): RankedRecipient {
this.user = user; return RankedRecipient(user = user)
this.thread = thread;
} }
public User getUser() { @JvmStatic
return user; fun of(thread: DirectThread): RankedRecipient {
} return RankedRecipient(thread = thread)
}
public DirectThread getThread() {
return thread;
}
public static RankedRecipient of(final User user) {
return new RankedRecipient(user, null);
}
public static RankedRecipient of(final DirectThread thread) {
return new RankedRecipient(null, thread);
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final RankedRecipient that = (RankedRecipient) o;
return Objects.equals(user, that.user) &&
Objects.equals(thread, that.thread);
}
@Override
public int hashCode() {
return Objects.hash(user, thread);
} }
} }

View File

@ -1,50 +1,10 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
import java.util.List; data class RankedRecipientsResponse(
val rankedRecipients: List<RankedRecipient>? = null,
public class RankedRecipientsResponse { val expires: Long = 0,
private final List<RankedRecipient> rankedRecipients; val filtered: Boolean = false,
private final long expires; val requestId: String? = null,
private final boolean filtered; val rankToken: String? = null,
private final String requestId; val status: String? = null,
private final String rankToken; )
private final String status;
public RankedRecipientsResponse(final List<RankedRecipient> rankedRecipients,
final long expires,
final boolean filtered,
final String requestId,
final String rankToken,
final String status) {
this.rankedRecipients = rankedRecipients;
this.expires = expires;
this.filtered = filtered;
this.requestId = requestId;
this.rankToken = rankToken;
this.status = status;
}
public List<RankedRecipient> getRankedRecipients() {
return rankedRecipients;
}
public long getExpires() {
return expires;
}
public boolean isFiltered() {
return filtered;
}
public String getRequestId() {
return requestId;
}
public String getRankToken() {
return rankToken;
}
public String getStatus() {
return status;
}
}

View File

@ -1,69 +1,43 @@
package awais.instagrabber.repositories.responses.directmessages; package awais.instagrabber.repositories.responses.directmessages
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName
import java.io.Serializable
import java.io.Serializable; data class RavenExpiringMediaActionSummary(
import java.util.Objects; val timestamp: Long = 0,
val count: Int = 0,
public final class RavenExpiringMediaActionSummary implements Serializable { val type: ActionType? = null,
private final ActionType type; ) : Serializable
private final long timestamp;
private final int count;
public RavenExpiringMediaActionSummary(final long timestamp, final int count, final ActionType type) {
this.timestamp = timestamp;
this.count = count;
this.type = type;
}
public long getTimestamp() {
return timestamp;
}
public int getCount() {
return count;
}
public ActionType getType() {
return type;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final RavenExpiringMediaActionSummary that = (RavenExpiringMediaActionSummary) o;
return timestamp == that.timestamp &&
count == that.count &&
type == that.type;
}
@Override
public int hashCode() {
return Objects.hash(type, timestamp, count);
}
// thanks to http://github.com/warifp/InstagramAutoPostImageUrl/blob/master/vendor/mgp25/instagram-php/src/Response/Model/ActionBadge.php // thanks to http://github.com/warifp/InstagramAutoPostImageUrl/blob/master/vendor/mgp25/instagram-php/src/Response/Model/ActionBadge.php
public enum ActionType { enum class ActionType {
@SerializedName("raven_delivered") @SerializedName("raven_delivered")
DELIVERED, DELIVERED,
@SerializedName("raven_sent") @SerializedName("raven_sent")
SENT, SENT,
@SerializedName("raven_opened") @SerializedName("raven_opened")
OPENED, OPENED,
@SerializedName("raven_screenshot") @SerializedName("raven_screenshot")
SCREENSHOT, SCREENSHOT,
@SerializedName("raven_replayed") @SerializedName("raven_replayed")
REPLAYED, REPLAYED,
@SerializedName("raven_cannot_deliver") @SerializedName("raven_cannot_deliver")
CANNOT_DELIVER, CANNOT_DELIVER,
@SerializedName("raven_sending") @SerializedName("raven_sending")
SENDING, SENDING,
@SerializedName("raven_blocked") @SerializedName("raven_blocked")
BLOCKED, BLOCKED,
@SerializedName("raven_unknown") @SerializedName("raven_unknown")
UNKNOWN, UNKNOWN,
@SerializedName("raven_suggested") @SerializedName("raven_suggested")
SUGGESTED, SUGGESTED,
} }
}

View File

@ -91,7 +91,7 @@ public class DMSyncService extends LifecycleService {
return; return;
} }
for (final DirectThread thread : threads) { for (final DirectThread thread : threads) {
if (thread.isMuted()) continue; if (thread.getMuted()) continue;
final boolean read = DMUtils.isRead(thread); final boolean read = DMUtils.isRead(thread);
if (read) continue; if (read) continue;
final List<DirectItem> unreadMessages = getUnreadMessages(thread); final List<DirectItem> unreadMessages = getUnreadMessages(thread);

View File

@ -15,6 +15,7 @@ import awais.instagrabber.models.enums.DirectItemType;
import awais.instagrabber.models.enums.MediaItemType; import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.Media;
import awais.instagrabber.repositories.responses.User; import awais.instagrabber.repositories.responses.User;
import awais.instagrabber.repositories.responses.directmessages.ActionType;
import awais.instagrabber.repositories.responses.directmessages.DirectItem; import awais.instagrabber.repositories.responses.directmessages.DirectItem;
import awais.instagrabber.repositories.responses.directmessages.DirectItemAnimatedMedia; import awais.instagrabber.repositories.responses.directmessages.DirectItemAnimatedMedia;
import awais.instagrabber.repositories.responses.directmessages.DirectItemReelShare; import awais.instagrabber.repositories.responses.directmessages.DirectItemReelShare;
@ -267,7 +268,7 @@ public final class DMUtils {
final DirectItemVisualMedia visualMedia = item.getVisualMedia(); final DirectItemVisualMedia visualMedia = item.getVisualMedia();
final RavenExpiringMediaActionSummary summary = visualMedia.getExpiringMediaActionSummary(); final RavenExpiringMediaActionSummary summary = visualMedia.getExpiringMediaActionSummary();
if (summary != null) { if (summary != null) {
final RavenExpiringMediaActionSummary.ActionType expiringMediaType = summary.getType(); final ActionType expiringMediaType = summary.getType();
int textRes = 0; int textRes = 0;
switch (expiringMediaType) { switch (expiringMediaType) {
case DELIVERED: case DELIVERED:

View File

@ -80,7 +80,7 @@ public class DirectSettingsViewModel extends AndroidViewModel {
// final List<Long> adminUserIds = thread.getAdminUserIds(); // final List<Long> adminUserIds = thread.getAdminUserIds();
// this.adminUserIds.postValue(adminUserIds); // this.adminUserIds.postValue(adminUserIds);
// viewerIsAdmin = adminUserIds.contains(viewerId); // viewerIsAdmin = adminUserIds.contains(viewerId);
// muted.postValue(thread.isMuted()); // muted.postValue(thread.getMuted());
// mentionsMuted.postValue(thread.isMentionsMuted()); // mentionsMuted.postValue(thread.isMentionsMuted());
// approvalRequiredToJoin.postValue(thread.isApprovalRequiredForNewMembers()); // approvalRequiredToJoin.postValue(thread.isApprovalRequiredForNewMembers());
// isPending.postValue(thread.isPending()); // isPending.postValue(thread.isPending());

View File

@ -107,7 +107,7 @@ public class DiscoverService extends BaseService {
// } // }
// final String type = clusterJson.optString("type"); // final String type = clusterJson.optString("type");
// final boolean canMute = clusterJson.optBoolean("can_mute"); // final boolean canMute = clusterJson.optBoolean("can_mute");
// final boolean isMuted = clusterJson.optBoolean("is_muted"); // final boolean getMuted = clusterJson.optBoolean("is_muted");
// final JSONObject coverMediaJson = clusterJson.optJSONObject("cover_media"); // final JSONObject coverMediaJson = clusterJson.optJSONObject("cover_media");
// final int rankedPosition = clusterJson.optInt("ranked_position"); // final int rankedPosition = clusterJson.optInt("ranked_position");
// final FeedModel feedModel = parseClusterCover(coverMediaJson); // final FeedModel feedModel = parseClusterCover(coverMediaJson);
@ -116,7 +116,7 @@ public class DiscoverService extends BaseService {
// title, // title,
// type, // type,
// canMute, // canMute,
// isMuted, // getMuted,
// rankedPosition, // rankedPosition,
// feedModel // feedModel
// ); // );