mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-13 12:38:58 +01:00
Change filename for downloaded chapters, using the last path from the url is not reliable. This will break compatibility with previously downloaded chapters, they have to be deleted and downloaded again.
Disable download progress in the chapters view, it will avoid some crashes.
This commit is contained in:
@@ -5,6 +5,10 @@ import java.net.URISyntaxException;
|
||||
|
||||
public class UrlUtil {
|
||||
|
||||
private static final String JPG = ".jpg";
|
||||
private static final String PNG = ".png";
|
||||
private static final String GIF = ".gif";
|
||||
|
||||
public static String getPath(String s) {
|
||||
try {
|
||||
URI uri = new URI(s);
|
||||
@@ -18,4 +22,37 @@ public class UrlUtil {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isJpg(String url) {
|
||||
return containsIgnoreCase(url, JPG);
|
||||
}
|
||||
|
||||
public static boolean isPng(String url) {
|
||||
return containsIgnoreCase(url, PNG);
|
||||
}
|
||||
|
||||
public static boolean isGif(String url) {
|
||||
return containsIgnoreCase(url, GIF);
|
||||
}
|
||||
|
||||
public static boolean containsIgnoreCase(String src, String what) {
|
||||
final int length = what.length();
|
||||
if (length == 0)
|
||||
return true; // Empty string is contained
|
||||
|
||||
final char firstLo = Character.toLowerCase(what.charAt(0));
|
||||
final char firstUp = Character.toUpperCase(what.charAt(0));
|
||||
|
||||
for (int i = src.length() - length; i >= 0; i--) {
|
||||
// Quick check before calling the more expensive regionMatches() method:
|
||||
final char ch = src.charAt(i);
|
||||
if (ch != firstLo && ch != firstUp)
|
||||
continue;
|
||||
|
||||
if (src.regionMatches(true, i, what, 0, length))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user