Anders Anders - 2 years ago 210
Java Question

Using Glide, ArrayLists repeats itself in a ViewPager?

I am using Glide to load the images from

s into a Fragment containing
, everything works smooth but when I install the Application over again and again then the List of images start to repeat 2, 3 times in
i.e after last page of
it will start from first again for like 2, 3 times and repeat the list, and if i clear the application data by going to
then it gets fine, I tried skipping the
but its still same.

Not important but here is the part of my

.load((Integer) data.get(position))

What is the best approach to solve this issue? clearing cache on exit? or skipping both memory and disk cache?

Number of images is really large about 700, but size of images is not much i.e around 30kb to 50kb.

Answer Source

For anyone else having the same issue.

The drawable IDs may change on each compile, that's why we have the R class, and I was testing my debug build, and version code doesn't change between builds.

Glide uses VersionCodeSignature (see load(int) sources) to make sure what I experienced doesn't happen in real life, because Play Store forces you to change the version on each release.

So when we change the VersionCode Glide doesn't use the old cache and creates new cache for new build.

Hope it helps someone

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