<p dir="auto">Hello, could it be possible to add one or two additional variables to the onResourceReady callback, which states whether the image was downloaded or loaded from cache?</p>
<p dir="auto">For example:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//final int FROM_INTERNET=0;
//final int FROM_CACHE=1;
//final int FROM_EXTERNAL=2;

Glide.with(c).load(url).listener(new RequestListener&lt;Drawable&gt;(){
    @Override
    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target&lt;Drawable&gt; target, boolean isFirstResource) {
        return false;
    }

    @Override
    public boolean onResourceReady(Drawable resource, Object model, Target&lt;Drawable&gt; target, DataSource dataSource, boolean isFirstResource, int loadedFrom, String loadPath) {
        Log.d(&quot;MainActivity&quot;,&quot;loadedFrom: &quot;+loadedFrom+&quot;, loadPath: &quot;+loadPath);
        // loadedFrom could return: 0 (downloaded), 1 (from cache), 2 (from external storage?), etc.
        // loadPath could return: url (for 0), path to cache (for 1), path to external location (for 2), etc.
        return false;
    }
})"><pre class="notranslate"><span class="pl-c">//final int FROM_INTERNET=0;</span>
<span class="pl-c">//final int FROM_CACHE=1;</span>
<span class="pl-c">//final int FROM_EXTERNAL=2;</span>

<span class="pl-smi">Glide</span>.<span class="pl-en">with</span>(<span class="pl-s1">c</span>).<span class="pl-en">load</span>(<span class="pl-s1">url</span>).<span class="pl-en">listener</span>(<span class="pl-k">new</span> <span class="pl-smi">RequestListener</span>&lt;<span class="pl-smi">Drawable</span>&gt;(){
    <span class="pl-c1">@</span><span class="pl-c1">Override</span>
    <span class="pl-k">public</span> <span class="pl-smi">boolean</span> <span class="pl-en">onLoadFailed</span>(<span class="pl-c1">@</span><span class="pl-c1">Nullable</span> <span class="pl-smi">GlideException</span> <span class="pl-s1">e</span>, <span class="pl-smi">Object</span> <span class="pl-s1">model</span>, <span class="pl-smi">Target</span>&lt;<span class="pl-smi">Drawable</span>&gt; <span class="pl-s1">target</span>, <span class="pl-smi">boolean</span> <span class="pl-s1">isFirstResource</span>) {
        <span class="pl-k">return</span> <span class="pl-c1">false</span>;
    }

    <span class="pl-c1">@</span><span class="pl-c1">Override</span>
    <span class="pl-k">public</span> <span class="pl-smi">boolean</span> <span class="pl-en">onResourceReady</span>(<span class="pl-smi">Drawable</span> <span class="pl-s1">resource</span>, <span class="pl-smi">Object</span> <span class="pl-s1">model</span>, <span class="pl-smi">Target</span>&lt;<span class="pl-smi">Drawable</span>&gt; <span class="pl-s1">target</span>, <span class="pl-smi">DataSource</span> <span class="pl-s1">dataSource</span>, <span class="pl-smi">boolean</span> <span class="pl-s1">isFirstResource</span>, <span class="pl-smi">int</span> <span class="pl-s1">loadedFrom</span>, <span class="pl-smi">String</span> <span class="pl-s1">loadPath</span>) {
        <span class="pl-smi">Log</span>.<span class="pl-en">d</span>(<span class="pl-s">"MainActivity"</span>,<span class="pl-s">"loadedFrom: "</span>+<span class="pl-s1">loadedFrom</span>+<span class="pl-s">", loadPath: "</span>+<span class="pl-s1">loadPath</span>);
        <span class="pl-c">// loadedFrom could return: 0 (downloaded), 1 (from cache), 2 (from external storage?), etc.</span>
        <span class="pl-c">// loadPath could return: url (for 0), path to cache (for 1), path to external location (for 2), etc.</span>
        <span class="pl-k">return</span> <span class="pl-c1">false</span>;
    }
})</pre></div>

<p dir="auto">Glide version: 4.11.0</p>

<p dir="auto">Integration: Okhttp3</p>

<p dir="auto">Device: Xiaomi MA 1A, Android 8.1.0</p>

