示例#1
0
  public void loadImage() {

    if (m_iv == null) return;

    onPreload(m_iv);
    if (m_url == null || m_url.isEmpty() || m_url.toLowerCase().endsWith(".gif")) {
      onFail(m_iv);
    } else {
      try {
        Bitmap cachedImage = m_aq.getCachedImage(m_url, m_width);
        if (cachedImage != null) {
          onSucc(m_iv, cachedImage, true);
        } else if (position >= 0 && m_aq.shouldDelay(position, convertView, parent, m_url)) {
          onFail(m_iv);
        } else {

          onAsyncStarted(m_iv);

          m_iv.setTag(AQuery.TAG_URL, m_url);

          BitmapAjaxCallback cb =
              new BitmapAjaxCallback() {
                @Override
                protected void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status) {

                  if (bm == null && onFail(iv)) return;
                  if (bm != null && onSucc(iv, bm, false)) return;
                  super.callback(url, iv, bm, status);
                }
              };
          cb.url(m_url);
          cb.fileCache(m_cacheFile);
          cb.memCache(m_cacheMemory);
          cb.targetWidth(m_width);
          cb.animation(AQuery.FADE_IN_NETWORK);

          // if (m_fail_placeholder != 0) cb.fallback(m_fail_placeholder);
          if (m_progress != 0) {
            m_aq.progress(m_progress);
          }
          m_aq.id(m_iv).image(cb);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }