FolioReader / FolioReader-Android

A Java ePub reader and parser framework for Android.
BSD 3-Clause "New" or "Revised" License
2.24k stars 710 forks source link

Last Read Position Value get updated automatically without any change in book reading #227

Open SonyGeorge opened 6 years ago

SonyGeorge commented 6 years ago

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"}
hrishikesh-kadam commented 6 years ago

Can you please send epub file for reproducing the issue?

SonyGeorge commented 6 years ago

sent yo your email you have in github account, please check