Created
March 27, 2019 11:29
-
-
Save mohamedagamy/51b62745be38093e358ea827cdff8fdc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://stackoverflow.com/questions/39374227/how-to-load-all-the-images-in-the-background-of-a-recyclerview-in-android | |
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment