1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 06:37:30 +00:00

patch downloaded check

This commit is contained in:
Austin Huang 2021-06-21 23:42:14 -04:00
parent bf9d847e4b
commit 65624f0b42
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F

View File

@ -24,6 +24,7 @@ import awais.instagrabber.models.PostsLayoutPreferences;
import awais.instagrabber.models.enums.MediaItemType; 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.AppExecutors;
import awais.instagrabber.utils.DownloadUtils; import awais.instagrabber.utils.DownloadUtils;
import awais.instagrabber.utils.ResponseBodyUtils; import awais.instagrabber.utils.ResponseBodyUtils;
import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.TextUtils;
@ -105,28 +106,33 @@ public class FeedGridItemViewHolder extends RecyclerView.ViewHolder {
binding.typeIcon.setVisibility(View.VISIBLE); binding.typeIcon.setVisibility(View.VISIBLE);
binding.typeIcon.setImageResource(typeIconRes); binding.typeIcon.setImageResource(typeIconRes);
} }
final List<Boolean> checkList = DownloadUtils.checkDownloaded(media); binding.downloaded.setVisibility(View.GONE);
if (checkList.isEmpty()) { AppExecutors.INSTANCE.getTasksThread().execute(() -> {
return; final List<Boolean> checkList = DownloadUtils.checkDownloaded(media);
} if (checkList.isEmpty()) {
switch (media.getMediaType()) { return;
case MEDIA_TYPE_IMAGE: }
case MEDIA_TYPE_VIDEO: AppExecutors.INSTANCE.getMainThread().execute(() -> {
binding.downloaded.setVisibility(checkList.get(0) ? View.VISIBLE : View.GONE); switch (media.getMediaType()) {
binding.downloaded.setImageTintList(ColorStateList.valueOf(itemView.getResources().getColor(R.color.green_A400))); case MEDIA_TYPE_IMAGE:
break; case MEDIA_TYPE_VIDEO:
case MEDIA_TYPE_SLIDER: binding.downloaded.setVisibility(checkList.get(0) ? View.VISIBLE : View.GONE);
binding.downloaded.setVisibility(checkList.get(0) ? View.VISIBLE : View.GONE); binding.downloaded.setImageTintList(ColorStateList.valueOf(itemView.getResources().getColor(R.color.green_A400)));
final List<Media> carouselMedia = media.getCarouselMedia(); break;
boolean allDownloaded = checkList.size() == (carouselMedia == null ? 0 : carouselMedia.size()); case MEDIA_TYPE_SLIDER:
if (allDownloaded) { binding.downloaded.setVisibility(checkList.get(0) ? View.VISIBLE : View.GONE);
allDownloaded = checkList.stream().allMatch(downloaded -> downloaded); final List<Media> carouselMedia = media.getCarouselMedia();
boolean allDownloaded = checkList.size() == (carouselMedia == null ? 0 : carouselMedia.size());
if (allDownloaded) {
allDownloaded = checkList.stream().allMatch(downloaded -> downloaded);
}
binding.downloaded.setImageTintList(ColorStateList.valueOf(itemView.getResources().getColor(
allDownloaded ? R.color.green_A400 : R.color.yellow_400)));
break;
default:
} }
binding.downloaded.setImageTintList(ColorStateList.valueOf(itemView.getResources().getColor( });
allDownloaded ? R.color.green_A400 : R.color.yellow_400))); });
break;
default:
}
} }
private void setThumbImage(final String thumbnailUrl) { private void setThumbImage(final String thumbnailUrl) {