Java 类com.android.volley.toolbox.ImageLoader 实例源码

项目:GitHub    文件:VolleyLoaderActivity.java   
@AfterViews
public void bindLvData(){
    moduleBeans=DataUtils.getAdapterData();
    if(mAdapter==null) {
        mAdapter = new QuickAdapter<ModuleBean>(this, R.layout.lv_item_base_layout,moduleBeans) {
            @Override
            protected void convert(BaseAdapterHelper helper, ModuleBean item) {
                //列表底下显示进度
                mAdapter.showIndeterminateProgress(true);
                helper.setText(R.id.text_lv_item_title, item.getModulename())
                        .setText(R.id.text_lv_item_description, item.getDescription());
                //setImageUrl(R.id.img_lv_item, item.getImgurl());
                //使用ImageLoader进行加载图片
                ImageView loader_img=helper.getView(R.id.img_lv_item);
                listener=ImageLoader.getImageListener(loader_img,R.drawable.ic_loading,R.drawable.ic_loading);
                imageLoader.get(item.getImgurl(),listener);
            }
        };
        lv_base_adapter.setAdapter(mAdapter);
    }
}
项目:AndroidBackendlessChat    文件:ChatSDKAbstractThreadsListAdapter.java   
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {

    if (killed)
        return;

    // If response was not immidate, i.e  image was cached we show the default image while loading
    if (isImmediate && response.getBitmap() == null)
    {
        setDefaultImg(threadListItem);
        return;
    }

    // Set the response to the image.
    if (response.getBitmap() != null) {
        if (DEBUG) Timber.i("Loading thread picture from url");

        // load image into imageview
        imgIcon.setImageBitmap(response.getBitmap());
    }
}
项目:chat-sdk-android-push-firebase    文件:ChatSDKAbstractThreadsListAdapter.java   
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {

    if (killed)
        return;

    // If response was not immidate, i.e  image was cached we show the default image while loading
    if (isImmediate && response.getBitmap() == null)
    {
        setDefaultImg(threadListItem);
        return;
    }

    // Set the response to the image.
    if (response.getBitmap() != null) {
        if (DEBUG) Timber.i("Loading thread picture from url");

        // load image into imageview
        imgIcon.setImageBitmap(response.getBitmap());
    }
}
项目:groupicture    文件:SaveLocalManager.java   
public static void savePrepared() {
    if (prepared == null)
        throw new RuntimeException("No ImageItem prepared");
    Toast.makeText(Global.baseActivity, "Saving...", Toast.LENGTH_SHORT).show();
    System.out.println("Proceeding to save item " + prepared.getId() + " " + prepared.getTitle());
    ImageLoader loader = VolleySingleton.getInstance(null).getImageLoader();
    loader.get(prepared.getRequestUrl(), new ImageLoader.ImageListener() {
        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() == null)
                makeError();
            else {
                saveBitmapOnLocal(response.getBitmap());
            }
        }

        @Override
        public void onErrorResponse(VolleyError error) {
            makeError();
        }
    });
}
项目:groupicture    文件:BigImageViewActivity.java   
private void loadImageFromServer(String requestUrl)
{
    loader.get(requestUrl, new ImageLoader.ImageListener() {
        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            BitmapDrawable drawable = new BitmapDrawable(getResources(), response.getBitmap());
            imageSwitcher.setImageDrawable(drawable);
            System.out.println("Image loaded from server");
        }

        @Override
        public void onErrorResponse(VolleyError error) {
            System.out.println("error " + error.getMessage());
        }
    });
}
项目:morscout-android    文件:MorScout.java   
@Override
public void onCreate() {
    super.onCreate();

    preferences = getSharedPreferences("org.team1515.morscout", MODE_PRIVATE);

    queue = Volley.newRequestQueue(this);
    imageLoader = new CookieImageLoader(queue, new ImageLoader.ImageCache() {
        private final LruCache<String, Bitmap> cache = new LruCache<>(50);

        @Override
        public Bitmap getBitmap(String url) {
            return cache.get(url);
        }

        @Override
        public void putBitmap(String url, Bitmap bitmap) {
            cache.put(url, bitmap);
        }
    });
}
项目:book-store-android    文件:CartAdapter.java   
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    //Get the data model based on position
    Book book = mBooks.get(position);

    // Setting item views based on my views and data model
    TextView textViewName = holder.nameTextView;
    textViewName.setText(book.getBookName());

    TextView textViewAuthor = holder.authorTextView;

    final NetworkImageView image = holder.bookImage;
    ImageLoader mImageLoader = MySingleton.getInstance(mContext).getImageLoader();
    image.setImageUrl(book.getBookImgUrl(), mImageLoader);
    image.setErrorImageResId(R.drawable.defaultcover);

}
项目:FMTech    文件:FifeNetworkImageView.java   
public final void setFifeImageUrl(String paramString, ImageLoader paramImageLoader, boolean paramBoolean)
{
  this.mImageLoader = paramImageLoader;
  this.mPreferWebP = paramBoolean;
  int i = getWidth();
  int j = getHeight();
  if ((i == 0) && (j == 0))
  {
    ViewGroup.LayoutParams localLayoutParams = getLayoutParams();
    if ((localLayoutParams != null) && (localLayoutParams.width > 0) && (localLayoutParams.height > 0))
    {
      i = localLayoutParams.width;
      j = localLayoutParams.height;
    }
  }
  if ((j != 0) && (i != 0))
  {
    this.mDeferredUntilViewSizedImageUrl = null;
    setImageUrl(WalletUiUtils.createFifeUrl(paramString, i, j, this.mPreferWebP), this.mImageLoader);
    return;
  }
  this.mDeferredUntilViewSizedImageUrl = paramString;
}
项目:digcsdn    文件:ImageLoading.java   
public synchronized static ImageLoading getInstance(){
    if (imageLoading == null) {
        imageLoading = new ImageLoading(new ImageLoader(VolleyUtil.getQueue(), new ImageCache() {

            LruCache<String, Bitmap> mCache= new LruCache<String,Bitmap>(maxSize){//缓存总大小
                @Override//匿名内部类继承LruCache类,即缓存池
                protected int sizeOf(String key, Bitmap value) {
                    return value.getRowBytes()*value.getHeight();//返回图片大小
                }
            };

            public Bitmap getBitmap(String url) {
                return mCache.get(url);
            }

            @Override
            public void putBitmap(String url, Bitmap bitmap) {
                mCache.put(url, bitmap);
            }
        }));
    }
    return imageLoading;
}
项目:Netease    文件:MySingleton.java   
private MySingleton(Context context) {
    mCtx = context;

    mRequestQueue = getRequestQueue();

    mImageLoader = new ImageLoader(mRequestQueue,
            //默认缓存20个单位的图片
            /*new ImageLoader.ImageCache() {
                private final LruCache<String, Bitmap>
                        cache = new LruCache<String, Bitmap>(20);

                @Override
                public Bitmap getBitmap(String url) {
                    return cache.get(url);
                }

                @Override
                public void putBitmap(String url, Bitmap bitmap) {
                    cache.put(url, bitmap);
                }
            });*/
            new MyLrnCache(mCtx), 1 * 3600 * 1000, 15 * 24 * 3600 * 1000, true);
}
项目:ShuTuier    文件:GridAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHodler hodler = null;
    if(convertView == null) {
        convertView = inflater.inflate(R.layout.grid_item,parent,false);
        hodler = new ViewHodler();
        hodler.img = (ImageView) convertView.findViewById(R.id.img_grid_item);
        hodler.tvAlign = (TextView) convertView.findViewById(R.id.tv_align_grid_img);
        hodler.tvDate = (TextView) convertView.findViewById(R.id.tv_date_grid);
        hodler.img.setLayoutParams(params);
        hodler.img.setImageResource(R.drawable.def);
        convertView.setTag(hodler);
    }else {
        hodler = (ViewHodler) convertView.getTag();
    }
    Map<String,String> map = data.get(position);
    loader.get(map.get("InternetImg"),ImageLoader.getImageListener(hodler.img,R.drawable.def,R.drawable.def));
    String status = map.get("Status").equals("1") ? "交易完成" : "未交易";
    hodler.tvAlign.setText(status);
    hodler.tvDate.setText(map.get("time"));
    return convertView;
}
项目:android-basics    文件:AdapterMovies.java   
private void loadImages(String urlThumbnail, final ViewHolderBoxOffice holder) {
    if (!urlThumbnail.equals("NA")) {
        mImageLoader.get(urlThumbnail, new ImageLoader.ImageListener() {
            @Override
            public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
                Bitmap bitmap = response.getBitmap();
                if (bitmap != null) {
                    holder.movieThumbnail.setImageBitmap(BitmapUtils.getRounded(bitmap, 15));
                }
            }

            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });
    }
}
项目:GitHub    文件:VolleyDraweeControllerBuilderSupplier.java   
public VolleyDraweeControllerBuilderSupplier(
    Context context,
    ImageLoader imageLoader,
    Set<ControllerListener> boundControllerListeners) {
  mContext = context;
  mImageLoader = imageLoader;
  mVolleyDraweeControllerFactory = new VolleyDraweeControllerFactory(
      context.getResources(),
      DeferredReleaser.getInstance(),
      UiThreadImmediateExecutorService.getInstance());
  mBoundControllerListeners = boundControllerListeners;
}
项目:GitHub    文件:VolleyDataSource.java   
public VolleyDataSource(
    final ImageLoader imageLoader,
    final Uri imageRequest,
    final AbstractDraweeControllerBuilder.CacheLevel cacheLevel) {

  String uriString = imageRequest.toString();
  int maxWidth = 0;
  int maxHeight = 0;

  if (cacheLevel != AbstractDraweeControllerBuilder.CacheLevel.FULL_FETCH) {
    if (!imageLoader.isCached(uriString, maxWidth, maxHeight)) {
      mImageContainer = null;
      setFailure(new NullPointerException("Image not found in bitmap-cache."));
      return;
    }
  }

  mImageContainer = imageLoader.get(
      uriString,
      new ImageLoader.ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
          setFailure(error.getCause());
        }
        @Override
        public void onResponse(final ImageLoader.ImageContainer response, boolean isImmediate) {
          if (response.getBitmap() != null) {
            setResult(response.getBitmap(), true);
          }
        }
      },
      maxWidth,
      maxHeight);
}
项目:GitHub    文件:VolleyDraweeControllerBuilder.java   
public VolleyDraweeControllerBuilder(
    Context context,
    ImageLoader imageLoader,
    VolleyDraweeControllerFactory volleyDraweeControllerFactory,
    Set<ControllerListener> boundControllerListeners) {
  super(context, boundControllerListeners);
  mImageLoader = imageLoader;
  mVolleyDraweeControllerFactory = volleyDraweeControllerFactory;
}
项目:android-advanced-light    文件:MainActivity.java   
private void UseNetworkImageView() {
    ImageLoader imageLoader = new ImageLoader(mQueue, new BitmapCache());
    nv_image.setDefaultImageResId(R.drawable.ico_default);
    nv_image.setErrorImageResId(R.drawable.ico_default);
    nv_image.setImageUrl("http://img.my.csdn.net/uploads/201603/26/1458988468_5804.jpg",
            imageLoader);

}
项目:AndroidBackendlessChat    文件:ChatBubbleImageView.java   
@Override
public void onResponse(final ImageLoader.ImageContainer response, boolean isImmediate) {
    if (isImmediate)
    {
        if (loadDone != null)
            loadDone.immediate(response.getBitmap() != null);
    }

    if (response.getBitmap() != null) {

        if (isCachedWithSize)
        {
            if (isKilled)
                return;

            image = new WeakReference<Bitmap>(response.getBitmap());
            invalidate();

            if (loadDone != null)
                loadDone.onDone();
        }
        else
        {
            // If the image was already in the cache that means that there is a task to fix the image.
            if (isImmediate)
                return;

            // Create a new task to fix the image size.
            fixImageAsyncTask = new FixImageAsyncTask(loadDone, this.imageUrl, width, height, isKilled);
            fixImageAsyncTask.execute(response.getBitmap());
        }
    }
}
项目:AndroidBackendlessChat    文件:ChatSDKAbstractUsersListAdapter.java   
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
    if (isImmediate && response.getBitmap() == null)
    {
        profilePic.setImageResource(com.braunster.chatsdk.R.drawable.ic_profile);
        return;
    }

    if (response.getBitmap() != null && !killed) {
        // load image into imageview
        profilePic.setImageBitmap(response.getBitmap());
    }
}
项目:AndroidBackendlessChat    文件:MakeThreadImage.java   
private void load(final String... urls) {
    this.urls = urls;

    for (final String url : urls) {
        VolleyUtils.getImageLoader().get(url, new ImageLoader.ImageListener() {
            @Override
            public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
                if (killed)
                    return;

                if (response.getBitmap() != null) {
                    bitmaps.add(response.getBitmap());
                    loadedCount++;

                    dispatchFinishedIfDid();
                }
            }

            @Override
            public void onErrorResponse(VolleyError error) {
                if (killed)
                    return;

                if (!errorUrls.contains(url))
                {
                    loadedCount++; 
                    if (DEBUG) Timber.e("Image Load Error: %s", error.getMessage());
                    errorUrls.add(url);
                    dispatchFinishedIfDid();
                }
            }
        });
    }
}
项目:AndroidBackendlessChat    文件:ChatSDKProfileHelper.java   
@Override
public void onResponse(final ImageLoader.ImageContainer response, boolean isImmediate) {

    if (killed)
        return;

    if (response.getBitmap() != null) {
        setProfilePic(response.getBitmap());

        if (saveAfterLoad)
            createTempFileAndSave(response.getBitmap());
    }
}
项目:AndroidBackendlessChat    文件:VolleyUtils.java   
/**
 * Returns instance of ImageLoader initialized with {@see FakeImageCache} which effectively means
 * that no memory caching is used. This is useful for images that you know that will be show
 * only once.
 *
 * @return
 */
