Exemplo n.º 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);
   }
 }
Exemplo n.º 2
0
 @Override
 protected void onPostExecute(T data) {
   if (callback != null) {
     callback.done(data);
   }
 }
Exemplo n.º 3
0
 @Override
 public void addCallback(ResourceCallback<? super Sound> callback) {
   callback.error(exception);
 }