mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
very strange fix (idea by Greg Kochaniak)
This commit is contained in:
parent
3c6fb84a0f
commit
6c739c6ccd
1 changed files with 33 additions and 27 deletions
|
@ -39,7 +39,13 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
|||
);
|
||||
}
|
||||
|
||||
private final FBReaderApp myReader = (FBReaderApp)FBReaderApp.Instance();
|
||||
private volatile FBReaderApp myReader;
|
||||
private synchronized FBReaderApp getReader() {
|
||||
if (myReader == null) {
|
||||
myReader = (FBReaderApp)FBReaderApp.Instance();
|
||||
}
|
||||
return myReader;
|
||||
}
|
||||
|
||||
private ApiObject.Error unsupportedMethodError(int method) {
|
||||
return new ApiObject.Error("Unsupported method code: " + method);
|
||||
|
@ -287,11 +293,11 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
|||
}
|
||||
|
||||
public String getBookLanguage() {
|
||||
return myReader.Model.Book.getLanguage();
|
||||
return getReader().Model.Book.getLanguage();
|
||||
}
|
||||
|
||||
public String getBookTitle() {
|
||||
return myReader.Model.Book.getTitle();
|
||||
return getReader().Model.Book.getTitle();
|
||||
}
|
||||
|
||||
public List<String> getBookTags() {
|
||||
|
@ -300,11 +306,11 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
|||
}
|
||||
|
||||
public String getBookFilePath() {
|
||||
return myReader.Model.Book.File.getPath();
|
||||
return getReader().Model.Book.File.getPath();
|
||||
}
|
||||
|
||||
public String getBookHash() {
|
||||
return myReader.Model.Book.getContentHashCode();
|
||||
return getReader().Model.Book.getContentHashCode();
|
||||
}
|
||||
|
||||
public String getBookUniqueId() {
|
||||
|
@ -354,20 +360,20 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
|||
|
||||
// page information
|
||||
public TextPosition getPageStart() {
|
||||
return getTextPosition(myReader.getTextView().getStartCursor());
|
||||
return getTextPosition(getReader().getTextView().getStartCursor());
|
||||
}
|
||||
|
||||
public TextPosition getPageEnd() {
|
||||
return getTextPosition(myReader.getTextView().getEndCursor());
|
||||
return getTextPosition(getReader().getTextView().getEndCursor());
|
||||
}
|
||||
|
||||
public boolean isPageEndOfSection() {
|
||||
final ZLTextWordCursor cursor = myReader.getTextView().getEndCursor();
|
||||
final ZLTextWordCursor cursor = getReader().getTextView().getEndCursor();
|
||||
return cursor.isEndOfParagraph() && cursor.getParagraphCursor().isEndOfSection();
|
||||
}
|
||||
|
||||
public boolean isPageEndOfText() {
|
||||
final ZLTextWordCursor cursor = myReader.getTextView().getEndCursor();
|
||||
final ZLTextWordCursor cursor = getReader().getTextView().getEndCursor();
|
||||
return cursor.isEndOfParagraph() && cursor.getParagraphCursor().isLast();
|
||||
}
|
||||
|
||||
|
@ -389,60 +395,60 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
|||
|
||||
// manage view
|
||||
public void setPageStart(TextPosition position) {
|
||||
myReader.getTextView().gotoPosition(position.ParagraphIndex, position.ElementIndex, position.CharIndex);
|
||||
myReader.getViewWidget().repaint();
|
||||
myReader.storePosition();
|
||||
getReader().getTextView().gotoPosition(position.ParagraphIndex, position.ElementIndex, position.CharIndex);
|
||||
getReader().getViewWidget().repaint();
|
||||
getReader().storePosition();
|
||||
}
|
||||
|
||||
public void highlightArea(TextPosition start, TextPosition end) {
|
||||
myReader.getTextView().highlight(
|
||||
getReader().getTextView().highlight(
|
||||
getZLTextPosition(start),
|
||||
getZLTextPosition(end)
|
||||
);
|
||||
}
|
||||
|
||||
public void clearHighlighting() {
|
||||
myReader.getTextView().clearHighlighting();
|
||||
getReader().getTextView().clearHighlighting();
|
||||
}
|
||||
|
||||
public int getBottomMargin() {
|
||||
return myReader.BottomMarginOption.getValue();
|
||||
return getReader().BottomMarginOption.getValue();
|
||||
}
|
||||
|
||||
public void setBottomMargin(int value) {
|
||||
myReader.BottomMarginOption.setValue(value);
|
||||
getReader().BottomMarginOption.setValue(value);
|
||||
}
|
||||
|
||||
public int getTopMargin() {
|
||||
return myReader.TopMarginOption.getValue();
|
||||
return getReader().TopMarginOption.getValue();
|
||||
}
|
||||
|
||||
public void setTopMargin(int value) {
|
||||
myReader.TopMarginOption.setValue(value);
|
||||
getReader().TopMarginOption.setValue(value);
|
||||
}
|
||||
|
||||
public int getLeftMargin() {
|
||||
return myReader.LeftMarginOption.getValue();
|
||||
return getReader().LeftMarginOption.getValue();
|
||||
}
|
||||
|
||||
public void setLeftMargin(int value) {
|
||||
myReader.LeftMarginOption.setValue(value);
|
||||
getReader().LeftMarginOption.setValue(value);
|
||||
}
|
||||
|
||||
public int getRightMargin() {
|
||||
return myReader.RightMarginOption.getValue();
|
||||
return getReader().RightMarginOption.getValue();
|
||||
}
|
||||
|
||||
public void setRightMargin(int value) {
|
||||
myReader.RightMarginOption.setValue(value);
|
||||
getReader().RightMarginOption.setValue(value);
|
||||
}
|
||||
|
||||
public int getParagraphsNumber() {
|
||||
return myReader.Model.getTextModel().getParagraphsNumber();
|
||||
return getReader().Model.getTextModel().getParagraphsNumber();
|
||||
}
|
||||
|
||||
public int getParagraphElementsCount(int paragraphIndex) {
|
||||
final ZLTextWordCursor cursor = new ZLTextWordCursor(myReader.getTextView().getStartCursor());
|
||||
final ZLTextWordCursor cursor = new ZLTextWordCursor(getReader().getTextView().getStartCursor());
|
||||
cursor.moveToParagraph(paragraphIndex);
|
||||
cursor.moveToParagraphEnd();
|
||||
return cursor.getElementIndex();
|
||||
|
@ -450,7 +456,7 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
|||
|
||||
public String getParagraphText(int paragraphIndex) {
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
final ZLTextWordCursor cursor = new ZLTextWordCursor(myReader.getTextView().getStartCursor());
|
||||
final ZLTextWordCursor cursor = new ZLTextWordCursor(getReader().getTextView().getStartCursor());
|
||||
cursor.moveToParagraph(paragraphIndex);
|
||||
cursor.moveToParagraphStart();
|
||||
while (!cursor.isEndOfParagraph()) {
|
||||
|
@ -465,7 +471,7 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
|||
|
||||
public List<String> getParagraphWords(int paragraphIndex) {
|
||||
final ArrayList<String> words = new ArrayList<String>();
|
||||
final ZLTextWordCursor cursor = new ZLTextWordCursor(myReader.getTextView().getStartCursor());
|
||||
final ZLTextWordCursor cursor = new ZLTextWordCursor(getReader().getTextView().getStartCursor());
|
||||
cursor.moveToParagraph(paragraphIndex);
|
||||
cursor.moveToParagraphStart();
|
||||
while (!cursor.isEndOfParagraph()) {
|
||||
|
@ -480,7 +486,7 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
|||
|
||||
public ArrayList<Integer> getParagraphWordIndices(int paragraphIndex) {
|
||||
final ArrayList<Integer> indices = new ArrayList<Integer>();
|
||||
final ZLTextWordCursor cursor = new ZLTextWordCursor(myReader.getTextView().getStartCursor());
|
||||
final ZLTextWordCursor cursor = new ZLTextWordCursor(getReader().getTextView().getStartCursor());
|
||||
cursor.moveToParagraph(paragraphIndex);
|
||||
cursor.moveToParagraphStart();
|
||||
while (!cursor.isEndOfParagraph()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue