]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Print reason for failed download.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Tue, 15 Dec 2015 20:25:53 +0000 (21:25 +0100)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Tue, 15 Dec 2015 20:25:53 +0000 (21:25 +0100)
src/com/hughes/android/dictionary/DictionaryManagerActivity.java

index 8ec7d2c0e7aa579e021f563474743b42045f63e0..523a4109cb147db9ee5c03a8370a11c2feb8b90b 100644 (file)
@@ -142,11 +142,17 @@ public class DictionaryManagerActivity extends ActionBarActivity {
                         .getInt(cursor
                                 .getColumnIndex(DownloadManager.COLUMN_STATUS));
                 if (DownloadManager.STATUS_SUCCESSFUL != status) {
+                    final int reason = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_REASON));
                     Log.w(LOG,
                             "Download failed: status=" + status +
-                                    ", reason=" + cursor.getString(cursor
-                                            .getColumnIndex(DownloadManager.COLUMN_REASON)));
-                    new AlertDialog.Builder(context).setTitle(getString(R.string.error)).setMessage(getString(R.string.downloadFailed, dest)).setNeutralButton("Close", null).show();
+                                    ", reason=" + reason);
+                    String msg = Integer.toString(reason);
+                    switch (reason) {
+                    case DownloadManager.ERROR_FILE_ALREADY_EXISTS: msg = "File exists"; break;
+                    case DownloadManager.ERROR_FILE_ERROR: msg = "File error"; break;
+                    case DownloadManager.ERROR_INSUFFICIENT_SPACE: msg = "Not enough space"; break;
+                    }
+                    new AlertDialog.Builder(context).setTitle(getString(R.string.error)).setMessage(getString(R.string.downloadFailed, reason)).setNeutralButton("Close", null).show();
                     return;
                 }