Masterminds / glide

Package Management for Golang
https://glide.sh
Other
8.15k stars 540 forks source link

How can I obtain the origin reference of the cached File? #954

Open RafaRuiz opened 6 years ago

RafaRuiz commented 6 years ago

Hello, I'm making a function that deletes images that are 5 days old through File.getLastModified()

The way I'm loading an image is this one

Glide.with(getContext())
        /**
         * Save in cache, but we say to load it from cache. Otherwise it will throw an error
         */
        .setDefaultRequestOptions(defaultDiskStrategy()
                .onlyRetrieveFromCache(true))
        .load(cachedSplashScreenUri)
        .listener(object : RequestListener<Drawable> {
            override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
                /**
                 * And when that error is thrown, we preload the image for the next time.
                 */
                splashActivityViewPresenter.showLogo()
                loadImageInCache(cachedSplashScreenUri)
                return true
            }

            override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
                /**
                 * TODO I need to know what's the File coming from
                 */
                return false
            }
        })
        .into(mainIV)

I tried .asFile() but I get an exception so I can't get the resource as File. I would like to have that File to modify the lastModified variable inside.

How can I do that?

cooppor commented 6 years ago

@RafaRuiz the glide is not your android glide lib, this is Vendor Package Management for Golang.