mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 14:47:29 +00:00
Handle unknown dm types. Fixes the crash in https://github.com/austinhuang0131/barinsta/issues/891
This commit is contained in:
parent
7dc9583e51
commit
4507d8b588
@ -146,7 +146,12 @@ public final class DirectItemsAdapter extends RecyclerView.Adapter<RecyclerView.
|
||||
@NonNull
|
||||
private DirectItemViewHolder getItemViewHolder(final LayoutInflater layoutInflater,
|
||||
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) {
|
||||
case TEXT: {
|
||||
final LayoutDmTextBinding binding = LayoutDmTextBinding.inflate(layoutInflater, baseBinding.message, false);
|
||||
@ -240,7 +245,11 @@ public final class DirectItemsAdapter extends RecyclerView.Adapter<RecyclerView.
|
||||
if (itemOrHeader.isHeader()) {
|
||||
return -1;
|
||||
}
|
||||
return itemOrHeader.item.getItemType().getId();
|
||||
final DirectItemType itemType = itemOrHeader.item.getItemType();
|
||||
if (itemType == null) {
|
||||
return 0;
|
||||
}
|
||||
return itemType.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,7 @@
|
||||
package awais.instagrabber.models.enums;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -59,7 +61,9 @@ public enum DirectItemType implements Serializable {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static DirectItemType valueOf(final int id) {
|
||||
if (!map.containsKey(id)) return null;
|
||||
return map.get(id);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user