Closed EGOISTK21 closed 7 years ago
guarantee in the API that getFirstFrame will return a non-null Bitmap.
Wups: There's no guarantee in the API that getFirstFrame will return a non-null Bitmap.
but it works well in Glide 3.7.0
@sjudd in what situations will the first frame be null?
The first frame is cleared after its displayed once. The API only exists as hack to allow us to have something to show during an animation. For example if you specify a cross fade and the GifDrawable hasn't loaded a frame yet, the cross fade will run from your placeholder to nothing. Keeping track of the first frame until the second frame is loaded lets us animate correctly without the extra memory overhead of keeping the first frame in memory for the life of the request.
Because the first frame is cleared after the second frame is loaded, it's basically never safe to assume that it's non-null.
Ah understood. I have a usecase where I want to tint my screen's colors according to the image. This works fine for static images, but for GIFs the first frame is occasionally null. Is there a better way to do this?
Glide Version: 4.0.0-RC1
Integration libraries: I load a local file.
Device/Android Version: Nexus 5X 7.1.2
Issue details / Repro steps / Use case background: Fail to get the firstFrame of a gif when I load it at second time.
When I get a gif path like "/storage/emulated/0/bluetooth/giphy.gif", I load it with as a gifDrawable and into an ImageView viewTarget(com.bumptech.glide.request.target.ViewTarget). Then I get its firstFrame, it works at the first time. But when I load from the same path secondly, the firstFrame is null.
Glide load line /
GlideModule
(if any) / list Adapter code (if any):Layout XML:
title_main.xml
activity_main.xml
activity_main.xml (land)
Stack trace / LogCat: