1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-06 03:50:19 +02:00

Library has no static instance since this moment

This commit is contained in:
Nikolay Pultsin 2010-10-14 13:04:42 +01:00
parent fa4ca04dc1
commit 017cdb852c
4 changed files with 13 additions and 18 deletions

View file

@ -50,7 +50,7 @@ public class BookSearchActivity extends SearchActivity {
boolean runSearch(final String pattern) {
final FBReader fbreader = (FBReader)FBReader.Instance();
fbreader.BookSearchPatternOption.setValue(pattern);
myTree = Library.Instance().searchBooks(pattern);
myTree = LibraryTabActivity.Instance.library().searchBooks(pattern);
return myTree.hasChildren();
}

View file

@ -45,6 +45,10 @@ public class LibraryTabActivity extends TabActivity implements MenuItem.OnMenuIt
private Library myLibrary;
Library library() {
return myLibrary;
}
private ListView createTab(String tag, int viewId, int iconId) {
final TabHost host = getTabHost();
final String label = myResource.getResource(tag).getValue();
@ -71,7 +75,7 @@ public class LibraryTabActivity extends TabActivity implements MenuItem.OnMenuIt
Thread.setDefaultUncaughtExceptionHandler(new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
if (myLibrary == null) {
myLibrary = Library.Instance();
myLibrary = new Library();
}
myLibrary.clear();
myLibrary.synchronize();

View file

@ -116,10 +116,10 @@ public final class FBReader extends ZLApplication {
public void run() {
Book book = createBookForFile(ZLFile.createFileByPath(myArg0));
if (book == null) {
book = Library.Instance().getRecentBook();
book = Library.getRecentBook();
}
if ((book == null) || !book.File.exists()) {
book = Book.getByFile(Library.Instance().getHelpFile());
book = Book.getByFile(Library.getHelpFile());
}
openBookInternal(book, null);
}
@ -205,7 +205,7 @@ public final class FBReader extends ZLApplication {
} else {
gotoBookmark(bookmark);
}
Library.Instance().addBookToRecentList(book);
Library.addBookToRecentList(book);
}
}
repaintView();

View file

@ -28,15 +28,6 @@ import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
import org.geometerplus.fbreader.Paths;
public final class Library {
private static Library ourInstance;
public static Library Instance() {
if (ourInstance == null) {
ourInstance = new Library();
}
return ourInstance;
}
private final LinkedList<Book> myBooks = new LinkedList<Book>();
private final HashSet<Book> myExternalBooks = new HashSet<Book>();
private final LibraryTree myLibraryByAuthor = new RootTree();
@ -46,7 +37,7 @@ public final class Library {
private boolean myDoRebuild = true;
private Library() {
public Library() {
}
public void clear() {
@ -60,7 +51,7 @@ public final class Library {
mySearchResult.clear();
}
public ZLResourceFile getHelpFile() {
public static ZLResourceFile getHelpFile() {
final ZLResourceFile file = ZLResourceFile.createResourceFile(
"data/help/MiniHelp." + Locale.getDefault().getLanguage() + ".fb2"
);
@ -318,7 +309,7 @@ public final class Library {
return myRecentBooks;
}
public Book getRecentBook() {
public static Book getRecentBook() {
List<Long> recentIds = BooksDatabase.Instance().listRecentBookIds();
return (recentIds.size() > 0) ? Book.getById(recentIds.get(0)) : null;
}
@ -338,7 +329,7 @@ public final class Library {
return mySearchResult;
}
public void addBookToRecentList(Book book) {
public static void addBookToRecentList(Book book) {
final BooksDatabase db = BooksDatabase.Instance();
final List<Long> ids = db.listRecentBookIds();
final Long bookId = book.getId();