Fixed encoding issues in webview

This commit is contained in:
daniel oeh 2012-07-11 21:39:37 +02:00
parent 04b8e54c50
commit bc977e1e20
1 changed files with 12 additions and 17 deletions

View File

@ -103,12 +103,15 @@ public class ItemDescriptionFragment extends SherlockFragment {
webViewLoader = null; webViewLoader = null;
} }
String url; String data;
@Override @Override
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
super.onPostExecute(result); super.onPostExecute(result);
webvDescription.loadData(url, "text/html", "utf-8"); // /webvDescription.loadData(url, "text/html", "utf-8");
webvDescription.loadDataWithBaseURL(null,
item.getContentEncoded(), "text/html", "utf-8",
"about:blank");
getSherlockActivity() getSherlockActivity()
.setSupportProgressBarIndeterminateVisibility(false); .setSupportProgressBarIndeterminateVisibility(false);
Log.d(TAG, "Webview loaded"); Log.d(TAG, "Webview loaded");
@ -125,21 +128,13 @@ public class ItemDescriptionFragment extends SherlockFragment {
@Override @Override
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {
Log.d(TAG, "Loading Webview"); Log.d(TAG, "Loading Webview");
url = ""; data = "";
try { if (item.getContentEncoded() == null
if (item.getContentEncoded() == null) { && item.getDescription() != null) {
url = URLEncoder.encode(item.getDescription(), "utf-8") data = item.getDescription();
.replaceAll("\\+", " ");
} else { } else {
url = URLEncoder.encode( data = StringEscapeUtils.unescapeHtml4(item
StringEscapeUtils.unescapeHtml4(item .getContentEncoded());
.getContentEncoded()), "utf-8")
.replaceAll("\\+", " ");
}
} catch (UnsupportedEncodingException e) {
url = "Page could not be loaded";
e.printStackTrace();
} }
return null; return null;