示例#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();
      }
    }
  }
示例#2
0
 @Override
 public void onLowMemory() {
   BitmapAjaxCallback.clearCache();
 }
示例#3
0
  @Override
  public void bindView(View v, Context context, Cursor c) {
    try {
      super.bindView(v, context, c);
      AQuery aq = new AQuery(v);

      Boolean img = Boolean.valueOf(c.getInt(c.getColumnIndex("img")) != 0);
      Integer _id = Integer.valueOf(c.getInt(c.getColumnIndex("_id")));
      String name = c.getString(c.getColumnIndex("name"));
      String title = c.getString(c.getColumnIndex("title"));

      String[] id_type_files = null;
      String[] file_files = null;
      if (!c.isNull(c.getColumnIndex("id_type_files"))
          && !c.isNull(c.getColumnIndex("file_files"))) {
        id_type_files = c.getString(c.getColumnIndex("id_type_files")).split(",");
        file_files = c.getString(c.getColumnIndex("file_files")).split(",");
      }

      if (Boolean.valueOf(c.getInt(c.getColumnIndex("favorite")) != 0))
        aq.id(R.id.item).backgroundColor(v.getResources().getColor(R.color.main_lite));
      else aq.id(R.id.item).backgroundColor(v.getResources().getColor(R.color.white));

      aq.id(R.id.title).text(title);

      if (img.booleanValue()) {
        if (funct.ExternalStorageState()) {
          File imgFile = new File(funct.get_dir_app() + "/img/books_brochures/" + name + ".jpg");
          if (imgFile.exists()) {
            BitmapAjaxCallback cb = new BitmapAjaxCallback();
            cb.targetWidth(0).round(10);
            aq.id(R.id.img).image(imgFile, false, 0, cb);

          } else {
            aq.id(R.id.img).image(R.drawable.ic_noimages);
            ContentValues initialValues = new ContentValues();
            initialValues.put("img", "0");
            database.update("magazine", initialValues, "_id=?", new String[] {_id.toString()});
          }
        } else {
          aq.id(R.id.img).image(R.drawable.ic_noimages);
        }
      } else {
        aq.id(R.id.img).image(R.drawable.ic_noimages);
      }

      aq.id(R.id.type1).image(R.drawable.ic_none_type);
      aq.id(R.id.type2).image(R.drawable.ic_none_type);
      aq.id(R.id.type3).image(R.drawable.ic_none_type);
      aq.id(R.id.type4).image(R.drawable.ic_none_type);
      aq.id(R.id.type5).image(R.drawable.ic_none_type);

      if (id_type_files != null) {
        Map<Integer, Boolean> tipe_files = funct.get_map_files(id_type_files, file_files);
        for (Integer key : tipe_files.keySet()) {
          switch (key) {
            case 1:
              if (tipe_files.get(key).booleanValue()) aq.id(R.id.type1).image(R.drawable.ic_pdf_1);
              else aq.id(R.id.type1).image(R.drawable.ic_pdf_0);
              break;
            case 2:
              if (tipe_files.get(key).booleanValue()) aq.id(R.id.type2).image(R.drawable.ic_epub_1);
              else aq.id(R.id.type2).image(R.drawable.ic_epub_0);
              break;
            case 3:
              if (tipe_files.get(key).booleanValue()) aq.id(R.id.type3).image(R.drawable.ic_mobi_1);
              else aq.id(R.id.type3).image(R.drawable.ic_mobi_0);
              break;

            case 6:
              if (tipe_files.get(key).booleanValue()) aq.id(R.id.type4).image(R.drawable.ic_mp3_1);
              else aq.id(R.id.type4).image(R.drawable.ic_mp3_0);
              break;

            case 7:
              if (tipe_files.get(key).booleanValue()) aq.id(R.id.type5).image(R.drawable.ic_aac_1);
              else aq.id(R.id.type5).image(R.drawable.ic_aac_0);
              break;

            default:
              break;
          }
        }
      }
    } catch (Exception e) {
      funct.send_bug_report(e);
    }
  }