From d532d28ac3ca47eebcaa5e6c77d976650fea289c Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sun, 30 May 2021 20:51:54 -0400 Subject: [PATCH] convert some to kotlin --- .../adapters/DirectItemsAdapter.java | 2 +- .../instagrabber/managers/ThreadManager.kt | 3 +- .../models/enums/DirectItemType.kt | 98 +++++++------------ .../models/enums/RavenMediaViewMode.kt | 6 +- .../models/enums/SuggestionType.kt | 5 - 5 files changed, 43 insertions(+), 71 deletions(-) delete mode 100755 app/src/main/java/awais/instagrabber/models/enums/SuggestionType.kt diff --git a/app/src/main/java/awais/instagrabber/adapters/DirectItemsAdapter.java b/app/src/main/java/awais/instagrabber/adapters/DirectItemsAdapter.java index 444d4aa1..40624082 100644 --- a/app/src/main/java/awais/instagrabber/adapters/DirectItemsAdapter.java +++ b/app/src/main/java/awais/instagrabber/adapters/DirectItemsAdapter.java @@ -139,7 +139,7 @@ public final class DirectItemsAdapter extends RecyclerView.Adapter map = new HashMap<>(); + companion object { + private val map: MutableMap = mutableMapOf() - static { - for (DirectItemType type : DirectItemType.values()) { - map.put(type.id, type); + @JvmStatic + fun getId(id: Int): DirectItemType? { + return map[id] } - } - - DirectItemType(final int id) { - this.id = id; - } - public int getId() { - return id; - } - - public static DirectItemType valueOf(final int id) { - if (!map.containsKey(id)) return DirectItemType.UNKNOWN; - return map.get(id); - } + @JvmStatic + fun getName(directItemType: DirectItemType): String? { + when (directItemType) { + TEXT -> return "text" + LIKE -> return "like" + LINK -> return "link" + MEDIA -> return "media" + RAVEN_MEDIA -> return "raven_media" + PROFILE -> return "profile" + VIDEO_CALL_EVENT -> return "video_call_event" + ANIMATED_MEDIA -> return "animated_media" + VOICE_MEDIA -> return "voice_media" + MEDIA_SHARE -> return "media_share" + REEL_SHARE -> return "reel_share" + ACTION_LOG -> return "action_log" + PLACEHOLDER -> return "placeholder" + STORY_SHARE -> return "story_share" + CLIP -> return "clip" + FELIX_SHARE -> return "felix_share" + LOCATION -> return "location" + } + return null + } - public String getName() { - switch (this) { - case TEXT: - return "text"; - case LIKE: - return "like"; - case LINK: - return "link"; - case MEDIA: - return "media"; - case RAVEN_MEDIA: - return "raven_media"; - case PROFILE: - return "profile"; - case VIDEO_CALL_EVENT: - return "video_call_event"; - case ANIMATED_MEDIA: - return "animated_media"; - case VOICE_MEDIA: - return "voice_media"; - case MEDIA_SHARE: - return "media_share"; - case REEL_SHARE: - return "reel_share"; - case ACTION_LOG: - return "action_log"; - case PLACEHOLDER: - return "placeholder"; - case STORY_SHARE: - return "story_share"; - case CLIP: - return "clip"; - case FELIX_SHARE: - return "felix_share"; - case LOCATION: - return "location"; + init { + for (type in DirectItemType.values()) { + map[type.id] = type + } } - return null; } } \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/models/enums/RavenMediaViewMode.kt b/app/src/main/java/awais/instagrabber/models/enums/RavenMediaViewMode.kt index 75f8ca76..2707d2f0 100644 --- a/app/src/main/java/awais/instagrabber/models/enums/RavenMediaViewMode.kt +++ b/app/src/main/java/awais/instagrabber/models/enums/RavenMediaViewMode.kt @@ -1,8 +1,8 @@ -package awais.instagrabber.models.enums; +package awais.instagrabber.models.enums -import com.google.gson.annotations.SerializedName; +import com.google.gson.annotations.SerializedName -public enum RavenMediaViewMode { +enum class RavenMediaViewMode { @SerializedName("permanent") PERMANENT, @SerializedName("replayable") diff --git a/app/src/main/java/awais/instagrabber/models/enums/SuggestionType.kt b/app/src/main/java/awais/instagrabber/models/enums/SuggestionType.kt deleted file mode 100755 index e24f542c..00000000 --- a/app/src/main/java/awais/instagrabber/models/enums/SuggestionType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package awais.instagrabber.models.enums - -enum class SuggestionType { - TYPE_USER, TYPE_HASHTAG, TYPE_LOCATION -} \ No newline at end of file