<p dir="auto">I have a specific use case where I animate an <code class="notranslate">ImageView</code> it does a flip animation and I see the next image. The issue is that while the next image is loading there is a bunch of white space.</p>
<p dir="auto">I tried <a href="https://github.com/bumptech/glide/issues/527#issuecomment-148840717" data-hovercard-type="issue" data-hovercard-url="/bumptech/glide/issues/527/hovercard">this implementation here</a>:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Glide
.with(context)
.load(imageUrl)
.thumbnail(Glide // this thumbnail request has to have the same RESULT cache key
        .with(context) // as the outer request, which usually simply means
        .load(oldImage) // same size/transformation(e.g. centerCrop)/format(e.g. asBitmap)
        .fitCenter() // have to be explicit here to match outer load exactly
)
.listener(new RequestListener&lt;String, GlideDrawable&gt;() {
    @Override public boolean onResourceReady(GlideDrawable resource, String model, Target&lt;GlideDrawable&gt; target, boolean isFromMemoryCache, boolean isFirstResource) {
        if (isFirstResource) {
            return false; // thumbnail was not shown, do as usual
        }
        return new DrawableCrossFadeFactory&lt;Drawable&gt;(/* customize animation here */)
                .build(false, false) // force crossFade() even if coming from memory cache
                .animate(resource, (ViewAdapter)target);
    }
})
//.fitCenter() // this is implicitly added when .into() is called if there's no scaleType in xml or the value is fitCenter there
.into(imageView);

oldImage = imageUrl;"><pre class="notranslate"><span class="pl-smi">Glide</span>
.<span class="pl-en">with</span>(<span class="pl-s1">context</span>)
.<span class="pl-en">load</span>(<span class="pl-s1">imageUrl</span>)
.<span class="pl-en">thumbnail</span>(<span class="pl-smi">Glide</span> <span class="pl-c">// this thumbnail request has to have the same RESULT cache key</span>
        .<span class="pl-en">with</span>(<span class="pl-s1">context</span>) <span class="pl-c">// as the outer request, which usually simply means</span>
        .<span class="pl-en">load</span>(<span class="pl-s1">oldImage</span>) <span class="pl-c">// same size/transformation(e.g. centerCrop)/format(e.g. asBitmap)</span>
        .<span class="pl-en">fitCenter</span>() <span class="pl-c">// have to be explicit here to match outer load exactly</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">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">if</span> (<span class="pl-s1">isFirstResource</span>) {
            <span class="pl-k">return</span> <span class="pl-c1">false</span>; <span class="pl-c">// thumbnail was not shown, do as usual</span>
        }
        <span class="pl-k">return</span> <span class="pl-k">new</span> <span class="pl-smi">DrawableCrossFadeFactory</span>&lt;<span class="pl-smi">Drawable</span>&gt;(<span class="pl-c">/* customize animation here */</span>)
                .<span class="pl-en">build</span>(<span class="pl-c1">false</span>, <span class="pl-c1">false</span>) <span class="pl-c">// force crossFade() even if coming from memory cache</span>
                .<span class="pl-en">animate</span>(<span class="pl-s1">resource</span>, (<span class="pl-smi">ViewAdapter</span>)<span class="pl-s1">target</span>);
    }
})
<span class="pl-c">//.fitCenter() // this is implicitly added when .into() is called if there's no scaleType in xml or the value is fitCenter there</span>
.<span class="pl-en">into</span>(<span class="pl-s1">imageView</span>);

<span class="pl-s1">oldImage</span> = <span class="pl-s1">imageUrl</span>;</pre></div>
<p dir="auto">But while this makes the previous image stick around and not disappear when the animation occurs and the next image loads, the previous image sticks around and the user is kind of stuck waiting looking at the previous image AFTER the animation is complete which is somewhat awkward.</p>
<p dir="auto">I was wondering if there is a way to <code class="notranslate">preload</code> the next image and save it in memory and upon animation start just set the next image in <code class="notranslate">Glide.with(...).load(mNextImageRequest)....</code></p>
<p dir="auto">Is this possible?</p>
<p dir="auto"><strong>Glide Version</strong>:4.4.0</p>

<p dir="auto"><strong>Device/Android Version</strong>: Xiomi mi A1/ 7.1.2</p>

<p dir="auto"><strong>Issue details / Repro steps / Use case background</strong>: I am serving local phone images for casting but in some phones captured images have wrong orientation, so need to save file with correct orientation as, displaying same images with glide in ImageView produced correct orientation.</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="FutureTarget&lt;Bitmap&gt; target = null;
              RequestManager requestManager = Glide.with(context);
              target = requestManager.asBitmap().load(metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI)).submit();
              try {
                  serve = new File(Util.getAppDir(), &quot;temp.jpg&quot;); 
                  FileOutputStream fOut = new FileOutputStream(serve);
                  Bitmap bitmap = target.get();
                  bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
                  fOut.close();
                  fOut.flush();
              } catch (Exception e) {
                  e.printStackTrace();
                  serve = new File(metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI));
              } finally {
                  if(target != null) {
                      target.cancel(true);
                  }
              }"><pre class="notranslate"><code class="notranslate">FutureTarget&lt;Bitmap&gt; target = null;
              RequestManager requestManager = Glide.with(context);
              target = requestManager.asBitmap().load(metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI)).submit();
              try {
                  serve = new File(Util.getAppDir(), "temp.jpg"); 
                  FileOutputStream fOut = new FileOutputStream(serve);
                  Bitmap bitmap = target.get();
                  bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
                  fOut.close();
                  fOut.flush();
              } catch (Exception e) {
                  e.printStackTrace();
                  serve = new File(metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI));
              } finally {
                  if(target != null) {
                      target.cancel(true);
                  }
              }
</code></pre></div>
<p dir="auto">I am asking is there any better way to achieve above functionality?</p>