コード例 #1
0
    @Override
    public void onFutureDone(final Future<File> future) {
      final File file = future.get();
      long id = 0;
      if (file != null) { // insert to database
        id = insertEntry(mUrl, file);
      }

      if (future.isCancelled()) {
        Utils.assertTrue(mProxySet.isEmpty());
        return;
      }

      synchronized (mTaskMap) {
        Entry entry = null;
        synchronized (mEntryMap) {
          if (file != null) {
            entry = new Entry(id, file);
            Utils.assertTrue(mEntryMap.put(mUrl, entry) == null);
          }
        }
        for (final TaskProxy proxy : mProxySet) {
          proxy.setResult(entry);
        }
        mTaskMap.remove(mUrl);
        freeSomeSpaceIfNeed(MAX_DELETE_COUNT);
      }
    }
コード例 #2
0
 public void removeProxy(final TaskProxy proxy) {
   synchronized (mTaskMap) {
     Utils.assertTrue(mProxySet.remove(proxy));
     if (mProxySet.isEmpty()) {
       mFuture.cancel();
       mTaskMap.remove(mUrl);
     }
   }
 }