私たちのアプリケーションを通じて、epubファイルを画面に表示しています。ファイルはSDCardに保存され、SDCardからファイルデータを取得してScreenに表示するために使用している次のロジックがあります。しかし、画面にコンテンツを読み込むのに時間がかかります。私のコードに問題はありますか?私の友人を助けてください。デバイスに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リーダーのリンクを教えていただけますか? –
私自身のプロジェクトを再度宣伝する危険性があるので、http://github.com/nightwhistler/pageturnerを見てください - GPLのライセンスがあることに気をつけてください。 – NightWhistler