How can I save images via url before displaying them using Fresco?

3

I loop the list with the images as follows:

for( Produto p : listProd){
        String error = "";
        cont++;

        try{
            // salvando dados no db
            produtoRepository.insertProduto(p);
            // salvar imagem p.getImg();

            this.progress = cont;
            publishProgress();

            if(cont > 10)
                break;

        }catch (Exception e){
            error += "erro ao inserir " + p.getProd() + "/n";
            error += "erro: " + e.getMessage();
            mProgressDialog.setMessage(error);
        }
    }

I need to save the image in sdcard before opening the activity that will display the images.

How can I do this using fresh and then display on a SimpleDraweeView ?

I was only able to change the path that the images are saved in the initialize of fresco , but the images are only downloaded qnd the image is displayed in Drawee .

Initialize:

Supplier<File> diskSupplier = new Supplier<File>() {
        public File get() {
            return Constants.EXTERNAl_DIRECTORY;
        }
    };

    DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(this)
            .setBaseDirectoryName("catalogo_images_teste1")
            .setBaseDirectoryPathSupplier(diskSupplier)
            .build();

    ImagePipelineConfig frescoConfig = ImagePipelineConfig.newBuilder(this)
            .setMainDiskCacheConfig(diskCacheConfig)
            .build();

    Fresco.initialize(this, frescoConfig);

Setting the image:

Uri uri = Uri.parse(DataUrl.getUrlCustom(Constants.URL_IMAGES + mList.get(position).getImg() , w )  );
        DraweeController dc = Fresco.newDraweeControllerBuilder()
                .setUri( uri )
                .setTapToRetryEnabled(true)
                .setControllerListener( listener )
                .setOldController( myViewHolder.ivProd.getController() )
                .build();

        RoundingParams rp = RoundingParams.fromCornersRadii(roundPixels, roundPixels, 0, 0);
        myViewHolder.ivProd.setController(dc);
        myViewHolder.ivProd.getHierarchy().setRoundingParams( rp );
    
asked by anonymous 09.06.2017 / 18:49

0 answers