mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
synchronization with library-service branch
This commit is contained in:
parent
be507cfd9c
commit
b0033a8ccc
38 changed files with 183 additions and 186 deletions
|
@ -33,8 +33,9 @@ import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.ui.android.R;
|
import org.geometerplus.zlibrary.ui.android.R;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.*;
|
||||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||||
import org.geometerplus.fbreader.library.*;
|
import org.geometerplus.fbreader.library.Library;
|
||||||
|
|
||||||
import org.geometerplus.android.util.UIUtil;
|
import org.geometerplus.android.util.UIUtil;
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,6 @@ import org.geometerplus.zlibrary.ui.android.view.AndroidFontUtil;
|
||||||
import org.geometerplus.fbreader.book.*;
|
import org.geometerplus.fbreader.book.*;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookModel;
|
import org.geometerplus.fbreader.bookmodel.BookModel;
|
||||||
import org.geometerplus.fbreader.fbreader.*;
|
import org.geometerplus.fbreader.fbreader.*;
|
||||||
import org.geometerplus.fbreader.library.Book;
|
|
||||||
import org.geometerplus.fbreader.tips.TipsManager;
|
import org.geometerplus.fbreader.tips.TipsManager;
|
||||||
|
|
||||||
import org.geometerplus.android.fbreader.api.*;
|
import org.geometerplus.android.fbreader.api.*;
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.geometerplus.zlibrary.core.filesystem.ZLPhysicalFile;
|
||||||
import org.geometerplus.zlibrary.core.filetypes.FileTypeCollection;
|
import org.geometerplus.zlibrary.core.filetypes.FileTypeCollection;
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
import org.geometerplus.fbreader.book.Book;
|
||||||
|
|
||||||
public abstract class FBUtil {
|
public abstract class FBUtil {
|
||||||
public static void shareBook(Activity activity, Book book) {
|
public static void shareBook(Activity activity, Book book) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.geometerplus.android.fbreader;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Bookmark;
|
import org.geometerplus.fbreader.book.Bookmark;
|
||||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||||
import org.geometerplus.fbreader.fbreader.FBView;
|
import org.geometerplus.fbreader.fbreader.FBView;
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.geometerplus.zlibrary.core.util.MimeType;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.ui.android.R;
|
import org.geometerplus.zlibrary.ui.android.R;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.*;
|
||||||
import org.geometerplus.fbreader.library.*;
|
import org.geometerplus.fbreader.library.*;
|
||||||
import org.geometerplus.fbreader.tree.FBTree;
|
import org.geometerplus.fbreader.tree.FBTree;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ import android.app.Service;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.*;
|
import org.geometerplus.fbreader.book.*;
|
||||||
|
import org.geometerplus.fbreader.library.Library;
|
||||||
|
|
||||||
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 {
|
||||||
|
|
|
@ -51,7 +51,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
migrate(context);
|
migrate(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void executeAsATransaction(Runnable actions) {
|
public /*protected*/ void executeAsATransaction(Runnable actions) {
|
||||||
boolean transactionStarted = false;
|
boolean transactionStarted = false;
|
||||||
try {
|
try {
|
||||||
myDatabase.beginTransaction();
|
myDatabase.beginTransaction();
|
||||||
|
@ -132,7 +132,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Book loadBook(long bookId) {
|
public /*protected*/ Book loadBook(long bookId) {
|
||||||
Book book = null;
|
Book book = null;
|
||||||
final Cursor cursor = myDatabase.rawQuery("SELECT file_id,title,encoding,language FROM Books WHERE book_id = " + bookId, null);
|
final Cursor cursor = myDatabase.rawQuery("SELECT file_id,title,encoding,language FROM Books WHERE book_id = " + bookId, null);
|
||||||
if (cursor.moveToNext()) {
|
if (cursor.moveToNext()) {
|
||||||
|
@ -145,7 +145,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void reloadBook(Book book) {
|
public /*protected*/ void reloadBook(Book book) {
|
||||||
final Cursor cursor = myDatabase.rawQuery("SELECT title,encoding,language FROM Books WHERE book_id = " + book.getId(), null);
|
final Cursor cursor = myDatabase.rawQuery("SELECT title,encoding,language FROM Books WHERE book_id = " + book.getId(), null);
|
||||||
if (cursor.moveToNext()) {
|
if (cursor.moveToNext()) {
|
||||||
book.setTitle(cursor.getString(0));
|
book.setTitle(cursor.getString(0));
|
||||||
|
@ -155,7 +155,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Book loadBookByFile(long fileId, ZLFile file) {
|
public /*protected*/ Book loadBookByFile(long fileId, ZLFile file) {
|
||||||
if (fileId == -1) {
|
if (fileId == -1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<Long,Book> loadBooks(FileInfoSet infos, boolean existing) {
|
public /*protected*/ Map<Long,Book> loadBooks(FileInfoSet infos, boolean existing) {
|
||||||
Cursor cursor = myDatabase.rawQuery(
|
Cursor cursor = myDatabase.rawQuery(
|
||||||
"SELECT book_id,file_id,title,encoding,language FROM Books WHERE `exists` = " + (existing ? 1 : 0), null
|
"SELECT book_id,file_id,title,encoding,language FROM Books WHERE `exists` = " + (existing ? 1 : 0), null
|
||||||
);
|
);
|
||||||
|
@ -272,7 +272,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setExistingFlag(Collection<Book> books, boolean flag) {
|
public /*protected*/ void setExistingFlag(Collection<Book> books, boolean flag) {
|
||||||
if (books.isEmpty()) {
|
if (books.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
|
|
||||||
private SQLiteStatement myUpdateBookInfoStatement;
|
private SQLiteStatement myUpdateBookInfoStatement;
|
||||||
@Override
|
@Override
|
||||||
protected void updateBookInfo(long bookId, long fileId, String encoding, String language, String title) {
|
public /*protected*/ void updateBookInfo(long bookId, long fileId, String encoding, String language, String title) {
|
||||||
if (myUpdateBookInfoStatement == null) {
|
if (myUpdateBookInfoStatement == null) {
|
||||||
myUpdateBookInfoStatement = myDatabase.compileStatement(
|
myUpdateBookInfoStatement = myDatabase.compileStatement(
|
||||||
"UPDATE OR IGNORE Books SET file_id = ?, encoding = ?, language = ?, title = ? WHERE book_id = ?"
|
"UPDATE OR IGNORE Books SET file_id = ?, encoding = ?, language = ?, title = ? WHERE book_id = ?"
|
||||||
|
@ -310,7 +310,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
|
|
||||||
private SQLiteStatement myInsertBookInfoStatement;
|
private SQLiteStatement myInsertBookInfoStatement;
|
||||||
@Override
|
@Override
|
||||||
protected long insertBookInfo(ZLFile file, String encoding, String language, String title) {
|
public /*protected*/ long insertBookInfo(ZLFile file, String encoding, String language, String title) {
|
||||||
if (myInsertBookInfoStatement == null) {
|
if (myInsertBookInfoStatement == null) {
|
||||||
myInsertBookInfoStatement = myDatabase.compileStatement(
|
myInsertBookInfoStatement = myDatabase.compileStatement(
|
||||||
"INSERT OR IGNORE INTO Books (encoding,language,title,file_id) VALUES (?,?,?,?)"
|
"INSERT OR IGNORE INTO Books (encoding,language,title,file_id) VALUES (?,?,?,?)"
|
||||||
|
@ -325,7 +325,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteStatement myDeleteBookAuthorsStatement;
|
private SQLiteStatement myDeleteBookAuthorsStatement;
|
||||||
protected void deleteAllBookAuthors(long bookId) {
|
public /*protected*/ void deleteAllBookAuthors(long bookId) {
|
||||||
if (myDeleteBookAuthorsStatement == null) {
|
if (myDeleteBookAuthorsStatement == null) {
|
||||||
myDeleteBookAuthorsStatement = myDatabase.compileStatement(
|
myDeleteBookAuthorsStatement = myDatabase.compileStatement(
|
||||||
"DELETE FROM BookAuthor WHERE book_id = ?"
|
"DELETE FROM BookAuthor WHERE book_id = ?"
|
||||||
|
@ -338,7 +338,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
private SQLiteStatement myGetAuthorIdStatement;
|
private SQLiteStatement myGetAuthorIdStatement;
|
||||||
private SQLiteStatement myInsertAuthorStatement;
|
private SQLiteStatement myInsertAuthorStatement;
|
||||||
private SQLiteStatement myInsertBookAuthorStatement;
|
private SQLiteStatement myInsertBookAuthorStatement;
|
||||||
protected void saveBookAuthorInfo(long bookId, long index, Author author) {
|
public /*protected*/ void saveBookAuthorInfo(long bookId, long index, Author author) {
|
||||||
if (myGetAuthorIdStatement == null) {
|
if (myGetAuthorIdStatement == null) {
|
||||||
myGetAuthorIdStatement = myDatabase.compileStatement(
|
myGetAuthorIdStatement = myDatabase.compileStatement(
|
||||||
"SELECT author_id FROM Authors WHERE name = ? AND sort_key = ?"
|
"SELECT author_id FROM Authors WHERE name = ? AND sort_key = ?"
|
||||||
|
@ -367,7 +367,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
myInsertBookAuthorStatement.execute();
|
myInsertBookAuthorStatement.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Author> loadAuthors(long bookId) {
|
public /*protected*/ List<Author> loadAuthors(long bookId) {
|
||||||
final Cursor cursor = myDatabase.rawQuery("SELECT Authors.name,Authors.sort_key FROM BookAuthor INNER JOIN Authors ON Authors.author_id = BookAuthor.author_id WHERE BookAuthor.book_id = ?", new String[] { "" + bookId });
|
final Cursor cursor = myDatabase.rawQuery("SELECT Authors.name,Authors.sort_key FROM BookAuthor INNER JOIN Authors ON Authors.author_id = BookAuthor.author_id WHERE BookAuthor.book_id = ?", new String[] { "" + bookId });
|
||||||
if (!cursor.moveToNext()) {
|
if (!cursor.moveToNext()) {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
@ -422,7 +422,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteStatement myDeleteBookTagsStatement;
|
private SQLiteStatement myDeleteBookTagsStatement;
|
||||||
protected void deleteAllBookTags(long bookId) {
|
public /*protected*/ void deleteAllBookTags(long bookId) {
|
||||||
if (myDeleteBookTagsStatement == null) {
|
if (myDeleteBookTagsStatement == null) {
|
||||||
myDeleteBookTagsStatement = myDatabase.compileStatement(
|
myDeleteBookTagsStatement = myDatabase.compileStatement(
|
||||||
"DELETE FROM BookTag WHERE book_id = ?"
|
"DELETE FROM BookTag WHERE book_id = ?"
|
||||||
|
@ -433,7 +433,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteStatement myInsertBookTagStatement;
|
private SQLiteStatement myInsertBookTagStatement;
|
||||||
protected void saveBookTagInfo(long bookId, Tag tag) {
|
public /*protected*/ void saveBookTagInfo(long bookId, Tag tag) {
|
||||||
if (myInsertBookTagStatement == null) {
|
if (myInsertBookTagStatement == null) {
|
||||||
myInsertBookTagStatement = myDatabase.compileStatement(
|
myInsertBookTagStatement = myDatabase.compileStatement(
|
||||||
"INSERT OR IGNORE INTO BookTag (book_id,tag_id) VALUES (?,?)"
|
"INSERT OR IGNORE INTO BookTag (book_id,tag_id) VALUES (?,?)"
|
||||||
|
@ -459,7 +459,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Tag> loadTags(long bookId) {
|
public /*protected*/ List<Tag> loadTags(long bookId) {
|
||||||
final Cursor cursor = myDatabase.rawQuery("SELECT Tags.tag_id FROM BookTag INNER JOIN Tags ON Tags.tag_id = BookTag.tag_id WHERE BookTag.book_id = ?", new String[] { "" + bookId });
|
final Cursor cursor = myDatabase.rawQuery("SELECT Tags.tag_id FROM BookTag INNER JOIN Tags ON Tags.tag_id = BookTag.tag_id WHERE BookTag.book_id = ?", new String[] { "" + bookId });
|
||||||
if (!cursor.moveToNext()) {
|
if (!cursor.moveToNext()) {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
@ -477,7 +477,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
private SQLiteStatement myInsertSeriesStatement;
|
private SQLiteStatement myInsertSeriesStatement;
|
||||||
private SQLiteStatement myInsertBookSeriesStatement;
|
private SQLiteStatement myInsertBookSeriesStatement;
|
||||||
private SQLiteStatement myDeleteBookSeriesStatement;
|
private SQLiteStatement myDeleteBookSeriesStatement;
|
||||||
protected void saveBookSeriesInfo(long bookId, SeriesInfo seriesInfo) {
|
public /*protected*/ void saveBookSeriesInfo(long bookId, SeriesInfo seriesInfo) {
|
||||||
if (myGetSeriesIdStatement == null) {
|
if (myGetSeriesIdStatement == null) {
|
||||||
myGetSeriesIdStatement = myDatabase.compileStatement(
|
myGetSeriesIdStatement = myDatabase.compileStatement(
|
||||||
"SELECT series_id FROM Series WHERE name = ?"
|
"SELECT series_id FROM Series WHERE name = ?"
|
||||||
|
@ -515,7 +515,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SeriesInfo loadSeriesInfo(long bookId) {
|
public /*protected*/ SeriesInfo loadSeriesInfo(long bookId) {
|
||||||
final Cursor cursor = myDatabase.rawQuery("SELECT Series.name,BookSeries.book_index FROM BookSeries INNER JOIN Series ON Series.series_id = BookSeries.series_id WHERE BookSeries.book_id = ?", new String[] { "" + bookId });
|
final Cursor cursor = myDatabase.rawQuery("SELECT Series.name,BookSeries.book_index FROM BookSeries INNER JOIN Series ON Series.series_id = BookSeries.series_id WHERE BookSeries.book_id = ?", new String[] { "" + bookId });
|
||||||
SeriesInfo info = null;
|
SeriesInfo info = null;
|
||||||
if (cursor.moveToNext()) {
|
if (cursor.moveToNext()) {
|
||||||
|
@ -526,7 +526,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteStatement myRemoveFileInfoStatement;
|
private SQLiteStatement myRemoveFileInfoStatement;
|
||||||
protected void removeFileInfo(long fileId) {
|
public /*protected*/ void removeFileInfo(long fileId) {
|
||||||
if (fileId == -1) {
|
if (fileId == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -541,7 +541,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
|
|
||||||
private SQLiteStatement myInsertFileInfoStatement;
|
private SQLiteStatement myInsertFileInfoStatement;
|
||||||
private SQLiteStatement myUpdateFileInfoStatement;
|
private SQLiteStatement myUpdateFileInfoStatement;
|
||||||
protected void saveFileInfo(FileInfo fileInfo) {
|
public /*protected*/ void saveFileInfo(FileInfo fileInfo) {
|
||||||
final long id = fileInfo.Id;
|
final long id = fileInfo.Id;
|
||||||
SQLiteStatement statement;
|
SQLiteStatement statement;
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
|
@ -580,7 +580,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Collection<FileInfo> loadFileInfos() {
|
public /*protected*/ Collection<FileInfo> loadFileInfos() {
|
||||||
Cursor cursor = myDatabase.rawQuery(
|
Cursor cursor = myDatabase.rawQuery(
|
||||||
"SELECT file_id,name,parent_id,size FROM Files", null
|
"SELECT file_id,name,parent_id,size FROM Files", null
|
||||||
);
|
);
|
||||||
|
@ -600,7 +600,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
return infosById.values();
|
return infosById.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Collection<FileInfo> loadFileInfos(ZLFile file) {
|
public /*protected*/ Collection<FileInfo> loadFileInfos(ZLFile file) {
|
||||||
final LinkedList<ZLFile> fileStack = new LinkedList<ZLFile>();
|
final LinkedList<ZLFile> fileStack = new LinkedList<ZLFile>();
|
||||||
for (; file != null; file = file.getParent()) {
|
for (; file != null; file = file.getParent()) {
|
||||||
fileStack.addFirst(file);
|
fileStack.addFirst(file);
|
||||||
|
@ -633,7 +633,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
return infos;
|
return infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Collection<FileInfo> loadFileInfos(long fileId) {
|
public /*protected*/ Collection<FileInfo> loadFileInfos(long fileId) {
|
||||||
final ArrayList<FileInfo> infos = new ArrayList<FileInfo>();
|
final ArrayList<FileInfo> infos = new ArrayList<FileInfo>();
|
||||||
while (fileId != -1) {
|
while (fileId != -1) {
|
||||||
final Cursor cursor = myDatabase.rawQuery(
|
final Cursor cursor = myDatabase.rawQuery(
|
||||||
|
@ -661,7 +661,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteStatement mySaveRecentBookStatement;
|
private SQLiteStatement mySaveRecentBookStatement;
|
||||||
protected void saveRecentBookIds(final List<Long> ids) {
|
public /*protected*/ void saveRecentBookIds(final List<Long> ids) {
|
||||||
if (mySaveRecentBookStatement == null) {
|
if (mySaveRecentBookStatement == null) {
|
||||||
mySaveRecentBookStatement = myDatabase.compileStatement(
|
mySaveRecentBookStatement = myDatabase.compileStatement(
|
||||||
"INSERT OR IGNORE INTO RecentBooks (book_id) VALUES (?)"
|
"INSERT OR IGNORE INTO RecentBooks (book_id) VALUES (?)"
|
||||||
|
@ -678,7 +678,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Long> loadRecentBookIds() {
|
public /*protected*/ List<Long> loadRecentBookIds() {
|
||||||
final Cursor cursor = myDatabase.rawQuery(
|
final Cursor cursor = myDatabase.rawQuery(
|
||||||
"SELECT book_id FROM RecentBooks ORDER BY book_index", null
|
"SELECT book_id FROM RecentBooks ORDER BY book_index", null
|
||||||
);
|
);
|
||||||
|
@ -691,7 +691,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteStatement myAddToFavoritesStatement;
|
private SQLiteStatement myAddToFavoritesStatement;
|
||||||
protected void addToFavorites(long bookId) {
|
public /*protected*/ void addToFavorites(long bookId) {
|
||||||
if (myAddToFavoritesStatement == null) {
|
if (myAddToFavoritesStatement == null) {
|
||||||
myAddToFavoritesStatement = myDatabase.compileStatement(
|
myAddToFavoritesStatement = myDatabase.compileStatement(
|
||||||
"INSERT OR IGNORE INTO Favorites(book_id) VALUES (?)"
|
"INSERT OR IGNORE INTO Favorites(book_id) VALUES (?)"
|
||||||
|
@ -702,7 +702,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteStatement myRemoveFromFavoritesStatement;
|
private SQLiteStatement myRemoveFromFavoritesStatement;
|
||||||
protected void removeFromFavorites(long bookId) {
|
public /*protected*/ void removeFromFavorites(long bookId) {
|
||||||
if (myRemoveFromFavoritesStatement == null) {
|
if (myRemoveFromFavoritesStatement == null) {
|
||||||
myRemoveFromFavoritesStatement = myDatabase.compileStatement(
|
myRemoveFromFavoritesStatement = myDatabase.compileStatement(
|
||||||
"DELETE FROM Favorites WHERE book_id = ?"
|
"DELETE FROM Favorites WHERE book_id = ?"
|
||||||
|
@ -712,7 +712,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
myRemoveFromFavoritesStatement.execute();
|
myRemoveFromFavoritesStatement.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Long> loadFavoriteIds() {
|
public /*protected*/ List<Long> loadFavoriteIds() {
|
||||||
final Cursor cursor = myDatabase.rawQuery(
|
final Cursor cursor = myDatabase.rawQuery(
|
||||||
"SELECT book_id FROM Favorites", null
|
"SELECT book_id FROM Favorites", null
|
||||||
);
|
);
|
||||||
|
@ -725,7 +725,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Bookmark> loadBookmarks(long bookId, boolean visible) {
|
public /*protected*/ List<Bookmark> loadBookmarks(long bookId, boolean visible) {
|
||||||
LinkedList<Bookmark> list = new LinkedList<Bookmark>();
|
LinkedList<Bookmark> list = new LinkedList<Bookmark>();
|
||||||
Cursor cursor = myDatabase.rawQuery(
|
Cursor cursor = myDatabase.rawQuery(
|
||||||
"SELECT Bookmarks.bookmark_id,Bookmarks.book_id,Books.title,Bookmarks.bookmark_text,Bookmarks.creation_time,Bookmarks.modification_time,Bookmarks.access_time,Bookmarks.access_counter,Bookmarks.model_id,Bookmarks.paragraph,Bookmarks.word,Bookmarks.char FROM Bookmarks INNER JOIN Books ON Books.book_id = Bookmarks.book_id WHERE Bookmarks.book_id = ? AND Bookmarks.visible = ?", new String[] { "" + bookId, visible ? "1" : "0" }
|
"SELECT Bookmarks.bookmark_id,Bookmarks.book_id,Books.title,Bookmarks.bookmark_text,Bookmarks.creation_time,Bookmarks.modification_time,Bookmarks.access_time,Bookmarks.access_counter,Bookmarks.model_id,Bookmarks.paragraph,Bookmarks.word,Bookmarks.char FROM Bookmarks INNER JOIN Books ON Books.book_id = Bookmarks.book_id WHERE Bookmarks.book_id = ? AND Bookmarks.visible = ?", new String[] { "" + bookId, visible ? "1" : "0" }
|
||||||
|
@ -752,7 +752,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Bookmark> loadAllVisibleBookmarks() {
|
public /*protected*/ List<Bookmark> loadAllVisibleBookmarks() {
|
||||||
LinkedList<Bookmark> list = new LinkedList<Bookmark>();
|
LinkedList<Bookmark> list = new LinkedList<Bookmark>();
|
||||||
myDatabase.execSQL("DELETE FROM Bookmarks WHERE book_id = -1");
|
myDatabase.execSQL("DELETE FROM Bookmarks WHERE book_id = -1");
|
||||||
Cursor cursor = myDatabase.rawQuery(
|
Cursor cursor = myDatabase.rawQuery(
|
||||||
|
@ -782,7 +782,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
private SQLiteStatement myInsertBookmarkStatement;
|
private SQLiteStatement myInsertBookmarkStatement;
|
||||||
private SQLiteStatement myUpdateBookmarkStatement;
|
private SQLiteStatement myUpdateBookmarkStatement;
|
||||||
@Override
|
@Override
|
||||||
protected long saveBookmark(Bookmark bookmark) {
|
public /*protected*/ long saveBookmark(Bookmark bookmark) {
|
||||||
SQLiteStatement statement;
|
SQLiteStatement statement;
|
||||||
if (bookmark.getId() == -1) {
|
if (bookmark.getId() == -1) {
|
||||||
if (myInsertBookmarkStatement == null) {
|
if (myInsertBookmarkStatement == null) {
|
||||||
|
@ -824,7 +824,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
|
|
||||||
private SQLiteStatement myDeleteBookmarkStatement;
|
private SQLiteStatement myDeleteBookmarkStatement;
|
||||||
@Override
|
@Override
|
||||||
protected void deleteBookmark(Bookmark bookmark) {
|
public /*protected*/ void deleteBookmark(Bookmark bookmark) {
|
||||||
if (myDeleteBookmarkStatement == null) {
|
if (myDeleteBookmarkStatement == null) {
|
||||||
myDeleteBookmarkStatement = myDatabase.compileStatement(
|
myDeleteBookmarkStatement = myDatabase.compileStatement(
|
||||||
"DELETE FROM Bookmarks WHERE bookmark_id = ?"
|
"DELETE FROM Bookmarks WHERE bookmark_id = ?"
|
||||||
|
@ -834,7 +834,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
myDeleteBookmarkStatement.execute();
|
myDeleteBookmarkStatement.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ZLTextPosition getStoredPosition(long bookId) {
|
public /*protected*/ ZLTextPosition getStoredPosition(long bookId) {
|
||||||
ZLTextPosition position = null;
|
ZLTextPosition position = null;
|
||||||
Cursor cursor = myDatabase.rawQuery(
|
Cursor cursor = myDatabase.rawQuery(
|
||||||
"SELECT paragraph,word,char FROM BookState WHERE book_id = " + bookId, null
|
"SELECT paragraph,word,char FROM BookState WHERE book_id = " + bookId, null
|
||||||
|
@ -851,7 +851,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteStatement myStorePositionStatement;
|
private SQLiteStatement myStorePositionStatement;
|
||||||
protected void storePosition(long bookId, ZLTextPosition position) {
|
public /*protected*/ void storePosition(long bookId, ZLTextPosition position) {
|
||||||
if (myStorePositionStatement == null) {
|
if (myStorePositionStatement == null) {
|
||||||
myStorePositionStatement = myDatabase.compileStatement(
|
myStorePositionStatement = myDatabase.compileStatement(
|
||||||
"INSERT OR REPLACE INTO BookState (book_id,paragraph,word,char) VALUES (?,?,?,?)"
|
"INSERT OR REPLACE INTO BookState (book_id,paragraph,word,char) VALUES (?,?,?,?)"
|
||||||
|
@ -877,7 +877,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteStatement myStoreVisitedHyperlinksStatement;
|
private SQLiteStatement myStoreVisitedHyperlinksStatement;
|
||||||
protected void addVisitedHyperlink(long bookId, String hyperlinkId) {
|
public /*protected*/ void addVisitedHyperlink(long bookId, String hyperlinkId) {
|
||||||
if (myStoreVisitedHyperlinksStatement == null) {
|
if (myStoreVisitedHyperlinksStatement == null) {
|
||||||
myStoreVisitedHyperlinksStatement = myDatabase.compileStatement(
|
myStoreVisitedHyperlinksStatement = myDatabase.compileStatement(
|
||||||
"INSERT OR IGNORE INTO VisitedHyperlinks(book_id,hyperlink_id) VALUES (?,?)"
|
"INSERT OR IGNORE INTO VisitedHyperlinks(book_id,hyperlink_id) VALUES (?,?)"
|
||||||
|
@ -889,7 +889,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
myStoreVisitedHyperlinksStatement.execute();
|
myStoreVisitedHyperlinksStatement.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Collection<String> loadVisitedHyperlinks(long bookId) {
|
public /*protected*/ Collection<String> loadVisitedHyperlinks(long bookId) {
|
||||||
final TreeSet<String> links = new TreeSet<String>();
|
final TreeSet<String> links = new TreeSet<String>();
|
||||||
final Cursor cursor = myDatabase.rawQuery("SELECT hyperlink_id FROM VisitedHyperlinks WHERE book_id = ?", new String[] { "" + bookId });
|
final Cursor cursor = myDatabase.rawQuery("SELECT hyperlink_id FROM VisitedHyperlinks WHERE book_id = ?", new String[] { "" + bookId });
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
|
|
|
@ -31,9 +31,10 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.text.hyphenation.ZLTextHyphenator;
|
import org.geometerplus.zlibrary.text.hyphenation.ZLTextHyphenator;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.formats.FormatPlugin;
|
import org.geometerplus.fbreader.book.SerializerUtil;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
||||||
|
import org.geometerplus.fbreader.formats.FormatPlugin;
|
||||||
|
|
||||||
import org.geometerplus.android.fbreader.FBReader;
|
import org.geometerplus.android.fbreader.FBReader;
|
||||||
import org.geometerplus.android.fbreader.library.BookInfoActivity;
|
import org.geometerplus.android.fbreader.library.BookInfoActivity;
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.geometerplus.fbreader.book;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
import org.geometerplus.fbreader.book.Book;
|
||||||
|
|
||||||
public abstract class AbstractBookCollection implements IBookCollection {
|
public abstract class AbstractBookCollection implements IBookCollection {
|
||||||
private final List<Listener> myListeners = Collections.synchronizedList(new LinkedList<Listener>());
|
private final List<Listener> myListeners = Collections.synchronizedList(new LinkedList<Listener>());
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
|
|
||||||
package org.geometerplus.fbreader.book;
|
package org.geometerplus.fbreader.book;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
|
||||||
import org.geometerplus.fbreader.library.Bookmark;
|
|
||||||
|
|
||||||
abstract class AbstractSerializer {
|
abstract class AbstractSerializer {
|
||||||
public abstract String serialize(Book book);
|
public abstract String serialize(Book book);
|
||||||
public abstract Book deserializeBook(String xml);
|
public abstract Book deserializeBook(String xml);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geometerplus.fbreader.library;
|
package org.geometerplus.fbreader.book;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -37,6 +37,7 @@ import org.geometerplus.fbreader.Paths;
|
||||||
import org.geometerplus.fbreader.book.*;
|
import org.geometerplus.fbreader.book.*;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
||||||
import org.geometerplus.fbreader.formats.*;
|
import org.geometerplus.fbreader.formats.*;
|
||||||
|
import org.geometerplus.fbreader.library.Library;
|
||||||
|
|
||||||
public class Book {
|
public class Book {
|
||||||
public static Book getById(long bookId) {
|
public static Book getById(long bookId) {
|
||||||
|
@ -121,7 +122,7 @@ public class Book {
|
||||||
private static final WeakReference<ZLImage> NULL_IMAGE = new WeakReference<ZLImage>(null);
|
private static final WeakReference<ZLImage> NULL_IMAGE = new WeakReference<ZLImage>(null);
|
||||||
private WeakReference<ZLImage> myCover;
|
private WeakReference<ZLImage> myCover;
|
||||||
|
|
||||||
public Book(long id, ZLFile file, String title, String encoding, String language) {
|
Book(long id, ZLFile file, String title, String encoding, String language) {
|
||||||
myId = id;
|
myId = id;
|
||||||
File = file;
|
File = file;
|
||||||
myTitle = title;
|
myTitle = title;
|
||||||
|
@ -130,7 +131,7 @@ public class Book {
|
||||||
myIsSaved = true;
|
myIsSaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Book(ZLFile file) throws BookReadingException {
|
public Book(ZLFile file) throws BookReadingException {
|
||||||
myId = -1;
|
myId = -1;
|
||||||
final FormatPlugin plugin = getPlugin(file);
|
final FormatPlugin plugin = getPlugin(file);
|
||||||
File = plugin.realBookFile(file);
|
File = plugin.realBookFile(file);
|
||||||
|
@ -167,7 +168,7 @@ public class Book {
|
||||||
return getPlugin(File);
|
return getPlugin(File);
|
||||||
}
|
}
|
||||||
|
|
||||||
void readMetaInfo() throws BookReadingException {
|
public void readMetaInfo() throws BookReadingException {
|
||||||
readMetaInfo(getPlugin());
|
readMetaInfo(getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +377,7 @@ public class Book {
|
||||||
addTag(Tag.getTag(null, tagName));
|
addTag(Tag.getTag(null, tagName));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean matches(String pattern) {
|
public boolean matches(String pattern) {
|
||||||
if (myTitle != null && ZLMiscUtil.matchesIgnoreCase(myTitle, pattern)) {
|
if (myTitle != null && ZLMiscUtil.matchesIgnoreCase(myTitle, pattern)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geometerplus.fbreader.library;
|
package org.geometerplus.fbreader.book;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
import org.geometerplus.zlibrary.core.image.ZLImage;
|
|
@ -17,7 +17,7 @@
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geometerplus.fbreader.library;
|
package org.geometerplus.fbreader.book;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
109
src/org/geometerplus/fbreader/book/BooksDatabase.java
Normal file
109
src/org/geometerplus/fbreader/book/BooksDatabase.java
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009-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.book;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||||
|
|
||||||
|
import org.geometerplus.zlibrary.text.view.ZLTextPosition;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.*;
|
||||||
|
|
||||||
|
public abstract class BooksDatabase {
|
||||||
|
private static BooksDatabase ourInstance;
|
||||||
|
|
||||||
|
public static BooksDatabase Instance() {
|
||||||
|
return ourInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public /*protected*/ BooksDatabase() {
|
||||||
|
ourInstance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public /*protected*/ Book createBook(long id, long fileId, String title, String encoding, String language) {
|
||||||
|
final FileInfoSet infos = new FileInfoSet(this, fileId);
|
||||||
|
return createBook(id, infos.getFile(fileId), title, encoding, language);
|
||||||
|
}
|
||||||
|
public /*protected*/ Book createBook(long id, ZLFile file, String title, String encoding, String language) {
|
||||||
|
return (file != null) ? new Book(id, file, title, encoding, language) : null;
|
||||||
|
}
|
||||||
|
public /*protected*/ void addAuthor(Book book, Author author) {
|
||||||
|
book.addAuthorWithNoCheck(author);
|
||||||
|
}
|
||||||
|
public /*protected*/ void addTag(Book book, Tag tag) {
|
||||||
|
book.addTagWithNoCheck(tag);
|
||||||
|
}
|
||||||
|
public /*protected*/ void setSeriesInfo(Book book, String series, String index) {
|
||||||
|
book.setSeriesInfoWithNoCheck(series, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public /*protected*/ abstract void executeAsATransaction(Runnable actions);
|
||||||
|
|
||||||
|
// returns map fileId -> book
|
||||||
|
public /*protected*/ abstract Map<Long,Book> loadBooks(FileInfoSet infos, boolean existing);
|
||||||
|
public /*protected*/ abstract void setExistingFlag(Collection<Book> books, boolean flag);
|
||||||
|
public /*protected*/ abstract Book loadBook(long bookId);
|
||||||
|
public /*protected*/ abstract void reloadBook(Book book);
|
||||||
|
public /*protected*/ abstract Book loadBookByFile(long fileId, ZLFile file);
|
||||||
|
|
||||||
|
public /*protected*/ abstract List<Author> loadAuthors(long bookId);
|
||||||
|
public /*protected*/ abstract List<Tag> loadTags(long bookId);
|
||||||
|
public /*protected*/ abstract SeriesInfo loadSeriesInfo(long bookId);
|
||||||
|
public /*protected*/ abstract void updateBookInfo(long bookId, long fileId, String encoding, String language, String title);
|
||||||
|
public /*protected*/ abstract long insertBookInfo(ZLFile file, String encoding, String language, String title);
|
||||||
|
public /*protected*/ abstract void deleteAllBookAuthors(long bookId);
|
||||||
|
public /*protected*/ abstract void saveBookAuthorInfo(long bookId, long index, Author author);
|
||||||
|
public /*protected*/ abstract void deleteAllBookTags(long bookId);
|
||||||
|
public /*protected*/ abstract void saveBookTagInfo(long bookId, Tag tag);
|
||||||
|
public /*protected*/ abstract void saveBookSeriesInfo(long bookId, SeriesInfo seriesInfo);
|
||||||
|
|
||||||
|
public /*protected*/ FileInfo createFileInfo(long id, String name, FileInfo parent) {
|
||||||
|
return new FileInfo(name, parent, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public /*protected*/ abstract Collection<FileInfo> loadFileInfos();
|
||||||
|
public /*protected*/ abstract Collection<FileInfo> loadFileInfos(ZLFile file);
|
||||||
|
public /*protected*/ abstract Collection<FileInfo> loadFileInfos(long fileId);
|
||||||
|
public /*protected*/ abstract void removeFileInfo(long fileId);
|
||||||
|
public /*protected*/ abstract void saveFileInfo(FileInfo fileInfo);
|
||||||
|
|
||||||
|
public /*protected*/ abstract List<Long> loadRecentBookIds();
|
||||||
|
public /*protected*/ abstract void saveRecentBookIds(final List<Long> ids);
|
||||||
|
|
||||||
|
public /*protected*/ abstract List<Long> loadFavoriteIds();
|
||||||
|
public /*protected*/ abstract void addToFavorites(long bookId);
|
||||||
|
public /*protected*/ abstract void removeFromFavorites(long bookId);
|
||||||
|
|
||||||
|
public /*protected*/ Bookmark createBookmark(long id, long bookId, String bookTitle, String text, Date creationDate, Date modificationDate, Date accessDate, int accessCounter, String modelId, int paragraphIndex, int wordIndex, int charIndex, boolean isVisible) {
|
||||||
|
return new Bookmark(id, bookId, bookTitle, text, creationDate, modificationDate, accessDate, accessCounter, modelId, paragraphIndex, wordIndex, charIndex, isVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
public /*protected*/ abstract List<Bookmark> loadBookmarks(long bookId, boolean isVisible);
|
||||||
|
public /*protected*/ abstract List<Bookmark> loadAllVisibleBookmarks();
|
||||||
|
public /*protected*/ abstract long saveBookmark(Bookmark bookmark);
|
||||||
|
public /*protected*/ abstract void deleteBookmark(Bookmark bookmark);
|
||||||
|
|
||||||
|
public /*protected*/ abstract ZLTextPosition getStoredPosition(long bookId);
|
||||||
|
public /*protected*/ abstract void storePosition(long bookId, ZLTextPosition position);
|
||||||
|
|
||||||
|
public /*protected*/ abstract Collection<String> loadVisitedHyperlinks(long bookId);
|
||||||
|
public /*protected*/ abstract void addVisitedHyperlink(long bookId, String hyperlinkId);
|
||||||
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geometerplus.fbreader.library;
|
package org.geometerplus.fbreader.book;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.tree.ZLTree;
|
import org.geometerplus.zlibrary.core.tree.ZLTree;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geometerplus.fbreader.library;
|
package org.geometerplus.fbreader.book;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
|
@ -25,9 +25,6 @@ import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.text.view.ZLTextPosition;
|
import org.geometerplus.zlibrary.text.view.ZLTextPosition;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
|
||||||
import org.geometerplus.fbreader.library.Bookmark;
|
|
||||||
|
|
||||||
public interface IBookCollection {
|
public interface IBookCollection {
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
public enum BookEvent {
|
public enum BookEvent {
|
||||||
|
|
|
@ -21,9 +21,6 @@ package org.geometerplus.fbreader.book;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
|
||||||
import org.geometerplus.fbreader.library.Bookmark;
|
|
||||||
|
|
||||||
public abstract class SerializerUtil {
|
public abstract class SerializerUtil {
|
||||||
private SerializerUtil() {
|
private SerializerUtil() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,6 @@ import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||||
import org.geometerplus.zlibrary.core.xml.ZLXMLReaderAdapter;
|
import org.geometerplus.zlibrary.core.xml.ZLXMLReaderAdapter;
|
||||||
import org.geometerplus.zlibrary.core.xml.ZLStringMap;
|
import org.geometerplus.zlibrary.core.xml.ZLStringMap;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
|
||||||
import org.geometerplus.fbreader.library.Bookmark;
|
|
||||||
|
|
||||||
class XMLSerializer extends AbstractSerializer {
|
class XMLSerializer extends AbstractSerializer {
|
||||||
@Override
|
@Override
|
||||||
public String serialize(Book book) {
|
public String serialize(Book book) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.text.model.*;
|
import org.geometerplus.zlibrary.text.model.*;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.formats.FormatPlugin;
|
import org.geometerplus.fbreader.formats.FormatPlugin;
|
||||||
|
|
||||||
public abstract class BookModel {
|
public abstract class BookModel {
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.geometerplus.zlibrary.core.image.*;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.text.model.*;
|
import org.geometerplus.zlibrary.text.model.*;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
import org.geometerplus.fbreader.book.Book;
|
||||||
|
|
||||||
abstract class BookModelImpl extends BookModel {
|
abstract class BookModelImpl extends BookModel {
|
||||||
protected CharStorage myInternalHyperlinks;
|
protected CharStorage myInternalHyperlinks;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.geometerplus.zlibrary.core.image.*;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.text.model.*;
|
import org.geometerplus.zlibrary.text.model.*;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.Paths;
|
import org.geometerplus.fbreader.Paths;
|
||||||
|
|
||||||
public class JavaBookModel extends BookModelImpl {
|
public class JavaBookModel extends BookModelImpl {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.text.model.*;
|
import org.geometerplus.zlibrary.text.model.*;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
import org.geometerplus.fbreader.book.Book;
|
||||||
|
|
||||||
public class NativeBookModel extends BookModelImpl {
|
public class NativeBookModel extends BookModelImpl {
|
||||||
private ZLTextModel myBookTextModel;
|
private ZLTextModel myBookTextModel;
|
||||||
|
|
|
@ -23,9 +23,9 @@ import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||||
import org.geometerplus.zlibrary.core.encodings.EncodingCollection;
|
import org.geometerplus.zlibrary.core.encodings.EncodingCollection;
|
||||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
import org.geometerplus.zlibrary.core.image.ZLImage;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookModel;
|
import org.geometerplus.fbreader.bookmodel.BookModel;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
||||||
import org.geometerplus.fbreader.library.Book;
|
|
||||||
|
|
||||||
public abstract class FormatPlugin {
|
public abstract class FormatPlugin {
|
||||||
private final String myFileType;
|
private final String myFileType;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
package org.geometerplus.fbreader.formats;
|
package org.geometerplus.fbreader.formats;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
import org.geometerplus.fbreader.book.Book;
|
||||||
|
|
||||||
public abstract class JavaFormatPlugin extends FormatPlugin {
|
public abstract class JavaFormatPlugin extends FormatPlugin {
|
||||||
protected JavaFormatPlugin(String fileType) {
|
protected JavaFormatPlugin(String fileType) {
|
||||||
|
|
|
@ -25,9 +25,9 @@ import org.geometerplus.zlibrary.core.encodings.JavaEncodingCollection;
|
||||||
import org.geometerplus.zlibrary.core.image.*;
|
import org.geometerplus.zlibrary.core.image.*;
|
||||||
import org.geometerplus.zlibrary.core.util.MimeType;
|
import org.geometerplus.zlibrary.core.util.MimeType;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookModel;
|
import org.geometerplus.fbreader.bookmodel.BookModel;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
||||||
import org.geometerplus.fbreader.library.Book;
|
|
||||||
import org.geometerplus.fbreader.formats.fb2.FB2NativePlugin;
|
import org.geometerplus.fbreader.formats.fb2.FB2NativePlugin;
|
||||||
import org.geometerplus.fbreader.formats.oeb.OEBNativePlugin;
|
import org.geometerplus.fbreader.formats.oeb.OEBNativePlugin;
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ import java.io.IOException;
|
||||||
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||||
import org.geometerplus.zlibrary.core.xml.*;
|
import org.geometerplus.zlibrary.core.xml.*;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.book.Tag;
|
import org.geometerplus.fbreader.book.Tag;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
||||||
import org.geometerplus.fbreader.library.Book;
|
|
||||||
|
|
||||||
public class FB2MetaInfoReader extends ZLXMLReaderAdapter {
|
public class FB2MetaInfoReader extends ZLXMLReaderAdapter {
|
||||||
private final static int READ_NOTHING = 0;
|
private final static int READ_NOTHING = 0;
|
||||||
|
|
|
@ -23,9 +23,9 @@ import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||||
import org.geometerplus.zlibrary.core.encodings.AutoEncodingCollection;
|
import org.geometerplus.zlibrary.core.encodings.AutoEncodingCollection;
|
||||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
import org.geometerplus.zlibrary.core.image.ZLImage;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookModel;
|
import org.geometerplus.fbreader.bookmodel.BookModel;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
||||||
import org.geometerplus.fbreader.library.Book;
|
|
||||||
import org.geometerplus.fbreader.formats.JavaFormatPlugin;
|
import org.geometerplus.fbreader.formats.JavaFormatPlugin;
|
||||||
|
|
||||||
public class FB2Plugin extends JavaFormatPlugin {
|
public class FB2Plugin extends JavaFormatPlugin {
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.geometerplus.zlibrary.core.constants.XMLNamespaces;
|
||||||
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||||
import org.geometerplus.zlibrary.core.xml.*;
|
import org.geometerplus.zlibrary.core.xml.*;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
||||||
|
|
||||||
class OEBMetaInfoReader extends ZLXMLReaderAdapter implements XMLNamespaces {
|
class OEBMetaInfoReader extends ZLXMLReaderAdapter implements XMLNamespaces {
|
||||||
|
|
|
@ -23,9 +23,9 @@ import org.geometerplus.zlibrary.core.filesystem.*;
|
||||||
import org.geometerplus.zlibrary.core.encodings.AutoEncodingCollection;
|
import org.geometerplus.zlibrary.core.encodings.AutoEncodingCollection;
|
||||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
import org.geometerplus.zlibrary.core.image.ZLImage;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookModel;
|
import org.geometerplus.fbreader.bookmodel.BookModel;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
||||||
import org.geometerplus.fbreader.library.Book;
|
|
||||||
import org.geometerplus.fbreader.formats.JavaFormatPlugin;
|
import org.geometerplus.fbreader.formats.JavaFormatPlugin;
|
||||||
|
|
||||||
public class OEBPlugin extends JavaFormatPlugin {
|
public class OEBPlugin extends JavaFormatPlugin {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.geometerplus.zlibrary.core.encodings.JavaEncodingCollection;
|
||||||
import org.geometerplus.zlibrary.core.language.ZLLanguageUtil;
|
import org.geometerplus.zlibrary.core.language.ZLLanguageUtil;
|
||||||
import org.geometerplus.zlibrary.core.util.MimeType;
|
import org.geometerplus.zlibrary.core.util.MimeType;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookModel;
|
import org.geometerplus.fbreader.bookmodel.BookModel;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
||||||
import org.geometerplus.fbreader.formats.JavaFormatPlugin;
|
import org.geometerplus.fbreader.formats.JavaFormatPlugin;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.geometerplus.fbreader.library;
|
package org.geometerplus.fbreader.library;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.book.Author;
|
import org.geometerplus.fbreader.book.Author;
|
||||||
|
import org.geometerplus.fbreader.book.Book;
|
||||||
|
|
||||||
public class AuthorTree extends LibraryTree {
|
public class AuthorTree extends LibraryTree {
|
||||||
public final Author Author;
|
public final Author Author;
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.geometerplus.fbreader.library;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.book.SeriesInfo;
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.tree.FBTree;
|
import org.geometerplus.fbreader.tree.FBTree;
|
||||||
|
|
||||||
public final class BookInSeriesTree extends BookTree {
|
public final class BookInSeriesTree extends BookTree {
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.geometerplus.fbreader.library;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
import org.geometerplus.zlibrary.core.image.ZLImage;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.book.Author;
|
import org.geometerplus.fbreader.book.*;
|
||||||
import org.geometerplus.fbreader.tree.FBTree;
|
import org.geometerplus.fbreader.tree.FBTree;
|
||||||
|
|
||||||
public class BookTree extends LibraryTree {
|
public class BookTree extends LibraryTree {
|
||||||
|
|
|
@ -1,109 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2009-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.*;
|
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.text.view.ZLTextPosition;
|
|
||||||
|
|
||||||
import org.geometerplus.fbreader.book.*;
|
|
||||||
|
|
||||||
public abstract class BooksDatabase {
|
|
||||||
private static BooksDatabase ourInstance;
|
|
||||||
|
|
||||||
public static BooksDatabase Instance() {
|
|
||||||
return ourInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BooksDatabase() {
|
|
||||||
ourInstance = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Book createBook(long id, long fileId, String title, String encoding, String language) {
|
|
||||||
final FileInfoSet infos = new FileInfoSet(this, fileId);
|
|
||||||
return createBook(id, infos.getFile(fileId), title, encoding, language);
|
|
||||||
}
|
|
||||||
protected Book createBook(long id, ZLFile file, String title, String encoding, String language) {
|
|
||||||
return (file != null) ? new Book(id, file, title, encoding, language) : null;
|
|
||||||
}
|
|
||||||
protected void addAuthor(Book book, Author author) {
|
|
||||||
book.addAuthorWithNoCheck(author);
|
|
||||||
}
|
|
||||||
protected void addTag(Book book, Tag tag) {
|
|
||||||
book.addTagWithNoCheck(tag);
|
|
||||||
}
|
|
||||||
protected void setSeriesInfo(Book book, String series, String index) {
|
|
||||||
book.setSeriesInfoWithNoCheck(series, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void executeAsATransaction(Runnable actions);
|
|
||||||
|
|
||||||
// returns map fileId -> book
|
|
||||||
protected abstract Map<Long,Book> loadBooks(FileInfoSet infos, boolean existing);
|
|
||||||
protected abstract void setExistingFlag(Collection<Book> books, boolean flag);
|
|
||||||
protected abstract Book loadBook(long bookId);
|
|
||||||
protected abstract void reloadBook(Book book);
|
|
||||||
protected abstract Book loadBookByFile(long fileId, ZLFile file);
|
|
||||||
|
|
||||||
protected abstract List<Author> loadAuthors(long bookId);
|
|
||||||
protected abstract List<Tag> loadTags(long bookId);
|
|
||||||
protected abstract SeriesInfo loadSeriesInfo(long bookId);
|
|
||||||
protected abstract void updateBookInfo(long bookId, long fileId, String encoding, String language, String title);
|
|
||||||
protected abstract long insertBookInfo(ZLFile file, String encoding, String language, String title);
|
|
||||||
protected abstract void deleteAllBookAuthors(long bookId);
|
|
||||||
protected abstract void saveBookAuthorInfo(long bookId, long index, Author author);
|
|
||||||
protected abstract void deleteAllBookTags(long bookId);
|
|
||||||
protected abstract void saveBookTagInfo(long bookId, Tag tag);
|
|
||||||
protected abstract void saveBookSeriesInfo(long bookId, SeriesInfo seriesInfo);
|
|
||||||
|
|
||||||
protected FileInfo createFileInfo(long id, String name, FileInfo parent) {
|
|
||||||
return new FileInfo(name, parent, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract Collection<FileInfo> loadFileInfos();
|
|
||||||
protected abstract Collection<FileInfo> loadFileInfos(ZLFile file);
|
|
||||||
protected abstract Collection<FileInfo> loadFileInfos(long fileId);
|
|
||||||
protected abstract void removeFileInfo(long fileId);
|
|
||||||
protected abstract void saveFileInfo(FileInfo fileInfo);
|
|
||||||
|
|
||||||
protected abstract List<Long> loadRecentBookIds();
|
|
||||||
protected abstract void saveRecentBookIds(final List<Long> ids);
|
|
||||||
|
|
||||||
protected abstract List<Long> loadFavoriteIds();
|
|
||||||
protected abstract void addToFavorites(long bookId);
|
|
||||||
protected abstract void removeFromFavorites(long bookId);
|
|
||||||
|
|
||||||
protected Bookmark createBookmark(long id, long bookId, String bookTitle, String text, Date creationDate, Date modificationDate, Date accessDate, int accessCounter, String modelId, int paragraphIndex, int wordIndex, int charIndex, boolean isVisible) {
|
|
||||||
return new Bookmark(id, bookId, bookTitle, text, creationDate, modificationDate, accessDate, accessCounter, modelId, paragraphIndex, wordIndex, charIndex, isVisible);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract List<Bookmark> loadBookmarks(long bookId, boolean isVisible);
|
|
||||||
protected abstract List<Bookmark> loadAllVisibleBookmarks();
|
|
||||||
protected abstract long saveBookmark(Bookmark bookmark);
|
|
||||||
protected abstract void deleteBookmark(Bookmark bookmark);
|
|
||||||
|
|
||||||
protected abstract ZLTextPosition getStoredPosition(long bookId);
|
|
||||||
protected abstract void storePosition(long bookId, ZLTextPosition position);
|
|
||||||
|
|
||||||
protected abstract Collection<String> loadVisitedHyperlinks(long bookId);
|
|
||||||
protected abstract void addVisitedHyperlink(long bookId, String hyperlinkId);
|
|
||||||
}
|
|
|
@ -21,6 +21,7 @@ package org.geometerplus.fbreader.library;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.book.SeriesInfo;
|
import org.geometerplus.fbreader.book.SeriesInfo;
|
||||||
|
|
||||||
public final class SeriesTree extends LibraryTree {
|
public final class SeriesTree extends LibraryTree {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.geometerplus.fbreader.library;
|
package org.geometerplus.fbreader.library;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.book.Tag;
|
import org.geometerplus.fbreader.book.Tag;
|
||||||
|
|
||||||
public final class TagTree extends LibraryTree {
|
public final class TagTree extends LibraryTree {
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.geometerplus.fbreader.library;
|
package org.geometerplus.fbreader.library;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.Book;
|
||||||
|
|
||||||
public final class TitleTree extends LibraryTree {
|
public final class TitleTree extends LibraryTree {
|
||||||
static String firstTitleLetter(Book book) {
|
static String firstTitleLetter(Book book) {
|
||||||
if (book == null) {
|
if (book == null) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue