Java Code Examples for com.android.volley.toolbox.ImageLoader#getImageListener()

The following examples show how to use com.android.volley.toolbox.ImageLoader#getImageListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
public void btnClick5(View view){
    ImageLoader loader = new ImageLoader(queue,new BitmapCache(this));

    /**
     * 参数2:默认图片
     * 参数3:错误图片
     */
    ImageLoader.ImageListener imageListener = ImageLoader.getImageListener(iv,
            R.mipmap.ic_launcher,
            R.mipmap.ic_launcher);

    loader.get("http://cdn8.staztic.com/app/a/5993/5993203/volley-17-l-280x280.png",imageListener);
}
 
Example 2
Source File: ImagesActivity.java    From volley_demo with Apache License 2.0 5 votes vote down vote up
private void get_imageloader()
{
    textview.setText("获取图片开始了");
    networkImageView.setImageBitmap(null);
    imageView.setImageBitmap(null);
    String url = "http://g.hiphotos.baidu.com/image/pic/item/21a4462309f790521631d9e908f3d7ca7bcbd53f.jpg";

    ImageLoader loader = new ImageLoader(MyApplication.getHttpQueues(), new BitmapCache());
    ImageLoader.ImageListener listener = ImageLoader.getImageListener(imageView, R.drawable.default_icon , R.drawable.error );

    loader.get(url, listener);

}
 
Example 3
Source File: RssListAdapter.java    From android-opensource-library-56 with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = mInflator.inflate(R.layout.card_list, null);
        holder = new ViewHolder();
        holder.text = (TextView) convertView.findViewById(R.id.title);
        holder.entryImage = (ImageView) convertView
                .findViewById(R.id.entry_image);
        holder.description = (TextView) convertView
                .findViewById(R.id.description);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    Item item = getItem(position);
    holder.text.setText(item.title);
    holder.description.setText(item.description);
    if (item.imageUrl != null) {
        ImageListener listener = ImageLoader.getImageListener(
                holder.entryImage, R.drawable.ic_launcher,
                R.drawable.ic_launcher);
        if (holder.container != null) {
            holder.container.cancelRequest();
        }
        holder.container = mImageLoader.get(item.imageUrl, listener);
        holder.entryImage.setVisibility(View.VISIBLE);
    } else {
        holder.entryImage.setVisibility(View.GONE);
    }

    return convertView;
}
 
Example 4
Source File: RssListAdapter.java    From android-opensource-library-56 with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = mInflator.inflate(R.layout.card_list, null);
        holder = new ViewHolder();
        holder.text = (TextView) convertView.findViewById(R.id.title);
        holder.entryImage = (ImageView) convertView
                .findViewById(R.id.entry_image);
        holder.description = (TextView) convertView
                .findViewById(R.id.description);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    Item item = getItem(position);
    holder.text.setText(item.title);
    holder.description.setText(item.description);
    if (item.imageUrl != null) {
        ImageListener listener = ImageLoader.getImageListener(
                holder.entryImage, R.drawable.ic_launcher,
                R.drawable.ic_launcher);
        if (holder.container != null) {
            holder.container.cancelRequest();
        }
        holder.container = mImageLoader.get(item.imageUrl, listener);
        holder.entryImage.setVisibility(View.VISIBLE);
    } else {
        holder.entryImage.setVisibility(View.GONE);
    }

    return convertView;
}
 
Example 5
Source File: MainActivity.java    From android-advanced-light with MIT License 4 votes vote down vote up
private void UseImageLoader() {
    ImageLoader imageLoader = new ImageLoader(mQueue, new BitmapCache());
    ImageLoader.ImageListener listener = ImageLoader.getImageListener(iv_image, R.drawable.ico_default, R.drawable.ico_default);
    imageLoader.get("http://img.my.csdn.net/uploads/201603/26/1458988468_5804.jpg", listener);
}
 
Example 6
Source File: CommonUtils.java    From allenglish with Apache License 2.0 4 votes vote down vote up
public static void setUrlImageToImageView(ImageView imageView, String url) {
    ImageLoader.ImageListener listener = ImageLoader.getImageListener(imageView,
            R.drawable.ic_default, R.drawable.ic_default);
    VolleySingleton.getInstance().getImageLoader().get(url,
            listener, imageView.getMeasuredWidth(), imageView.getMeasuredHeight(), ImageView.ScaleType.FIT_XY);
}
 
Example 7
Source File: NewsAdapter.java    From QuickNews with MIT License 4 votes vote down vote up
public void getImage(ImageView imageView, String url) {
    ImageLoader imageLoader = new ImageLoader(mRequestQueue, new BitmapCache());
    ImageLoader.ImageListener listener = ImageLoader.getImageListener(imageView,
            R.drawable.default_picture, R.drawable.default_picture);
    imageLoader.get(url, listener);
}
 
Example 8
Source File: CommentsAdapter.java    From QuickNews with MIT License 4 votes vote down vote up
public void getImage(ImageView imageView, String url) {
    ImageLoader imageLoader = new ImageLoader(mRequestQueue, new BitmapCache());
    ImageLoader.ImageListener listener = ImageLoader.getImageListener(imageView,
            R.drawable.default_picture, R.drawable.default_picture);
    imageLoader.get(url, listener);
}
 
Example 9
Source File: VolleyHelper.java    From AndroidLinkup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 加载网络图片到ImageView
 * 
 * @param iv
 *            ImageView实例
 * @param url
 *            url地址
 */
public void loadImage(ImageView iv, String url) {
    ImageLoader imageLoader = new ImageLoader(requestQueue, new BitmapCache());
    ImageListener listener = ImageLoader.getImageListener(iv, R.drawable.icon_default, R.drawable.icon_default);
    imageLoader.get(url, listener);
}