mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
AbstractLibrary has gone
This commit is contained in:
parent
42b9345d5a
commit
64911efecf
4 changed files with 7 additions and 161 deletions
|
@ -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();
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010-2013 Geometer Plus <contact@geometerplus.com>
|
||||
*
|
||||
* 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<Bookmark> allBookmarks() {
|
||||
// TODO: implement
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Bookmark> invisibleBookmarks(Book book) {
|
||||
// TODO: implement
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2013 Geometer Plus <contact@geometerplus.com>
|
||||
*
|
||||
* 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<Bookmark> allBookmarks();
|
||||
public abstract List<Bookmark> invisibleBookmarks(Book book);
|
||||
}
|
|
@ -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<Long> recentIds = myDatabase.loadRecentBookIds();
|
||||
return recentIds.size() > 0 ? Book.getById(recentIds.get(0)) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Book getPreviousBook() {
|
||||
List<Long> 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<Long> 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<Bookmark> allBookmarks() {
|
||||
return BooksDatabase.Instance().loadAllVisibleBookmarks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Bookmark> invisibleBookmarks(Book book) {
|
||||
final List<Bookmark> list = BooksDatabase.Instance().loadBookmarks(book.getId(), false);
|
||||
Collections.sort(list, new Bookmark.ByTimeComparator());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue