添加修改下载文件夹为 gid-title 入口

This commit is contained in:
seven332 committed 2014-10-12 22:43:53 +08:00
1 parent a7a3d56c91
commit 0ed34f2eca
16 files changed
+409 -266

No files matched your search

+71 -2
View File
@@ -18,19 +18,88 @@ package com.hippo.ehviewer.util;
import java.io.File;
import com.hippo.ehviewer.data.ListUrls;
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
};
// 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"}
};
public static int getCategory(String type) {
int i;
for (i = 0; i < CATEGORY_STRINGS.length - 1; i++) {
for (String str : CATEGORY_STRINGS[i])
if (str.equalsIgnoreCase(type))
return CATEGORY_VALUES[i];
}
return CATEGORY_VALUES[i];
}
public static String getCategory(int type) {
int i;
for (i = 0; i < CATEGORY_VALUES.length - 1; i++) {
if (CATEGORY_VALUES[i] == type)
break;
}
return CATEGORY_STRINGS[i][0];
}
/**
* Get gallery for read and download
* Gid is constant, but title may be changed
* 非要标题,记一下 gid 不行么
*
* @param gid
* @param title
* @return
*/
public static File getGalleryDir(int gid) {
return new File(Config.getDownloadPath(),
public static File getGalleryDir(int gid, String title) {
File downloadDir = new File(Config.getDownloadPath());
File gDir = new File(downloadDir,
Utils.standardizeFilename(Integer.toString(gid)));
if (gDir.exists())
return gDir;
else
return generateGalleryDir(gid, title);
// 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));
}
/**