1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 17:59:33 +02:00

second (external) sd card supported

This commit is contained in:
Nikolay Pultsin 2015-09-25 18:55:09 +01:00
parent bd608b7e37
commit 605b5f12d5
2 changed files with 84 additions and 17 deletions

View file

@ -19,6 +19,8 @@
package org.geometerplus.fbreader.library;
import java.util.List;
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
import org.geometerplus.zlibrary.core.resources.ZLResource;
@ -43,22 +45,32 @@ public class FileFirstLevelTree extends FirstLevelTree {
public void waitForOpening() {
clear();
for (String dir : Paths.BookPathOption.getValue()) {
addChild(dir, "fileTreeLibrary", dir);
addChild(dir, resource().getResource("fileTreeLibrary").getValue(), dir);
}
addChild("/", "fileTreeRoot");
final List<String> cards = Paths.allCardDirectories();
if (cards.size() == 1) {
addChild(cards.get(0), "fileTreeCard");
} else {
final ZLResource res = resource().getResource("fileTreeCard");
final String title = res.getResource("withIndex").getValue();
final String summary = res.getResource("summary").getValue();
int index = 0;
for (String dir : cards) {
addChild(dir, title.replaceAll("%s", String.valueOf(++index)), summary);
}
}
addChild("/", "fileTreeRoot", null);
addChild(Paths.cardDirectory(), "fileTreeCard", null);
}
private void addChild(String path, String resourceKey, String summary) {
private void addChild(String path, String title, String summary) {
final ZLFile file = ZLFile.createFileByPath(path);
if (file != null) {
final ZLResource resource = resource().getResource(resourceKey);
new FileTree(
this,
file,
resource.getValue(),
summary != null ? summary : resource.getResource("summary").getValue()
);
new FileTree(this, file, title, summary);
}
}
private void addChild(String path, String resourceKey) {
final ZLResource resource = resource().getResource(resourceKey);
addChild(path, resource.getValue(), resource.getResource("summary").getValue());
}
}