Fix image extension

This commit is contained in:
NekoInverter committed 2020-10-27 22:11:35 +08:00
1 parent 867a9fb66f
commit 257804cc85
7 files changed
+87 -4

No files matched your search

@@ -629,6 +629,39 @@ public final class SpiderQueen implements Runnable {
}
}
@Nullable
public String getExtension(int index) {
int state = getPageState(index);
if (STATE_FINISHED != state) {
return null;
}
InputStreamPipe pipe = mSpiderDen.openInputStreamPipe(index);
if (null == pipe) {
return null;
}
OutputStream os = null;
try {
pipe.obtain();
// Get dst file
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(pipe.open(), null, options);
pipe.close();
return MimeTypeMap.getSingleton().getExtensionFromMimeType(options.outMimeType);
} catch (IOException e) {
return null;
} finally {
pipe.close();
pipe.release();
IOUtils.closeQuietly(os);
}
}
public int getStartPage() {
SpiderInfo spiderInfo = readSpiderInfoFromLocal();
if (spiderInfo != null) {