diff --git a/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java b/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java index 6fd3fc9fe..1faa40430 100644 --- a/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java +++ b/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java @@ -29,7 +29,7 @@ import org.geometerplus.android.fbreader.library.SQLiteBooksDatabase; public class LibraryService extends Service implements Library.ChangeListener { public final class LibraryImplementation extends LibraryInterface.Stub { - private final AbstractLibrary myBaseLibrary; + private final Library myBaseLibrary; LibraryImplementation() { BooksDatabase database = SQLiteBooksDatabase.Instance(); diff --git a/src/org/geometerplus/android/fbreader/libraryService/LibraryShadow.java b/src/org/geometerplus/android/fbreader/libraryService/LibraryShadow.java deleted file mode 100644 index 0c81118ba..000000000 --- a/src/org/geometerplus/android/fbreader/libraryService/LibraryShadow.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2010-2013 Geometer Plus - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -package org.geometerplus.android.fbreader.libraryService; - -import java.util.*; - -import android.os.RemoteException; - -import org.geometerplus.fbreader.library.*; - -public class LibraryShadow extends AbstractLibrary { - private final LibraryInterface myInterface; - - public LibraryShadow(LibraryInterface iface) { - myInterface = iface; - } - - @Override - public boolean isUpToDate() { - try { - return myInterface.isUpToDate(); - } catch (RemoteException e) { - return false; - } - } - - @Override - public boolean canRemoveBookFile(Book book) { - // TODO: implement - return false; - } - - @Override - public void removeBook(Book book, int removeMode) { - // TODO: implement - } - - public Book getRecentBook() { - // TODO: implement - return null; - } - - public Book getPreviousBook() { - // TODO: implement - return null; - } - - public void addBookToRecentList(Book book) { - // TODO: implement - } - - @Override - public boolean isBookInFavorites(Book book) { - // TODO: implement - return false; - } - - @Override - public void addBookToFavorites(Book book) { - // TODO: implement - } - - @Override - public void removeBookFromFavorites(Book book) { - // TODO: implement - } - - @Override - public void startBookSearch(final String pattern) { - // TODO: implement - } - - @Override - public List allBookmarks() { - // TODO: implement - return Collections.emptyList(); - } - - @Override - public List invisibleBookmarks(Book book) { - // TODO: implement - return Collections.emptyList(); - } -} diff --git a/src/org/geometerplus/fbreader/library/AbstractLibrary.java b/src/org/geometerplus/fbreader/library/AbstractLibrary.java deleted file mode 100644 index e164e54d9..000000000 --- a/src/org/geometerplus/fbreader/library/AbstractLibrary.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2007-2013 Geometer Plus - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -package org.geometerplus.fbreader.library; - -import java.util.*; - -public abstract class AbstractLibrary { - public abstract boolean isUpToDate(); - - public static final int REMOVE_DONT_REMOVE = 0x00; - public static final int REMOVE_FROM_LIBRARY = 0x01; - public static final int REMOVE_FROM_DISK = 0x02; - public static final int REMOVE_FROM_LIBRARY_AND_DISK = REMOVE_FROM_LIBRARY | REMOVE_FROM_DISK; - public abstract boolean canRemoveBookFile(Book book); - public abstract void removeBook(Book book, int removeMode); - - public abstract Book getRecentBook(); - public abstract Book getPreviousBook(); - public abstract void addBookToRecentList(Book book); - - public abstract boolean isBookInFavorites(Book book); - public abstract void addBookToFavorites(Book book); - public abstract void removeBookFromFavorites(Book book); - - public abstract void startBookSearch(final String pattern); - - public abstract List allBookmarks(); - public abstract List invisibleBookmarks(Book book); -} diff --git a/src/org/geometerplus/fbreader/library/Library.java b/src/org/geometerplus/fbreader/library/Library.java index 0f7da2386..045311cf7 100644 --- a/src/org/geometerplus/fbreader/library/Library.java +++ b/src/org/geometerplus/fbreader/library/Library.java @@ -30,7 +30,7 @@ import org.geometerplus.fbreader.book.*; import org.geometerplus.fbreader.bookmodel.BookReadingException; import org.geometerplus.fbreader.tree.FBTree; -public final class Library extends AbstractLibrary { +public final class Library { public static ZLResource resource() { return ZLResource.resource("library"); } @@ -44,6 +44,11 @@ public final class Library extends AbstractLibrary { public static final String ROOT_BY_TAG = "byTag"; public static final String ROOT_FILE_TREE = "fileTree"; + public static final int REMOVE_DONT_REMOVE = 0x00; + public static final int REMOVE_FROM_LIBRARY = 0x01; + public static final int REMOVE_FROM_DISK = 0x02; + public static final int REMOVE_FROM_LIBRARY_AND_DISK = REMOVE_FROM_LIBRARY | REMOVE_FROM_DISK; + private static Library ourInstance; public static Library Instance() { if (ourInstance == null) { @@ -493,24 +498,20 @@ public final class Library extends AbstractLibrary { builder.start(); } - @Override public boolean isUpToDate() { return myStatusMask == 0; } - @Override public Book getRecentBook() { List recentIds = myDatabase.loadRecentBookIds(); return recentIds.size() > 0 ? Book.getById(recentIds.get(0)) : null; } - @Override public Book getPreviousBook() { List recentIds = myDatabase.loadRecentBookIds(); return recentIds.size() > 1 ? Book.getById(recentIds.get(1)) : null; } - @Override public void startBookSearch(final String pattern) { setStatus(myStatusMask | STATUS_SEARCHING); final Thread searcher = new Thread("Library.searchBooks") { @@ -565,7 +566,6 @@ public final class Library extends AbstractLibrary { } } - @Override public void addBookToRecentList(Book book) { final List ids = myDatabase.loadRecentBookIds(); final Long bookId = book.getId(); @@ -577,7 +577,6 @@ public final class Library extends AbstractLibrary { myDatabase.saveRecentBookIds(ids); } - @Override public boolean isBookInFavorites(Book book) { if (book == null) { return false; @@ -591,7 +590,6 @@ public final class Library extends AbstractLibrary { return false; } - @Override public void addBookToFavorites(Book book) { if (isBookInFavorites(book)) { return; @@ -601,7 +599,6 @@ public final class Library extends AbstractLibrary { myDatabase.addToFavorites(book.getId()); } - @Override public void removeBookFromFavorites(Book book) { if (getFirstLevelTree(ROOT_FAVORITES).removeBook(book, false)) { myDatabase.removeFromFavorites(book.getId()); @@ -609,7 +606,6 @@ public final class Library extends AbstractLibrary { } } - @Override public boolean canRemoveBookFile(Book book) { ZLFile file = book.File; if (file.getPhysicalFile() == null) { @@ -624,7 +620,6 @@ public final class Library extends AbstractLibrary { return true; } - @Override public void removeBook(Book book, int removeMode) { if (removeMode == REMOVE_DONT_REMOVE) { return; @@ -644,12 +639,10 @@ public final class Library extends AbstractLibrary { } } - @Override public List allBookmarks() { return BooksDatabase.Instance().loadAllVisibleBookmarks(); } - @Override public List invisibleBookmarks(Book book) { final List list = BooksDatabase.Instance().loadBookmarks(book.getId(), false); Collections.sort(list, new Bookmark.ByTimeComparator());