public static ImageLoader getImageLoader() {
    if (mImageLoader != null) {
        return mImageLoader;
    } else {
        throw new IllegalStateException("ImageLoader not initialized");
    }
}
项目:VolleyImageLoader    文件:MainActivity.java   
@Override
protected void onStart() {
    super.onStart();
    // Instantiate the RequestQueue.
    mImageLoader = CustomVolleyRequestQueue.getInstance(this.getApplicationContext())
            .getImageLoader();
    //Image URL - This can point to any image file supported by Android
    final String url = "http://goo.gl/0rkaBz";
    mImageLoader.get(url, ImageLoader.getImageListener(mNetworkImageView,
            R.mipmap.truiton_short, android.R.drawable
                    .ic_dialog_alert));
    mNetworkImageView.setImageUrl(url, mImageLoader);
}
项目:chat-sdk-android-push-firebase    文件:ChatBubbleImageView.java   
@Override
public void onResponse(final ImageLoader.ImageContainer response, boolean isImmediate) {
    if (isImmediate)
    {
        if (loadDone != null)
            loadDone.immediate(response.getBitmap() != null);
    }

    if (response.getBitmap() != null) {

        if (isCachedWithSize)
        {
            if (isKilled)
                return;

            image = new WeakReference<Bitmap>(response.getBitmap());
            invalidate();

            if (loadDone != null)
                loadDone.onDone();
        }
        else
        {
            // If the image was already in the cache that means that there is a task to fix the image.
            if (isImmediate)
                return;

            // Create a new task to fix the image size.
            fixImageAsyncTask = new FixImageAsyncTask(loadDone, this.imageUrl, width, height, isKilled);
            fixImageAsyncTask.execute(response.getBitmap());
        }
    }
}
项目:chat-sdk-android-push-firebase    文件:ChatSDKAbstractUsersListAdapter.java   
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
    if (isImmediate && response.getBitmap() == null)
    {
        profilePic.setImageResource(com.braunster.chatsdk.R.drawable.ic_profile);
        return;
    }

    if (response.getBitmap() != null && !killed) {
        // load image into imageview
        profilePic.setImageBitmap(response.getBitmap());
    }
}
项目:chat-sdk-android-push-firebase    文件:MakeThreadImage.java   
private void load(final String... urls) {
    this.urls = urls;

    for (final String url : urls) {
        VolleyUtils.getImageLoader().get(url, new ImageLoader.ImageListener() {
            @Override
            public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
                if (killed)
                    return;

                if (response.getBitmap() != null) {
                    bitmaps.add(response.getBitmap());
                    loadedCount++;

                    dispatchFinishedIfDid();
                }
            }

            @Override
            public void onErrorResponse(VolleyError error) {
                if (killed)
                    return;

                if (!errorUrls.contains(url))
                {
                    loadedCount++; 
                    if (DEBUG) Timber.e("Image Load Error: %s", error.getMessage());
                    errorUrls.add(url);
                    dispatchFinishedIfDid();
                }
            }
        });
    }
}
项目:chat-sdk-android-push-firebase    文件:ChatSDKProfileHelper.java   
@Override
public void onResponse(final ImageLoader.ImageContainer response, boolean isImmediate) {

    if (killed)
        return;

    if (response.getBitmap() != null) {
        setProfilePic(response.getBitmap());

        if (saveAfterLoad)
            createTempFileAndSave(response.getBitmap());
    }
}
项目:chat-sdk-android-push-firebase    文件:VolleyUtils.java   
/**
 * Returns instance of ImageLoader initialized with {@see FakeImageCache} which effectively means
 * that no memory caching is used. This is useful for images that you know that will be show
 * only once.
 *
 * @return
 */
public static ImageLoader getImageLoader() {
    if (mImageLoader != null) {
        return mImageLoader;
    } else {
        throw new IllegalStateException("ImageLoader not initialized");
    }
}
项目:papara-android    文件:MyVolley.java   
void init(Context context) {
    mRequestQueue = Volley.newRequestQueue(context);
    int memory = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
    int cacheSize = 1024 * 1024 * memory / 8;
    mImageLoader = new ImageLoader(mRequestQueue, new BitmapLruCache(cacheSize));

    // int memClass = ((ActivityManager)
    // context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
    // // Use 1/8th of the available memory for this memory cache.
    // int cacheSize = 1024 * 1024 * memClass / 8;
    // mImageLoader = new ImageLoader(mRequestQueue, new
    // BitmapLruCache(cacheSize));

}
项目:papara-android    文件:MyVolley.java   
/**
 * Returns instance of ImageLoader initialized with {@see FakeImageCache}
 * which effectively means that no memory caching is used. This is useful
 * for images that you know that will be show only once.
 * 
 * @return
 */
public ImageLoader getImageLoader() {
    if (mImageLoader != null) {
        return mImageLoader;
    } else {
        throw new IllegalStateException("ImageLoader not initialized");
    }
}
项目:GeekZone    文件:VolleyImageLoader.java   
private VolleyImageLoader(Context context) {
    mImageQueue = BaseRequestQueue.newSpecialRequestQueue(context);
    ImageBitmapCache.ImageCacheParams cacheParams = new ImageBitmapCache.ImageCacheParams(IMAGE_CACHE_DIR);
    cacheParams.memCacheSize = 1024 * 1024 * com.hanyee.androidlib.cache.image.ImageUtils.getMemoryClass(context) / 3;
    mImageCache = ImageBitmapCache.getInstanceCache(context, cacheParams);
    mImageLoader = new ImageLoader(mImageQueue, mImageCache);
}
项目:Goalie_Android    文件:FeedsRecycler.java   
private void setNonExistingUserImage(final String createdUsername, final TextView textView) {
    Drawable profileRoundedDrawableImage = mCachedImages.get(createdUsername);

    if (profileRoundedDrawableImage == null) {
        ImageLoader imageLoader = VolleyRequestQueue.getInstance().getImageLoader();
        imageLoader.get(RESTGetPhoto.getURL(createdUsername), new ImageLoader.ImageListener() {
            @Override
            public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
                if (response.getBitmap() != null) {
                    Drawable profileDrawableImage = convertProfileImageToRoundedDrawable(response.getBitmap());
                    textView.setCompoundDrawablesWithIntrinsicBounds(null, profileDrawableImage, null, null);
                    mCachedImages.put(createdUsername, profileDrawableImage);
                } else {
                    textView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_profile_default_small, 0, 0);
                    mCachedImages.put(createdUsername, textView.getCompoundDrawables()[1]);
                }
            }

            @Override
            public void onErrorResponse(VolleyError error) {
                textView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_profile_default_small, 0, 0);
                mCachedImages.put(createdUsername, textView.getCompoundDrawables()[1]);
            }
        });
    } else {
        textView.setCompoundDrawablesWithIntrinsicBounds(null, profileRoundedDrawableImage, null, null);
    }
}
项目:omnicrow-android    文件:MyVolley.java   
void init(Context context) {
    mRequestQueue = Volley.newRequestQueue(context);
    int memory = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
    int cacheSize = 1024 * 1024 * memory / 8;
    mImageLoader = new ImageLoader(mRequestQueue, new BitmapLruCache(cacheSize));

    // int memClass = ((ActivityManager)
    // context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
    // // Use 1/8th of the available memory for this memory cache.
    // int cacheSize = 1024 * 1024 * memClass / 8;
    // mImageLoader = new ImageLoader(mRequestQueue, new
    // BitmapLruCache(cacheSize));

}
项目:omnicrow-android    文件:MyVolley.java   
/**
 * Returns instance of ImageLoader initialized with {@see FakeImageCache}
 * which effectively means that no memory caching is used. This is useful
 * for images that you know that will be show only once.
 * 
 * @return
 */
