获取图片Retrofit、RxJava和volloy的区别

获取图片通过Retrofit、RxJava

  Action1 bitmapAction1 = new Action1() {
                @Override
                public void call(Bitmap bitmap) {
                    holder.ivImg.setImageBitmap(bitmap);
                }
            };
            GetBitmap getBitmap = RetrofitManager.getInstance().getRetrofit().create(GetBitmap.class);
            getBitmap
                    .getPicFromNet(stories.getImages().get(0))
                    .map(new Func1() {
                        @Override
                        public Bitmap call(ResponseBody responseBody) {
                            //decode pic
                            return BitmapFactory.decodeStream(responseBody.byteStream());
                        }
                    })
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(bitmapAction1);

获取图片通过volloy、ImageLoader

   ImageLoader imageLoader = new ImageLoader(VolleyManager.getInstance().getRequestQueue(context.getApplicationContext())
                    , new ImageLoader.ImageCache() {
                @Override
                public Bitmap getBitmap(String url) {
                    return null;
                }

                @Override
                public void putBitmap(String url, Bitmap bitmap) {

                }
            });
            ImageLoader.ImageListener imageListener = ImageLoader.getImageListener(holder.ivImg, R.mipmap.ic_launcher, R.mipmap.ic_launcher);
            imageLoader.get(stories.getImages().get(0), imageListener);

你可能感兴趣的:(Android)