Ejemplo n.º 1
0
  private void updateLanguage(final OCRLanguage language, int status) {
    language.mDownloading = false;
    if (status == DownloadManager.STATUS_SUCCESSFUL) {
      language.mDownloaded = true;
    } else {
      language.mDownloaded = false;
      runOnUiThread(
          new Runnable() {

            @Override
            public void run() {
              String msg = getString(R.string.download_failed);
              msg = String.format(msg, language.mDisplayText);
              Toast.makeText(OCRLanguageActivity.this, msg, Toast.LENGTH_LONG).show();
            }
          });
    }
    mAdapter.notifyDataSetChanged();
  }
Ejemplo n.º 2
0
 private void updateLanguageListWithDownloadManagerStatus(OCRLanguageAdapter adapter) {
   if (adapter != null) {
     // find languages that are currently beeing downloaded
     Query query = new Query();
     query.setFilterByStatus(
         DownloadManager.STATUS_RUNNING
             | DownloadManager.STATUS_PENDING
             | DownloadManager.STATUS_PAUSED);
     final DownloadManager dm = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
     Cursor c = dm.query(query);
     int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_TITLE);
     while (c.moveToNext()) {
       final String title = c.getString(columnIndex);
       adapter.setDownloading(title, true);
     }
     adapter.notifyDataSetChanged();
     c.close();
   }
 }