Как обрабатывать java.util.concurrent.RejectedExecutionException в Android - PullRequest
2 голосов
/ 17 июня 2019

Я получаю java.util.concurrent.RejectedExecutionException исключение при попытке загрузить изображения в ImageView. Это происходит не каждый раз, а иногда. Я знаю, почему возникает проблема, но не знаю, как ее решить.

    public void onPostExecute(HttpResource[] httpResources) {
            if (httpResources != null) {
                String imageUrl = httpResources[0].getUrl();
                File imageFile = httpResources[0].getFile();
                int count = 0;

                ArrayList<ImageItem> list = map.get(imageUrl);
                if (list != null) {
                    //TODO implement pagination or manage concurrent threads
                    for (ImageItem imageItem : list) {
                            ImageHelper.loadImage(context, imageItem.getImageView(), imageFile, imageItem.isAutoResize(), imageItem.isAutoOrientation(), CROP_LAYOUTS_PARAMS);
                    }
                }

                map.remove(imageUrl);

                if (map.isEmpty()) {
                    LogHelper.i(LibConst.TAG, "HttpImageProvider cache is empty");
                }
            }
        }
    } 
...