public ImageLoader getImageLoader() {
    if (mImageLoader != null) {
        return mImageLoader;
    } else {
        throw new IllegalStateException("ImageLoader not initialized");
    }
}
项目:MeifuGO    文件:HttpImage.java   
@Override
public void onResponse(ImageLoader.ImageContainer imageContainer, boolean isImmediate) {
    if (imageContainer.getBitmap() != null) {
        imageView.setImageBitmap(imageContainer.getBitmap());
    } else if (errorImage != 0) {
        imageView.setImageResource(errorImage);
    }
}
项目:VolleyImageLoader    文件:MainActivity.java   
@Override
protected void onStart() {
    super.onStart();
    // Instantiate the RequestQueue.
    mImageLoader = CustomVolleyRequestQueue.getInstance(this.getApplicationContext())
            .getImageLoader();
    //Image URL - This can point to any image file supported by Android
    final String url = "http://goo.gl/0rkaBz";
    mImageLoader.get(url, ImageLoader.getImageListener(mNetworkImageView,
            R.mipmap.truiton_short, android.R.drawable
                    .ic_dialog_alert));
    mNetworkImageView.setImageUrl(url, mImageLoader);
}
项目:lovelife    文件:RequestManager.java   
public static void init(Context context) {
        mRequestQueue = Volley.newRequestQueue(context);

//      int memClass = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
        // Use 1/8th of the available memory for this memory cache.
        int cacheSize = 1024 * 1024 * 200 / 8;
        mImageLoader = new ImageLoader(mRequestQueue, new BitmapLruCache(cacheSize));
    }
