This commit is contained in:
David Development 2015-04-03 14:14:54 +02:00
parent 7bb62e94dd
commit 0241d58c11
2 changed files with 20 additions and 7 deletions

View file

@ -30,6 +30,7 @@ import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -163,11 +164,25 @@ public class NewsDetailFragment extends Fragment {
mWebView.setVisibility(View.VISIBLE);
mProgressBarLoading.setVisibility(View.GONE);
SetSoftwareRenderModeForWebView(htmlPage, mWebView);
mWebView.loadDataWithBaseURL("", htmlPage, "text/html", "UTF-8", "");
super.onPostExecute(htmlPage);
}
}
public static void SetSoftwareRenderModeForWebView(String htmlPage, WebView webView) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if(htmlPage.contains(".gif")) {
webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
Log.v("NewsDetailFragment", "Using LAYER_TYPE_SOFTWARE");
} else {
webView.setLayerType(WebView.LAYER_TYPE_HARDWARE, null);
Log.v("NewsDetailFragment", "Using LAYER_TYPE_HARDWARE");
}
}
}
@SuppressLint("SetJavaScriptEnabled")
private void init_webView()
@ -192,10 +207,6 @@ public class NewsDetailFragment extends Fragment {
//webSettings.setDatabaseEnabled(true);
//webview.clearCache(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
mWebView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
mWebView.addJavascriptInterface(new WebViewLinkLongClickInterface(getActivity()), "Android");
mWebView.setWebChromeClient(new WebChromeClient() {

View file

@ -39,6 +39,7 @@ import butterknife.InjectView;
import butterknife.Optional;
import de.greenrobot.dao.query.LazyList;
import de.greenrobot.event.EventBus;
import de.luhmer.owncloudnewsreader.NewsDetailActivity;
import de.luhmer.owncloudnewsreader.NewsDetailFragment;
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
import de.luhmer.owncloudnewsreader.R;
@ -413,10 +414,11 @@ public class NewsListArrayAdapter extends GreenDaoListAdapter<RssItem> {
webViewContent.setClickable(false);
webViewContent.setFocusable(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
webViewContent.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
String htmlPage = NewsDetailFragment.getHtmlPage(mActivity, rssItem);
webViewContent.loadDataWithBaseURL("", NewsDetailFragment.getHtmlPage(mActivity, rssItem), "text/html", "UTF-8", "");
NewsDetailFragment.SetSoftwareRenderModeForWebView(htmlPage, webViewContent);
webViewContent.loadDataWithBaseURL("", htmlPage, "text/html", "UTF-8", "");
}