Skip to content

Listeners

OnPlayerEventsListener

This interface has various callback methods which will notify your activity on various events. Below are the methods.

OnPlayerEventsListener notifies the application on various events that are triggered form the reader. The application implementing Kitaboo SDK can override these events to perform any specific action they would like to perform either when the content is loaded or when the user performs any action on the reader.

Kitaboo sample reader implements OnPlayerEventsListener on PlayerActivity class and overrides its interfaces to create the reader UI and perform actions on the content.

However, you might want to change the default behaviour with some of your custom UI or user experience. You can do that by replacing the code with your customer code. For instance, if you want to change the colors in the highlight popup you should instantiate it immediately after the SDK has loaded the content, which would be onReaderAttached().

/**
* Interface to provide different events of the Reader.
*/
public interface OnPlayerEventsListener {
   /**
    * Invoked when view port is ready to render reader
    */
   void onReaderAttached();

   /**
    *  Invoked when page loading started
    * @param pageVo :An object of page whose page loading started
    */
   void onPageLoadingStart(IPage pageVo);

   /**
    * Invoked when page loading completed.
    * @param pageVo :An object of page whose page loading completed.
    */
   void onPageLoadingCompleted(IPage pageVo);

   /**
    * Called on each page change / swipe
    * @param pagePosition : index position of current page.
    * @param currentPageData :Data of current page.
    */
   void onPageChanged(int pagePosition,IPage[] currentPageData);

   /**
    * Invoked when page get scrolled
    */
   void onPageScrolling();


   /**
    * Invoked when long press is done on page text. It is also called when Highlight is dragged
    * The selected text will be highlighted
    * @param rectLocation :Location of the highlighted text
    * @param selectedText :Selected text
    */
   void onPageTextSelected(Rect rectLocation, String selectedText);

   /**
    * Invoked when note icon click.
    * @param vo : Object of highlihgt.
    */
   void onNoteClick(HighlightVO vo);

   /**
    * Callback on highlight draw completed
    * @param vo : Object of highlihgt
    */
   void onHighlightDrawComplete(HighlightVO vo);

   /**
    * Callback on Longpress of on stickynote view
     * @param view  : View of StickyNote.
    */
   void onStickynoteLongpress(View view);


   /**
    * Callback on tap on the highlited text to show highlight popup
    * @param existHighlight : Object of highlited text which has been tapped.
    */
   void onHighlightTaped(HighlightVO existHighlight);

   /**
    * Callback while save the bookmark data
    * @param bookmarkvo : An object of BookMark.
    */
   void onBookmarkSave(BookMarkVO bookmarkvo);

   /**
    * Callback while tap  on the bookmark view
    * @param v
    */
   void onBookmarkTap(View v);

   /**
    * Callback on bookload complete or parsing
    * @param book : An object of book.
    */
   void onBookLoaded(IBook book);

   /**
    * Call back on bookclose to save last visited page
    * @param lastvisitedpage : the page on which book has been closed.
    */
   void saveLastVisitedPage(IPage lastvisitedpage);
   /**
    * Callback on single tap on bookplayer.
    */
   void onTapofBookRenderer();

   /**
    * Callback on pendraw completed
    * @param vo An Object of Pen
    */
   void onPenDrawCompleted(PentoolVO vo);

   /**
    * Callback on penundo completed
    * @param vo An Object of Pen.
    */
   void onPenUndoCompleted(PentoolVO vo);

   /**
    * Callback on selection of pendraw for deletion
    * @param vo An Object of Pen
    */
   void onPenSelectedForDeletion( PentoolVO vo);

   /**
    * Callback on occurrence of error while book parsing
    * @param ex : An Exception thrown incase of book loading failed.
    */
   void onBookLoadingFailed(Exception ex);


   /**
    * Callback on occurrence of error while
    * @param ex : An Exception thrown incase of page loading failed.
    */
   void onPageLoadingFailed(Exception ex);

   /**
    * callback on setting panel for Epub relowable books.
    * @param nightSwitchCompat :To handle Day/Night mode for Epub reflowable books.
    * @param pageScrollSwitchCompact :To handle Vertical/Horizontal page mode for Epub                       reflowable book.
    * @param setFontSize :To handle fontsize of page .
    */
   void settingPanelComponentHandling(SwitchCompat nightSwitchCompat, SwitchCompat pageScrollSwitchCompact, SeekBar setFontSize);

Here's an example of how we have overriden one of the interfaces of OnPlayerEventsListener ()

Override the onReaderAttached()

This function is invoked when the renderer has attached to the activity.

  • Inside this function create the Book object which holds book path and their id and ISBN
bookId = getIntent().getLongExtra(BOOK_ID, 0);
bookVersion = getIntent().getStringExtra(BOOK_VERSION);
userID = getIntent().getLongExtra(USER_ID, 0);
token = getIntent().hasExtra(TOKEN) ?  getIntent().getStringExtra(TOKEN) : "";
isbn=getIntent().getStringExtra(ISBN);
   mthumbnailpath = getIntent().getStringExtra(MEDIA_PATH);

// Creating an instance of bookwith the required details.
BookInfo book = new BookInfo(
        getIntent().getStringExtra(MEDIA_PATH),
        bookId,
        getIntent().getStringExtra(ISBN));
book.setBookEncrypt(getIntent().getBooleanExtra(IS_BOOK_ENCRYPT, false));

// send the specific user id to sdk to keep track of UGC data for User
KitabooSDKModel.getInstance().setUserID(userID);
KitabooSDKModel.getInstance().setUserToken(token);

accountType=getIntent().getStringExtra(ROLE_NAME);
IsClassAccociated =getIntent().getExtras().getBoolean(IS_CLASSACCOCIATED,false);
GlobalDataManager.getInstance().setClassAssociated(IsClassAccociated);

Inside onReaderAttached() function initialize kitaboo sdk

renderView.playBook(book);

TOCListener

This interface("TOCListener ") is implemented by a class "PlayerActivity" of SampleReader and allow the user to modify the default view if TOC and internal tabs ( Table of content,Table of Resources and Bookmarks .

/**
*  Interface to provide different events of the Reader for TOC( Table of content).
* This interface is implemented by a class "PlayerActivitiy" of SampleReader and facilitate you multiple callbacks related to TOC frame(which includes "Table of content","Resources" and "Bookmarks" ).
*/
public interface TocListner {
   /**
    *  Callback when Toc view set.
    * @param view Toc View.
    */
   void setTocLayout(View view);

   /**
    * Callback to set the TOC dialog position.By default the dialog position is top left corner of tablet device.however for mobile device,TOC dialog will open in an new screen.
    * @param dialog
    */
   void setDialogPosition(Dialog dialog);

   /**
    * Callback for initializing Toc tabs.
    * @param tabHost
    */
   void initialiseTabHost(TabHost tabHost);

   /**
    * Callback to return TOC view.
    * @param tag
    * @param mListner Listener.
    * @return a view based on type of books( Epub/KitabooFixed(PDF version) and type of content ( Table of content, Resources or Bookmark).
    */
   View returnTabView(String tag, TOCEnterpriseView.TocItemClickListener mListner);

   /**
    * Callback when back press called when Toc dialog.
    */
   void onDialogBackpressed();
}

onTOBItemClick

This is an interface supported by KitabooSdk and provides callbacks on bookmark item click event.

A class "PlayerAcitivity" of sampleReader implements "onTOBItemClick" and override the "onTobitemClick(BookMarkVO bookMarkVO)" method and accordingly user can navigate to the specific pages where the bookmark exist similar to the navigation incase of TOC item click event.

/**
*  An interface to provide events on BookMark list item Click.
*/
public interface OnTOBItemClick {
   /**
    * callback on bookmark click event.
    * @param bookMarkVO An object of Bookmark.
    */
   void onTobitemClick(BookMarkVO bookMarkVO);
}

onTORItemClick

KitabooSdk facilitate an interface which exposes an method "**OnTORItemClick " and a class( "PlayerActivity") of SampleReader override this method by implementing "onTORItemClick" interface and take necessary action based on which type of resource clicked from the list of resources listed in TOR list . TOR list is the list of all the resources available on each pages of the book. These resources can be of different type such as [ External resources, link ,markup ..etc].

/**
*  An interface to trigger the events on list of Resource item Click.
*/
public interface OnTORItemClick {
   /**
    *  callback on click of table of resource item.
    * @param torVo
    */
   void onTorItemClick(TableOfResourceVo torVo);

SearchListener

KitabooSdk exposes an interface "SearchListener "which allow the user to perform certain action based on the events triggered .

A class "PlayerActivity" of KitabooSampleReader implements "SearchListener" and override its methods which facilitate user to trigger click event on search list from SearchDialog through
onSearchItemClick(String query, SearchItemVO searchObj) and user can navigate to specific page or can perform certain action.

/**
 * An interface to tiger the events performed on search item listed in search dialog.
.
 */
public interface SearchListener
{
   /**
    *  callback on serchDialog back press.
    */
   void onDialogBackpressed();

   /**
    *  callback on click of event of searched item.
    * @param query entity which has to be searched.
    * @param searchObj an object in which you want to search.
    */
   void onSearchItemClick(String query, SearchItemVO searchObj);

   /**
    *  callback once serached data cleared from the field.
    */
   void onClearSearchText();
}

SearchActionListener

A class "PlayerActivity" of KitabooSampleReader implements "SearchActionListener " and override its methods which facilitate user to trigger click event on search bar panel through onSearchTextClick() and user can close the searchList dialog or may take an another action.

/**
*  An interface to provide callbacks of search view.
*/
public interface SearchActionListener {
   /**
    *  callback on search dialog cancelled.
    */
   void onSearchDialogCancel();
   /**
    *  callback on search text clicked.
    */
   void onSearchTextClick();
}

ThumbnailsListener

KitabooSDK exposes an interface "ThumbnailsListener " which triggers various events occured on Book Thumbnail of the Reader.

A class "PlayerActivity" of KitabooSampleReader implements this interface and overrides various methods.

/**
*  An interface to provide callbacks on book Thumbnails
*/
public interface ThumbnailsListner {
   /**
    *  callbakcs on thumnail page navigation.
    * @param pageid id of page.
    */
   void ThumbnailpageNavigation(long pageid);

   /**
    *  callback when thumnails view created.
    * @param view Thumbnails view.
    */
   void onThumbnailViewCreated(View view);

   /**
    *  callback on seekBar view created.
    * @param seekBarHint Seeekbar  object.
    */
   void onSeekbarViewCreated(SeekBarHint seekBarHint);

   /**
    *  Callback when GoToPage clicked.
    * @param Pageno
    */
   void onGotoClick(String Pageno);

   /**
    * Callabck when thumnails navigate to previous page.
    */
   void NavigatePreviousPage();
   /**
    * Callabck when thumnails navigate to next page.
    */
   void NavigateNextPage();
   /**
    * Callabck when page history button view created.
    */
   void onPageHistoryButtonsCreated(Button mPageHistNext, Button mPageHistPrevious);

}

User can customize Thubmnailview by overriding a method "**onThumbnailViewCreated". However KiabboSDK provide a default view of Thumbnail which can be created with the help of class "TabThumbnailFragment".

**
 * Click event of each button in actionbar
 *
 * @param menu : clicked item view
 */
@Override
public void onMenuItemClick(View menu) {
if (menu.getId() == R.id.action_thumbnail) {
     showThumbnail();
   }
}


/**
* Responsible to to create default thumbnail supported by KitabooSDK and custmize Thubmnail and registering their listeners.
*/
private void showThumbnail() {

TabThumbnailFragment tabThumbnailFragment = TabThumbnailFragment.newInstance("thumbnail", mThumbnailColl, mthumbnailpath, currentviewpagerindex, currentviewpagerindexl1, currentviewpagerindexl2);
tabThumbnailFragment.setThemeColor(themeUserSettingVo);
tabThumbnailFragment.showHistoryButtons(false);
tabThumbnailFragment.setThumbListener(this);
try {
   fragmentManager = getSupportFragmentManager();
   fragmentTransaction = fragmentManager.beginTransaction();
   mPageThumbnailcontainer.setVisibility(View.VISIBLE);
   fragmentTransaction.add(R.id.thumbnailview, tabThumbnailFragment, "thumbnail");
   fragmentTransaction.addToBackStack("thumbnail");
   fragmentTransaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out);
   fragmentTransaction.commit();
}
catch (Exception e) {
   if (Constants.IS_DEBUG_ENABLED) {
       e.printStackTrace();
   }
}
}

onColorSelectedListener

KitabooSdk exposes an interface "onColorSelectedListener " which triggers an event when any pen color selected from pen color Dialog. Based on selected pen marker color user will be able draw on page with the selected pen color.

A class "PlayerActivity" of KitabooSampleReader implements "onColorSelectedListener"interface and overrides various methods.

To create a pen color dialog with custom color, KitabooSDK facilitate a class "PentoolHelper". For more detail kindly see the section Pen feature implementation and callbacks.

/**
* An interface to trigger events on pen color dialog.
*/
public interface OnColorSelectedListener {

   /**
    * Called when a specific color has been selected.
    */
   void onColorSelected(int color);

   /**
    * callback on pen color dialog cancelled.
    */
   void onDismiss();
}

onSizeChangeListener on your Activity [PlayerActivity]

  • Kitaboosdk exposes an interface "onSizeChangeListener " which trigger an event when their is any changes in pen marker thickness selected.
  • A class "PlayerActivity" of "KitabooSampleReader" implements an interface"onSizeChangeListener " which override method "OnSizeChanged" to get the event triggered if there is any changes done in pen marker thickness.
/**
* Interface to trigger a callback when pen bar thickness size is changed.
*/
public interface OnSizeChangedListener {

   /**
    * Called when pen bar thickness size is changed.
    */
   void OnSizeChanged(int size);

   /**
    * Called when pen bar thickness size dialog cancelled.
    */
   void onSizeDismiss();
}

IStickyNoteShareSettingListener

An interface IStickyNoteShareSettingListener exposed by KitabooSdk notifies the application on the events that are triggered from the reader when the StickyNote data is shared among users from share option available in Note dialog..

A class "PlayerActivity" from KitabooSampleReader implements an interface "IStickyNoteShareSettingListener " which allow you to override its method and user can save or update the shared data into database accordingly and may perform some other action as per the demand.

/**
*  An interface which trigger an event when sticky note data is shared among the users from share-setting panel.
*/
public interface IStickyNoteShareSettingListener {
   /**
    * Callback when StickyNote data Saved to dataBase.
    * @param _mNoteVO
    * @param mCurrentSelectedClass
    */
   void onStickyNoteDataSaveToDataBase(HighlightVO _mNoteVO,UserClassVO mCurrentSelectedClass);
}

ISharingSettingListner

An interface IStickyNoteShareSettingListener exposed by KitabooSdk notifies the events that are triggered from the reader when the StickyNote data is shared among users from share option available on Note dialog .

A class "PlayerActivity" from KitabooSampleReader implements an interface "ISharingSettingListner"" which allow you to override its method and user can save or update the shared Note/Highlight into database accordingly and may perform some other action as per the demand.

/**
*  An interface to trigger events highlightNote settings.
*/
public interface ISharingSettingListner {
   /**
    *
    * @param mSharingData
    * @param mCurrentSelectedClass
    * @param mUgcHolder
    */
   void saveMydataHiglightedNotetoDatabase(HighlightVO mSharingData,UserClassVO mCurrentSelectedClass,MyDataFragment mUgcHolder);

   /**
    * callback on when user synced incase of HighlightSetting service.
    * @param arrayList
    * @param iServiceResponseListener
    */
   void syncUserForHighlightSettingService(ArrayList<IClass> arrayList, IServiceResponseListener iServiceResponseListener);
}

AssesmentControlListeneron

AssesmentControlListeneron notifies the application on various events that are triggered form the reader. The application implementing Kitaboo SDK can override these events to perform any specific action they would like to perform either when you wants to load the student data for assessment or when the user want to send teacher data for syncing or user might want to load the specific page data for teacher's review.

Kitaboo sample reader implements AssesmentControlListeneron on PlayerActivity class and overrides its interfaces to perform certain action based on the event triggers.

/**
*  An interface to trigger teacher student data and their callbacks.
*/
public interface AssesmentControlListener
{
  /**
   * Callback when teacher student assesment panel closed.
   * @param mAnnotationpages list of pages.
   */
  void closeTeacherAssesmentbar(ArrayList<UserPageVO> mAnnotationpages);

  /**
   *
   * Callback for loading Current Page object to teacher's review
   * @param mAnnotationpages
   */
  void loadReviewdataToPage(UserPageVO mAnnotationpages);

  /**
   * Callback to send the teacher dat for syncing.
   * @param learnerID student id.
   * @param pentoolVOs list of pen objects.
   * @param linkVOs list of links.
   * @param iServiceResponseListener listener.
   */
  void sendTeacherDataForSyncing(long learnerID, ArrayList<PentoolVO> pentoolVOs, ArrayList<LinkVO> linkVOs, IServiceResponseListener iServiceResponseListener);

  /**
   * Callback of Service Request for Student data to Review.
   * @param learnerID student id.
   * @param iServiceResponseListener Listener.
   */
  void sendRequestForUserData(long learnerID, IServiceResponseListener iServiceResponseListener);

  /**
   * Service Request for Student list to Review
   * @param iServiceResponseListener Service Callback Context
   */
  void sendRequestForStudentList(IServiceResponseListener iServiceResponseListener);
}

IServiceResponseListener

KitabooSDK exposes an interface "IServiceResponseListener" which will trigger an event in case of Service Call success or failure.

A class "PlayerActivity" of SampleKitabooReader implement "IServiceResponseListener" which allow you to overrides methods . This overridden method will be triggered when Requested service respond with success or failure. User can take further action on service call successful or failure.

/**
*  An interface to trigger callbacks when service respond.
*/
public interface IServiceResponseListener
{
  /**
   * Callback when service respond with success.
   * @param response service response data.
   */
  void requestCompleted(IServiceResponse response);

  /**
   * Callback when service respond with failure.
   * @param exeption an exception object.
   */
  void requestErrorOccured(ServiceException exeption);
}

OnMarkupIconClicked

KitabooSdk exposes an interface "OnMarkupIconClicked" which triggers an event from reader incase there is an click action taken on Markup icon.

A class "PlayerActivity" of KitabooSampleReader implements "OnMarkupIconClicked" and override a method "OnMarkupClick(LinkVO linkVO, View view)" which will be triggered when Markup icon is clicked.

/**
*  An interface to trigger callbacks on Markup click.
*/
public interface OnMarkupIconClicked {
   /**
    *  callback when markup clicked .
    * @param linkVO an object of link.
    * @param view view of Markup.
    */
   void OnMarkupClick(LinkVO linkVO, View view);
}

IEpubSettingPanelListner

KitabooSDk exposes an interface "IEpubSettingPanelListner" specific for ePubReflowable books and allow the user to perform the certain action from setting panel of ePub Reflowable books.

Kitaboo sample reader implements IEpubSettingPanelListner on PlayerActivity class and overrides its interfaces to perform certain action based on the event triggers such day/night mode switch action performed,scroll mode enable/disable, font size changes, text alignment changes .

public interface IEpubSettingPanelListner {
   /**
    * Callback responsible for customizing the Setting panel Views.
    * @param setFontSize size of font .
    * @param nightSwitchCompat a switch to handle night/day mode.
    * @param pageSwitchCompact a switch to switch page.
    */
   void settingPanelViewsCallback(SeekBar setFontSize, SwitchCompat nightSwitchCompat, SwitchCompat pageSwitchCompact);
   /**
    * Callback responsible for Setting Panel Nightmode button Pressed
    *
    * @param isClicked
    */
   void onNightmodePressed(Boolean isClicked);
   /**
    * Callback responsible for Setting Panel Scrollmode button Pressed.
    *
    * @param isClicked
    */
   void onScrollmodePressed(Boolean isClicked);
   /**
    * Callback responsible for Setting Panel SeekBarSize changed
    *
    * @param fontSize size of font.
    */
   void fontSeekBarSize(int fontSize);
   /**
    * Callback responsible for Setting Panel Popup window
    *
    * @param popupWindow window to display popup.
    */
   void onSettingPanelPopup(PopupWindow popupWindow);
   /**
    * Callback responsible for Setting Panel Sepiamode button Pressed
    *
    * @param value boolean 1 0r 0.
    */
   void onSepiaModeClicked(boolean value);

   /**
    * Callback responsible for textAlignment.
    * @param s position of text.
    */
   void onTextAlignButtodClicked(String s);
}

FIBCallbackListener

KitabooSdk exposes an interface "FIBCallbackListener" which will allow the user to implement the same and override a abstract methods.

A class "PlayerActivity" of SamplekitabooSdk implements the "FIBCallbackListener" .An event gets triggered on certain action such as when user save answers to FIB (Fill in the blanks) or might select an answer from dropdown list . Accordingly,user can take necessary action when these event get triggered.

/**
*  An interface to trigger callback on Fib(Fill in the blanks) events.
*/
public interface FIBCallbackListener {
   /**
    * Callback when user answers have been saved to Database.
    * @param mObjVO
    * @param trim
    * @param b
    */
   void onSavingTheUserAnswer(LinkVO mObjVO, String trim, boolean b);

   /**
    *  Callback when user select any item listed in drop-down list.
    * @param position position of selected answer
    * @param id id of the selected item
    * @param mData link object
    * @param mItems list of answers.
    */
   void setOnDropDownItemSelected(int position, long id, LinkVO mData, String[] mItems);
}