question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

While I load the images in ListView, some of the images I get are corrupted and shown with half-grayish background. (link attached). currupt_image

While downloading, I am also saving the image to the disk. Below is the way I’m doing it:

` GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(context.getResources()); builder .setFadeDuration(50) .setProgressBarImage(null) .setPlaceholderImage(R.color.colorPrimaryLightWithMoreAlpha) .setPlaceholderImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);

    GenericDraweeHierarchy hierarchy =builder.build();
    Uri lowResUri= Uri.parse(imageUrl+"_blur");
    Uri highResUri= Uri.parse(imageUrl);
    imageView.setHierarchy(hierarchy);
    ProductImageHelper productImageHelper = new ProductImageHelper();
    Uri uriLocal = productImageHelper.getUriForProductImage(context,productId);
    ImageRequest localImageRequest = ImageRequestBuilder.newBuilderWithSource(uriLocal).setRequestPriority(priority).build();
    ImageRequest hiresImageRequest = ImageRequestBuilder.newBuilderWithSource(highResUri).setResizeOptions(new ResizeOptions((int) context.getResources().getDimension(R.dimen.product_width),(int) context.getResources().getDimension(R.dimen.product_height))).setRequestPriority(priority).build();
    ImageRequest lowResImageRequest = ImageRequestBuilder.newBuilderWithSource(lowResUri).setRequestPriority(priority).build();
    ImageRequest[] requests = { localImageRequest, hiresImageRequest};
    ImagePipeline imagePipeline = Fresco.getImagePipeline();

    DataSource<CloseableReference<CloseableImage>> dataSource =
            imagePipeline.fetchDecodedImage(hiresImageRequest, context.getApplicationContext());
    dataSource.subscribe(new CustomBitmapDataSubscriber(context.getApplicationContext(),productId,highResUri,uriLocal), CallerThreadExecutor.getInstance());

    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setLowResImageRequest(lowResImageRequest)
            .setFirstAvailableImageRequests(requests)
            .setOldController(imageView.getController())
            .build();
    imageView.setController(controller);

`

in CustomBitmapDataSubscriber, I am removing hiResUri from memory cache and prefetching localuri in memory cache.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
prgometcommented, Jan 16, 2017

Problem solved! In my case problem was because onBindViewHolder was called before download was completed and i was checking only if file exists and because of that Fresco loads corrupted image (file is created when download starts), for me solution was to check in database if download was completed.

0reactions
foghinacommented, Jan 16, 2017

@triple-dot any chance you’re doing a similar thing to @prgomet?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Corrupted Image Repair Guide to Recover Damaged Photos ...
Are your photos corrupted? Here's is a guide on why your photos get damaged, how to perform corrupted image repair, and how you...
Read more >
Top 10 ways to repair & recover corrupt JPG files - YourStory
One of the simplest way to repair corrupt JPG files is to rename it without changing the file extension (.jpg). Save the image...
Read more >
Best Free Methods to Repair Corrupt JPEG Files in 2022
Top Free Ways to Repair Corrupt JPEG Files · Change the Image Format · Repair with Image Editors · Rename the JPEG files...
Read more >
Repair Corrupted JPEG/JPG, GIF, TIFF, BMP, PNG or RAW ...
Do-it-yourself recovery of image files. Fix corrupted images. Restore damaged JPEG and JPG files. Recover broken TIFF files. Fix corrupt GIF files.
Read more >
(3 Ways) How to Repair Corrupted/Damaged/Broken JPEG Files
Use Another Application to View Images 01:41 Fix 3. Repair Corrupted Image Files Using 4DDiG How to Use 4DDiG to Repair Corrupted/Damaged ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found