1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 17:59:33 +02:00

API implementation (in progress)

This commit is contained in:
Nikolay Pultsin 2011-06-18 01:01:04 +01:00
parent c48df4b0f0
commit 92929e6752
5 changed files with 143 additions and 14 deletions

View file

@ -26,16 +26,34 @@ import org.geometerplus.fbreader.fbreader.FBReaderApp;
public class ApiImplementation extends ApiInterface.Stub {
private final FBReaderApp myReader = (FBReaderApp)FBReaderApp.Instance();
@Override
public int getPageStartParagraphIndex() {
// TODO: check for NPE
return myReader.getTextView().getStartCursor().getParagraphIndex();
private TextPosition getTextPosition(ZLTextWordCursor cursor) {
return new TextPosition(
cursor.getParagraphIndex(),
cursor.getElementIndex(),
cursor.getCharIndex()
);
}
@Override
public int getMaxParagraphIndex() {
public TextPosition getPageStart() {
return getTextPosition(myReader.getTextView().getStartCursor());
}
@Override
public TextPosition getPageEnd() {
return getTextPosition(myReader.getTextView().getEndCursor());
}
@Override
public void setPageStart(TextPosition position) {
myReader.getTextView().gotoPosition(position.ParagraphIndex, position.ElementIndex, position.CharIndex);
myReader.getViewWidget().repaint();
}
@Override
public int getParagraphsNumber() {
// TODO: check for NPE
return myReader.Model.BookTextModel.getParagraphsNumber() - 1;
return myReader.Model.BookTextModel.getParagraphsNumber();
}
@Override