diff --git a/src/org/geometerplus/android/fbreader/BookSearchActivity.java b/src/org/geometerplus/android/fbreader/BookSearchActivity.java index 8fbc246bd..1e5025470 100644 --- a/src/org/geometerplus/android/fbreader/BookSearchActivity.java +++ b/src/org/geometerplus/android/fbreader/BookSearchActivity.java @@ -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(); } diff --git a/src/org/geometerplus/android/fbreader/LibraryTabActivity.java b/src/org/geometerplus/android/fbreader/LibraryTabActivity.java index 9330694a5..ca21728f6 100644 --- a/src/org/geometerplus/android/fbreader/LibraryTabActivity.java +++ b/src/org/geometerplus/android/fbreader/LibraryTabActivity.java @@ -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(); diff --git a/src/org/geometerplus/fbreader/fbreader/FBReader.java b/src/org/geometerplus/fbreader/fbreader/FBReader.java index a872dfc58..4842c72f1 100644 --- a/src/org/geometerplus/fbreader/fbreader/FBReader.java +++ b/src/org/geometerplus/fbreader/fbreader/FBReader.java @@ -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(); diff --git a/src/org/geometerplus/fbreader/library/Library.java b/src/org/geometerplus/fbreader/library/Library.java index 4da63c9df..095958016 100644 --- a/src/org/geometerplus/fbreader/library/Library.java +++ b/src/org/geometerplus/fbreader/library/Library.java @@ -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 myBooks = new LinkedList(); private final HashSet myExternalBooks = new HashSet(); 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 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 ids = db.listRecentBookIds(); final Long bookId = book.getId();