项目:lovelife    文件:RequestManager.java   
/**
 * Returns instance of ImageLoader initialized with {@see FakeImageCache}
 * which effectively means that no memory caching is used. This is useful
 * for images that you know that will be show only once.
 * 
 * @return
 */
public static ImageLoader getImageLoader() {
    if (mImageLoader != null) {
        return mImageLoader;
    } else {
        throw new IllegalStateException("ImageLoader not initialized");
    }
}
项目:Meizitu    文件:ImageCacheManager.java   
private ImageCacheManager(Context context) {
    MEM_CACHE_SIZE = 1024 * 1024
            * ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass() / 8;

    mImageLoader = new ImageLoader(
            RequestManager.getInstance(context).getRequestQueue()
            , new BitmapLruCache(MEM_CACHE_SIZE));
}
项目:Meizitu    文件:ImageCacheManager.java   
public static ImageLoader.ImageListener getImageListener(
        final Resources r, final ImageView iv, final Drawable defDrawable, final Drawable errorDrawable) {

    return new ImageLoader.ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorDrawable != null) {
                iv.setImageDrawable(errorDrawable);
            }
        }

        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                if (!isImmediate && defDrawable != null) {
                    TransitionDrawable transitionDrawable = new TransitionDrawable(
                            new Drawable[]{
                                    defDrawable,
                                    new BitmapDrawable(r, response.getBitmap())
                            }
                    );
                    transitionDrawable.setCrossFadeEnabled(true);
                    iv.setImageDrawable(transitionDrawable);
                    transitionDrawable.startTransition(100);
                } else {
                    iv.setImageBitmap(response.getBitmap());
                }
            } else if (defDrawable != null) {
                iv.setImageDrawable(defDrawable);
            }
        }
    };
}
项目:kanxue    文件:PostReplyAdapter.java   
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
    ViewHolder holder = null;

    if (view == null) {
        view = LayoutInflater.from(mContext).inflate(R.layout.posts_listview_item, null);
        holder = new ViewHolder();
        holder.imb_icon = (ImageButton) view.findViewById(R.id.id_imb_user_icon);
        holder.username = (TextView) view.findViewById(R.id.id_post_username);
        holder.time = (TextView) view.findViewById(R.id.id_post_date);
        holder.comment = (TextView) view.findViewById(R.id.id_tv_post_reply_content);
        holder.floor = (TextView) view.findViewById(R.id.id_tv_reply_floor);
        holder.title = (TextView) view.findViewById(R.id.id_tv_post_title);
        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }
    StringBuilder sb= new StringBuilder();
    sb.append(i+1).append("#");
    holder.floor.setText(sb.toString());
    PostBitsBean bean = list.get(i);
    if (i == 0) {
        holder.title.setVisibility(View.VISIBLE);
        holder.title.setText(bean.getTitle());
    } else {
        holder.title.setVisibility(View.GONE);
    }
    holder.username.setText(bean.getUsername());
    holder.comment.setText(Html.fromHtml(bean.getMessage()));
    holder.time.setText(bean.getPostdate() + " " + bean.getPosttime());
    int userid = bean.getUserid();
    if(bean.getAvatar()==1){
        ImageLoader.ImageListener listener = ImageLoader.getImageListener(holder.imb_icon, R.mipmap.user_default_icon, R.mipmap.user_default_icon);
        mImageLoad.get(AppConstants.USER_ICON_PATH+userid,listener);
    }else{
        holder.imb_icon.setBackgroundResource(R.mipmap.user_default_icon);
    }

    return view;
}