@@ -927,12 +927,20 @@ private static void generateNewThumbnail(OCFile file,
927927 Bitmap thumbnail = ThumbnailsCacheManager .getBitmapFromDiskCache (
928928 ThumbnailsCacheManager .PREFIX_THUMBNAIL + file .getRemoteId ());
929929
930+ if (thumbnail != null ) {
931+ // If thumbnail is already in cache, display it immediately
932+ thumbnailView .setImageBitmap (thumbnail );
933+ stopShimmer (shimmerThumbnail , thumbnailView );
934+ return ;
935+ }
936+
930937 for (ThumbnailsCacheManager .ThumbnailGenerationTask task : asyncTasks ) {
931938 if (file .getRemoteId () != null && task .getImageKey () != null &&
932939 file .getRemoteId ().equals (task .getImageKey ())) {
933940 return ;
934941 }
935942 }
943+
936944 try {
937945 final ThumbnailsCacheManager .ThumbnailGenerationTask task =
938946 new ThumbnailsCacheManager .ThumbnailGenerationTask (thumbnailView ,
@@ -941,32 +949,34 @@ private static void generateNewThumbnail(OCFile file,
941949 asyncTasks ,
942950 gridView ,
943951 file .getRemoteId ());
944- if (thumbnail == null ) {
945- Drawable drawable = MimeTypeUtil .getFileTypeIcon (file .getMimeType (),
946- file .getFileName (),
947- context ,
948- viewThemeUtils );
949- if (drawable == null ) {
950- drawable = ResourcesCompat .getDrawable (context .getResources (),
951- R .drawable .file_image ,
952- null );
953- }
954- if (drawable == null ) {
955- drawable = new ColorDrawable (Color .GRAY );
956- }
957-
958- int px = ThumbnailsCacheManager .getThumbnailDimension ();
959- thumbnail = BitmapUtils .drawableToBitmap (drawable , px , px );
952+ Drawable drawable = MimeTypeUtil .getFileTypeIcon (file .getMimeType (),
953+ file .getFileName (),
954+ context ,
955+ viewThemeUtils );
956+ if (drawable == null ) {
957+ drawable = ResourcesCompat .getDrawable (context .getResources (),
958+ R .drawable .file_image ,
959+ null );
960+ }
961+ if (drawable == null ) {
962+ drawable = new ColorDrawable (Color .GRAY );
960963 }
964+
965+ int px = ThumbnailsCacheManager .getThumbnailDimension ();
966+ thumbnail = BitmapUtils .drawableToBitmap (drawable , px , px );
961967 final ThumbnailsCacheManager .AsyncThumbnailDrawable asyncDrawable =
962968 new ThumbnailsCacheManager .AsyncThumbnailDrawable (context .getResources (),
963969 thumbnail , task );
964970
965- if (shimmerThumbnail != null && shimmerThumbnail .getVisibility () == View .GONE ) {
966- if (gridView ) {
967- configShimmerGridImageSize (shimmerThumbnail , preferences .getGridColumns ());
968- }
969- startShimmer (shimmerThumbnail , thumbnailView );
971+ if (shimmerThumbnail != null ) {
972+ shimmerThumbnail .postDelayed (() -> {
973+ if (thumbnailView .getDrawable () == null ) {
974+ if (gridView ) {
975+ configShimmerGridImageSize (shimmerThumbnail , preferences .getGridColumns ());
976+ }
977+ startShimmer (shimmerThumbnail , thumbnailView );
978+ }
979+ }, 100 );
970980 }
971981
972982 task .setListener (new ThumbnailsCacheManager .ThumbnailGenerationTask .Listener () {
0 commit comments