1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 14:47:29 +00:00
This commit is contained in:
Ammar Githam 2021-03-29 23:02:42 +09:00
parent 7dc9583e51
commit 4507d8b588
2 changed files with 15 additions and 2 deletions

View File

@ -146,7 +146,12 @@ public final class DirectItemsAdapter extends RecyclerView.Adapter<RecyclerView.
@NonNull @NonNull
private DirectItemViewHolder getItemViewHolder(final LayoutInflater layoutInflater, private DirectItemViewHolder getItemViewHolder(final LayoutInflater layoutInflater,
final LayoutDmBaseBinding baseBinding, final LayoutDmBaseBinding baseBinding,
@NonNull final DirectItemType directItemType) { final DirectItemType directItemType) {
if (directItemType == null) {
// For unknown dm types
final LayoutDmTextBinding binding = LayoutDmTextBinding.inflate(layoutInflater, baseBinding.message, false);
return new DirectItemDefaultViewHolder(baseBinding, binding, currentUser, thread, callback);
}
switch (directItemType) { switch (directItemType) {
case TEXT: { case TEXT: {
final LayoutDmTextBinding binding = LayoutDmTextBinding.inflate(layoutInflater, baseBinding.message, false); final LayoutDmTextBinding binding = LayoutDmTextBinding.inflate(layoutInflater, baseBinding.message, false);
@ -240,7 +245,11 @@ public final class DirectItemsAdapter extends RecyclerView.Adapter<RecyclerView.
if (itemOrHeader.isHeader()) { if (itemOrHeader.isHeader()) {
return -1; return -1;
} }
return itemOrHeader.item.getItemType().getId(); final DirectItemType itemType = itemOrHeader.item.getItemType();
if (itemType == null) {
return 0;
}
return itemType.getId();
} }
@Override @Override

View File

@ -1,5 +1,7 @@
package awais.instagrabber.models.enums; package awais.instagrabber.models.enums;
import androidx.annotation.Nullable;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.io.Serializable; import java.io.Serializable;
@ -59,7 +61,9 @@ public enum DirectItemType implements Serializable {
return id; return id;
} }
@Nullable
public static DirectItemType valueOf(final int id) { public static DirectItemType valueOf(final int id) {
if (!map.containsKey(id)) return null;
return map.get(id); return map.get(id);
} }