Cómo mostrar todas las páginas y todos los capítulos utilizando nl.siegmann.epublib

Esto es lo que traté de realizar la tarea si alguien puede ayudar a que sería más apreciado. Así que en este código se mostrará sólo la portada. Leí http://www.siegmann.nl/static/epublib/apidocs/ que podría utilizar getSpine() para obtener todo, pero sólo se muestra una cosa en mi caso, que es la portada.

 webView = (WebView)findViewById(R.id.webView); webView.getSettings().setJavaScriptEnabled(true); AssetManager am = getAssets(); try { InputStream epubInputStream = am.open(bookName); book = (new EpubReader()).readEpub(epubInputStream); } catch (IOException e) { Log.e("epublib", e.getMessage()); } Spine spine = book.getSpine(); for (SpineReference bookSection : spine.getSpineReferences()) { Resource res = bookSection.getResource(); try { InputStream is = res.getInputStream(); StringBuffer string = new StringBuffer(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); try { while ((line = reader.readLine()) != null) { linez = string.append(line + "\n").toString(); } } catch (IOException e) {e.printStackTrace();} //do something with stream } catch (IOException e) { e.printStackTrace(); } } webView.loadData(linez, "text/html", "utf-8"); 

Así que lo que descubrí utilizando la columna vertebral en http://www.siegmann.nl/static/epublib/apidocs/ es que todavía funciona por secciones. Así que traté de averiguar cuántas secciones hay identificando números de cuenta. Luego coloca esos números en Resource res = spine.getResource(i); . Si lo haría Resource res = spine.getResource(2); Exhibiría la espina dorsal de 2 que debe ser capítulo 2 a menos que alguien ensucie encima del formato del epub.

 Spine spine = book.getSpine(); List<SpineReference> spineList = spine.getSpineReferences() ; int count = spineList.size(); tv.setText(Integer.toString(count)); StringBuilder string = new StringBuilder(); for (int i = 0; count > i; i++) { Resource res = spine.getResource(i); try { InputStream is = res.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); try { while ((line = reader.readLine()) != null) { linez = string.append(line + "\n").toString(); } } catch (IOException e) {e.printStackTrace();} //do something with stream } catch (IOException e) { e.printStackTrace(); } } webView.loadData(linez, "text/html", "utf-8"); 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.