article fragment: simplify things a bit

This commit is contained in:
Andrew Dolgov 2015-06-05 15:51:50 +03:00
parent e5159ab48a
commit 9523151a25

View File

@ -221,18 +221,6 @@ public class ArticleFragment extends Fragment {
if (title != null) {
/* if (m_prefs.getBoolean("enable_condensed_fonts", false)) {
Typeface tf = TypefaceCache.get(m_activity, "sans-serif-condensed", Typeface.NORMAL);
if (tf != null && !tf.equals(title.getTypeface())) {
title.setTypeface(tf);
}
title.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, articleFontSize + 5));
} else {
title.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, articleFontSize + 3));
} */
title.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, articleFontSize + 3));
String titleStr;
@ -372,14 +360,6 @@ public class ArticleFragment extends Fragment {
}
}
if (m_article != null) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (m_web != null) {
m_web.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
@ -406,7 +386,6 @@ public class ArticleFragment extends Fragment {
}
}
String content;
String cssOverride = "";
WebSettings ws = m_web.getSettings();
@ -447,8 +426,7 @@ public class ArticleFragment extends Fragment {
ws.setDefaultFontSize(articleFontSize);
content =
"<html>" +
StringBuilder content = new StringBuilder("<html>" +
"<head>" +
"<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">" +
"<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />" +
@ -459,7 +437,9 @@ public class ArticleFragment extends Fragment {
cssOverride +
"</style>" +
"</head>" +
"<body>" + articleContent;
"<body>");
content.append(articleContent);
if (m_article.attachments != null && m_article.attachments.size() != 0) {
String flatContent = articleContent.replaceAll("[\r\n]", "");
@ -474,7 +454,7 @@ public class ArticleFragment extends Fragment {
URL url = new URL(a.content_url.trim());
String strUrl = url.toString().trim();
content += "<p><img src=\"" + strUrl.replace("\"", "\\\"") + "\"></p>";
content.append("<p><img src=\"" + strUrl.replace("\"", "\\\"") + "\"></p>");
}
} catch (MalformedURLException e) {
@ -486,7 +466,7 @@ public class ArticleFragment extends Fragment {
}
}
content += "</body></html>";
content.append("</body></html>");
try {
String baseUrl = null;
@ -499,13 +479,13 @@ public class ArticleFragment extends Fragment {
}
if (savedInstanceState == null || !acceleratedWebview) {
m_web.loadDataWithBaseURL(baseUrl, content, "text/html", "utf-8", null);
m_web.loadDataWithBaseURL(baseUrl, content.toString(), "text/html", "utf-8", null);
} else {
WebBackForwardList rc = m_web.restoreState(savedInstanceState);
if (rc == null) {
// restore failed...
m_web.loadDataWithBaseURL(baseUrl, content, "text/html", "utf-8", null);
m_web.loadDataWithBaseURL(baseUrl, content.toString(), "text/html", "utf-8", null);
}
}
@ -513,16 +493,7 @@ public class ArticleFragment extends Fragment {
e.printStackTrace();
}
// if (m_activity.isSmallScreen())
// web.setOnTouchListener(m_gestureListener);
m_web.setVisibility(View.VISIBLE);
}
}
}, 100);
}
return view;
}