mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
fixed NPE
This commit is contained in:
parent
6f6fdf6b12
commit
0ddf4550fd
2 changed files with 12 additions and 1 deletions
|
@ -199,6 +199,10 @@ public class BookCollectionShadow implements IBookCollection, ServiceConnection
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final TextPosition position = myInterface.getStoredPosition(bookId);
|
final TextPosition position = myInterface.getStoredPosition(bookId);
|
||||||
|
if (position == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new ZLTextFixedPosition(
|
return new ZLTextFixedPosition(
|
||||||
position.ParagraphIndex, position.ElementIndex, position.CharIndex
|
position.ParagraphIndex, position.ElementIndex, position.CharIndex
|
||||||
);
|
);
|
||||||
|
@ -208,7 +212,7 @@ public class BookCollectionShadow implements IBookCollection, ServiceConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void storePosition(long bookId, ZLTextPosition position) {
|
public synchronized void storePosition(long bookId, ZLTextPosition position) {
|
||||||
if (myInterface != null) {
|
if (position != null && myInterface != null) {
|
||||||
try {
|
try {
|
||||||
myInterface.storePosition(bookId, new TextPosition(
|
myInterface.storePosition(bookId, new TextPosition(
|
||||||
position.getParagraphIndex(), position.getElementIndex(), position.getCharIndex()
|
position.getParagraphIndex(), position.getElementIndex(), position.getCharIndex()
|
||||||
|
|
|
@ -172,12 +172,19 @@ public class LibraryService extends Service {
|
||||||
|
|
||||||
public TextPosition getStoredPosition(long bookId) {
|
public TextPosition getStoredPosition(long bookId) {
|
||||||
final ZLTextPosition position = myCollection.getStoredPosition(bookId);
|
final ZLTextPosition position = myCollection.getStoredPosition(bookId);
|
||||||
|
if (position == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new TextPosition(
|
return new TextPosition(
|
||||||
position.getParagraphIndex(), position.getElementIndex(), position.getCharIndex()
|
position.getParagraphIndex(), position.getElementIndex(), position.getCharIndex()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storePosition(long bookId, TextPosition position) {
|
public void storePosition(long bookId, TextPosition position) {
|
||||||
|
if (position == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
myCollection.storePosition(bookId, new ZLTextFixedPosition(
|
myCollection.storePosition(bookId, new ZLTextFixedPosition(
|
||||||
position.ParagraphIndex, position.ElementIndex, position.CharIndex
|
position.ParagraphIndex, position.ElementIndex, position.CharIndex
|
||||||
));
|
));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue