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

more code around book progress

This commit is contained in:
Nikolay Pultsin 2013-10-10 03:28:27 +01:00
parent f3bde8ade9
commit 0c12d14922
3 changed files with 8 additions and 5 deletions

View file

@ -1048,7 +1048,7 @@ final class SQLiteBooksDatabase extends BooksDatabase {
private SQLiteStatement mySaveProgessStatement; private SQLiteStatement mySaveProgessStatement;
@Override @Override
protected void saveProgress(long bookId, RationalNumber progress) { protected void saveBookProgress(long bookId, RationalNumber progress) {
if (mySaveProgessStatement == null) { if (mySaveProgessStatement == null) {
mySaveProgessStatement = myDatabase.compileStatement( mySaveProgessStatement = myDatabase.compileStatement(
"INSERT OR REPLACE INTO BookReadingProgress (book_id,numerator,denominator) VALUES (?,?,?)" "INSERT OR REPLACE INTO BookReadingProgress (book_id,numerator,denominator) VALUES (?,?,?)"
@ -1061,7 +1061,7 @@ final class SQLiteBooksDatabase extends BooksDatabase {
} }
@Override @Override
protected RationalNumber loadProgress(long bookId) { protected RationalNumber getProgress(long bookId) {
final RationalNumber progress; final RationalNumber progress;
final Cursor cursor = myDatabase.rawQuery( final Cursor cursor = myDatabase.rawQuery(
"SELECT numerator,denominator FROM BookReadingProgress WHERE book_id = " + bookId, null "SELECT numerator,denominator FROM BookReadingProgress WHERE book_id = " + bookId, null

View file

@ -150,6 +150,7 @@ public class Book extends TitledEntity {
myLabels = database.listLabels(myId); myLabels = database.listLabels(myId);
mySeriesInfo = database.getSeriesInfo(myId); mySeriesInfo = database.getSeriesInfo(myId);
myUids = database.listUids(myId); myUids = database.listUids(myId);
myProgress = database.getProgress(myId);
HasBookmark = database.hasVisibleBookmark(myId); HasBookmark = database.hasVisibleBookmark(myId);
myIsSaved = true; myIsSaved = true;
if (myUids == null || myUids.isEmpty()) { if (myUids == null || myUids.isEmpty()) {
@ -472,6 +473,9 @@ public class Book extends TitledEntity {
for (UID uid : uids()) { for (UID uid : uids()) {
database.saveBookUid(myId, uid); database.saveBookUid(myId, uid);
} }
if (myProgress != null) {
database.saveBookProgress(myId, myProgress);
}
} }
}); });

View file

@ -59,6 +59,7 @@ public abstract class BooksDatabase {
protected abstract SeriesInfo getSeriesInfo(long bookId); protected abstract SeriesInfo getSeriesInfo(long bookId);
protected abstract List<UID> listUids(long bookId); protected abstract List<UID> listUids(long bookId);
protected abstract boolean hasVisibleBookmark(long bookId); protected abstract boolean hasVisibleBookmark(long bookId);
protected abstract RationalNumber getProgress(long bookId);
protected abstract Long bookIdByUid(UID uid); protected abstract Long bookIdByUid(UID uid);
@ -71,6 +72,7 @@ public abstract class BooksDatabase {
protected abstract void saveBookSeriesInfo(long bookId, SeriesInfo seriesInfo); protected abstract void saveBookSeriesInfo(long bookId, SeriesInfo seriesInfo);
protected abstract void deleteAllBookUids(long bookId); protected abstract void deleteAllBookUids(long bookId);
protected abstract void saveBookUid(long bookId, UID uid); protected abstract void saveBookUid(long bookId, UID uid);
protected abstract void saveBookProgress(long bookId, RationalNumber progress);
protected FileInfo createFileInfo(long id, String name, FileInfo parent) { protected FileInfo createFileInfo(long id, String name, FileInfo parent) {
return new FileInfo(name, parent, id); return new FileInfo(name, parent, id);
@ -123,7 +125,4 @@ public abstract class BooksDatabase {
protected abstract Collection<String> loadVisitedHyperlinks(long bookId); protected abstract Collection<String> loadVisitedHyperlinks(long bookId);
protected abstract void addVisitedHyperlink(long bookId, String hyperlinkId); protected abstract void addVisitedHyperlink(long bookId, String hyperlinkId);
protected abstract void saveProgress(long bookId, RationalNumber progress);
protected abstract RationalNumber loadProgress(long bookId);
} }