Skip to content

Commit 2c78dd0

Browse files
committed
修复下载图片时保存的图片格式与实际格式不相符的问题
1 parent 0fe1c1e commit 2c78dd0

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ android {
2626

2727
defaultConfig {
2828
applicationId "com.xjs.ehviewer"
29-
minSdkVersion 24
29+
minSdkVersion 23
3030
//noinspection ExpiredTargetSdkVersion
31-
targetSdkVersion 30
31+
targetSdkVersion 29
3232
versionCode 111
3333
versionName "1.9.9.3"
3434
vectorDrawables.useSupportLibrary = true

app/src/main/java/com/hippo/ehviewer/gallery/GalleryProvider2.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public abstract class GalleryProvider2 extends GalleryProvider {
2929
".jpeg",
3030
".png", // Portable Network Graphics
3131
".gif", // Graphics Interchange Format
32+
".webp"
3233
};
3334

3435
public int getStartPage() {

app/src/main/java/com/hippo/ehviewer/spider/SpiderDen.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,12 @@ private OutputStreamPipe openDownloadOutputStreamPipe(int index, @Nullable Strin
321321
if (dir == null) {
322322
return null;
323323
}
324+
if (extension==null||!extension.contains(".")){
325+
extension = fixExtension('.' + extension);
326+
}else {
327+
extension = fixExtension(extension);
328+
}
324329

325-
extension = fixExtension('.' + extension);
326330
UniFile file = dir.createFile(generateImageFilename(index, extension));
327331
if (file != null) {
328332
return new UniFileOutputStreamPipe(file);

app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,9 @@ private boolean downloadImage(long gid, int index, String pToken, String previou
13721372
MediaType mediaType = responseBody.contentType();
13731373
if (mediaType != null) {
13741374
extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mediaType.toString());
1375+
if (extension != null&&!extension.contains(".")){
1376+
extension= "."+extension;
1377+
}
13751378
}
13761379
// Ensure extension
13771380
if (!Utilities.contain(GalleryProvider2.SUPPORT_IMAGE_EXTENSIONS, extension)) {

0 commit comments

Comments
 (0)