Panczur Panczur - 1 year ago 128
Android Question

Andorid, Glide shows wrong image for about one second

So, I'm using Glide library for loading images from URL, which i get from Graph Request (Facebook). It's used in RecyclerAdapter. When i'm scrolling, each ImageView shows wrong picture for about less than one second, then correct one. Here is the code:

public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {

ImageView main_image = viewHolder.main_image,

getEventCover(position, main_image);


private void getEventCover(int position, final ImageView img){

GraphRequest request = GraphRequest.newGraphPathRequest(
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {

JSONObject data = response.getJSONObject();

try {
JSONObject cover = data.getJSONObject("cover");
String source = cover.getString("source");


} catch (JSONException e) {

Bundle parameters = new Bundle();
parameters.putString("fields", "cover");

Answer Source

Your "problem" is that the ImageViews you are using are recycled from previous rows (which are disappearing while scrolling). Thus your ImageView in onBindViewHolder already contains a previous image.

This image is displayed until the network requests (GraphRequest and Glide) for the new image are finished.

To avoid the problem you have to clear your ImageView before calling getEventCover. This can be done by setting an placeholder image or by setting a transparent image as follows:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download