1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-15 19:27:31 +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; downloadVisible = true;
menuDownload.setVisible(true); menuDownload.setVisible(true);
} }
if (currentStory.canReply() && menuDm != null) { if (currentStory.getCanReply() && menuDm != null) {
dmVisible = true; dmVisible = true;
menuDm.setVisible(true); menuDm.setVisible(true);
} }
@ -1021,7 +1021,7 @@ public class StoryViewerFragment extends Fragment {
downloadVisible = true; downloadVisible = true;
menuDownload.setVisible(true); menuDownload.setVisible(true);
} }
if (currentStory.canReply() && menuDm != null) { if (currentStory.getCanReply() && menuDm != null) {
dmVisible = true; dmVisible = true;
menuDm.setVisible(true); menuDm.setVisible(true);
} }
@ -1041,7 +1041,7 @@ public class StoryViewerFragment extends Fragment {
downloadVisible = true; downloadVisible = true;
menuDownload.setVisible(true); menuDownload.setVisible(true);
} }
if (currentStory.canReply() && menuDm != null) { if (currentStory.getCanReply() && menuDm != null) {
dmVisible = true; dmVisible = true;
menuDm.setVisible(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; data class StoryModel(
import awais.instagrabber.models.stickers.PollModel; val storyMediaId: String?,
import awais.instagrabber.models.stickers.QuestionModel; val storyUrl: String?,
import awais.instagrabber.models.stickers.QuizModel; var thumbnail: String?,
import awais.instagrabber.models.stickers.SliderModel; val itemType: MediaItemType?,
import awais.instagrabber.models.stickers.SwipeUpModel; val timestamp: Long,
val username: String?,
public final class StoryModel implements Serializable { val userId: Long,
private final String storyMediaId; val canReply: Boolean
private final String storyUrl; ) : Serializable {
private String thumbnail; var videoUrl: String? = null
private final String username; var tappableShortCode: String? = null
private final long userId; val tappableId: String? = null
private final MediaItemType itemType; var spotify: String? = null
private final long timestamp; var poll: PollModel? = null
private String videoUrl; var question: QuestionModel? = null
private String tappableShortCode; var slider: SliderModel? = null
private String tappableId; var quiz: QuizModel? = null
private String spotify; var swipeUp: SwipeUpModel? = null
private PollModel poll; var mentions: Array<String>? = null
private QuestionModel question; var position = 0
private SliderModel slider; var isCurrentSlide = false
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;
}
} }

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"), TEXT("text"),
REACTION("reaction"), REACTION("reaction"),
REELSHARE("reel_share"), REELSHARE("reel_share"),
@ -9,15 +9,5 @@ public enum BroadcastItemType {
VIDEO("configure_video"), VIDEO("configure_video"),
VOICE("share_voice"), VOICE("share_voice"),
ANIMATED_MEDIA("animated_media"), ANIMATED_MEDIA("animated_media"),
MEDIA_SHARE("media_share"); MEDIA_SHARE("media_share"),
private final String value;
BroadcastItemType(final String value) {
this.value = value;
}
public String getValue() {
return value;
}
} }

View File

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

View File

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

View File

@ -1,11 +1,8 @@
package awais.instagrabber.models.enums; package awais.instagrabber.models.enums
import java.io.Serializable; import java.io.Serializable
import java.util.HashMap;
import java.util.Map;
public enum NotificationType implements Serializable { enum class NotificationType(val itemType: Int) : Serializable {
// story_type
LIKE(60), LIKE(60),
FOLLOW(101), FOLLOW(101),
COMMENT(12), // NOT TESTED COMMENT(12), // NOT TESTED
@ -15,27 +12,20 @@ public enum NotificationType implements Serializable {
TAGGED_COMMENT(14), TAGGED_COMMENT(14),
RESPONDED_STORY(213), RESPONDED_STORY(213),
REQUEST(75), REQUEST(75),
// aymf - arbitrary, misspelled as ayml but eh
AYML(9999); AYML(9999);
private final int itemType; companion object {
private static final Map<Integer, NotificationType> map = new HashMap<>(); private val map: MutableMap<Int, NotificationType> = mutableMapOf()
static { @JvmStatic
for (NotificationType type : NotificationType.values()) { fun valueOfType(itemType: Int): NotificationType? {
map.put(type.itemType, type); return map[itemType]
}
} }
NotificationType(final int itemType) { init {
this.itemType = itemType; for (type in values()) {
} map[type.itemType] = type
}
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 { enum class PostItemType : Serializable {
MAIN, MAIN, DISCOVER, FEED, SAVED, COLLECTION, LIKED, TAGGED, HASHTAG, LOCATION
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 { enum class SuggestionType {
TYPE_USER, TYPE_USER, TYPE_HASHTAG, TYPE_LOCATION
TYPE_HASHTAG,
TYPE_LOCATION
} }