Commit 22b062da authored by feihuaduo's avatar feihuaduo

根据卡组路径获取分类名

parent 12c260a1
...@@ -24,9 +24,9 @@ public class DeckUtil { ...@@ -24,9 +24,9 @@ public class DeckUtil {
public static List<DeckType> getDeckTypeList(Context context) { public static List<DeckType> getDeckTypeList(Context context) {
List<DeckType> deckTypeList = new ArrayList<>(); List<DeckType> deckTypeList = new ArrayList<>();
deckTypeList.add(new DeckType(context.getResources().getString(R.string.category_pack), AppsSettings.get().getPackDeckDir())); deckTypeList.add(new DeckType(YGOUtil.s(R.string.category_pack), AppsSettings.get().getPackDeckDir()));
deckTypeList.add(new DeckType(context.getResources().getString(R.string.category_windbot_deck), AppsSettings.get().getAiDeckDir())); deckTypeList.add(new DeckType(YGOUtil.s(R.string.category_windbot_deck), AppsSettings.get().getAiDeckDir()));
deckTypeList.add(new DeckType(context.getResources().getString(R.string.category_Uncategorized), AppsSettings.get().getDeckDir())); deckTypeList.add(new DeckType(YGOUtil.s(R.string.category_Uncategorized), AppsSettings.get().getDeckDir()));
File[] files = new File(AppsSettings.get().getDeckDir()).listFiles(); File[] files = new File(AppsSettings.get().getDeckDir()).listFiles();
if (files != null) { if (files != null) {
...@@ -49,10 +49,36 @@ public class DeckUtil { ...@@ -49,10 +49,36 @@ public class DeckUtil {
} }
} }
} }
Collections.sort(deckList,nameCom); Collections.sort(deckList, nameCom);
return deckList; return deckList;
} }
/**
* 根据卡组绝对路径获取卡组分类名称
* @param deckPath
* @return
*/
public static String getDeckTypeName(String deckPath) {
File file = new File(deckPath);
if (file.exists()) {
String name = file.getParentFile().getName();
String lastName = file.getParentFile().getParentFile().getName();
if (name.equals("pack") || name.equals("cacheDeck")) {
//卡包
return YGOUtil.s(R.string.category_pack);
} else if (name.equals("Decks")&&lastName.equals(Constants.WINDBOT_PATH)) {
//ai卡组
return YGOUtil.s(R.string.category_windbot_deck);
} else if (name.equals("deck") && lastName.equals(Constants.PREF_DEF_GAME_DIR)) {
//如果是deck并且上一个目录是ygocore的话,保证不会把名字为deck的卡包识别为未分类
return YGOUtil.s(R.string.category_Uncategorized);
} else {
return name;
}
}
return null;
}
public static List<DeckFile> getExpansionsDeckList() throws IOException { public static List<DeckFile> getExpansionsDeckList() throws IOException {
AppsSettings appsSettings = AppsSettings.get(); AppsSettings appsSettings = AppsSettings.get();
List<DeckFile> deckList = new ArrayList<>(); List<DeckFile> deckList = new ArrayList<>();
...@@ -85,11 +111,11 @@ public class DeckUtil { ...@@ -85,11 +111,11 @@ public class DeckUtil {
} }
} }
} }
Collections.sort(deckList,nameCom); Collections.sort(deckList, nameCom);
return deckList; return deckList;
} }
static Comparator nameCom= new Comparator<DeckFile>() { static Comparator nameCom = new Comparator<DeckFile>() {
@Override @Override
public int compare(DeckFile ydk1, DeckFile ydk2) { public int compare(DeckFile ydk1, DeckFile ydk2) {
return ydk1.getName().compareTo(ydk2.getName()); return ydk1.getName().compareTo(ydk2.getName());
......
...@@ -81,13 +81,14 @@ public class YGODialogUtil { ...@@ -81,13 +81,14 @@ public class YGODialogUtil {
File file = new File(selectDeckPath); File file = new File(selectDeckPath);
if (file.exists()) { if (file.exists()) {
String name = file.getParentFile().getName(); String name = file.getParentFile().getName();
String lastName=file.getParentFile().getParentFile().getName();
if (name.equals("pack") || name.equals("cacheDeck")) { if (name.equals("pack") || name.equals("cacheDeck")) {
//卡包 //卡包
typeSelectPosition = 0; typeSelectPosition = 0;
} else if (name.equals("Decks")) { } else if (name.equals("Decks")&&lastName.equals(Constants.WINDBOT_PATH)) {
//ai卡组 //ai卡组
typeSelectPosition = 1; typeSelectPosition = 1;
} else if (name.equals("deck") && new File(selectDeckPath).getParentFile().getParentFile().getName().equals(Constants.PREF_DEF_GAME_DIR)) { } else if (name.equals("deck") && lastName.equals(Constants.PREF_DEF_GAME_DIR)) {
//如果是deck并且上一个目录是ygocore的话,保证不会把名字为deck的卡包识别为未分类 //如果是deck并且上一个目录是ygocore的话,保证不会把名字为deck的卡包识别为未分类
} else { } else {
//其他卡包 //其他卡包
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment