Soru & Cevap

Json ile indirilen resmi anlık olarak galeride görüntülemek ...

10.06.2015 - 01:56

Merhaba arkadaşlar benim basit ama anlamayamadığım bir sorunum var.

  • Sorunum şöyle ben json ile resim çekiyorum ancak güzelce galeriye kaydediyor. Bunun ardından resmi görüntüleyemiyorum. 
  • Ama telefona restart atınca sorun düzeliyor. Yani indirdiğim resimler hooop galeriye geliyor.
  • Amacım restart atmadan galeriye indirilen resimleri anlık olarak kaydetmek.
  • ​Çözüm media store provider ama anlayamadım açıkcası.

    private void downloadImage() {
        if (future != null) {
            //set the callback and start downloading
            future.withResponse().setCallback(new FutureCallback<Response<InputStream>>() {
                @Override
                public void onCompleted(Exception e, Response<InputStream> result) {
                    boolean success = false;
                    if (e == null && result != null && result.getResult() != null) {
                        try {
                            //prepare the file name
                            String url = mSelectedImage.getUrl();
                            String fileName = url.substring(url.lastIndexOf('/') + 1, url.length());
                            //create a temporary directory within the cache folder
                            File dir = Utils.getAlbumStorageDir("wall-tx");
                            //create the file
                            File file = new File(dir, fileName);
                            if (!file.exists()) {
                                file.createNewFile();
                            }

                            //copy the image onto this file
                            Utils.copyInputStreamToFile(result.getResult(), file);

                            //animate the first elements
                            animateCompleteFirst(true);

                            success = true;
                        } catch (Exception ex) {
                            Log.e("walltx", ex.toString());
                        }

                        //animate after complete
                        animateComplete(success);
                    } else {
                        animateReset(true);
                    }
                }
            });
        }
    }

 

 

7 Görüntülenme

0 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.