1

In my Android app, I have a GridView which uses a BaseAdapter to load data from DynamoDB and S3 in order to set every cell.
This is the code which I'm using to get the items pictures from S3:

    ExecutorService exec = Executors.newSingleThreadExecutor();
    Future<Bitmap> future = exec.submit(new Callable<Bitmap>() {
        @Override
        public Bitmap call() {
            try {
                url = new URL(/*S3 url*/);
                bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
            } catch (MalformedURLException e) {
                Log.e("Malformed", e.getMessage());
            } catch (IOException e) {
                Log.e("IO", e.getMessage());
            }
            return bmp;
        }
    });
    try {
        holder.itemImage.setImageBitmap(future.get());
    } catch (ExecutionException e) {
        Log.e("Execution", e.getMessage());
    } catch (InterruptedException er) {
        Log.e("Interrupted", er.getMessage());
    }

The code gets a Bitmap from S3 URL, and sets the ImageView on the GridView cell layout as the .jpg file on S3 URL. The problem is that getting the images from S3 takes very long.

Is there any way to speed this process? Maybe writing this code at the beginning and load it there?

Gopal
  • 1,734
  • 1
  • 14
  • 34
Ido
  • 171
  • 2
  • 13
  • 1
    I don't know about the speed problem. What I can recommend though is to use some image processing library. Why reinvent the wheel? Try [Glide](https://github.com/bumptech/glide). – Andrej Jurkin Jan 13 '17 at 08:39
  • you can choose from the verity of libraries, take a look at this once http://stackoverflow.com/questions/29363321/picasso-v-s-imageloader-v-s-fresco-vs-glide – Gopal Jan 13 '17 at 08:42

0 Answers0