From ac770877ee66633eabb194ae61b458a97ae1af0d Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Mon, 6 Jul 2020 14:16:19 -0400 Subject: [PATCH] v16.6-a6 fix bug related to "Gone" thumbnail --- .../java/awais/instagrabber/adapters/PostsAdapter.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/awais/instagrabber/adapters/PostsAdapter.java b/app/src/main/java/awais/instagrabber/adapters/PostsAdapter.java index 4fb4598f..0098d86e 100755 --- a/app/src/main/java/awais/instagrabber/adapters/PostsAdapter.java +++ b/app/src/main/java/awais/instagrabber/adapters/PostsAdapter.java @@ -16,6 +16,8 @@ import com.bumptech.glide.load.engine.GlideException; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.Target; +import java.net.HttpURLConnection; +import java.net.URL; import java.util.ArrayList; import awais.instagrabber.R; @@ -78,7 +80,11 @@ public final class PostsAdapter extends RecyclerView.Adapter { @Override public boolean onLoadFailed(@Nullable final GlideException e, final Object model, final Target target, final boolean isFirstResource) { holder.progressView.setVisibility(View.GONE); - glideRequestManager.load(postModel.getDisplayUrl()).into(holder.postImage); + final HttpURLConnection conn = (HttpURLConnection) new URL(postModel.getDisplayUrl()).openConnection(); + conn.setUseCaches(false); + conn.connect(); + if (conn.getResponseCode() != HttpURLConnection.HTTP_GONE) + glideRequestManager.load(postModel.getDisplayUrl()).into(holder.postImage); return false; } }).into(holder.postImage);