]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryManagerActivity.java
Refine check for failed download manager query.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryManagerActivity.java
index 4b1723fe0b46fff71d5d73b83c1b42772143627a..dacc6d75cd2c806fc72317d2c96b78cec0a9731c 100644 (file)
@@ -131,7 +131,7 @@ public class DictionaryManagerActivity extends ActionBarActivity {
                 final DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
                 final Cursor cursor = downloadManager.query(query);
 
-                if (!cursor.moveToFirst()) {
+                if (cursor == null || !cursor.moveToFirst()) {
                     Log.e(LOG, "Couldn't find download.");
                     return;
                 }
@@ -617,9 +617,11 @@ public class DictionaryManagerActivity extends ActionBarActivity {
         query.setFilterByStatus(DownloadManager.STATUS_PAUSED | DownloadManager.STATUS_PENDING | DownloadManager.STATUS_RUNNING);
         final Cursor cursor = downloadManager.query(query);
 
+        // Due to a bug, cursor is null instead of empty when
+        // the download manager is disabled.
         if (cursor == null) {
             new AlertDialog.Builder(DictionaryManagerActivity.this).setTitle(getString(R.string.error))
-                    .setMessage(getString(R.string.downloadFailed, "Couldn't query Download Manager"))
+                    .setMessage(getString(R.string.downloadFailed, R.string.downloadManagerQueryFailed))
                     .setNeutralButton("Close", null).show();
             return;
         }