1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-12-23 05:16:58 +00:00

Convert to kotlin

This commit is contained in:
Ammar Githam 2021-05-23 17:10:49 +09:00
parent a808d600bb
commit 7dc3732e3e
8 changed files with 63 additions and 231 deletions

View File

@ -980,7 +980,7 @@ public class StoryViewerFragment extends Fragment {
downloadVisible = true;
menuDownload.setVisible(true);
}
if (currentStory.canReply() && menuDm != null) {
if (currentStory.getCanReply() && menuDm != null) {
dmVisible = true;
menuDm.setVisible(true);
}
@ -1021,7 +1021,7 @@ public class StoryViewerFragment extends Fragment {
downloadVisible = true;
menuDownload.setVisible(true);
}
if (currentStory.canReply() && menuDm != null) {
if (currentStory.getCanReply() && menuDm != null) {
dmVisible = true;
menuDm.setVisible(true);
}
@ -1041,7 +1041,7 @@ public class StoryViewerFragment extends Fragment {
downloadVisible = true;
menuDownload.setVisible(true);
}
if (currentStory.canReply() && menuDm != null) {
if (currentStory.getCanReply() && menuDm != null) {
dmVisible = true;
menuDm.setVisible(true);
}

View File

@ -1,167 +1,29 @@
package awais.instagrabber.models;
package awais.instagrabber.models
import java.io.Serializable;
import awais.instagrabber.models.enums.MediaItemType
import awais.instagrabber.models.stickers.*
import java.io.Serializable
import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.models.stickers.PollModel;
import awais.instagrabber.models.stickers.QuestionModel;
import awais.instagrabber.models.stickers.QuizModel;
import awais.instagrabber.models.stickers.SliderModel;
import awais.instagrabber.models.stickers.SwipeUpModel;
public final class StoryModel implements Serializable {
private final String storyMediaId;
private final String storyUrl;
private String thumbnail;
private final String username;
private final long userId;
private final MediaItemType itemType;
private final long timestamp;
private String videoUrl;
private String tappableShortCode;
private String tappableId;
private String spotify;
private PollModel poll;
private QuestionModel question;
private SliderModel slider;
private QuizModel quiz;
private SwipeUpModel swipeUp;
private String[] mentions;
private int position;
private boolean isCurrentSlide = false;
private final boolean canReply;
public StoryModel(final String storyMediaId, final String storyUrl, final String thumbnail, final MediaItemType itemType,
final long timestamp, final String username, final long userId, final boolean canReply) {
this.storyMediaId = storyMediaId;
this.storyUrl = storyUrl;
this.thumbnail = thumbnail;
this.itemType = itemType;
this.timestamp = timestamp;
this.username = username;
this.userId = userId;
this.canReply = canReply;
}
public String getStoryUrl() {
return storyUrl;
}
public String getThumbnail() {
return thumbnail;
}
public String getStoryMediaId() {
return storyMediaId;
}
public MediaItemType getItemType() {
return itemType;
}
public long getTimestamp() {
return timestamp;
}
public String getVideoUrl() {
return videoUrl;
}
public String getTappableShortCode() {
return tappableShortCode;
}
public PollModel getPoll() {
return poll;
}
public QuestionModel getQuestion() {
return question;
}
public SliderModel getSlider() {
return slider;
}
public QuizModel getQuiz() {
return quiz;
}
public SwipeUpModel getSwipeUp() { return swipeUp;}
public String[] getMentions() {
return mentions;
}
public int getPosition() {
return position;
}
public void setThumbnail(final String thumbnail) {
this.thumbnail = thumbnail;
}
public void setVideoUrl(final String videoUrl) {
this.videoUrl = videoUrl;
}
public String getSpotify() {
return spotify;
}
public void setSpotify(final String spotify) {
this.spotify = spotify;
}
public void setTappableShortCode(final String tappableShortCode) {
this.tappableShortCode = tappableShortCode;
}
public void setPoll(final PollModel poll) {
this.poll = poll;
}
public void setQuestion(final QuestionModel question) {
this.question = question;
}
public void setSlider(final SliderModel slider) {
this.slider = slider;
}
public void setQuiz(final QuizModel quiz) {
this.quiz = quiz;
}
public void setMentions(final String[] mentions) {
this.mentions = mentions;
}
public void setSwipeUp(final SwipeUpModel swipeUp) {
this.swipeUp = swipeUp;
}
public void setPosition(final int position) {
this.position = position;
}
public void setCurrentSlide(final boolean currentSlide) {
this.isCurrentSlide = currentSlide;
}
public boolean isCurrentSlide() {
return isCurrentSlide;
}
public boolean canReply() {
return canReply;
}
public String getUsername() {
return username;
}
public long getUserId() {
return userId;
}
data class StoryModel(
val storyMediaId: String?,
val storyUrl: String?,
var thumbnail: String?,
val itemType: MediaItemType?,
val timestamp: Long,
val username: String?,
val userId: Long,
val canReply: Boolean
) : Serializable {
var videoUrl: String? = null
var tappableShortCode: String? = null
val tappableId: String? = null
var spotify: String? = null
var poll: PollModel? = null
var question: QuestionModel? = null
var slider: SliderModel? = null
var quiz: QuizModel? = null
var swipeUp: SwipeUpModel? = null
var mentions: Array<String>? = null
var position = 0
var isCurrentSlide = false
}

View File

@ -1,6 +1,6 @@
package awais.instagrabber.models.enums;
package awais.instagrabber.models.enums
public enum BroadcastItemType {
enum class BroadcastItemType(val value: String) {
TEXT("text"),
REACTION("reaction"),
REELSHARE("reel_share"),
@ -9,15 +9,5 @@ public enum BroadcastItemType {
VIDEO("configure_video"),
VOICE("share_voice"),
ANIMATED_MEDIA("animated_media"),
MEDIA_SHARE("media_share");
private final String value;
BroadcastItemType(final String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
MEDIA_SHARE("media_share"),
}

View File

@ -1,8 +1,8 @@
package awais.instagrabber.models.enums;
package awais.instagrabber.models.enums
public enum FavoriteType {
TOP, // used just for searching
enum class FavoriteType {
TOP, // used just for searching
USER,
HASHTAG,
LOCATION,
}
}

View File

@ -1,9 +1,9 @@
package awais.instagrabber.models.enums;
package awais.instagrabber.models.enums
public enum IntentModelType {
enum class IntentModelType {
UNKNOWN,
USERNAME,
POST,
HASHTAG,
LOCATION
LOCATION,
}

View File

@ -1,41 +1,31 @@
package awais.instagrabber.models.enums;
package awais.instagrabber.models.enums
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.io.Serializable
public enum NotificationType implements Serializable {
// story_type
enum class NotificationType(val itemType: Int) : Serializable {
LIKE(60),
FOLLOW(101),
COMMENT(12), // NOT TESTED
COMMENT(12), // NOT TESTED
COMMENT_MENTION(66),
TAGGED(102), // NOT TESTED
TAGGED(102), // NOT TESTED
COMMENT_LIKE(13),
TAGGED_COMMENT(14),
RESPONDED_STORY(213),
REQUEST(75),
// aymf - arbitrary, misspelled as ayml but eh
AYML(9999);
private final int itemType;
private static final Map<Integer, NotificationType> map = new HashMap<>();
companion object {
private val map: MutableMap<Int, NotificationType> = mutableMapOf()
static {
for (NotificationType type : NotificationType.values()) {
map.put(type.itemType, type);
@JvmStatic
fun valueOfType(itemType: Int): NotificationType? {
return map[itemType]
}
init {
for (type in values()) {
map[type.itemType] = type
}
}
}
NotificationType(final int itemType) {
this.itemType = itemType;
}
public int getItemType() {
return itemType;
}
public static NotificationType valueOfType(final int itemType) {
return map.get(itemType);
}
}

View File

@ -1,15 +1,7 @@
package awais.instagrabber.models.enums;
package awais.instagrabber.models.enums
import java.io.Serializable;
import java.io.Serializable
public enum PostItemType implements Serializable {
MAIN,
DISCOVER,
FEED,
SAVED,
COLLECTION,
LIKED,
TAGGED,
HASHTAG,
LOCATION
enum class PostItemType : Serializable {
MAIN, DISCOVER, FEED, SAVED, COLLECTION, LIKED, TAGGED, HASHTAG, LOCATION
}

View File

@ -1,7 +1,5 @@
package awais.instagrabber.models.enums;
package awais.instagrabber.models.enums
public enum SuggestionType {
TYPE_USER,
TYPE_HASHTAG,
TYPE_LOCATION
enum class SuggestionType {
TYPE_USER, TYPE_HASHTAG, TYPE_LOCATION
}