当前位置: 首页>>代码示例>>Java>>正文


Java ImageLoader.ImageListener方法代码示例

本文整理汇总了Java中com.android.volley.toolbox.ImageLoader.ImageListener方法的典型用法代码示例。如果您正苦于以下问题:Java ImageLoader.ImageListener方法的具体用法?Java ImageLoader.ImageListener怎么用?Java ImageLoader.ImageListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.volley.toolbox.ImageLoader的用法示例。


在下文中一共展示了ImageLoader.ImageListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getImageListener

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
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);
            }
        }
    };
}
 
开发者ID:duanze,项目名称:Meizitu,代码行数:34,代码来源:ImageCacheManager.java

示例2: getView

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
@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;
}
 
开发者ID:bianwl,项目名称:kanxue,代码行数:41,代码来源:PostReplyAdapter.java

示例3: getImageListener

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
public static ImageLoader.ImageListener getImageListener(final ImageView view,
                                                         final Drawable defaultImageDrawable, final Drawable errorImageDrawable) {
    return new ImageLoader.ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorImageDrawable != null) {
                view.setImageDrawable(errorImageDrawable);
            }
        }

        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                if (!isImmediate && defaultImageDrawable != null) {
                    TransitionDrawable transitionDrawable = new TransitionDrawable(
                            new Drawable[]{
                                    defaultImageDrawable,
                                    new BitmapDrawable(App.getContext().getResources(),
                                            response.getBitmap())
                            }
                    );
                    transitionDrawable.setCrossFadeEnabled(true);
                    view.setImageDrawable(transitionDrawable);
                    transitionDrawable.startTransition(100);
                } else {
                    view.setImageBitmap(response.getBitmap());
                }
            } else if (defaultImageDrawable != null) {
                view.setImageDrawable(defaultImageDrawable);
            }
        }
    };
}
 
开发者ID:SparkYuan,项目名称:Material-9GAG,代码行数:34,代码来源:ImageCacheManager.java

示例4: send

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
public static void send(ImageView iv, String resId, int maxWidth, int maxHeight) {
    ImageLoader.ImageListener imageListener = ImageLoader.getImageListener(iv,
            R.mipmap.pic_load_wait, R.mipmap.pic_load_failed);
    String url = getPictureUrl(resId);
    imageLoader.get(url, imageListener, maxWidth, maxHeight);
    LogUtil.log("GET PIC => " + url);
}
 
开发者ID:sczyh30,项目名称:yuedong-app,代码行数:8,代码来源:BitmapRequestClient.java

示例5: getImageListener

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
public static ImageLoader.ImageListener getImageListener(final ImageView view, final Drawable defaultImageDrawable, final Drawable errorImageDrawable) {
    return new ImageLoader.ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorImageDrawable != null) {
                view.setImageDrawable(errorImageDrawable);
            }
        }

        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                if (!isImmediate && defaultImageDrawable != null) {
                    TransitionDrawable transitionDrawable = new TransitionDrawable(
                            new Drawable[]{
                                    defaultImageDrawable,
                                    new BitmapDrawable(App.getContext().getResources(),
                                            response.getBitmap())
                            }
                    );
                    transitionDrawable.setCrossFadeEnabled(true);
                    view.setImageDrawable(transitionDrawable);
                    transitionDrawable.startTransition(100);
                } else {
                    view.setImageBitmap(response.getBitmap());
                }
            } else if (defaultImageDrawable != null) {
                view.setImageDrawable(defaultImageDrawable);
            }
        }
    };
}
 
开发者ID:iQuick,项目名称:VolleyManager,代码行数:33,代码来源:ImageCacheManager.java

示例6: loadImage

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
/**
 * 限制图片的宽高,如果w,h的参数为0,则不压缩
 * @param imageView
 * @param url
 * @param w
 * @param h
 */
public static void loadImage(ImageView imageView, String url,int w,int h) {

    ImageLoader.ImageListener listener = ImageLoader.getImageListener(imageView,
            R.drawable.default_avatar_ori, R.drawable.default_avatar_ori);
    ImageLoader imageLoader = new ImageLoader(queue, new BitmapCache());

    if (w<=0||h<=0){
        imageLoader.get(url, listener);
    }else{
        imageLoader.get(url, listener,w,h);
    }
}
 
开发者ID:chenjunqian,项目名称:here,代码行数:20,代码来源:HttpRequest.java

示例7: getImageListener

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
public static ImageLoader.ImageListener getImageListener(final ImageView view,
                                                         final Drawable defaultImageDrawable, final Drawable errorImageDrawable) {
    return new ImageLoader.ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorImageDrawable != null) {
                view.setImageDrawable(errorImageDrawable);
            }
        }

        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                if (!isImmediate && defaultImageDrawable != null) {
                    TransitionDrawable transitionDrawable = new TransitionDrawable(
                            new Drawable[]{
                                    defaultImageDrawable,
                                    new BitmapDrawable(BaseApplication.getBaseApplication().getResources(),
                                            response.getBitmap())
                            });
                    transitionDrawable.setCrossFadeEnabled(true);
                    view.setImageDrawable(transitionDrawable);
                    transitionDrawable.startTransition(100);
                } else {
                    view.setImageBitmap(response.getBitmap());
                }
            } else if (defaultImageDrawable != null) {
                view.setImageDrawable(defaultImageDrawable);
            }
        }
    };
}
 
