mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-12 17:57:29 +00:00
convert some to kotlin
This commit is contained in:
parent
7cf659c4f5
commit
d532d28ac3
@ -139,7 +139,7 @@ public final class DirectItemsAdapter extends RecyclerView.Adapter<RecyclerView.
|
||||
return new HeaderViewHolder(LayoutDmHeaderBinding.inflate(layoutInflater, parent, false));
|
||||
}
|
||||
final LayoutDmBaseBinding baseBinding = LayoutDmBaseBinding.inflate(layoutInflater, parent, false);
|
||||
final DirectItemType directItemType = DirectItemType.valueOf(type);
|
||||
final DirectItemType directItemType = DirectItemType.Companion.getId(type);
|
||||
final DirectItemViewHolder itemViewHolder = getItemViewHolder(layoutInflater, baseBinding, directItemType);
|
||||
itemViewHolder.setLongClickListener(longClickListener);
|
||||
return itemViewHolder;
|
||||
|
@ -10,6 +10,7 @@ import androidx.lifecycle.Transformations.distinctUntilChanged
|
||||
import androidx.lifecycle.Transformations.map
|
||||
import awais.instagrabber.R
|
||||
import awais.instagrabber.customviews.emoji.Emoji
|
||||
import awais.instagrabber.models.enums.DirectItemType.Companion.getName
|
||||
import awais.instagrabber.models.Resource
|
||||
import awais.instagrabber.models.Resource.Companion.error
|
||||
import awais.instagrabber.models.Resource.Companion.loading
|
||||
@ -645,7 +646,7 @@ class ThreadManager private constructor(
|
||||
data.postValue(error("item type is null", null))
|
||||
return data
|
||||
}
|
||||
val itemTypeName = itemType.getName()
|
||||
val itemTypeName = getName(itemType)
|
||||
if (itemTypeName == null) {
|
||||
Log.e(TAG, "forward: itemTypeName was null!")
|
||||
data.postValue(error("itemTypeName is null", null))
|
||||
|
@ -1,12 +1,11 @@
|
||||
package awais.instagrabber.models.enums;
|
||||
package awais.instagrabber.models.enums
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.io.Serializable
|
||||
import java.util.*
|
||||
|
||||
public enum DirectItemType implements Serializable {
|
||||
enum class DirectItemType(val id: Int) : Serializable {
|
||||
UNKNOWN(0),
|
||||
@SerializedName("text")
|
||||
TEXT(1),
|
||||
@ -45,65 +44,42 @@ public enum DirectItemType implements Serializable {
|
||||
@SerializedName("xma")
|
||||
XMA(18); // self avatar stickers
|
||||
|
||||
private final int id;
|
||||
private static final Map<Integer, DirectItemType> map = new HashMap<>();
|
||||
companion object {
|
||||
private val map: MutableMap<Int, DirectItemType> = 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);
|
||||
}
|
||||
|
||||
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";
|
||||
@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
|
||||
}
|
||||
|
||||
init {
|
||||
for (type in DirectItemType.values()) {
|
||||
map[type.id] = type
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -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")
|
||||
|
@ -1,5 +0,0 @@
|
||||
package awais.instagrabber.models.enums
|
||||
|
||||
enum class SuggestionType {
|
||||
TYPE_USER, TYPE_HASHTAG, TYPE_LOCATION
|
||||
}
|
Loading…
Reference in New Issue
Block a user