Skip to content

Commit

Permalink
Apply Dar9586/NClientV2 !762
Browse files Browse the repository at this point in the history
  • Loading branch information
damianjester committed Dec 5, 2024
1 parent 8862712 commit ff7c6c1
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
8 changes: 7 additions & 1 deletion app/src/main/java/com/dar/nclientv2/api/SimpleGallery.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public SimpleGallery(Context context, Element e) {
a = e.getElementsByTag("img").first();
temp = a.hasAttr("data-src") ? a.attr("data-src") : a.attr("src");
mediaId = Integer.parseInt(temp.substring(temp.indexOf("galleries") + 10, temp.lastIndexOf('/')));
thumbnail = Page.charToExt(temp.charAt(temp.length() - 3));
String extension = temp.substring(temp.lastIndexOf('.') + 1);
thumbnail = Page.charToExt(extension.charAt(0));
title = e.getElementsByTag("div").first().text();
if (context != null && id > Global.getMaxId()) Global.updateMaxId(context, id);
}
Expand All @@ -93,13 +94,18 @@ public SimpleGallery(Gallery gallery) {
}

private static String extToString(ImageExt ext) {
if (ext == null) {
return null;
}
switch (ext) {
case GIF:
return "gif";
case PNG:
return "png";
case JPG:
return "jpg";
case WEBP:
return "webp";
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ private void readPagePath(String path) throws IOException {
case 'p':
case 'j':
case 'g':
case 'w':
if (specialImages) {
cover = new Page(ImageType.COVER, Page.charToExt(actualChar));
thumbnail = new Page(ImageType.THUMBNAIL, Page.charToExt(actualChar));
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/dar/nclientv2/api/components/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public static String extToString(ImageExt ext) {
return "png";
case JPG:
return "jpg";
case WEBP:
return "webp";
}
return null;
}
Expand All @@ -102,6 +104,8 @@ public static char extToChar(ImageExt imageExt) {
return 'p';
case JPG:
return 'j';
case WEBP:
return 'w';
}
return '\0';
}
Expand All @@ -114,6 +118,8 @@ public static ImageExt charToExt(int ext) {
return ImageExt.PNG;
case 'j':
return ImageExt.JPG;
case 'w':
return ImageExt.WEBP;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.dar.nclientv2.api.enums;

public enum ImageExt {
JPG("jpg"), PNG("png"), GIF("gif");
JPG("jpg"), PNG("png"), GIF("gif"), WEBP("webp");

private final char firstLetter;
private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public LocalGallery[] newArray(int size) {
return new LocalGallery[size];
}
};
private static final Pattern FILE_PATTERN = Pattern.compile("^(\\d{1,9})\\.(gif|png|jpg)$", Pattern.CASE_INSENSITIVE);
private static final Pattern FILE_PATTERN = Pattern.compile("^(\\d{1,9})\\.(gif|png|jpg|webp)$", Pattern.CASE_INSENSITIVE);
private static final Pattern DUP_PATTERN = Pattern.compile("^(.*)\\.DUP\\d+$");
private static final Pattern IDFILE_PATTERN = Pattern.compile("^\\.\\d{1,6}$");
private final GalleryFolder folder;
Expand Down Expand Up @@ -106,6 +106,8 @@ public static File getPage(File dir, int page) {
if (dir == null || !dir.exists()) return null;
String pag = String.format(Locale.US, "%03d.", page);
File x;
x = new File(dir, pag + "webp");
if (x.exists()) return x;
x = new File(dir, pag + "jpg");
if (x.exists()) return x;
x = new File(dir, pag + "png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public GalleryFolder[] newArray(int size) {
return new GalleryFolder[size];
}
};
private static final Pattern FILE_PATTERN = Pattern.compile("^0*(\\d{1,9})\\.(gif|png|jpg)$", Pattern.CASE_INSENSITIVE);
private static final Pattern FILE_PATTERN = Pattern.compile("^0*(\\d{1,9})\\.(gif|png|jpg|webp)$", Pattern.CASE_INSENSITIVE);
private static final Pattern IDFILE_PATTERN = Pattern.compile("^\\.(\\d{1,6})$");
private static final String NOMEDIA_FILE = ".nomedia";
private final SparseArrayCompat<PageFile> pageArray = new SparseArrayCompat<>();
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/dar/nclientv2/files/PageFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public PageFile[] newArray(int size) {
return new PageFile[size];
}
};
private static final Pattern DEFAULT_THUMBNAIL = Pattern.compile("^0*1\\.(gif|png|jpg)$", Pattern.CASE_INSENSITIVE);
private static final Pattern VALID_PAGE = Pattern.compile("^0*(\\d+)\\.(gif|png|jpg)$", Pattern.CASE_INSENSITIVE);
private static final Pattern DEFAULT_THUMBNAIL = Pattern.compile("^0*1\\.(gif|png|jpg|webp)$", Pattern.CASE_INSENSITIVE);
private static final Pattern VALID_PAGE = Pattern.compile("^0*(\\d+)\\.(gif|png|jpg|webp)$", Pattern.CASE_INSENSITIVE);
private final ImageExt ext;
private final int page;

Expand Down

0 comments on commit ff7c6c1

Please sign in to comment.