mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-08 07:57:28 +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
|
@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
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user