1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 18:29:23 +02:00

AbstractLibrary has gone

This commit is contained in:
Nikolay Pultsin 2013-01-14 05:12:07 +04:00
parent 42b9345d5a
commit 64911efecf
4 changed files with 7 additions and 161 deletions

View file

@ -29,7 +29,7 @@ import org.geometerplus.android.fbreader.library.SQLiteBooksDatabase;
public class LibraryService extends Service implements Library.ChangeListener { public class LibraryService extends Service implements Library.ChangeListener {
public final class LibraryImplementation extends LibraryInterface.Stub { public final class LibraryImplementation extends LibraryInterface.Stub {
private final AbstractLibrary myBaseLibrary; private final Library myBaseLibrary;
LibraryImplementation() { LibraryImplementation() {
BooksDatabase database = SQLiteBooksDatabase.Instance(); BooksDatabase database = SQLiteBooksDatabase.Instance();

View file

@ -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();
}
}

View file

@ -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);
}

View file

@ -30,7 +30,7 @@ import org.geometerplus.fbreader.book.*;
import org.geometerplus.fbreader.bookmodel.BookReadingException; import org.geometerplus.fbreader.bookmodel.BookReadingException;
import org.geometerplus.fbreader.tree.FBTree; import org.geometerplus.fbreader.tree.FBTree;
public final class Library extends AbstractLibrary { public final class Library {
public static ZLResource resource() { public static ZLResource resource() {
return ZLResource.resource("library"); 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_BY_TAG = "byTag";
public static final String ROOT_FILE_TREE = "fileTree"; 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; private static Library ourInstance;
public static Library Instance() { public static Library Instance() {
if (ourInstance == null) { if (ourInstance == null) {
@ -493,24 +498,20 @@ public final class Library extends AbstractLibrary {
builder.start(); builder.start();
} }
@Override
public boolean isUpToDate() { public boolean isUpToDate() {
return myStatusMask == 0; return myStatusMask == 0;
} }
@Override
public Book getRecentBook() { public Book getRecentBook() {
List<Long> recentIds = myDatabase.loadRecentBookIds(); List<Long> recentIds = myDatabase.loadRecentBookIds();
return recentIds.size() > 0 ? Book.getById(recentIds.get(0)) : null; return recentIds.size() > 0 ? Book.getById(recentIds.get(0)) : null;
} }
@Override
public Book getPreviousBook() { public Book getPreviousBook() {
List<Long> recentIds = myDatabase.loadRecentBookIds(); List<Long> recentIds = myDatabase.loadRecentBookIds();
return recentIds.size() > 1 ? Book.getById(recentIds.get(1)) : null; return recentIds.size() > 1 ? Book.getById(recentIds.get(1)) : null;
} }
@Override
public void startBookSearch(final String pattern) { public void startBookSearch(final String pattern) {
setStatus(myStatusMask | STATUS_SEARCHING); setStatus(myStatusMask | STATUS_SEARCHING);
final Thread searcher = new Thread("Library.searchBooks") { final Thread searcher = new Thread("Library.searchBooks") {
@ -565,7 +566,6 @@ public final class Library extends AbstractLibrary {
} }
} }
@Override
public void addBookToRecentList(Book book) { public void addBookToRecentList(Book book) {
final List<Long> ids = myDatabase.loadRecentBookIds(); final List<Long> ids = myDatabase.loadRecentBookIds();
final Long bookId = book.getId(); final Long bookId = book.getId();
@ -577,7 +577,6 @@ public final class Library extends AbstractLibrary {
myDatabase.saveRecentBookIds(ids); myDatabase.saveRecentBookIds(ids);
} }
@Override
public boolean isBookInFavorites(Book book) { public boolean isBookInFavorites(Book book) {
if (book == null) { if (book == null) {
return false; return false;
@ -591,7 +590,6 @@ public final class Library extends AbstractLibrary {
return false; return false;
} }
@Override
public void addBookToFavorites(Book book) { public void addBookToFavorites(Book book) {
if (isBookInFavorites(book)) { if (isBookInFavorites(book)) {
return; return;
@ -601,7 +599,6 @@ public final class Library extends AbstractLibrary {
myDatabase.addToFavorites(book.getId()); myDatabase.addToFavorites(book.getId());
} }
@Override
public void removeBookFromFavorites(Book book) { public void removeBookFromFavorites(Book book) {
if (getFirstLevelTree(ROOT_FAVORITES).removeBook(book, false)) { if (getFirstLevelTree(ROOT_FAVORITES).removeBook(book, false)) {
myDatabase.removeFromFavorites(book.getId()); myDatabase.removeFromFavorites(book.getId());
@ -609,7 +606,6 @@ public final class Library extends AbstractLibrary {
} }
} }
@Override
public boolean canRemoveBookFile(Book book) { public boolean canRemoveBookFile(Book book) {
ZLFile file = book.File; ZLFile file = book.File;
if (file.getPhysicalFile() == null) { if (file.getPhysicalFile() == null) {
@ -624,7 +620,6 @@ public final class Library extends AbstractLibrary {
return true; return true;
} }
@Override
public void removeBook(Book book, int removeMode) { public void removeBook(Book book, int removeMode) {
if (removeMode == REMOVE_DONT_REMOVE) { if (removeMode == REMOVE_DONT_REMOVE) {
return; return;
@ -644,12 +639,10 @@ public final class Library extends AbstractLibrary {
} }
} }
@Override
public List<Bookmark> allBookmarks() { public List<Bookmark> allBookmarks() {
return BooksDatabase.Instance().loadAllVisibleBookmarks(); return BooksDatabase.Instance().loadAllVisibleBookmarks();
} }
@Override
public List<Bookmark> invisibleBookmarks(Book book) { public List<Bookmark> invisibleBookmarks(Book book) {
final List<Bookmark> list = BooksDatabase.Instance().loadBookmarks(book.getId(), false); final List<Bookmark> list = BooksDatabase.Instance().loadBookmarks(book.getId(), false);
Collections.sort(list, new Bookmark.ByTimeComparator()); Collections.sort(list, new Bookmark.ByTimeComparator());