diff --git a/src/org/geometerplus/android/fbreader/libraryService/BookCollectionShadow.java b/src/org/geometerplus/android/fbreader/libraryService/BookCollectionShadow.java index 28c619e79..b7e15c274 100644 --- a/src/org/geometerplus/android/fbreader/libraryService/BookCollectionShadow.java +++ b/src/org/geometerplus/android/fbreader/libraryService/BookCollectionShadow.java @@ -199,6 +199,10 @@ public class BookCollectionShadow implements IBookCollection, ServiceConnection try { final TextPosition position = myInterface.getStoredPosition(bookId); + if (position == null) { + return null; + } + return new ZLTextFixedPosition( position.ParagraphIndex, position.ElementIndex, position.CharIndex ); @@ -208,7 +212,7 @@ public class BookCollectionShadow implements IBookCollection, ServiceConnection } public synchronized void storePosition(long bookId, ZLTextPosition position) { - if (myInterface != null) { + if (position != null && myInterface != null) { try { myInterface.storePosition(bookId, new TextPosition( position.getParagraphIndex(), position.getElementIndex(), position.getCharIndex() diff --git a/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java b/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java index cd96f7f4f..d1fa876cb 100644 --- a/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java +++ b/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java @@ -172,12 +172,19 @@ public class LibraryService extends Service { public TextPosition getStoredPosition(long bookId) { final ZLTextPosition position = myCollection.getStoredPosition(bookId); + if (position == null) { + return null; + } + return new TextPosition( position.getParagraphIndex(), position.getElementIndex(), position.getCharIndex() ); } public void storePosition(long bookId, TextPosition position) { + if (position == null) { + return; + } myCollection.storePosition(bookId, new ZLTextFixedPosition( position.ParagraphIndex, position.ElementIndex, position.CharIndex ));