<p dir="auto"><strong>Glide Version</strong>: glide:3.7.0</p>

<p dir="auto"><strong>Integration libraries</strong>: none</p>

<p dir="auto"><strong>Device/Android Version</strong>: Galaxy Note3/SM-N9500 5.0</p>

<p dir="auto"><strong>Issue details / Repro steps / Use case background</strong>: Glide load images in disorder.</p>

<p dir="auto"><strong>Glide load line / <code class="notranslate">GlideModule</code> (if any) / list Adapter code (if any)</strong>:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="public class MyGlideModule implements GlideModule {

    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        MemorySizeCalculator calculator = new MemorySizeCalculator(context);
        int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
        int defaultBitmapPoolSize = calculator.getBitmapPoolSize();

        int customMemoryCacheSize = (int) (0.3 * defaultMemoryCacheSize);
        int customBitmapPoolSize = (int) (0.3 * defaultBitmapPoolSize);

        builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
        builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));
    }

    @Override
    public void registerComponents(Context context, Glide glide) {
    }
}"><pre class="notranslate"><span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-smi">MyGlideModule</span> <span class="pl-k">implements</span> <span class="pl-smi">GlideModule</span> {

    <span class="pl-c1">@</span><span class="pl-c1">Override</span>
    <span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">applyOptions</span>(<span class="pl-smi">Context</span> <span class="pl-s1">context</span>, <span class="pl-smi">GlideBuilder</span> <span class="pl-s1">builder</span>) {
        <span class="pl-smi">MemorySizeCalculator</span> <span class="pl-s1">calculator</span> = <span class="pl-k">new</span> <span class="pl-smi">MemorySizeCalculator</span>(<span class="pl-s1">context</span>);
        <span class="pl-smi">int</span> <span class="pl-s1">defaultMemoryCacheSize</span> = <span class="pl-s1">calculator</span>.<span class="pl-en">getMemoryCacheSize</span>();
        <span class="pl-smi">int</span> <span class="pl-s1">defaultBitmapPoolSize</span> = <span class="pl-s1">calculator</span>.<span class="pl-en">getBitmapPoolSize</span>();

        <span class="pl-smi">int</span> <span class="pl-s1">customMemoryCacheSize</span> = (<span class="pl-smi">int</span>) (<span class="pl-c1">0.3</span> * <span class="pl-s1">defaultMemoryCacheSize</span>);
        <span class="pl-smi">int</span> <span class="pl-s1">customBitmapPoolSize</span> = (<span class="pl-smi">int</span>) (<span class="pl-c1">0.3</span> * <span class="pl-s1">defaultBitmapPoolSize</span>);

        <span class="pl-s1">builder</span>.<span class="pl-en">setMemoryCache</span>(<span class="pl-k">new</span> <span class="pl-smi">LruResourceCache</span>(<span class="pl-s1">customMemoryCacheSize</span>));
        <span class="pl-s1">builder</span>.<span class="pl-en">setBitmapPool</span>(<span class="pl-k">new</span> <span class="pl-smi">LruBitmapPool</span>(<span class="pl-s1">customBitmapPoolSize</span>));
    }

    <span class="pl-c1">@</span><span class="pl-c1">Override</span>
    <span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">registerComponents</span>(<span class="pl-smi">Context</span> <span class="pl-s1">context</span>, <span class="pl-smi">Glide</span> <span class="pl-s1">glide</span>) {
    }
}</pre></div>

<p dir="auto"><strong>Layout XML</strong>:</p>
<div class="highlight highlight-text-xml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:background=&quot;@drawable/list_bg&quot;
    android:orientation=&quot;horizontal&quot;&gt;

    &lt;TextView
        android:id=&quot;@+id/tv_rank&quot;
        android:layout_width=&quot;50dp&quot;
        android:layout_height=&quot;match_parent&quot;
        android:gravity=&quot;center&quot; /&gt;

    &lt;ImageView
        android:id=&quot;@+id/iv_logo&quot;
        android:layout_width=&quot;60dp&quot;
        android:layout_height=&quot;50dp&quot;
        android:layout_margin=&quot;5dp&quot;
        android:contentDescription=&quot;@string/app_name&quot; /&gt;

    &lt;TextView
        android:id=&quot;@+id/tv_name&quot;
        android:layout_width=&quot;100dp&quot;
        android:layout_height=&quot;match_parent&quot;
        android:gravity=&quot;center&quot; /&gt;

