Example #1
0
 @Override
 protected void doGetText(final String path, final ResourceCallback<String> callback) {
   try {
     InputStream is = openAsset(path);
     try {
       StringBuilder fileData = new StringBuilder(1000);
       BufferedReader reader = new BufferedReader(new InputStreamReader(is));
       char[] buf = new char[1024];
       int numRead = 0;
       while ((numRead = reader.read(buf)) != -1) {
         String readData = String.valueOf(buf, 0, numRead);
         fileData.append(readData);
       }
       reader.close();
       String text = fileData.toString();
       callback.done(text);
     } finally {
       is.close();
     }
   } catch (IOException e) {
     callback.error(e);
   }
 }
Example #2
0
 @Override
 protected void onPostExecute(T data) {
   if (callback != null) {
     callback.done(data);
   }
 }