本文整理匯總了Java中com.android.volley.toolbox.ImageLoader類的典型用法代碼示例。如果您正苦於以下問題:Java ImageLoader類的具體用法?Java ImageLoader怎麽用?Java ImageLoader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ImageLoader類屬於com.android.volley.toolbox包,在下文中一共展示了ImageLoader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: bindLvData
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
@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);
}
}
示例2: onResponse
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
@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());
}
}
示例3: savePrepared
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
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();
}
});
}
示例4: loadImageFromServer
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
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());
}
});
}
示例5: onCreate
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
@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);
}
});
}
示例6: onBindViewHolder
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
@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);
}
示例7: setFifeImageUrl
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
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;
}
示例8: getInstance
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
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;
}
示例9: MySingleton
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
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);
}
示例10: getView
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
@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;
}
示例11: loadImages
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
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) {
}
});
}
}
示例12: VolleyDraweeControllerBuilderSupplier
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
public VolleyDraweeControllerBuilderSupplier(
Context context,
ImageLoader imageLoader,
Set<ControllerListener> boundControllerListeners) {
mContext = context;
mImageLoader = imageLoader;
mVolleyDraweeControllerFactory = new VolleyDraweeControllerFactory(
context.getResources(),
DeferredReleaser.getInstance(),
UiThreadImmediateExecutorService.getInstance());
mBoundControllerListeners = boundControllerListeners;
}
示例13: VolleyDataSource
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
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);
}
示例14: VolleyDraweeControllerBuilder
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
public VolleyDraweeControllerBuilder(
Context context,
ImageLoader imageLoader,
VolleyDraweeControllerFactory volleyDraweeControllerFactory,
Set<ControllerListener> boundControllerListeners) {
super(context, boundControllerListeners);
mImageLoader = imageLoader;
mVolleyDraweeControllerFactory = volleyDraweeControllerFactory;
}
示例15: UseNetworkImageView
import com.android.volley.toolbox.ImageLoader; //導入依賴的package包/類
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);
}