fixed crash when playing video
This commit is contained in:
parent
154da52ca9
commit
5452a03338
|
@ -120,18 +120,22 @@ public class VideoLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SingleResponse<File> doInBackground(Object... params) {
|
protected SingleResponse<File> doInBackground(Object... params) {
|
||||||
final File file = mPreLoader.mDiskCache.get(mUri);
|
final DiskCache diskCache = mPreLoader.mDiskCache;
|
||||||
if (file.isFile() && file.length() > 0) return SingleResponse.getInstance(file);
|
final File cachedFile = diskCache.get(mUri);
|
||||||
|
if (cachedFile != null && cachedFile.isFile() && cachedFile.length() > 0)
|
||||||
|
return SingleResponse.getInstance(cachedFile);
|
||||||
|
InputStream is = null;
|
||||||
try {
|
try {
|
||||||
final InputStream is = mPreLoader.mImageDownloader.getStream(mUri, null);
|
is = mPreLoader.mImageDownloader.getStream(mUri, null);
|
||||||
mPreLoader.mDiskCache.save(mUri, is, this);
|
diskCache.save(mUri, is, this);
|
||||||
IoUtils.closeSilently(is);
|
return SingleResponse.getInstance(diskCache.get(mUri));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
mPreLoader.mDiskCache.remove(mUri);
|
diskCache.remove(mUri);
|
||||||
Log.w(LOGTAG, e);
|
Log.w(LOGTAG, e);
|
||||||
return SingleResponse.getInstance(e);
|
return SingleResponse.getInstance(e);
|
||||||
|
} finally {
|
||||||
|
IoUtils.closeSilently(is);
|
||||||
}
|
}
|
||||||
return SingleResponse.getInstance(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue