1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 10:49:24 +02:00

BooksDatabase.listAuthor() method (with no parameters)

This commit is contained in:
Nikolay Pultsin 2013-02-02 09:22:56 +00:00
parent e7d9b6f59e
commit 0ee49e45b1
3 changed files with 24 additions and 9 deletions

View file

@ -357,7 +357,21 @@ final class SQLiteBooksDatabase extends BooksDatabase {
myInsertBookAuthorStatement.execute(); myInsertBookAuthorStatement.execute();
} }
protected List<Author> loadAuthors(long bookId) { protected List<Author> listAuthors() {
final Cursor cursor = myDatabase.rawQuery("SELECT name,sort_key FROM Authors", null);
if (!cursor.moveToNext()) {
cursor.close();
return null;
}
final ArrayList<Author> list = new ArrayList<Author>();
do {
list.add(new Author(cursor.getString(0), cursor.getString(1)));
} while (cursor.moveToNext());
cursor.close();
return list;
}
protected List<Author> listAuthors(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();
@ -449,7 +463,7 @@ final class SQLiteBooksDatabase extends BooksDatabase {
return tag; return tag;
} }
protected List<Tag> loadTags(long bookId) { protected List<Tag> listTags(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();
@ -505,7 +519,7 @@ final class SQLiteBooksDatabase extends BooksDatabase {
} }
} }
protected SeriesInfo loadSeriesInfo(long bookId) { protected SeriesInfo getSeriesInfo(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()) {

View file

@ -134,9 +134,9 @@ public class Book {
} }
void loadLists(BooksDatabase database) { void loadLists(BooksDatabase database) {
myAuthors = database.loadAuthors(myId); myAuthors = database.listAuthors(myId);
myTags = database.loadTags(myId); myTags = database.listTags(myId);
mySeriesInfo = database.loadSeriesInfo(myId); mySeriesInfo = database.getSeriesInfo(myId);
myIsSaved = true; myIsSaved = true;
} }

View file

@ -51,9 +51,10 @@ public abstract class BooksDatabase {
protected abstract Book loadBook(long bookId); protected abstract Book loadBook(long bookId);
protected abstract Book loadBookByFile(long fileId, ZLFile file); protected abstract Book loadBookByFile(long fileId, ZLFile file);
protected abstract List<Author> loadAuthors(long bookId); protected abstract List<Author> listAuthors();
protected abstract List<Tag> loadTags(long bookId); protected abstract List<Author> listAuthors(long bookId);
protected abstract SeriesInfo loadSeriesInfo(long bookId); protected abstract List<Tag> listTags(long bookId);
protected abstract SeriesInfo getSeriesInfo(long bookId);
protected abstract void updateBookInfo(long bookId, long fileId, String encoding, String language, String title); 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 long insertBookInfo(ZLFile file, String encoding, String language, String title);
protected abstract void deleteAllBookAuthors(long bookId); protected abstract void deleteAllBookAuthors(long bookId);