{"action":"created","issue":{"url":"https://api.github.com/repos/bumptech/glide/issues/2218","repository_url":"https://api.github.com/repos/bumptech/glide","labels_url":"https://api.github.com/repos/bumptech/glide/issues/2218/labels{/name}","comments_url":"https://api.github.com/repos/bumptech/glide/issues/2218/comments","events_url":"https://api.github.com/repos/bumptech/glide/issues/2218/events","html_url":"https://github.com/bumptech/glide/issues/2218","id":248593345,"number":2218,"title":"Can not find the right cache file  when loading a gif image using DiskLruCache?","user":{"login":"miguoer","id":18592547,"avatar_url":"https://avatars1.githubusercontent.com/u/18592547?v=4","gravatar_id":"","url":"https://api.github.com/users/miguoer","html_url":"https://github.com/miguoer","followers_url":"https://api.github.com/users/miguoer/followers","following_url":"https://api.github.com/users/miguoer/following{/other_user}","gists_url":"https://api.github.com/users/miguoer/gists{/gist_id}","starred_url":"https://api.github.com/users/miguoer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miguoer/subscriptions","organizations_url":"https://api.github.com/users/miguoer/orgs","repos_url":"https://api.github.com/users/miguoer/repos","events_url":"https://api.github.com/users/miguoer/events{/privacy}","received_events_url":"https://api.github.com/users/miguoer/received_events","type":"User","site_admin":false},"labels":[{"id":46953960,"url":"https://api.github.com/repos/bumptech/glide/labels/question","name":"question","color":"d4c5f9","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-08-08T03:51:02Z","updated_at":"2017-11-19T00:42:25Z","closed_at":null,"author_association":"NONE","body":"Hello. I am using Glide to load some gif images. I use the DiskLruCache for caching. But each time when I finish the activity, and then re-start it, the diskcache for gif images doesn't work. \r\n\r\nI have checked the cache files at data/data/package_name/cache/image_manager_disk_cache. The gif images are in the folder. Then I checked the put and get method at class DiskLruCacheWrapper. I found that the safeKey from safeKeyGenerator.getSafeKey(key) is different from the safeKey  put into the cache. It really doubts me. Can you help me to figure out this problem?\r\n\r\nBy the way, each time when I create the acitivity, I preload the gif image. \r\n\r\n- my Glide config:\r\n```\r\n        RequestOptions mNormalOptions = new RequestOptions()\r\n                .fitCenter()\r\n                .priority(Priority.HIGH)\r\n                .diskCacheStrategy(DiskCacheStrategy.RESOURCE);\r\n```\r\n\r\n\r\n- my code:\r\n```\r\n        public void displayGifWithPlaceHolder(final Context mContext, final ImageView mImageView, final AnimateImageInfo mInfo) {\r\n        LogUtil.d(TAG, \"displayGifWithPlaceHolder: animateUrl=\" + mInfo.getAnimateImageUrl() + \", firstFrameUrl\" + mInfo.getFirstFrameImageUrl() + \", staticImageUrl\" + mInfo.getStaticImageUrl());\r\n        Glide.with(mContext)\r\n                .load(mInfo.getAnimateImageUrl())\r\n                .apply(mNormalOptions)\r\n                .into(new ImageViewTarget<Drawable>(mImageView) {\r\n                    @Override\r\n                    protected void setResource(@Nullable Drawable resource) {\r\n                    }\r\n\r\n                    @Override\r\n                    public void onLoadFailed(@Nullable Drawable errorDrawable) {\r\n                        LogUtil.d(TAG, \"Load animate image failed. Url is \" + mInfo.getAnimateImageUrl());\r\n                        Glide.with(mContext)\r\n                                .load(mInfo.getFirstFrameImageUrl())\r\n                                .apply(mNormalOptions)\r\n                                .into(new SimpleTarget<Drawable>() {\r\n                                    @Override\r\n                                    public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {\r\n                                        LogUtil.d(TAG, \"First frame image resource ready. Url is \" + mInfo.getFirstFrameImageUrl());\r\n                                        mImageView.setImageDrawable(resource);\r\n                                    }\r\n\r\n                                    @Override\r\n                                    public void onLoadFailed(@Nullable Drawable errorDrawable) {\r\n                                        LogUtil.d(TAG, \"Load first frame image failed. Url is \" + mInfo.getFirstFrameImageUrl());\r\n                                        Glide.with(mContext)\r\n                                                .load(mInfo.getStaticImageUrl())\r\n                                                .apply(mNormalOptions)\r\n                                                .into(new SimpleTarget<Drawable>() {\r\n                                                    @Override\r\n                                                    public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {\r\n                                                        mImageView.setImageDrawable(resource);\r\n                                                    }\r\n                                                });\r\n                                    }\r\n                                });\r\n                    }\r\n\r\n                    @Override\r\n                    public void onLoadStarted(@Nullable final Drawable placeholder) {\r\n                        LogUtil.d(TAG, \"start to load animate image \" + mInfo.getAnimateImageUrl());\r\n                        Glide.with(mContext)\r\n                                .load(mInfo.getFirstFrameImageUrl())\r\n                                .apply(mNormalOptions)\r\n                                .into(new SimpleTarget<Drawable>() {\r\n                                    @Override\r\n                                    public void onLoadStarted(@Nullable Drawable placeholder) {\r\n                                        LogUtil.d(TAG, \"Load static image as place holder when loading first frame image.\");\r\n                                        Glide.with(mContext)\r\n                                                .load(mInfo.getStaticImageUrl())\r\n                                                .apply(mNormalOptions)\r\n                                                .into(new SimpleTarget<Drawable>() {\r\n                                                    @Override\r\n                                                    public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {\r\n                                                        LogUtil.d(TAG, \"Static image resource ready. Url is \" + mInfo.getStaticImageUrl());\r\n                                                        if (!mInfo.isFirstFrameResourceReady()) {\r\n                                                            mImageView.setImageDrawable(resource);\r\n                                                        }\r\n                                                    }\r\n                                                });\r\n                                    }\r\n\r\n                                    @Override\r\n                                    public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {\r\n                                        LogUtil.d(TAG, \"First frame image resource ready. Url is \" + mInfo.getFirstFrameImageUrl());\r\n                                        mInfo.setFirstFrameResourceReady(true);\r\n                                        if ((mImageView.getDrawable() instanceof GifDrawable && ((GifDrawable) mImageView.getDrawable()).isRunning())) {\r\n                                            LogUtil.d(TAG, \"Gif is running. Don't load first frame image.\");\r\n                                            return;\r\n                                        }\r\n                                        if (mInfo.isAnimate() && !mInfo.isAutoPlay() && !mImageView.isSelected()) {\r\n                                            return;\r\n                                        }\r\n                                        mImageView.setImageDrawable(resource);\r\n                                    }\r\n\r\n                                    @Override\r\n                                    public void onLoadFailed(@Nullable Drawable errorDrawable) {\r\n                                        LogUtil.d(TAG, \"Load first frame image failed. Url is \" + mInfo.getFirstFrameImageUrl());\r\n                                        Glide.with(mContext)\r\n                                                .load(mInfo.getStaticImageUrl())\r\n                                                .apply(mNormalOptions)\r\n                                                .into(new SimpleTarget<Drawable>() {\r\n                                                    @Override\r\n                                                    public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {\r\n                                                        LogUtil.d(TAG, \"Static image resource ready. Url is \" + mInfo.getStaticImageUrl());\r\n                                                        mImageView.setImageDrawable(resource);\r\n                                                    }\r\n\r\n                                                    @Override\r\n                                                    public void onLoadFailed(@Nullable Drawable errorDrawable) {\r\n                                                        LogUtil.d(TAG, \"Load static image failed. Url is \" + mInfo.getStaticImageUrl());\r\n                                                    }\r\n                                                });\r\n                                    }\r\n\r\n                                });\r\n\r\n\r\n                    }\r\n\r\n                    @Override\r\n                    public void onResourceReady(Drawable resource, @Nullable Transition<? super Drawable> transition) {\r\n                        LogUtil.d(TAG, \"Animate image resource ready. Url is \" + mInfo.getAnimateImageUrl());\r\n                        if (resource instanceof GifDrawable) {\r\n                            mImageView.setImageDrawable(resource);\r\n                            ((GifDrawable) resource).start();\r\n                        }\r\n                    }\r\n                });\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/bumptech/glide/issues/comments/345482696","html_url":"https://github.com/bumptech/glide/issues/2218#issuecomment-345482696","issue_url":"https://api.github.com/repos/bumptech/glide/issues/2218","id":345482696,"user":{"login":"stale[bot]","id":26384082,"avatar_url":"https://avatars2.githubusercontent.com/u/26350515?v=4","gravatar_id":"","url":"https://api.github.com/users/stale%5Bbot%5D","html_url":"https://github.com/apps/stale","followers_url":"https://api.github.com/users/stale%5Bbot%5D/followers","following_url":"https://api.github.com/users/stale%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/stale%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/stale%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stale%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/stale%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/stale%5Bbot%5D/repos","events_url":"https://api.github.com/users/stale%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/stale%5Bbot%5D/received_events","type":"Bot","site_admin":false},"created_at":"2017-11-19T00:42:25Z","updated_at":"2017-11-19T00:42:25Z","author_association":"NONE","body":"This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.\n"}}
{"actor":{"display_login":"stale"}}