现在我正在开发电子书阅读器..我从这个http://www.siegmann.nl/epublib/android获得了一个epub库,但是需要很长时间才能逐行阅读内容,在我的项目中有一个选项来突出显示内容..如何使它成为可能..提前谢谢..
答案 0 :(得分:1)
所以我不知道我是怎么想出那个答案的。不过。
对于您当前的问题,可以查看脊椎索引(脊柱与目录相比区别不同)或内容表(如果信息在元数据中)。
现在你如何为脊椎索引做这件事:
Spine spine = new Spine(book.getTableOfContents());
List<SpineReference> spineList = spine.getSpineReferences(); //List of spine information
Resource res = spine.getResource(1);//1 is an example to proper utilize this you have to store the information on which part you are in and how much you rendered. I suggest keeping a static integer on what your location is and after this part is done you can go to the next one and so on.
InputStream is = res.getInputStream();//getting the inputstream
StringBuilder string = new StringBuilder();//Create a builder as we will add more information to the string
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
string html,line = null;
while ((line = reader.readLine()) != null) {//start reading the information line by line
html = string.append(line + "\n").toString();//get information for line by line basis
}
现在您需要从文本中解析出html信息以获取正确的信息
现在,对于目录,除了1行变更之外,它将与顶部相同
ArrayList<TOCReference> book_list = new ArrayList<TOCReference>(amBook().getTableOfContents().getTocReferences());
阅读它的方式相同。 BufferReader - &gt;的InputStream