Merge branch 'dev' of github.com:seven332/EhViewer into dev

This commit is contained in:
seven332 committed 2014-10-25 13:17:17 +08:00
commit 4b4aaa982f
1 file changed
+23 -38
+23 -38
View File
@@ -24,34 +24,16 @@ public final class EhUtils {
public static final String EH_DOWNLOAD_FILENAME = ".ehviewer";
private static final int[] CATEGORY_VALUES = {
ListUrls.MISC,
ListUrls.DOUJINSHI,
ListUrls.MANGA,
ListUrls.ARTIST_CG,
ListUrls.GAME_CG,
ListUrls.IMAGE_SET,
ListUrls.COSPLAY,
ListUrls.ASIAN_PORN,
ListUrls.NON_H,
ListUrls.WESTERN,
ListUrls.UNKNOWN
};
private static final int[] CATEGORY_VALUES = { ListUrls.MISC, ListUrls.DOUJINSHI, ListUrls.MANGA,
ListUrls.ARTIST_CG, ListUrls.GAME_CG, ListUrls.IMAGE_SET, ListUrls.COSPLAY, ListUrls.ASIAN_PORN,
ListUrls.NON_H, ListUrls.WESTERN, ListUrls.UNKNOWN };
// TODO How about "Private"
private static final String[][] CATEGORY_STRINGS = {
new String[]{"misc"},
new String[]{"doujinshi"},
new String[]{"manga"},
new String[]{"artistcg", "Artist CG Sets"},
new String[]{"gamecg", "Game CG Sets"},
new String[]{"imageset", "Image Sets"},
new String[]{"cosplay"},
new String[]{"asianporn", "Asian Porn"},
new String[]{"non-h"},
new String[]{"western"},
new String[]{"unknown"}
};
private static final String[][] CATEGORY_STRINGS = { new String[] { "misc" }, new String[] { "doujinshi" },
new String[] { "manga" }, new String[] { "artistcg", "Artist CG Sets" },
new String[] { "gamecg", "Game CG Sets" }, new String[] { "imageset", "Image Sets" },
new String[] { "cosplay" }, new String[] { "asianporn", "Asian Porn" }, new String[] { "non-h" },
new String[] { "western" }, new String[] { "unknown" } };
public static int getCategory(String type) {
int i;
@@ -74,9 +56,8 @@ public final class EhUtils {
}
/**
* Get gallery for read and download
* Gid is constant, but title may be changed
* 非要标题,记一下 gid 不行么
* Get gallery for read and download Gid is constant, but title may be
* changed 非要标题,记一下 gid 不行么
*
* @param gid
* @param title
@@ -85,8 +66,7 @@ public final class EhUtils {
public static File getGalleryDir(int gid, String title) {
File downloadDir = new File(Config.getDownloadPath());
File gDir = new File(downloadDir,
Utils.standardizeFilename(Integer.toString(gid)));
File gDir = new File(downloadDir, Utils.standardizeFilename(Integer.toString(gid)));
File defaultDir = generateGalleryDir(gid, title);
if (gDir.exists()) {
@@ -95,16 +75,22 @@ public final class EhUtils {
else
return gDir;
} else {
// TODO I need a better way or only call it in non-UI thread
String[] fileList = downloadDir.list();
if (fileList != null) {
for (String str : fileList) {
// For title changed
if (str.startsWith(gid + "-") && (gDir = new File(downloadDir, str)) != null && gDir.isDirectory())
return gDir;
}
}
return defaultDir;
}
// TODO check a dir start with the gid, but it may take a long time
// Create a map to record all ?
}
public static File generateGalleryDir(int gid, String title) {
return new File(Config.getDownloadPath(),
Utils.standardizeFilename(gid + "-" + title));
return new File(Config.getDownloadPath(), Utils.standardizeFilename(gid + "-" + title));
}
/**
@@ -118,10 +104,9 @@ public final class EhUtils {
return String.format("%08d.%s", index + 1, extension);
}
public static String[] getPossibleImageFilenames(int index) {
String prefix = String.format("%08d.", index + 1);
return new String[]{prefix + "jpg", prefix + "jpeg", prefix + "png", prefix + "gif"};
return new String[] { prefix + "jpg", prefix + "jpeg", prefix + "png", prefix + "gif" };
}
}