Skip to content

Commit

Permalink
修复下载图片时保存的图片格式与实际格式不相符的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojieonly committed Nov 14, 2024
1 parent 0fe1c1e commit 2c78dd0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ android {

defaultConfig {
applicationId "com.xjs.ehviewer"
minSdkVersion 24
minSdkVersion 23
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 30
targetSdkVersion 29
versionCode 111
versionName "1.9.9.3"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public abstract class GalleryProvider2 extends GalleryProvider {
".jpeg",
".png", // Portable Network Graphics
".gif", // Graphics Interchange Format
".webp"
};

public int getStartPage() {
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/com/hippo/ehviewer/spider/SpiderDen.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,12 @@ private OutputStreamPipe openDownloadOutputStreamPipe(int index, @Nullable Strin
if (dir == null) {
return null;
}
if (extension==null||!extension.contains(".")){
extension = fixExtension('.' + extension);
}else {
extension = fixExtension(extension);
}

extension = fixExtension('.' + extension);
UniFile file = dir.createFile(generateImageFilename(index, extension));
if (file != null) {
return new UniFileOutputStreamPipe(file);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.java
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,9 @@ private boolean downloadImage(long gid, int index, String pToken, String previou
MediaType mediaType = responseBody.contentType();
if (mediaType != null) {
extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mediaType.toString());
if (extension != null&&!extension.contains(".")){
extension= "."+extension;
}
}
// Ensure extension
if (!Utilities.contain(GalleryProvider2.SUPPORT_IMAGE_EXTENSIONS, extension)) {
Expand Down

0 comments on commit 2c78dd0

Please sign in to comment.