我們通過我們的應用程序在屏幕上顯示epub文件。該文件保存在SDCard中,以及我們用於從SDCard獲取文件數據並在屏幕中顯示的以下邏輯。但花費很長時間才能在屏幕上加載內容。我的代碼的任何問題?請幫助我的朋友。花費很長時間在設備上顯示epub文件
File rootDir = Environment.getExternalStorageDirectory();
EpubReader epubReader = new EpubReader();
try {
book = epubReader.readEpub(new FileInputStream("/sdcard/forbook.epub"));
Toast.makeText(getApplicationContext(), "Book : " + book, Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
Toast.makeText(getApplicationContext(), "File Not Found" + book, Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
Toast.makeText(getApplicationContext(), "IO Found" + book, Toast.LENGTH_LONG).show();
e.printStackTrace();
}
Spine spine = book.getSpine();
List<SpineReference> spineList = spine.getSpineReferences() ;
int count = spineList.size();
StringBuilder string = new StringBuilder();
String linez = null;
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 {
String line;
while ((line = reader.readLine()) != null) {
linez = string.append(line + "\n").toString();
//linez=line.toString();
}
} catch (IOException e) {e.printStackTrace();}
//do something with stream
} catch (IOException e) {
e.printStackTrace();
}
}
final String mimeType = "text/html";
final String encoding = "UTF-8";
webView.loadDataWithBaseURL("", linez, mimeType, encoding,null);
}
請幫助我的朋友。
任何人都可以給我鏈接樣本EPUB閱讀器? – 2012-05-10 07:01:54
有可能再次發佈我自己的項目,請看看:http://github.com/nightwhistler/pageturner - 請注意,它是GPL許可的。 – NightWhistler 2012-05-11 08:34:51