title: How to priorly get future Glide image size which will be stored in cache in Android/Java?
body: <p>In MainActivity, I'm loading some images using glide into recyclerview according to imageview size.</p>
  <p>See:</p>
  <pre><code> @Override
      public void onBindViewHolder(PreviewAdapter.MyViewHolder holder, int position) {
          Glide.with(context).load(previewArrayList.get(position).getUrl()).diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).into(holder.postImage);
  }
  </code></pre>
  <p>XML:</p>
  <pre><code>&lt;ImageView
      android:id=&quot;@+id/post_image&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_marginTop=&quot;4dp&quot;
      android:layout_height=&quot;250dp&quot;
      android:layout_below=&quot;@+id/post_name&quot;
      android:scaleType=&quot;centerCrop&quot; /&gt;
  </code></pre>
  <p>As you can observe, I'm using Glide cache  <code>DiskCacheStrategy.AUTOMATIC</code> also so that next time without Internet Glide can show the images. Now you can read in this post <a href="https://medium.com/@multidots/glide-vs-picasso-930eed42b81d" rel="nofollow noreferrer">https://medium.com/@multidots/glide-vs-picasso-930eed42b81d</a> that &quot; <strong><code>Glide resizes the image as per the dimension of the ImageView.</code></strong>&quot;</p>
  <p>Now, I want that final size inside SpalshActivity, which Glide will be stored in cache. So that when After SpalshActivity, when user opens MainActivity <strong>without Internet Conncetion</strong> for the very first time also, then it should load Images.</p>
  <p>So how is it possible?</p>
  <p>In SpalshActivity, I'm already caching Images, but it is again downloading/resizing in MainActivity for the very first time.</p>
  <p>SpalshActivity:</p>
  <pre><code>private void preloadImage(String url) {
          try {
  
              //File file = Glide.with(this).asFile().load(url).submit().get();
              //String path = file.getPath();
  
  
              Glide.with(this)
                      .load(url)
                      .diskCacheStrategy(DiskCacheStrategy.ALL)
                      .listener(new RequestListener&lt;Drawable&gt;() {
                          @Override
                          public boolean onLoadFailed(@Nullable GlideException e, Object model, Target&lt;Drawable&gt; target, boolean isFirstResource) {
                              if (isPostDataLoaded) {
                                  postImagesLoaded++;
                                  if (postImagesLoaded == postImagesCount) {
                                      binding.progressBar.setVisibility(View.GONE);
                                      AlertDialogManager.showAlertDialogMessage(SplashActivity.this, &quot;Error&quot;, &quot;Something went wrong, Please try again later&quot;, false, &quot;Exit&quot;, null, SplashActivity.this, IS_TABLET);
                                  }
                              } else {
                                  previewImagesLoaded++;
                                  if (previewImagesLoaded == previewImagesCount) {
                                      binding.progressBar.setVisibility(View.GONE);
                                      AlertDialogManager.showAlertDialogMessage(SplashActivity.this, &quot;Error&quot;, &quot;Something went wrong, Please try again later&quot;, false, &quot;Exit&quot;, null, SplashActivity.this, IS_TABLET);
                                  }
                              }
                              return true;
                          }
  
                          @Override
                          public boolean onResourceReady(Drawable resource, Object model, Target&lt;Drawable&gt; target, DataSource dataSource, boolean isFirstResource) {
                              if (isPostDataLoaded) {
                                  postImagesLoaded++;
                                  if (postImagesLoaded == postImagesCount) {
                                      PostSingleton.getInstance().setPostMap(postMap);
                                      startFreshActivity(PreviewActivity.class);
                                  }
                              } else {
                                  previewImagesLoaded++;
                                  if (previewImagesLoaded == previewImagesCount) {
                                      PreviewSingleton.getInstance().setPreviewList(previewList);
                                      getPostImageCount();
                                      postPreloadAllImages();
                                  }
                              }
                              return true;
                          }
                      }).preload();
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  </code></pre>