Browse Source

Convert to kotlin

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
7dc3732e3e
  1. 6
      app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java
  2. 194
      app/src/main/java/awais/instagrabber/models/StoryModel.kt
  3. 16
      app/src/main/java/awais/instagrabber/models/enums/BroadcastItemType.kt
  4. 4
      app/src/main/java/awais/instagrabber/models/enums/FavoriteType.kt
  5. 6
      app/src/main/java/awais/instagrabber/models/enums/IntentModelType.kt
  6. 32
      app/src/main/java/awais/instagrabber/models/enums/NotificationType.kt
  7. 16
      app/src/main/java/awais/instagrabber/models/enums/PostItemType.kt
  8. 8
      app/src/main/java/awais/instagrabber/models/enums/SuggestionType.kt

6
app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java

@ -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);
} }

194
app/src/main/java/awais/instagrabber/models/StoryModel.kt

@ -1,167 +1,29 @@
package awais.instagrabber.models;
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;
}
package awais.instagrabber.models
import awais.instagrabber.models.enums.MediaItemType
import awais.instagrabber.models.stickers.*
import java.io.Serializable
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
} }

16
app/src/main/java/awais/instagrabber/models/enums/BroadcastItemType.kt

@ -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");
private final String value;
BroadcastItemType(final String value) {
this.value = value;
}
public String getValue() {
return value;
}
MEDIA_SHARE("media_share"),
} }

4
app/src/main/java/awais/instagrabber/models/enums/FavoriteType.kt

@ -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,

6
app/src/main/java/awais/instagrabber/models/enums/IntentModelType.kt

@ -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,
} }

32
app/src/main/java/awais/instagrabber/models/enums/NotificationType.kt

@ -1,11 +1,8 @@
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), 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;
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]
} }
NotificationType(final int itemType) {
this.itemType = itemType;
init {
for (type in values()) {
map[type.itemType] = type
} }
public int getItemType() {
return itemType;
} }
public static NotificationType valueOfType(final int itemType) {
return map.get(itemType);
} }
} }

16
app/src/main/java/awais/instagrabber/models/enums/PostItemType.kt

@ -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
} }

8
app/src/main/java/awais/instagrabber/models/enums/SuggestionType.kt

@ -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
} }
Loading…
Cancel
Save