當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageLoader類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:VolleyLoaderActivity.java

示例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());
    }
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:22,代碼來源:ChatSDKAbstractThreadsListAdapter.java

示例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();
        }
    });
}
 
開發者ID:timitoc,項目名稱:groupicture,代碼行數:23,代碼來源:SaveLocalManager.java

示例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());
        }
    });
}
 
開發者ID:timitoc,項目名稱:groupicture,代碼行數:17,代碼來源:BigImageViewActivity.java

示例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);
        }
    });
}
 
開發者ID:mortorqrobotics,項目名稱:morscout-android,代碼行數:22,代碼來源:MorScout.java

示例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);

}
 
開發者ID:datafile4,項目名稱:book-store-android,代碼行數:18,代碼來源:CartAdapter.java

示例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;
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:24,代碼來源:FifeNetworkImageView.java

示例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;
}
 
開發者ID:poberwong,項目名稱:digcsdn,代碼行數:24,代碼來源:ImageLoading.java

示例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);
}
 
開發者ID:freedomofme,項目名稱:Netease,代碼行數:24,代碼來源:MySingleton.java

示例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;
}
 
開發者ID:rantianhua,項目名稱:ShuTuier,代碼行數:23,代碼來源:GridAdapter.java

示例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) {

            }
        });
    }
}
 
開發者ID:maikotrindade,項目名稱:android-basics,代碼行數:19,代碼來源:AdapterMovies.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:VolleyDraweeControllerBuilderSupplier.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:35,代碼來源:VolleyDataSource.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:VolleyDraweeControllerBuilder.java

示例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);

}
 
開發者ID:henrymorgen,項目名稱:android-advanced-light,代碼行數:9,代碼來源:MainActivity.java


注:本文中的com.android.volley.toolbox.ImageLoader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。