コード例 #1
0
ファイル: ResourceRecycler.java プロジェクト: hegazy/glide
 @Override
 public boolean handleMessage(Message message) {
   if (message.what == RECYCLE_RESOURCE) {
     Resource<?> resource = (Resource<?>) message.obj;
     resource.recycle();
     return true;
   }
   return false;
 }
コード例 #2
0
  @Override
  public synchronized void recycle() {
    stateVerifier.throwIfRecycled();

    this.isRecycled = true;
    if (!isLocked) {
      toWrap.recycle();
      release();
    }
  }
コード例 #3
0
ファイル: ResourceRecycler.java プロジェクト: hegazy/glide
  public void recycle(Resource<?> resource) {
    Util.assertMainThread();

    if (isRecycling) {
      // If a resource has sub-resources, releasing a sub resource can cause it's parent to be
      // synchronously
      // evicted which leads to a recycle loop when the parent releases it's children. Posting
      // breaks this loop.
      handler.obtainMessage(ResourceRecyclerCallback.RECYCLE_RESOURCE, resource).sendToTarget();
    } else {
      isRecycling = true;
      resource.recycle();
      isRecycling = false;
    }
  }