1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-26 00:27:30 +00:00

Null check

This commit is contained in:
Ammar Githam 2021-05-23 17:11:12 +09:00
parent 7dc3732e3e
commit 7ca0d513dc

View File

@ -21,6 +21,7 @@ import awais.instagrabber.R;
import awais.instagrabber.adapters.FeedAdapterV2; import awais.instagrabber.adapters.FeedAdapterV2;
import awais.instagrabber.databinding.ItemFeedGridBinding; import awais.instagrabber.databinding.ItemFeedGridBinding;
import awais.instagrabber.models.PostsLayoutPreferences; import awais.instagrabber.models.PostsLayoutPreferences;
import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.Media;
import awais.instagrabber.repositories.responses.User; import awais.instagrabber.repositories.responses.User;
import awais.instagrabber.utils.DownloadUtils; import awais.instagrabber.utils.DownloadUtils;
@ -68,7 +69,9 @@ public class FeedGridItemViewHolder extends RecyclerView.ViewHolder {
setUserDetails(media, layoutPreferences); setUserDetails(media, layoutPreferences);
String thumbnailUrl = null; String thumbnailUrl = null;
final int typeIconRes; final int typeIconRes;
switch (media.getMediaType()) { final MediaItemType mediaType = media.getMediaType();
if (mediaType == null) return;
switch (mediaType) {
case MEDIA_TYPE_IMAGE: case MEDIA_TYPE_IMAGE:
typeIconRes = -1; typeIconRes = -1;
thumbnailUrl = ResponseBodyUtils.getThumbUrl(media); thumbnailUrl = ResponseBodyUtils.getThumbUrl(media);
@ -103,7 +106,7 @@ public class FeedGridItemViewHolder extends RecyclerView.ViewHolder {
binding.typeIcon.setImageResource(typeIconRes); binding.typeIcon.setImageResource(typeIconRes);
} }
final List<Boolean> checkList = DownloadUtils.checkDownloaded(media); final List<Boolean> checkList = DownloadUtils.checkDownloaded(media);
if (checkList == null || checkList.isEmpty()) { if (checkList.isEmpty()) {
return; return;
} }
switch (media.getMediaType()) { switch (media.getMediaType()) {