mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
platform-independent code has been moved to non-android directory
This commit is contained in:
parent
15a0394ccf
commit
0ae1f66dda
6 changed files with 44 additions and 35 deletions
|
@ -167,41 +167,8 @@ abstract class BaseActivity extends ListActivity implements View.OnCreateContext
|
|||
}
|
||||
|
||||
boolean isTreeSelected(FBTree tree) {
|
||||
if (mySelectedBook == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (((LibraryTree)tree).containsBook(mySelectedBook)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Book book = ((LibraryTree)tree).getBook();
|
||||
if (book != null) {
|
||||
return mySelectedBook.equals(book);
|
||||
} else if (tree instanceof SeriesTree) {
|
||||
final SeriesInfo info = mySelectedBook.getSeriesInfo();
|
||||
final String series = ((SeriesTree)tree).Series;
|
||||
return info != null && series != null && series.equals(info.Name);
|
||||
} else if (tree instanceof FileTree) {
|
||||
final FileTree fileTree = (FileTree)tree;
|
||||
if (!fileTree.isSelectable()) {
|
||||
return false;
|
||||
}
|
||||
final ZLFile file = fileTree.getFile();
|
||||
String prefix = file.getPath();
|
||||
if (file.isDirectory()) {
|
||||
if (!prefix.endsWith("/")) {
|
||||
prefix += '/';
|
||||
}
|
||||
} else if (file.isArchive()) {
|
||||
prefix += ':';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return mySelectedBookPath.startsWith(prefix);
|
||||
}
|
||||
|
||||
return false;
|
||||
final LibraryTree lTree = (LibraryTree)tree;
|
||||
return lTree.isSelectable() && lTree.containsBook(mySelectedBook);
|
||||
}
|
||||
|
||||
protected void openBook(Book book) {
|
||||
|
|
|
@ -69,4 +69,9 @@ public class BookTree extends LibraryTree {
|
|||
protected ZLImage createCover() {
|
||||
return Library.getCover(Book.File);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsBook(Book book) {
|
||||
return book != null && book.equals(Book);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ public class FileTree extends LibraryTree {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelectable() {
|
||||
return myIsSelectable;
|
||||
}
|
||||
|
@ -109,6 +110,24 @@ public class FileTree extends LibraryTree {
|
|||
return Book.getByFile(myFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsBook(Book book) {
|
||||
if (book == null) {
|
||||
return false;
|
||||
}
|
||||
if (myFile.isDirectory()) {
|
||||
String prefix = myFile.getPath();
|
||||
if (!prefix.endsWith("/")) {
|
||||
prefix += "/";
|
||||
}
|
||||
return book.File.getPath().startsWith(prefix);
|
||||
} else if (myFile.isArchive()) {
|
||||
return book.File.getPath().startsWith(myFile.getPath() + ":");
|
||||
} else {
|
||||
return book.equals(getBook());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status getOpeningStatus() {
|
||||
if (!myFile.isReadable()) {
|
||||
|
|
|
@ -44,6 +44,10 @@ public abstract class LibraryTree extends FBTree {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean isSelectable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
TagTree createTagSubTree(Tag tag) {
|
||||
return new TagTree(this, tag);
|
||||
}
|
||||
|
|
|
@ -69,4 +69,9 @@ public class RootTree extends LibraryTree {
|
|||
public void waitForOpening() {
|
||||
myLibrary.waitForState(Library.STATE_FULLY_INITIALIZED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelectable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,4 +40,13 @@ public final class SeriesTree extends LibraryTree {
|
|||
BookTree createBookInSeriesSubTree(Book book) {
|
||||
return new BookInSeriesTree(this, book);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsBook(Book book) {
|
||||
if (book == null) {
|
||||
return false;
|
||||
}
|
||||
final SeriesInfo info = book.getSeriesInfo();
|
||||
return info != null && Series.equals(info.Name);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue