1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 18:29:23 +02:00

fixed NPE

This commit is contained in:
Nikolay Pultsin 2013-01-13 11:01:30 +04:00
parent 6f6fdf6b12
commit 0ddf4550fd
2 changed files with 12 additions and 1 deletions

View file

@ -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()

View file

@ -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
));