private void highlightParagraph() { if (0 <= myParagraphIndex && myParagraphIndex < myParagraphsNumber) { myApi.highlightArea( new TextPosition(myParagraphIndex, 0, 0), new TextPosition(myParagraphIndex, Integer.MAX_VALUE, 0)); } else { myApi.clearHighlighting(); } }
private void highlightSentence(int startWord, int endWord) { if (0 <= myParagraphIndex && myParagraphIndex < myParagraphsNumber) { myApi.highlightArea( new TextPosition(myParagraphIndex, startWord, 0), new TextPosition(myParagraphIndex, endWord + 1, 0)); } else { myApi.clearHighlighting(); } }
public ApiObject request(int method, ApiObject[] parameters) { try { switch (method) { case GET_FBREADER_VERSION: return ApiObject.envelope(getFBReaderVersion()); case GET_OPTION_VALUE: return ApiObject.envelope( getOptionValue( ((ApiObject.String) parameters[0]).Value, ((ApiObject.String) parameters[1]).Value)); case SET_OPTION_VALUE: setOptionValue( ((ApiObject.String) parameters[0]).Value, ((ApiObject.String) parameters[1]).Value, ((ApiObject.String) parameters[2]).Value); return ApiObject.Void.Instance; case GET_BOOK_LANGUAGE: if (parameters.length == 0) { return ApiObject.envelope(getBookLanguage()); } else { return ApiObject.envelope(getBookLanguage(((ApiObject.Long) parameters[0]).Value)); } case GET_BOOK_TITLE: if (parameters.length == 0) { return ApiObject.envelope(getBookTitle()); } else { return ApiObject.envelope(getBookTitle(((ApiObject.Long) parameters[0]).Value)); } case GET_BOOK_FILE_PATH: if (parameters.length == 0) { return ApiObject.envelope(getBookFilePath()); } else { return ApiObject.envelope(getBookFilePath(((ApiObject.Long) parameters[0]).Value)); } case GET_BOOK_HASH: if (parameters.length == 0) { return ApiObject.envelope(getBookHash()); } else { return ApiObject.envelope(getBookHash(((ApiObject.Long) parameters[0]).Value)); } case GET_BOOK_UNIQUE_ID: if (parameters.length == 0) { return ApiObject.envelope(getBookUniqueId()); } else { return ApiObject.envelope(getBookUniqueId(((ApiObject.Long) parameters[0]).Value)); } case GET_BOOK_LAST_TURNING_TIME: if (parameters.length == 0) { return ApiObject.envelope(getBookLastTurningTime()); } else { return ApiObject.envelope( getBookLastTurningTime(((ApiObject.Long) parameters[0]).Value)); } case GET_PARAGRAPHS_NUMBER: return ApiObject.envelope(getParagraphsNumber()); case GET_PARAGRAPH_ELEMENTS_COUNT: return ApiObject.envelope( getParagraphElementsCount(((ApiObject.Integer) parameters[0]).Value)); case GET_PARAGRAPH_TEXT: return ApiObject.envelope(getParagraphText(((ApiObject.Integer) parameters[0]).Value)); case GET_PAGE_START: return getPageStart(); case GET_PAGE_END: return getPageEnd(); case IS_PAGE_END_OF_SECTION: return ApiObject.envelope(isPageEndOfSection()); case IS_PAGE_END_OF_TEXT: return ApiObject.envelope(isPageEndOfText()); case SET_PAGE_START: setPageStart((TextPosition) parameters[0]); return ApiObject.Void.Instance; case HIGHLIGHT_AREA: { highlightArea((TextPosition) parameters[0], (TextPosition) parameters[1]); return ApiObject.Void.Instance; } case CLEAR_HIGHLIGHTING: clearHighlighting(); return ApiObject.Void.Instance; case GET_BOTTOM_MARGIN: return ApiObject.envelope(getBottomMargin()); case SET_BOTTOM_MARGIN: setBottomMargin(((ApiObject.Integer) parameters[0]).Value); return ApiObject.Void.Instance; case GET_TOP_MARGIN: return ApiObject.envelope(getTopMargin()); case SET_TOP_MARGIN: setTopMargin(((ApiObject.Integer) parameters[0]).Value); return ApiObject.Void.Instance; case GET_LEFT_MARGIN: return ApiObject.envelope(getLeftMargin()); case SET_LEFT_MARGIN: setLeftMargin(((ApiObject.Integer) parameters[0]).Value); return ApiObject.Void.Instance; case GET_RIGHT_MARGIN: return ApiObject.envelope(getRightMargin()); case SET_RIGHT_MARGIN: setRightMargin(((ApiObject.Integer) parameters[0]).Value); return ApiObject.Void.Instance; case GET_KEY_ACTION: return ApiObject.envelope( getKeyAction( ((ApiObject.Integer) parameters[0]).Value, ((ApiObject.Boolean) parameters[1]).Value)); case SET_KEY_ACTION: setKeyAction( ((ApiObject.Integer) parameters[0]).Value, ((ApiObject.Boolean) parameters[1]).Value, ((ApiObject.String) parameters[2]).Value); return ApiObject.Void.Instance; case GET_ZONEMAP: return ApiObject.envelope(getZoneMap()); case SET_ZONEMAP: setZoneMap(((ApiObject.String) parameters[0]).Value); return ApiObject.Void.Instance; case GET_ZONEMAP_HEIGHT: return ApiObject.envelope(getZoneMapHeight(((ApiObject.String) parameters[0]).Value)); case GET_ZONEMAP_WIDTH: return ApiObject.envelope(getZoneMapWidth(((ApiObject.String) parameters[0]).Value)); case GET_TAPZONE_ACTION: return ApiObject.envelope( getTapZoneAction( ((ApiObject.String) parameters[0]).Value, ((ApiObject.Integer) parameters[1]).Value, ((ApiObject.Integer) parameters[2]).Value, ((ApiObject.Boolean) parameters[3]).Value)); case GET_TAP_ACTION_BY_COORDINATES: return ApiObject.envelope( getTapActionByCoordinates( ((ApiObject.String) parameters[0]).Value, ((ApiObject.Integer) parameters[1]).Value, ((ApiObject.Integer) parameters[2]).Value, ((ApiObject.Integer) parameters[3]).Value, ((ApiObject.Integer) parameters[4]).Value, ((ApiObject.Boolean) parameters[5]).Value)); case SET_TAPZONE_ACTION: setTapZoneAction( ((ApiObject.String) parameters[0]).Value, ((ApiObject.Integer) parameters[1]).Value, ((ApiObject.Integer) parameters[2]).Value, ((ApiObject.Boolean) parameters[3]).Value, ((ApiObject.String) parameters[4]).Value); return ApiObject.Void.Instance; case CREATE_ZONEMAP: createZoneMap( ((ApiObject.String) parameters[0]).Value, ((ApiObject.Integer) parameters[1]).Value, ((ApiObject.Integer) parameters[2]).Value); return ApiObject.Void.Instance; case IS_ZONEMAP_CUSTOM: return ApiObject.envelope(isZoneMapCustom(((ApiObject.String) parameters[0]).Value)); case DELETE_ZONEMAP: deleteZoneMap(((ApiObject.String) parameters[0]).Value); return ApiObject.Void.Instance; default: return unsupportedMethodError(method); } } catch (Throwable e) { return new ApiObject.Error("Exception in method " + method + ": " + e); } }
@Override protected void onStop() { stopTalking(); myApi.clearHighlighting(); super.onStop(); }