Minor tweak to UriDataSource.

This commit is contained in:
Oliver Woodman 2014-10-28 14:12:55 +00:00
parent b5c4148f8f
commit c34f7368ae

View file

@ -62,24 +62,21 @@ public final class UriDataSource implements DataSource {
@Override
public long open(DataSpec dataSpec) throws IOException {
Assertions.checkState(dataSource == null);
dataSource = dataSpec.uri.getScheme().equals(FILE_URI_SCHEME) ? fileDataSource : httpDataSource;
dataSource = FILE_URI_SCHEME.equals(dataSpec.uri.getScheme()) ? fileDataSource : httpDataSource;
return dataSource.open(dataSpec);
}
@Override
public void close() throws IOException {
Assertions.checkNotNull(dataSource);
dataSource.close();
dataSource = null;
}
@Override
public int read(byte[] buffer, int offset, int readLength) throws IOException {
Assertions.checkNotNull(dataSource);
return dataSource.read(buffer, offset, readLength);
}
@Override
public void close() throws IOException {
if (dataSource != null) {
dataSource.close();
dataSource = null;
}
}
}