Open
Description
Hi Team,
This is how i use SetReadPosition in my code
Uri uri = Uri.fromFile(fileToOpen);
FolioReader folioReader = FolioReader.getInstance(getApplicationContext());
folioReader.setReadPositionListener(new ReadPositionListener() {
@Override
public void saveReadPosition(ReadPosition readPosition) {
Util.updateSharedPref(getApplicationContext(), "book_pk_" + bookVO.getUniqueid(), readPosition.toJson());
Log.v("EBOOK", "ReadPosition saved to pref. with key :book_pk_" + bookVO.getUniqueid());
Log.v("EBOOK", "ReadPosition SavedValue is :" + readPosition.toJson());
}
});
// check if read position exist
String readPositionJsonStr = Util.getSharedPreferences(getApplicationContext()).getString("book_pk_" + bookVO.getUniqueid(), null);
if (readPositionJsonStr != null && !readPositionJsonStr.isEmpty()) {
ObjectReader objectReader = ObjectMapperSingleton.getObjectMapper().reader();
ReadPosition readPosition = objectReader.forType(ReadPositionImpl.class).readValue(readPositionJsonStr);
Log.v("EBOOK", "ReadPosition ReadValue is :" + readPosition.toJson());
folioReader.setReadPosition(readPosition);
}
folioReader.openBook(uri.getPath(), folioReaderConfig, String.valueOf(bookVO.getUniqueid()));
But each time when i just open the book and closing it, the value gets updated..
please see the log
I do not do anything on the UI, no touch, no scroll, i just open the book, then close the book by backbutton of android.
06-28 16:13:45/com.ebook.reader V/EBOOK: ReadPosition ReadValue is :{"bookId":"56329","chapterId":"id24","chapterHref":"index_split_002.html","chapterIndex":3,"usingId":false,"value":"34"}
06-28 16:14:09/com.ebook.reader V/EBOOK: ReadPosition saved to pref. with key :book_pk_56329
06-28 16:14:36/com.ebook.reader V/EBOOK: ReadPosition SavedValue is :{"bookId":"56329","chapterId":"id24","chapterHref":"index_split_002.html","chapterIndex":3,"usingId":false,"value":"65"}
06-28 16:14:18/com.ebook.reader V/EBOOK: ReadPosition ReadValue is :{"bookId":"56329","chapterId":"id24","chapterHref":"index_split_002.html","chapterIndex":3,"usingId":false,"value":"65"}
06-28 16:14:36/com.ebook.reader V/EBOOK: ReadPosition saved to pref. with key :book_pk_56329
06-28 16:14:36/com.ebook.reader V/EBOOK: ReadPosition SavedValue is :{"bookId":"56329","chapterId":"id24","chapterHref":"index_split_002.html","chapterIndex":3,"usingId":false,"value":"124"}
06-28 16:15:51/com.ebook.reader V/EBOOK: ReadPosition ReadValue is :{"bookId":"56329","chapterId":"id24","chapterHref":"index_split_002.html","chapterIndex":3,"usingId":false,"value":"124"}
06-28 16:16:05/com.ebook.reader V/EBOOK: ReadPosition saved to pref. with key :book_pk_56329
06-28 16:16:05/com.ebook.reader V/EBOOK: ReadPosition SavedValue is :{"bookId":"56329","chapterId":"id24","chapterHref":"index_split_002.html","chapterIndex":3,"usingId":false,"value":"241"}