我最初是webview
用来在线查看课堂笔记(在 HTML 中创建的)。缓存非常简单。这是代码。
webView = (WebView)findViewById(R.id.webView);
if (webView != null) {
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAppCacheMaxSize( 5 * 1024 * 1024 ); // 5MB
webView.getSettings().setAppCachePath( getApplicationContext().getCacheDir().getAbsolutePath() );
webView.getSettings().setAllowFileAccess( true );
webView.getSettings().setAppCacheEnabled( true );
webView.getSettings().setJavaScriptEnabled( true );
webView.getSettings().setCacheMode( WebSettings.LOAD_DEFAULT ); // load online by default
}
webView.setWebViewClient(new WebViewClient(){
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
super.onReceivedError(view, request, error);
Toast.makeText(NoteViewActivity.this, error.toString(), Toast.LENGTH_SHORT).show();
}
@Override
public void onPageFinished(WebView view, String url) {
findViewById(R.id.loadingPanel).setVisibility(View.GONE); //Make progress disappear
}
});
if ( !isNetworkAvailable() ) { // loading offline
webView.getSettings().setCacheMode( WebSettings.LOAD_CACHE_ELSE_NETWORK );
}
webView.loadUrl(getIntent().getStringExtra("NOTE_LINK"));
那么有没有办法用来自 GitHub的PDFViewer来做同样的事情
com.github.barteksc.pdfviewer.PDFView
使用pdfView.fromUri(uri)