mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 14:47: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));
|
return new HeaderViewHolder(LayoutDmHeaderBinding.inflate(layoutInflater, parent, false));
|
||||||
}
|
}
|
||||||
final LayoutDmBaseBinding baseBinding = LayoutDmBaseBinding.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);
|
final DirectItemViewHolder itemViewHolder = getItemViewHolder(layoutInflater, baseBinding, directItemType);
|
||||||
itemViewHolder.setLongClickListener(longClickListener);
|
itemViewHolder.setLongClickListener(longClickListener);
|
||||||
return itemViewHolder;
|
return itemViewHolder;
|
||||||
|
@ -10,6 +10,7 @@ import androidx.lifecycle.Transformations.distinctUntilChanged
|
|||||||
import androidx.lifecycle.Transformations.map
|
import androidx.lifecycle.Transformations.map
|
||||||
import awais.instagrabber.R
|
import awais.instagrabber.R
|
||||||
import awais.instagrabber.customviews.emoji.Emoji
|
import awais.instagrabber.customviews.emoji.Emoji
|
||||||
|
import awais.instagrabber.models.enums.DirectItemType.Companion.getName
|
||||||
import awais.instagrabber.models.Resource
|
import awais.instagrabber.models.Resource
|
||||||
import awais.instagrabber.models.Resource.Companion.error
|
import awais.instagrabber.models.Resource.Companion.error
|
||||||
import awais.instagrabber.models.Resource.Companion.loading
|
import awais.instagrabber.models.Resource.Companion.loading
|
||||||
@ -645,7 +646,7 @@ class ThreadManager private constructor(
|
|||||||
data.postValue(error("item type is null", null))
|
data.postValue(error("item type is null", null))
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
val itemTypeName = itemType.getName()
|
val itemTypeName = getName(itemType)
|
||||||
if (itemTypeName == null) {
|
if (itemTypeName == null) {
|
||||||
Log.e(TAG, "forward: itemTypeName was null!")
|
Log.e(TAG, "forward: itemTypeName was null!")
|
||||||
data.postValue(error("itemTypeName is null", 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.io.Serializable
|
||||||
import java.util.HashMap;
|
import java.util.*
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public enum DirectItemType implements Serializable {
|
enum class DirectItemType(val id: Int) : Serializable {
|
||||||
UNKNOWN(0),
|
UNKNOWN(0),
|
||||||
@SerializedName("text")
|
@SerializedName("text")
|
||||||
TEXT(1),
|
TEXT(1),
|
||||||
@ -45,65 +44,42 @@ public enum DirectItemType implements Serializable {
|
|||||||
@SerializedName("xma")
|
@SerializedName("xma")
|
||||||
XMA(18); // self avatar stickers
|
XMA(18); // self avatar stickers
|
||||||
|
|
||||||
private final int id;
|
companion object {
|
||||||
private static final Map<Integer, DirectItemType> map = new HashMap<>();
|
private val map: MutableMap<Int, DirectItemType> = mutableMapOf()
|
||||||
|
|
||||||
static {
|
@JvmStatic
|
||||||
for (DirectItemType type : DirectItemType.values()) {
|
fun getId(id: Int): DirectItemType? {
|
||||||
map.put(type.id, type);
|
return map[id]
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectItemType(final int id) {
|
@JvmStatic
|
||||||
this.id = id;
|
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 int getId() {
|
init {
|
||||||
return id;
|
for (type in DirectItemType.values()) {
|
||||||
|
map[type.id] = type
|
||||||
}
|
}
|
||||||
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
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")
|
@SerializedName("permanent")
|
||||||
PERMANENT,
|
PERMANENT,
|
||||||
@SerializedName("replayable")
|
@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