From eab6fea0abb13ecc7f8e3d0847c5857f8765d8f1 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Tue, 25 May 2021 01:22:59 +0900 Subject: [PATCH] Convert to kotlin --- .../DirectItemActionLogViewHolder.java | 9 +- .../DirectItemVideoCallEventViewHolder.java | 6 +- .../DirectItemXmaViewHolder.java | 7 +- .../instagrabber/managers/ThreadManager.java | 2 +- .../directmessages/DirectItemActionLog.kt | 97 ++------------- .../directmessages/DirectItemAnimatedMedia.kt | 60 ++-------- .../directmessages/DirectItemEmojiReaction.kt | 66 ++-------- .../directmessages/DirectItemLink.kt | 59 ++------- .../directmessages/DirectItemLinkContext.kt | 59 ++------- .../directmessages/DirectItemPlaceholder.kt | 50 ++------ .../directmessages/DirectItemReactions.kt | 69 ++--------- .../directmessages/DirectItemSeenResponse.kt | 100 +--------------- .../DirectItemSeenResponsePayload.kt | 3 + .../DirectItemVideoCallEvent.kt | 69 ++--------- .../directmessages/DirectItemVoiceMedia.kt | 51 ++------ .../responses/directmessages/DirectItemXma.kt | 113 ++---------------- .../DirectThreadBroadcastResponse.kt | 64 ++-------- ...tThreadBroadcastResponseMessageMetadata.kt | 62 ++-------- .../DirectThreadBroadcastResponsePayload.kt | 50 ++------ .../DirectThreadFeedResponse.kt | 23 +--- .../directmessages/DirectThreadLastSeenAt.kt | 40 +------ .../responses/directmessages/TextRange.kt | 10 ++ .../responses/directmessages/ThreadContext.kt | 40 +------ 23 files changed, 158 insertions(+), 951 deletions(-) create mode 100644 app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemSeenResponsePayload.kt create mode 100644 app/src/main/java/awais/instagrabber/repositories/responses/directmessages/TextRange.kt diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemActionLogViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemActionLogViewHolder.java index 45c83805..c212efbf 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemActionLogViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemActionLogViewHolder.java @@ -22,6 +22,7 @@ import awais.instagrabber.repositories.responses.User; import awais.instagrabber.repositories.responses.directmessages.DirectItem; import awais.instagrabber.repositories.responses.directmessages.DirectItemActionLog; import awais.instagrabber.repositories.responses.directmessages.DirectThread; +import awais.instagrabber.repositories.responses.directmessages.TextRange; import awais.instagrabber.utils.TextUtils; public class DirectItemActionLogViewHolder extends DirectItemViewHolder { @@ -45,16 +46,16 @@ public class DirectItemActionLogViewHolder extends DirectItemViewHolder { final DirectItemActionLog actionLog = directItemModel.getActionLog(); final String text = actionLog.getDescription(); final SpannableStringBuilder sb = new SpannableStringBuilder(text); - final List bold = actionLog.getBold(); + final List bold = actionLog.getBold(); if (bold != null && !bold.isEmpty()) { - for (final DirectItemActionLog.TextRange textRange : bold) { + for (final TextRange textRange : bold) { final StyleSpan boldStyleSpan = new StyleSpan(Typeface.BOLD); sb.setSpan(boldStyleSpan, textRange.getStart(), textRange.getEnd(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); } } - final List textAttributes = actionLog.getTextAttributes(); + final List textAttributes = actionLog.getTextAttributes(); if (textAttributes != null && !textAttributes.isEmpty()) { - for (final DirectItemActionLog.TextRange textAttribute : textAttributes) { + for (final TextRange textAttribute : textAttributes) { if (!TextUtils.isEmpty(textAttribute.getColor())) { final ForegroundColorSpan colorSpan = new ForegroundColorSpan(itemView.getResources().getColor(R.color.deep_orange_400)); sb.setSpan(colorSpan, textAttribute.getStart(), textAttribute.getEnd(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemVideoCallEventViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemVideoCallEventViewHolder.java index 77a43a5a..4c56922a 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemVideoCallEventViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemVideoCallEventViewHolder.java @@ -17,9 +17,9 @@ import awais.instagrabber.databinding.LayoutDmActionLogBinding; import awais.instagrabber.databinding.LayoutDmBaseBinding; import awais.instagrabber.repositories.responses.User; import awais.instagrabber.repositories.responses.directmessages.DirectItem; -import awais.instagrabber.repositories.responses.directmessages.DirectItemActionLog; import awais.instagrabber.repositories.responses.directmessages.DirectItemVideoCallEvent; import awais.instagrabber.repositories.responses.directmessages.DirectThread; +import awais.instagrabber.repositories.responses.directmessages.TextRange; import awais.instagrabber.utils.TextUtils; public class DirectItemVideoCallEventViewHolder extends DirectItemViewHolder { @@ -41,9 +41,9 @@ public class DirectItemVideoCallEventViewHolder extends DirectItemViewHolder { final DirectItemVideoCallEvent videoCallEvent = directItemModel.getVideoCallEvent(); final String text = videoCallEvent.getDescription(); final SpannableStringBuilder sb = new SpannableStringBuilder(text); - final List textAttributes = videoCallEvent.getTextAttributes(); + final List textAttributes = videoCallEvent.getTextAttributes(); if (textAttributes != null && !textAttributes.isEmpty()) { - for (final DirectItemActionLog.TextRange textAttribute : textAttributes) { + for (final TextRange textAttribute : textAttributes) { if (!TextUtils.isEmpty(textAttribute.getColor())) { final ForegroundColorSpan colorSpan = new ForegroundColorSpan(itemView.getResources().getColor(R.color.deep_orange_400)); sb.setSpan(colorSpan, textAttribute.getStart(), textAttribute.getEnd(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemXmaViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemXmaViewHolder.java index adee0226..d6420bda 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemXmaViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemXmaViewHolder.java @@ -15,6 +15,7 @@ import awais.instagrabber.repositories.responses.User; import awais.instagrabber.repositories.responses.directmessages.DirectItem; import awais.instagrabber.repositories.responses.directmessages.DirectItemXma; import awais.instagrabber.repositories.responses.directmessages.DirectThread; +import awais.instagrabber.repositories.responses.directmessages.XmaUrlInfo; import awais.instagrabber.utils.NullSafePair; import awais.instagrabber.utils.NumberUtils; @@ -35,13 +36,13 @@ public class DirectItemXmaViewHolder extends DirectItemViewHolder { @Override public void bindItem(final DirectItem item, final MessageDirection messageDirection) { final DirectItemXma xma = item.getXma(); - final DirectItemXma.XmaUrlInfo playableUrlInfo = xma.getPlayableUrlInfo(); - final DirectItemXma.XmaUrlInfo previewUrlInfo = xma.getPreviewUrlInfo(); + final XmaUrlInfo playableUrlInfo = xma.getPlayableUrlInfo(); + final XmaUrlInfo previewUrlInfo = xma.getPreviewUrlInfo(); if (playableUrlInfo == null && previewUrlInfo == null) { binding.ivAnimatedMessage.setController(null); return; } - final DirectItemXma.XmaUrlInfo urlInfo = playableUrlInfo != null ? playableUrlInfo : previewUrlInfo; + final XmaUrlInfo urlInfo = playableUrlInfo != null ? playableUrlInfo : previewUrlInfo; final String url = urlInfo.getUrl(); final NullSafePair widthHeight = NumberUtils.calculateWidthHeight( urlInfo.getHeight(), diff --git a/app/src/main/java/awais/instagrabber/managers/ThreadManager.java b/app/src/main/java/awais/instagrabber/managers/ThreadManager.java index 21c50a83..b479b427 100644 --- a/app/src/main/java/awais/instagrabber/managers/ThreadManager.java +++ b/app/src/main/java/awais/instagrabber/managers/ThreadManager.java @@ -49,7 +49,7 @@ import awais.instagrabber.repositories.responses.directmessages.DirectItem; import awais.instagrabber.repositories.responses.directmessages.DirectItemEmojiReaction; import awais.instagrabber.repositories.responses.directmessages.DirectItemReactions; import awais.instagrabber.repositories.responses.directmessages.DirectItemSeenResponse; -import awais.instagrabber.repositories.responses.directmessages.DirectItemSeenResponse.DirectItemSeenResponsePayload; +import awais.instagrabber.repositories.responses.directmessages.DirectItemSeenResponsePayload; import awais.instagrabber.repositories.responses.directmessages.DirectThread; import awais.instagrabber.repositories.responses.directmessages.DirectThreadBroadcastResponse; import awais.instagrabber.repositories.responses.directmessages.DirectThreadBroadcastResponseMessageMetadata; diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemActionLog.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemActionLog.kt index c6b40581..320e4092 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemActionLog.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemActionLog.kt @@ -1,92 +1,9 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.List; -import java.util.Objects; +import java.io.Serializable -public class DirectItemActionLog implements Serializable { - private final String description; - private final List bold; - private final List textAttributes; - - public DirectItemActionLog(final String description, - final List bold, - final List textAttributes) { - this.description = description; - this.bold = bold; - this.textAttributes = textAttributes; - } - - public String getDescription() { - return description; - } - - public List getBold() { - return bold; - } - - public List getTextAttributes() { - return textAttributes; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemActionLog that = (DirectItemActionLog) o; - return Objects.equals(description, that.description) && - Objects.equals(bold, that.bold) && - Objects.equals(textAttributes, that.textAttributes); - } - - @Override - public int hashCode() { - return Objects.hash(description, bold, textAttributes); - } - - public static class TextRange implements Serializable { - private final int start; - private final int end; - private final String color; - private final String intent; - - public TextRange(final int start, final int end, final String color, final String intent) { - this.start = start; - this.end = end; - this.color = color; - this.intent = intent; - } - - public int getStart() { - return start; - } - - public int getEnd() { - return end; - } - - public String getColor() { - return color; - } - - public String getIntent() { - return intent; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final TextRange textRange = (TextRange) o; - return start == textRange.start && - end == textRange.end && - Objects.equals(color, textRange.color) && - Objects.equals(intent, textRange.intent); - } - - @Override - public int hashCode() { - return Objects.hash(start, end, color, intent); - } - } -} +data class DirectItemActionLog( + val description: String? = null, + val bold: List? = null, + val textAttributes: List? = null +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemAnimatedMedia.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemAnimatedMedia.kt index b948726c..085943ec 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemAnimatedMedia.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemAnimatedMedia.kt @@ -1,53 +1,11 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import awais.instagrabber.repositories.responses.AnimatedMediaImages +import java.io.Serializable -import awais.instagrabber.repositories.responses.AnimatedMediaImages; - -public final class DirectItemAnimatedMedia implements Serializable { - private final String id; - private final AnimatedMediaImages images; - private final boolean isRandom; - private final boolean isSticker; - - public DirectItemAnimatedMedia(final String id, final AnimatedMediaImages images, final boolean isRandom, final boolean isSticker) { - - this.id = id; - this.images = images; - this.isRandom = isRandom; - this.isSticker = isSticker; - } - - public String getId() { - return id; - } - - public AnimatedMediaImages getImages() { - return images; - } - - public boolean isRandom() { - return isRandom; - } - - public boolean isSticker() { - return isSticker; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemAnimatedMedia that = (DirectItemAnimatedMedia) o; - return isRandom == that.isRandom && - isSticker == that.isSticker && - Objects.equals(id, that.id) && - Objects.equals(images, that.images); - } - - @Override - public int hashCode() { - return Objects.hash(id, images, isRandom, isSticker); - } -} +data class DirectItemAnimatedMedia( + val id: String? = null, + val images: AnimatedMediaImages? = null, + val isRandom: Boolean = false, + val isSticker: Boolean = false, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemEmojiReaction.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemEmojiReaction.kt index 068c17f6..a0620406 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemEmojiReaction.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemEmojiReaction.kt @@ -1,60 +1,10 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import java.io.Serializable -public class DirectItemEmojiReaction implements Serializable { - private final long senderId; - private final long timestamp; - private final String emoji; - private final String superReactType; - - public DirectItemEmojiReaction(final long senderId, final long timestamp, final String emoji, final String superReactType) { - this.senderId = senderId; - this.timestamp = timestamp; - this.emoji = emoji; - this.superReactType = superReactType; - } - - public long getSenderId() { - return senderId; - } - - public long getTimestamp() { - return timestamp; - } - - public String getEmoji() { - return emoji; - } - - public String getSuperReactType() { - return superReactType; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemEmojiReaction that = (DirectItemEmojiReaction) o; - return senderId == that.senderId && - timestamp == that.timestamp && - Objects.equals(emoji, that.emoji) && - Objects.equals(superReactType, that.superReactType); - } - - @Override - public int hashCode() { - return Objects.hash(senderId, timestamp, emoji, superReactType); - } - - @Override - public String toString() { - return "DirectItemEmojiReaction{" + - "senderId=" + senderId + - ", timestamp=" + timestamp + - ", emoji='" + emoji + '\'' + - ", superReactType='" + superReactType + '\'' + - '}'; - } -} +data class DirectItemEmojiReaction( + val senderId: Long = 0, + val timestamp: Long = 0, + val emoji: String? = null, + val superReactType: String? = null +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemLink.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemLink.kt index d4d1915e..f190568c 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemLink.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemLink.kt @@ -1,53 +1,10 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import java.io.Serializable -public class DirectItemLink implements Serializable { - private final String text; - private final DirectItemLinkContext linkContext; - private final String clientContext; - private final String mutationToken; - - public DirectItemLink(final String text, - final DirectItemLinkContext linkContext, - final String clientContext, - final String mutationToken) { - this.text = text; - this.linkContext = linkContext; - this.clientContext = clientContext; - this.mutationToken = mutationToken; - } - - public String getText() { - return text; - } - - public DirectItemLinkContext getLinkContext() { - return linkContext; - } - - public String getClientContext() { - return clientContext; - } - - public String getMutationToken() { - return mutationToken; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemLink that = (DirectItemLink) o; - return Objects.equals(text, that.text) && - Objects.equals(linkContext, that.linkContext) && - Objects.equals(clientContext, that.clientContext) && - Objects.equals(mutationToken, that.mutationToken); - } - - @Override - public int hashCode() { - return Objects.hash(text, linkContext, clientContext, mutationToken); - } -} +data class DirectItemLink( + val text: String? = null, + val linkContext: DirectItemLinkContext? = null, + val clientContext: String? = null, + val mutationToken: String? = null, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemLinkContext.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemLinkContext.kt index 6f31a711..5190208d 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemLinkContext.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemLinkContext.kt @@ -1,53 +1,10 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import java.io.Serializable -public class DirectItemLinkContext implements Serializable { - private final String linkUrl; - private final String linkTitle; - private final String linkSummary; - private final String linkImageUrl; - - public DirectItemLinkContext(final String linkUrl, - final String linkTitle, - final String linkSummary, - final String linkImageUrl) { - this.linkUrl = linkUrl; - this.linkTitle = linkTitle; - this.linkSummary = linkSummary; - this.linkImageUrl = linkImageUrl; - } - - public String getLinkUrl() { - return linkUrl; - } - - public String getLinkTitle() { - return linkTitle; - } - - public String getLinkSummary() { - return linkSummary; - } - - public String getLinkImageUrl() { - return linkImageUrl; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemLinkContext that = (DirectItemLinkContext) o; - return Objects.equals(linkUrl, that.linkUrl) && - Objects.equals(linkTitle, that.linkTitle) && - Objects.equals(linkSummary, that.linkSummary) && - Objects.equals(linkImageUrl, that.linkImageUrl); - } - - @Override - public int hashCode() { - return Objects.hash(linkUrl, linkTitle, linkSummary, linkImageUrl); - } -} +data class DirectItemLinkContext( + val linkUrl: String? = null, + val linkTitle: String? = null, + val linkSummary: String? = null, + val linkImageUrl: String? = null +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemPlaceholder.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemPlaceholder.kt index 5c309504..d01006ec 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemPlaceholder.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemPlaceholder.kt @@ -1,45 +1,9 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import java.io.Serializable -public class DirectItemPlaceholder implements Serializable { - private final boolean isLinked; - private final String title; - private final String message; - - public DirectItemPlaceholder(final boolean isLinked, - final String title, - final String message) { - this.isLinked = isLinked; - this.title = title; - this.message = message; - } - - public boolean isLinked() { - return isLinked; - } - - 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 DirectItemPlaceholder that = (DirectItemPlaceholder) o; - return isLinked == that.isLinked && - Objects.equals(title, that.title) && - Objects.equals(message, that.message); - } - - @Override - public int hashCode() { - return Objects.hash(isLinked, title, message); - } -} +data class DirectItemPlaceholder( + val isLinked: Boolean = false, + val title: String? = null, + val message: String? = null, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemReactions.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemReactions.kt index 30d3cf6c..5f08c499 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemReactions.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemReactions.kt @@ -1,62 +1,13 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import androidx.annotation.NonNull; +import java.io.Serializable -import java.io.Serializable; -import java.util.List; -import java.util.Objects; - -public class DirectItemReactions implements Cloneable, Serializable { - private List emojis; - private List likes; - - public DirectItemReactions(final List emojis, - final List likes) { - this.emojis = emojis; - this.likes = likes; +data class DirectItemReactions( + var emojis: List? = null, + var likes: List? = null, +) : Cloneable, Serializable { + @Throws(CloneNotSupportedException::class) + public override fun clone(): Any { + return super.clone() } - - public List getEmojis() { - return emojis; - } - - public List getLikes() { - return likes; - } - - public void setLikes(final List likes) { - this.likes = likes; - } - - public void setEmojis(final List emojis) { - this.emojis = emojis; - } - - @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 DirectItemReactions that = (DirectItemReactions) o; - return Objects.equals(emojis, that.emojis) && - Objects.equals(likes, that.likes); - } - - @Override - public int hashCode() { - return Objects.hash(emojis, likes); - } - - @Override - public String toString() { - return "DirectItemReactions{" + - "emojis=" + emojis + - ", likes=" + likes + - '}'; - } -} +} \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemSeenResponse.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemSeenResponse.kt index e1c88dab..85d27381 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemSeenResponse.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemSeenResponse.kt @@ -1,95 +1,7 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import androidx.annotation.NonNull; - -import java.util.Objects; - -public class DirectItemSeenResponse { - private final String action; - private final DirectItemSeenResponsePayload payload; - private final String status; - - public DirectItemSeenResponse(final String action, final DirectItemSeenResponsePayload payload, final String status) { - this.action = action; - this.payload = payload; - this.status = status; - } - - public String getAction() { - return action; - } - - public DirectItemSeenResponsePayload getPayload() { - return payload; - } - - public String getStatus() { - return status; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemSeenResponse that = (DirectItemSeenResponse) o; - return Objects.equals(action, that.action) && - Objects.equals(payload, that.payload) && - Objects.equals(status, that.status); - } - - @Override - public int hashCode() { - return Objects.hash(action, payload, status); - } - - @NonNull - @Override - public String toString() { - return "DirectItemSeenResponse{" + - "action='" + action + '\'' + - ", payload=" + payload + - ", status='" + status + '\'' + - '}'; - } - - public static class DirectItemSeenResponsePayload { - private final int count; - private final String timestamp; - - public DirectItemSeenResponsePayload(final int count, final String timestamp) { - this.count = count; - this.timestamp = timestamp; - } - - public int getCount() { - return count; - } - - public String getTimestamp() { - return timestamp; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemSeenResponsePayload that = (DirectItemSeenResponsePayload) o; - return count == that.count && - Objects.equals(timestamp, that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash(count, timestamp); - } - - @NonNull - @Override - public String toString() { - return "DirectItemSeenResponsePayload{" + - "count=" + count + - ", timestamp='" + timestamp + '\'' + - '}'; - } - } -} +data class DirectItemSeenResponse( + val action: String? = null, + val payload: DirectItemSeenResponsePayload? = null, + val status: String? = null, +) \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemSeenResponsePayload.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemSeenResponsePayload.kt new file mode 100644 index 00000000..9bbdb553 --- /dev/null +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemSeenResponsePayload.kt @@ -0,0 +1,3 @@ +package awais.instagrabber.repositories.responses.directmessages + +data class DirectItemSeenResponsePayload(val count: Int = 0, val timestamp: String? = null) \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemVideoCallEvent.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemVideoCallEvent.kt index da68d633..ae1ea0ad 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemVideoCallEvent.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemVideoCallEvent.kt @@ -1,62 +1,11 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.List; -import java.util.Objects; +import java.io.Serializable -public final class DirectItemVideoCallEvent implements Serializable { - private final String action; - private final String encodedServerDataInfo; - private final String description; - private final boolean threadHasAudioOnlyCall; - private final List textAttributes; - - public DirectItemVideoCallEvent(final String action, - final String encodedServerDataInfo, - final String description, - final boolean threadHasAudioOnlyCall, - final List textAttributes) { - this.action = action; - this.encodedServerDataInfo = encodedServerDataInfo; - this.description = description; - this.threadHasAudioOnlyCall = threadHasAudioOnlyCall; - this.textAttributes = textAttributes; - } - - public String getAction() { - return action; - } - - public String getEncodedServerDataInfo() { - return encodedServerDataInfo; - } - - public String getDescription() { - return description; - } - - public boolean isThreadHasAudioOnlyCall() { - return threadHasAudioOnlyCall; - } - - public List getTextAttributes() { - return textAttributes; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemVideoCallEvent that = (DirectItemVideoCallEvent) o; - return threadHasAudioOnlyCall == that.threadHasAudioOnlyCall && - Objects.equals(action, that.action) && - Objects.equals(encodedServerDataInfo, that.encodedServerDataInfo) && - Objects.equals(description, that.description) && - Objects.equals(textAttributes, that.textAttributes); - } - - @Override - public int hashCode() { - return Objects.hash(action, encodedServerDataInfo, description, threadHasAudioOnlyCall, textAttributes); - } -} +data class DirectItemVideoCallEvent( + val action: String? = null, + val encodedServerDataInfo: String? = null, + val description: String? = null, + val threadHasAudioOnlyCall: Boolean = false, + val textAttributes: List? = null, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemVoiceMedia.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemVoiceMedia.kt index 006fa509..4ab35e24 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemVoiceMedia.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemVoiceMedia.kt @@ -1,45 +1,10 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import awais.instagrabber.repositories.responses.Media +import java.io.Serializable -import awais.instagrabber.repositories.responses.Media; - -public class DirectItemVoiceMedia implements Serializable { - private final Media media; - private final int seenCount; - private final String viewMode; - - public DirectItemVoiceMedia(final Media media, final int seenCount, final String viewMode) { - this.media = media; - this.seenCount = seenCount; - this.viewMode = viewMode; - } - - public Media getMedia() { - return media; - } - - public int getSeenCount() { - return seenCount; - } - - public String getViewMode() { - return viewMode; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemVoiceMedia that = (DirectItemVoiceMedia) o; - return seenCount == that.seenCount && - Objects.equals(media, that.media) && - Objects.equals(viewMode, that.viewMode); - } - - @Override - public int hashCode() { - return Objects.hash(media, seenCount, viewMode); - } -} +data class DirectItemVoiceMedia( + val media: Media? = null, + val seenCount: Int = 0, + val viewMode: String? = null, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemXma.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemXma.kt index 518e6efc..e28bbb9e 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemXma.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemXma.kt @@ -1,104 +1,15 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import androidx.annotation.NonNull; +import java.io.Serializable -import java.io.Serializable; -import java.util.Objects; +data class DirectItemXma( + val previewUrlInfo: XmaUrlInfo? = null, + val playableUrlInfo: XmaUrlInfo? = null, +) : Serializable -public class DirectItemXma { - private final XmaUrlInfo previewUrlInfo; - private final XmaUrlInfo playableUrlInfo; - - public DirectItemXma(final XmaUrlInfo previewUrlInfo, final XmaUrlInfo playableUrlInfo) { - this.previewUrlInfo = previewUrlInfo; - this.playableUrlInfo = playableUrlInfo; - } - - public XmaUrlInfo getPreviewUrlInfo() { - return previewUrlInfo; - } - - public XmaUrlInfo getPlayableUrlInfo() { - return playableUrlInfo; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemXma that = (DirectItemXma) o; - return Objects.equals(previewUrlInfo, that.previewUrlInfo) && - Objects.equals(playableUrlInfo, that.playableUrlInfo); - } - - @Override - public int hashCode() { - return Objects.hash(previewUrlInfo, playableUrlInfo); - } - - @NonNull - @Override - public String toString() { - return "DirectItemXma{" + - "previewUrlInfo=" + previewUrlInfo + - ", playableUrlInfo=" + playableUrlInfo + - '}'; - } - - public static class XmaUrlInfo implements Serializable { - private final String url; - private final long urlExpirationTimestampUs; - private final int width; - private final int height; - - public XmaUrlInfo(final String url, final long urlExpirationTimestampUs, final int width, final int height) { - this.url = url; - this.urlExpirationTimestampUs = urlExpirationTimestampUs; - this.width = width; - this.height = height; - } - - public String getUrl() { - return url; - } - - public long getUrlExpirationTimestampUs() { - return urlExpirationTimestampUs; - } - - public int getWidth() { - return width; - } - - public int getHeight() { - return height; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final XmaUrlInfo that = (XmaUrlInfo) o; - return urlExpirationTimestampUs == that.urlExpirationTimestampUs && - width == that.width && - height == that.height && - Objects.equals(url, that.url); - } - - @Override - public int hashCode() { - return Objects.hash(url, urlExpirationTimestampUs, width, height); - } - - @NonNull - @Override - public String toString() { - return "XmaUrlInfo{" + - "url='" + url + '\'' + - ", urlExpirationTimestampUs=" + urlExpirationTimestampUs + - ", width=" + width + - ", height=" + height + - '}'; - } - } -} +data class XmaUrlInfo( + val url: String? = null, + val urlExpirationTimestampUs: Long = 0, + val width: Int = 0, + val height: Int = 0, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadBroadcastResponse.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadBroadcastResponse.kt index 0acf4929..0669450d 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadBroadcastResponse.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadBroadcastResponse.kt @@ -1,57 +1,9 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import androidx.annotation.NonNull; - -import java.util.List; - -public class DirectThreadBroadcastResponse { - private final String action; - private final String statusCode; - private final DirectThreadBroadcastResponsePayload payload; - private final List messageMetadata; - private final String status; - - public DirectThreadBroadcastResponse(final String action, - final String statusCode, - final DirectThreadBroadcastResponsePayload payload, - final List messageMetadata, - final String status) { - this.action = action; - this.statusCode = statusCode; - this.payload = payload; - this.messageMetadata = messageMetadata; - this.status = status; - } - - public String getAction() { - return action; - } - - public String getStatusCode() { - return statusCode; - } - - public DirectThreadBroadcastResponsePayload getPayload() { - return payload; - } - - public List getMessageMetadata() { - return messageMetadata; - } - - public String getStatus() { - return status; - } - - @NonNull - @Override - public String toString() { - return "DirectThreadBroadcastResponse{" + - "action='" + action + '\'' + - ", statusCode='" + statusCode + '\'' + - ", payload=" + payload + - ", messageMetadata=" + messageMetadata + - ", status='" + status + '\'' + - '}'; - } -} +data class DirectThreadBroadcastResponse( + val action: String? = null, + val statusCode: String? = null, + val payload: DirectThreadBroadcastResponsePayload? = null, + val messageMetadata: List? = null, + val status: String? = null +) \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadBroadcastResponseMessageMetadata.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadBroadcastResponseMessageMetadata.kt index 1025aab3..720ab2de 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadBroadcastResponseMessageMetadata.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadBroadcastResponseMessageMetadata.kt @@ -1,55 +1,9 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.util.List; - -public class DirectThreadBroadcastResponseMessageMetadata { - private final String clientContext; - private final String itemId; - private final long timestamp; - private final String threadId; - private final List participantIds; - - - public DirectThreadBroadcastResponseMessageMetadata(final String clientContext, - final String itemId, - final long timestamp, - final String threadId, - final List participantIds) { - this.clientContext = clientContext; - this.itemId = itemId; - this.timestamp = timestamp; - this.threadId = threadId; - this.participantIds = participantIds; - } - - public String getClientContext() { - return clientContext; - } - - public String getItemId() { - return itemId; - } - - public long getTimestamp() { - return timestamp; - } - - public String getThreadId() { - return threadId; - } - - public List getParticipantIds() { - return participantIds; - } - - @Override - public String toString() { - return "DirectThreadBroadcastResponseMessageMetadata{" + - "clientContext='" + clientContext + '\'' + - ", itemId='" + itemId + '\'' + - ", timestamp=" + timestamp + - ", threadId='" + threadId + '\'' + - ", participantIds=" + participantIds + - '}'; - } -} +data class DirectThreadBroadcastResponseMessageMetadata( + val clientContext: String? = null, + val itemId: String? = null, + val timestamp: Long = 0, + val threadId: String? = null, + val participantIds: List? = null, +) \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadBroadcastResponsePayload.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadBroadcastResponsePayload.kt index 35b160a2..ca4655f9 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadBroadcastResponsePayload.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadBroadcastResponsePayload.kt @@ -1,44 +1,8 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -public class DirectThreadBroadcastResponsePayload { - private final String clientContext; - private final String itemId; - private final long timestamp; - private final String threadId; - - public DirectThreadBroadcastResponsePayload(final String clientContext, - final String itemId, - final long timestamp, - final String threadId) { - this.clientContext = clientContext; - this.itemId = itemId; - this.timestamp = timestamp; - this.threadId = threadId; - } - - public String getClientContext() { - return clientContext; - } - - public String getItemId() { - return itemId; - } - - public long getTimestamp() { - return timestamp; - } - - public String getThreadId() { - return threadId; - } - - @Override - public String toString() { - return "DirectThreadBroadcastResponsePayload{" + - "clientContext='" + clientContext + '\'' + - ", itemId='" + itemId + '\'' + - ", timestamp=" + timestamp + - ", threadId='" + threadId + '\'' + - '}'; - } -} +data class DirectThreadBroadcastResponsePayload( + val clientContext: String? = null, + val itemId: String? = null, + val timestamp: Long = 0, + val threadId: String? = null, +) \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadFeedResponse.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadFeedResponse.kt index 0101aa50..19f7451e 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadFeedResponse.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadFeedResponse.kt @@ -1,19 +1,6 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -public class DirectThreadFeedResponse { - private final DirectThread thread; - private final String status; - - public DirectThreadFeedResponse(final DirectThread thread, final String status) { - this.thread = thread; - this.status = status; - } - - public DirectThread getThread() { - return thread; - } - - public String getStatus() { - return status; - } -} +data class DirectThreadFeedResponse( + val thread: DirectThread? = null, + val status: String? = null, +) \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadLastSeenAt.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadLastSeenAt.kt index 83eda360..14547b40 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadLastSeenAt.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadLastSeenAt.kt @@ -1,36 +1,8 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import java.io.Serializable -public class DirectThreadLastSeenAt implements Serializable { - private final String timestamp; - private final String itemId; - - public DirectThreadLastSeenAt(final String timestamp, final String itemId) { - this.timestamp = timestamp; - this.itemId = itemId; - } - - public String getTimestamp() { - return timestamp; - } - - public String getItemId() { - return itemId; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectThreadLastSeenAt that = (DirectThreadLastSeenAt) o; - return Objects.equals(timestamp, that.timestamp) && - Objects.equals(itemId, that.itemId); - } - - @Override - public int hashCode() { - return Objects.hash(timestamp, itemId); - } -} +data class DirectThreadLastSeenAt( + val timestamp: String? = null, + val itemId: String? = null, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/TextRange.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/TextRange.kt new file mode 100644 index 00000000..2cea10bc --- /dev/null +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/TextRange.kt @@ -0,0 +1,10 @@ +package awais.instagrabber.repositories.responses.directmessages + +import java.io.Serializable + +data class TextRange( + val start: Int = 0, + val end: Int = 0, + val color: String? = null, + val intent: String? = null, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/ThreadContext.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/ThreadContext.kt index c44c0e29..60369140 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/ThreadContext.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/ThreadContext.kt @@ -1,36 +1,8 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import java.io.Serializable -public class ThreadContext implements Serializable { - private final int type; - private final String text; - - public ThreadContext(final int type, final String text) { - this.type = type; - this.text = text; - } - - public int getType() { - return type; - } - - public String getText() { - return text; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final ThreadContext that = (ThreadContext) o; - return type == that.type && - Objects.equals(text, that.text); - } - - @Override - public int hashCode() { - return Objects.hash(type, text); - } -} +data class ThreadContext( + val type: Int = 0, + val text: String? = null, +) : Serializable \ No newline at end of file