&lt;/LinearLayout&gt;"><pre class="notranslate">&lt;?<span class="pl-ent">xml</span><span class="pl-e"> version</span>=<span class="pl-s"><span class="pl-pds">"</span>1.0<span class="pl-pds">"</span></span><span class="pl-e"> encoding</span>=<span class="pl-s"><span class="pl-pds">"</span>utf-8<span class="pl-pds">"</span></span>?&gt;
&lt;<span class="pl-ent">LinearLayout</span> <span class="pl-e">xmlns</span><span class="pl-e">:</span><span class="pl-e">android</span>=<span class="pl-s"><span class="pl-pds">"</span>http://schemas.android.com/apk/res/android<span class="pl-pds">"</span></span>
    <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>match_parent<span class="pl-pds">"</span></span>
    <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>wrap_content<span class="pl-pds">"</span></span>
    <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">background</span>=<span class="pl-s"><span class="pl-pds">"</span>@drawable/list_bg<span class="pl-pds">"</span></span>
    <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">orientation</span>=<span class="pl-s"><span class="pl-pds">"</span>horizontal<span class="pl-pds">"</span></span>&gt;

    &lt;<span class="pl-ent">TextView</span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">"</span>@+id/tv_rank<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>50dp<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>match_parent<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">gravity</span>=<span class="pl-s"><span class="pl-pds">"</span>center<span class="pl-pds">"</span></span> /&gt;

    &lt;<span class="pl-ent">ImageView</span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">"</span>@+id/iv_logo<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>60dp<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>50dp<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_margin</span>=<span class="pl-s"><span class="pl-pds">"</span>5dp<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">contentDescription</span>=<span class="pl-s"><span class="pl-pds">"</span>@string/app_name<span class="pl-pds">"</span></span> /&gt;

    &lt;<span class="pl-ent">TextView</span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">"</span>@+id/tv_name<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>100dp<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>match_parent<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">gravity</span>=<span class="pl-s"><span class="pl-pds">"</span>center<span class="pl-pds">"</span></span> /&gt;

&lt;/<span class="pl-ent">LinearLayout</span>&gt;</pre></div>

<p dir="auto"><strong>Stack trace / LogCat</strong>: none</p>

<p dir="auto">Glide load images in disorder when I use <code class="notranslate">MyGlideModule</code>.<br>
<a target="_blank" rel="noopener noreferrer" href="https://github.com/shangmingchao/GlideTest/blob/master/screenshots/screenshot_1.png?raw=true"><img src="https://github.com/shangmingchao/GlideTest/blob/master/screenshots/screenshot_1.png?raw=true" alt="disorder" style="max-width: 100%;"></a><br>
Is there something wrong?<br>
it's not happened without using <code class="notranslate">MyGlideModule</code> or in the Galaxy S4 device.<br>
Here is the <a href="https://github.com/shangmingchao/GlideTest">Repo</a>.</p>
<p dir="auto">In my app, I have a Recycler view with GridLayoutManager. The code I am using to load images bindImage method of recycler view adapter:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@Override
public void onBindViewHolder(ImageViewHolder holder, int position) {
    GSImage dbImage = mLandscapeImagesList.get(position);
    File imageFile = new File(mImageDirectoryFile, dbImage.getImageName());

    Glide.with(MyImageFragement.this).load(imageFile).centerCrop().into(holder.imageView);

    int indexInSelectedImagesSet = mSelectedLandscapeImages.indexOf(dbImage);
    if (indexInSelectedImagesSet&gt;-1){
        holder.itemView.setSelected(true);
    } else {
        holder.itemView.setSelected(false);
    }

}"><pre class="notranslate"><span class="pl-c1">@</span><span class="pl-c1">Override</span>
<span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-s1">onBindViewHolder</span>(<span class="pl-smi">ImageViewHolder</span> <span class="pl-s1">holder</span>, <span class="pl-smi">int</span> <span class="pl-s1">position</span>) {
    <span class="pl-smi">GSImage</span> <span class="pl-s1">dbImage</span> = <span class="pl-s1">mLandscapeImagesList</span>.<span class="pl-en">get</span>(<span class="pl-s1">position</span>);
    <span class="pl-smi">File</span> <span class="pl-s1">imageFile</span> = <span class="pl-k">new</span> <span class="pl-smi">File</span>(<span class="pl-s1">mImageDirectoryFile</span>, <span class="pl-s1">dbImage</span>.<span class="pl-en">getImageName</span>());

    <span class="pl-smi">Glide</span>.<span class="pl-en">with</span>(<span class="pl-smi">MyImageFragement</span>.<span class="pl-smi">this</span>).<span class="pl-en">load</span>(<span class="pl-s1">imageFile</span>).<span class="pl-en">centerCrop</span>().<span class="pl-en">into</span>(<span class="pl-s1">holder</span>.<span class="pl-s1">imageView</span>);

    <span class="pl-smi">int</span> <span class="pl-s1">indexInSelectedImagesSet</span> = <span class="pl-s1">mSelectedLandscapeImages</span>.<span class="pl-en">indexOf</span>(<span class="pl-s1">dbImage</span>);
    <span class="pl-k">if</span> (<span class="pl-s1">indexInSelectedImagesSet</span>&gt;-<span class="pl-c1">1</span>){
        <span class="pl-s1">holder</span>.<span class="pl-s1">itemView</span>.<span class="pl-en">setSelected</span>(<span class="pl-c1">true</span>);
    } <span class="pl-k">else</span> {
        <span class="pl-s1">holder</span>.<span class="pl-s1">itemView</span>.<span class="pl-en">setSelected</span>(<span class="pl-c1">false</span>);
    }

}</pre></div>
<p dir="auto">The Cell layout I am using is:</p>
<div class="highlight highlight-text-xml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
     xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:background=&quot;@drawable/images_background&quot;
      android:layout_marginTop=&quot;9dp&quot;
      android:layout_marginLeft=&quot;10dp&quot;
      android:layout_marginRight=&quot;0dp&quot;
      android:layout_marginBottom=&quot;0dp&quot;
      android:padding=&quot;2dp&quot;&gt;

      &lt;com.gaurav.myProject.commons.AspectRatioImageView
                 android:id=&quot;@+id/image_thumb&quot;
                 android:layout_width=&quot;match_parent&quot;
                 android:layout_height=&quot;wrap_content&quot;
                 android:scaleType=&quot;fitXY&quot;
                 app:viewAspectRatio=&quot;1.33&quot;/&gt;

&lt;/RelativeLayout&gt;"><pre class="notranslate">&lt;?<span class="pl-ent">xml</span><span class="pl-e"> version</span>=<span class="pl-s"><span class="pl-pds">"</span>1.0<span class="pl-pds">"</span></span><span class="pl-e"> encoding</span>=<span class="pl-s"><span class="pl-pds">"</span>utf-8<span class="pl-pds">"</span></span>?&gt;
&lt;<span class="pl-ent">RelativeLayout</span> <span class="pl-e">xmlns</span><span class="pl-e">:</span><span class="pl-e">android</span>=<span class="pl-s"><span class="pl-pds">"</span>http://schemas.android.com/apk/res/android<span class="pl-pds">"</span></span>
     <span class="pl-e">xmlns</span><span class="pl-e">:</span><span class="pl-e">app</span>=<span class="pl-s"><span class="pl-pds">"</span>http://schemas.android.com/apk/res-auto<span class="pl-pds">"</span></span>
      <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>wrap_content<span class="pl-pds">"</span></span>
      <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>wrap_content<span class="pl-pds">"</span></span>
      <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">background</span>=<span class="pl-s"><span class="pl-pds">"</span>@drawable/images_background<span class="pl-pds">"</span></span>
      <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_marginTop</span>=<span class="pl-s"><span class="pl-pds">"</span>9dp<span class="pl-pds">"</span></span>
      <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_marginLeft</span>=<span class="pl-s"><span class="pl-pds">"</span>10dp<span class="pl-pds">"</span></span>
      <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_marginRight</span>=<span class="pl-s"><span class="pl-pds">"</span>0dp<span class="pl-pds">"</span></span>
      <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_marginBottom</span>=<span class="pl-s"><span class="pl-pds">"</span>0dp<span class="pl-pds">"</span></span>
      <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">padding</span>=<span class="pl-s"><span class="pl-pds">"</span>2dp<span class="pl-pds">"</span></span>&gt;

      &lt;<span class="pl-ent">com</span>.gaurav.myProject.commons.AspectRatioImageView
                 <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">"</span>@+id/image_thumb<span class="pl-pds">"</span></span>
                 <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>match_parent<span class="pl-pds">"</span></span>
                 <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>wrap_content<span class="pl-pds">"</span></span>
                 <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">scaleType</span>=<span class="pl-s"><span class="pl-pds">"</span>fitXY<span class="pl-pds">"</span></span>
                 <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">viewAspectRatio</span>=<span class="pl-s"><span class="pl-pds">"</span>1.33<span class="pl-pds">"</span></span>/&gt;

&lt;/<span class="pl-ent">RelativeLayout</span>&gt;</pre></div>
<p dir="auto">Here AspectRatioImageView(subclass of ImageView) automatically resizes the height of image view according to the provided aspect ratio.</p>
<p dir="auto">The above code is working fine on my devices (Xiaomi MiPad, ViewSonic Tablet, Android emaulators and Samsung Galaxy S3) but is not working correctly on my client's device (Samsung 10.1 inch tablet).<br>
In his end, images are being duplicated in the recycler grid. Also the the duplicates mostly occurs in adjacent recycler grid positions. I can't share any code as I even unable to reproduce the issue on my devices.</p>
<p dir="auto">Do you guys have any idea what could the cause of this? Can you please suggest me any thing that I can try?</p>
<p dir="auto">Thanks</p>