예제 #1
0
 @Override
 protected void onPostExecute(SingleResponse<File> result) {
   super.onPostExecute(result);
   if (mListener != null) {
     if (result.hasData()) {
       mListener.onVideoLoadingComplete(mUri, mListener, result.getData());
     } else {
       mListener.onVideoLoadingFailed(mUri, mListener, result.getException());
     }
   }
   mPreLoader.notifyTaskFinish(mUri, result.hasData());
 }
예제 #2
0
 @Override
 protected SingleResponse<File> doInBackground(Object... params) {
   final DiskCache diskCache = mPreLoader.mDiskCache;
   final File cachedFile = diskCache.get(mUri);
   if (!mForceReload && cachedFile != null && cachedFile.isFile() && cachedFile.length() > 0)
     return SingleResponse.getInstance(cachedFile);
   InputStream is = null;
   try {
     is = mPreLoader.mImageDownloader.getStream(mUri, null);
     diskCache.save(mUri, is, this);
     return SingleResponse.getInstance(diskCache.get(mUri));
   } catch (IOException e) {
     diskCache.remove(mUri);
     Log.w(LOGTAG, e);
     return SingleResponse.getInstance(e);
   } finally {
     IoUtils.closeSilently(is);
   }
 }