开发者ID:lofei117,项目名称:TuChongAndroid,代码行数:33,代码来源:RequestManager.java

示例8: get_imageloader

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
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);

}
 
开发者ID:Tim9Liu9,项目名称:volley_demo,代码行数:14,代码来源:ImagesActivity.java

示例9: getImage

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
public static void getImage(String imgUrl, ImageView view) {
    initRequestQueue();
    ImageLoader imageLoader = new ImageLoader(mRequestQueue, new BitmapCache());
    ImageLoader.ImageListener listener = ImageLoader.getImageListener(view, R.mipmap.loading, R.mipmap.email);
    imageLoader.get(imgUrl,listener);
}
 
开发者ID:ligongzai,项目名称:QianXun,代码行数:7,代码来源:RequestManager.java

示例10: getUserPhoto

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
public static void getUserPhoto(String imgUrl, ImageView view) {
    initRequestQueue();
    ImageLoader imageLoader = new ImageLoader(mRequestQueue, new BitmapCache());
    ImageLoader.ImageListener listener = ImageLoader.getImageListener(view, R.mipmap.profile_picture, R.mipmap.profile_picture);
    imageLoader.get(imgUrl,listener);
}
 
开发者ID:ligongzai,项目名称:QianXun,代码行数:7,代码来源:RequestManager.java

示例11: UseImageLoader

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
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);
}
 
开发者ID:henrymorgen,项目名称:android-advanced-light,代码行数:6,代码来源:MainActivity.java

示例12: getImage

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
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);
}
 
开发者ID:yuchenfw,项目名称:QuickNews,代码行数:7,代码来源:NewsAdapter.java

示例13: loadImage

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
public ImageLoader.ImageContainer loadImage(String requestUrl,
                                            ImageLoader.ImageListener imageListener) {
    return loadImage(requestUrl, imageListener, 0, 0);
}
 
开发者ID:duanze,项目名称:Meizitu,代码行数:5,代码来源:ImageCacheManager.java

示例14: getView

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
    ViewHolder holder;
    if (view == null) {
        view = LayoutInflater.from(mContext).inflate(R.layout.forum_listview_item, null);
        holder = new ViewHolder();
        holder.imv = (ImageView) view.findViewById(R.id.id_imv_user_icon);
        holder.title = (TextView) view.findViewById(R.id.id_tv_title);
        holder.readCount = (TextView) view.findViewById(R.id.id_tv_readNum);
        holder.replyCount = (TextView) view.findViewById(R.id.id_tv_replyNum);
        holder.username = (TextView) view.findViewById(R.id.id_tv_threadusername);
        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }
    ThreadBean bean = list.get(i);
    if (bean != null) {
        String title = bean.getThreadtitle();
        if (AppConstants.NEW_FORUM_ID != threadType) {
            if (AppConstants.GLOBLE_TOP_FORUM == bean.getGlobalsticky()) {
                title = "<font color=\"red\">【总顶】</font>" + bean.getThreadtitle();

            } else if (AppConstants.TOP_FORUM == bean.getSticky()) {
                title = "<font color=\"red\">【置顶】</font>" + bean.getThreadtitle();
            }
        }
        if (bean.getAvatar() == 0) {
            holder.imv.setBackgroundResource(R.mipmap.nopic);
        } else if (bean.getAvatar() == 1) {
            int userId = bean.getPostuserid();
            ImageLoader.ImageListener listener = ImageLoader.getImageListener(holder.imv, R.mipmap.nopic, R.mipmap.nopic);
            imageLoader.get(AppConstants.USER_ICON_PATH + userId, listener);
        }
        holder.title.setText(Html.fromHtml(title));
        holder.replyCount.setText(bean.getReplycount() + "");
        holder.readCount.setText(bean.getViews() + "");
        holder.username.setText(bean.getPostusername());
    }

    return view;
}
 
开发者ID:bianwl,项目名称:kanxue,代码行数:42,代码来源:ThreadAdapter.java

示例15: loadImage

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
public static ImageLoader.ImageContainer loadImage(String requestUrl,
                                                   ImageLoader.ImageListener imageListener) {
    return loadImage(requestUrl, imageListener, 0, 0);
}
 
开发者ID:SparkYuan,项目名称:Material-9GAG,代码行数:5,代码来源:ImageCacheManager.java


注:本文中的com.android.volley.toolbox.ImageLoader.ImageListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。