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

more methods in API

This commit is contained in:
Nikolay Pultsin 2011-06-18 20:13:04 +01:00
parent 81bbd64901
commit 726c28111d
3 changed files with 28 additions and 1 deletions

View file

@ -26,6 +26,12 @@ import org.geometerplus.fbreader.fbreader.FBReaderApp;
public class ApiImplementation extends ApiInterface.Stub {
private final FBReaderApp myReader = (FBReaderApp)FBReaderApp.Instance();
@Override
public String getBookLanguage() {
// TODO: check for NPE
return myReader.Model.Book.getLanguage();
}
private TextPosition getTextPosition(ZLTextWordCursor cursor) {
return new TextPosition(
cursor.getParagraphIndex(),
@ -56,9 +62,16 @@ public class ApiImplementation extends ApiInterface.Stub {
return myReader.Model.BookTextModel.getParagraphsNumber();
}
@Override
public int getElementsNumber(int paragraphIndex) {
final ZLTextWordCursor cursor = new ZLTextWordCursor(myReader.getTextView().getStartCursor());
cursor.moveToParagraph(paragraphIndex);
cursor.moveToParagraphEnd();
return cursor.getElementIndex();
}
@Override
public String getParagraphText(int paragraphIndex) {
// TODO: check for NPEs
final StringBuffer sb = new StringBuffer();
final ZLTextWordCursor cursor = new ZLTextWordCursor(myReader.getTextView().getStartCursor());
cursor.moveToParagraph(paragraphIndex);