Esempio n. 1
0
  public boolean trySetCoverImage(ImageView coverView, FBTree tree) {
    final CoverHolder holder = getHolder(coverView, tree);

    Bitmap coverBitmap;
    try {
      coverBitmap = Cache.getBitmap(holder.Key);
    } catch (CoverCache.NullObjectException e) {
      return false;
    }

    if (coverBitmap == null) {
      final ZLImage cover = tree.getCover();
      if (cover instanceof ZLLoadableImage) {
        final ZLLoadableImage img = (ZLLoadableImage) cover;
        if (img.isSynchronized()) {
          setCoverForView(holder, img);
        } else {
          img.startSynchronization(holder.new CoverSyncRunnable(img));
        }
      } else if (cover != null) {
        coverBitmap = getBitmap(cover);
      }
    }
    if (coverBitmap != null) {
      holder.CoverView.setImageBitmap(coverBitmap);
      return true;
    }
    return false;
  }
Esempio n. 2
0
 void setCoverForView(CoverHolder holder, ZLLoadableImage image) {
   synchronized (holder) {
     try {
       final Bitmap coverBitmap = Cache.getBitmap(holder.Key);
       if (coverBitmap != null) {
         holder.CoverView.setImageBitmap(coverBitmap);
       } else if (holder.coverBitmapTask == null) {
         holder.coverBitmapTask = myPool.submit(holder.new CoverBitmapRunnable(image));
       }
     } catch (CoverCache.NullObjectException e) {
     }
   }
 }