Pre Caching LayoutManager for RecyclerView

PreCachingLayoutManager.java

public class PreCachingLayoutManager extends LinearLayoutManager {
    private static final int DEFAULT_EXTRA_LAYOUT_SPACE = 600;
    private int extraLayoutSpace = -1;
    private Context context;
 
    public PreCachingLayoutManager(Context context) {
        super(context);
        this.context = context;
    }
 
    public PreCachingLayoutManager(Context context, int extraLayoutSpace) {
        super(context);
        this.context = context;
        this.extraLayoutSpace = extraLayoutSpace;
    }
 
    public PreCachingLayoutManager(Context context, int orientation, boolean reverseLayout) {
        super(context, orientation, reverseLayout);
        this.context = context;
    }
 
    public void setExtraLayoutSpace(int extraLayoutSpace) {
        this.extraLayoutSpace = extraLayoutSpace;
    }
 
    @Override
    protected int getExtraLayoutSpace(RecyclerView.State state) {
        if (extraLayoutSpace > 0) {
            return extraLayoutSpace;
        }
        return DEFAULT_EXTRA_LAYOUT_SPACE;
    }
}

References
https://androiddevx.wordpress.com/2014/12/05/recycler-view-pre-cache-views/

Working with Glide, Image Loader Library for Android

build.gradle

repositories {
  mavenCentral() // jcenter() works as well because it pulls from Maven Central
}

dependencies {
  compile 'com.github.bumptech.glide:glide:4.0.0'
  compile 'com.android.support:support-v4:25.3.1'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
}

ProGaurd

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

# for DexGuard only
-keepresourcexmlelements manifest/application/meta-data@value=GlideModule

Generated API

MyAppGlideModule.java

package com.example.myapp;
   
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
   
@GlideModule
public final class MyAppGlideModule extends AppGlideModule {}

Kotlin

apply plugin: 'kotlin-kapt'
kapt 'com.github.bumptech.glide:compiler:4.0.0'

Use :

            GlideApp.with(context)
                    .load(image.getFile())
                    .override(measuredWidth,measuredWidth)
                    .centerCrop()
                    .placeholder(context.getResources().getDrawable(R.mipmap.image_placeholder))
                    .into(holder.imageViewThumbnail);

References
http://bumptech.github.io/glide/
https://github.com/bumptech/glide
http://bumptech.github.io/glide/doc/generatedapi.html
https://inthecheesefactory.com/blog/get-to-know-glide-recommended-by-google/en