Open veeyka opened 6 years ago
Follow This Link https://github.com/FolioReader/FolioReader-Android#wiki
@KishanViramgama hi . I searched at FolioReader wiki you mean that get/set readposition. But I can not figure out how can I apply in my app?
store the read position with database
//--------------set book-------------//
folioReader.setReadPositionListener(new ReadPositionListener() {
@Override
public void saveReadPosition(ReadPosition readPosition) {
Log.d("readPosition", readPosition.toJson());
if (db.checkIdEpub(id)) {
db.addEpub(id, readPosition.toJson());
} else {
db.updateEpub(id, readPosition.toJson());
}
}
});
/----------- open book----------/
try {
String string = db.getEpub(id);
JSONObject jsonObject = new JSONObject(string);
String bookId = jsonObject.getString("bookId");
String chapterId = jsonObject.getString("chapterId");
String chapterHref = jsonObject.getString("chapterHref");
int chapterIndex = Integer.parseInt(jsonObject.getString("chapterIndex"));
boolean usingId = Boolean.parseBoolean(jsonObject.getString("usingId"));
String value = jsonObject.getString("value");
ReadPosition readPosition = new ReadPositionImpl(bookId, chapterId,
chapterHref, chapterIndex, usingId, value);
folioReader.setReadPosition(readPosition);
folioReader.openBook(sdIconStorageDir.toString());
} catch (JSONException e) {
e.printStackTrace();
}
@KishanViramgama Thanks for your reply. I try the copy+paste your code to my app, the "db" and "addEpub" "updateEpub" give me an error "Cannot resolve symbol"
Again how can I apply get/set read position in my app ? I tried the sample FolioReader app and the app doesn't include get/set read position
@veeyka Storing page number as last read position would be inconsistent as page number would be different on portarait and landscape mode or on tablet and mobiles. So we store the first visible span index or id as the last read position. Hope you have seen Wiki pages related to ReadPosition
@dumanapp We have updated Wiki pages, please have a look. It might help you to understand better.
@KishanViramgama i want to to calculate the total page number and store it on db for make a progress for the book for exampls : when user open the app it shows him the percentage of the book that he already read can you help me ! ( sorry for my bad english )
@TidelxD Check the bottom of Text Highlighting screen short in README.md
Hey , You can get the total number of Pages for current chapter in 'FolioPageFragment' using "webViewPager!!.totalPages()". Also , you can get total chapters in book in FolioActivity using "spine?.size".
With the combination of these two, we can find total number of pages in epub.
hey how can i get page number to save it in a sharedPreference when we close book i need page number to save it and open book if user opens it later (open in last page closed) give me a sample code please thanks