diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2013-02-05 10:19:19 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-02-05 15:53:02 +0000 |
commit | 5dded1e3847bc091c09e49ee083a7586d30335f8 (patch) | |
tree | 09b8b56a8c396e99cdd68e94790acfa81d175c2a /android/src | |
parent | 12a4f4bbce1c56b70373ac1a619765c0d9540784 (diff) | |
download | mupdf-5dded1e3847bc091c09e49ee083a7586d30335f8.tar.xz |
Android: avoid byte[] -> String -> byte[]
Diffstat (limited to 'android/src')
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFCore.java | 13 | ||||
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFReflowView.java | 16 |
2 files changed, 7 insertions, 22 deletions
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFCore.java b/android/src/com/artifex/mupdfdemo/MuPDFCore.java index af726760..a432371a 100644 --- a/android/src/com/artifex/mupdfdemo/MuPDFCore.java +++ b/android/src/com/artifex/mupdfdemo/MuPDFCore.java @@ -201,18 +201,9 @@ public class MuPDFCore return searchPage(text); } - public synchronized String html(int page) { + public synchronized byte[] html(int page) { gotoPage(page); - byte chars[] = textAsHtml(); - String res = new String(); - int i; - int len = chars.length; - - for (i = 0; i < len; i++) { - res += (char)(chars[i] & 0xFF); - } - - return res; + return textAsHtml(); } public synchronized TextWord [][] textLines(int page) { diff --git a/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java b/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java index 8824436f..90d0ec8e 100644 --- a/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java +++ b/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java @@ -17,7 +17,7 @@ public class MuPDFReflowView extends WebView implements MuPDFView { private final Point mParentSize; private int mPage; private int mContentHeight; - AsyncTask<Void,Void,String> mLoadHTML; + AsyncTask<Void,Void,byte[]> mLoadHTML; public MuPDFReflowView(Context c, MuPDFCore core, Point parentSize) { super(c); @@ -46,20 +46,14 @@ public class MuPDFReflowView extends WebView implements MuPDFView { requestHeight(); } }); - mLoadHTML = new AsyncTask<Void,Void,String>() { + mLoadHTML = new AsyncTask<Void,Void,byte[]>() { @Override - protected String doInBackground(Void... params) { + protected byte[] doInBackground(Void... params) { return mCore.html(mPage); } @Override - protected void onPostExecute(String result) { - byte [] utf8; - try { - utf8 = result.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - utf8 = result.getBytes(); - } - String b64 = Base64.encodeToString(utf8, Base64.DEFAULT); + protected void onPostExecute(byte[] result) { + String b64 = Base64.encodeToString(result, Base64.DEFAULT); loadData(b64, "text/html; charset=utf-8", "base64"); } }; |