當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。