X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2FDictionaryManagerActivity.java;h=dacc6d75cd2c806fc72317d2c96b78cec0a9731c;hb=4f0e2b9302b6c3921e444467bb295f0ed6db1b99;hp=159a7f0abf5037a9516e65e6bf4536c8ee4411f0;hpb=e426fbc423c46beecbb34ed45d69b76208fde354;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/DictionaryManagerActivity.java b/src/com/hughes/android/dictionary/DictionaryManagerActivity.java index 159a7f0..dacc6d7 100644 --- a/src/com/hughes/android/dictionary/DictionaryManagerActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryManagerActivity.java @@ -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; } @@ -616,6 +616,16 @@ public class DictionaryManagerActivity extends ActionBarActivity { final DownloadManager.Query query = new DownloadManager.Query(); 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, R.string.downloadManagerQueryFailed)) + .setNeutralButton("Close", null).show(); + return; + } + while (cursor.moveToNext()) { if (downloadUrl.equals(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_URI)))) break;