<p dir="auto">Why: I simply want to know whether an image has been downloaded or fetched from cache when loaded. I've read and tried to implement onlyRetrieveFromCache(true) with custom target and listener, and it's not reliable, convenient, or efficient for checking it.</p>
<p dir="auto">I have a ViewPager with 3 fragments inside. Each fragment is a list to retrieve some exercises from a remote server. The 3 fragments are in order: "explore", "favorite", "recent".</p>
<p dir="auto">In "explore" list, all images correctly appear. unfortunately in the "favorite" no image appears (just place holder thumbnail).</p>
<p dir="auto">This is my common adapter:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@Override public View getView(int position, View convertView, ViewGroup parent) {
    final T item = getItem(position);
    ....
    Glide.with(getContext())
        .load(UIUtils.getThumbnailImageUrl(item.images))
        .placeholder(R.drawable.default_thumbnail_picture)
        .crossFade()
        .listener(new RequestListener&lt;String, GlideDrawable&gt;() {
            @Override
            public boolean onException(Exception e, String model, Target&lt;GlideDrawable&gt; target, boolean isFirstResource) {
                return false;
            }

            @Override
            public boolean onResourceReady(GlideDrawable resource, String model, Target&lt;GlideDrawable&gt; target, boolean isFromMemoryCache, boolean isFirstResource) {
                return false;
            }
        })
        .into(viewHolder.mExerciseImageView);
    return convertView;
}"><pre class="notranslate"><span class="pl-c1">@</span><span class="pl-c1">Override</span> <span class="pl-k">public</span> <span class="pl-smi">View</span> <span class="pl-s1">getView</span>(<span class="pl-smi">int</span> <span class="pl-s1">position</span>, <span class="pl-smi">View</span> <span class="pl-s1">convertView</span>, <span class="pl-smi">ViewGroup</span> <span class="pl-s1">parent</span>) {
    <span class="pl-k">final</span> <span class="pl-smi">T</span> <span class="pl-s1">item</span> = <span class="pl-en">getItem</span>(<span class="pl-s1">position</span>);
    ....
    <span class="pl-smi">Glide</span>.<span class="pl-en">with</span>(<span class="pl-en">getContext</span>())
        .<span class="pl-en">load</span>(<span class="pl-smi">UIUtils</span>.<span class="pl-en">getThumbnailImageUrl</span>(<span class="pl-s1">item</span>.<span class="pl-s1">images</span>))
        .<span class="pl-en">placeholder</span>(<span class="pl-smi">R</span>.<span class="pl-s1">drawable</span>.<span class="pl-s1">default_thumbnail_picture</span>)
        .<span class="pl-en">crossFade</span>()
        .<span class="pl-en">listener</span>(<span class="pl-k">new</span> <span class="pl-smi">RequestListener</span>&lt;<span class="pl-smi">String</span>, <span class="pl-smi">GlideDrawable</span>&gt;() {
            <span class="pl-c1">@</span><span class="pl-c1">Override</span>
            <span class="pl-k">public</span> <span class="pl-smi">boolean</span> <span class="pl-en">onException</span>(<span class="pl-smi">Exception</span> <span class="pl-s1">e</span>, <span class="pl-smi">String</span> <span class="pl-s1">model</span>, <span class="pl-smi">Target</span>&lt;<span class="pl-smi">GlideDrawable</span>&gt; <span class="pl-s1">target</span>, <span class="pl-smi">boolean</span> <span class="pl-s1">isFirstResource</span>) {
                <span class="pl-k">return</span> <span class="pl-c1">false</span>;
            }

            <span class="pl-c1">@</span><span class="pl-c1">Override</span>
            <span class="pl-k">public</span> <span class="pl-smi">boolean</span> <span class="pl-en">onResourceReady</span>(<span class="pl-smi">GlideDrawable</span> <span class="pl-s1">resource</span>, <span class="pl-smi">String</span> <span class="pl-s1">model</span>, <span class="pl-smi">Target</span>&lt;<span class="pl-smi">GlideDrawable</span>&gt; <span class="pl-s1">target</span>, <span class="pl-smi">boolean</span> <span class="pl-s1">isFromMemoryCache</span>, <span class="pl-smi">boolean</span> <span class="pl-s1">isFirstResource</span>) {
                <span class="pl-k">return</span> <span class="pl-c1">false</span>;
            }
        })
        .<span class="pl-en">into</span>(<span class="pl-s1">viewHolder</span>.<span class="pl-s1">mExerciseImageView</span>);
    <span class="pl-k">return</span> <span class="pl-s1">convertView</span>;
}</pre></div>
<p dir="auto">I put a breakpoint in "onException()" function, and there are several break. Unfortunately, exception is always equal at null...</p>
<p dir="auto">Could you help me guys?</p>
<p dir="auto">Thank you very much!</p>