DownloadManager.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package com.rdgk.cemetery.downloadmanager;
  2. public interface DownloadManager {
  3. /**
  4. * Status when the download is currently pending.
  5. */
  6. int STATUS_PENDING = 1 << 0;
  7. /**
  8. * Status when the download is currently pending.
  9. */
  10. int STATUS_STARTED = 1 << 1;
  11. /**
  12. * Status when the download network call is connecting to destination.
  13. */
  14. int STATUS_CONNECTING = 1 << 2;
  15. /**
  16. * Status when the download is currently running.
  17. */
  18. int STATUS_RUNNING = 1 << 3;
  19. /**
  20. * Status when the download has successfully completed.
  21. */
  22. int STATUS_SUCCESSFUL = 1 << 4;
  23. /**
  24. * Status when the download has failed.
  25. */
  26. int STATUS_FAILED = 1 << 5;
  27. /**
  28. * Status when the download has failed due to broken url or invalid download url
  29. */
  30. int STATUS_NOT_FOUND = 1 << 6;
  31. /**
  32. * Status when the download is attempted for retry due to connection timeouts.
  33. */
  34. int STATUS_RETRYING = 1 << 7;
  35. /**
  36. * Error code when writing download content to the destination file.
  37. */
  38. int ERROR_FILE_ERROR = 1001;
  39. /**
  40. * Error code when an HTTP code was received that download manager can't
  41. * handle.
  42. */
  43. int ERROR_UNHANDLED_HTTP_CODE = 1002;
  44. /**
  45. * Error code when an error receiving or processing data occurred at the
  46. * HTTP level.
  47. */
  48. int ERROR_HTTP_DATA_ERROR = 1004;
  49. /**
  50. * Error code when there were too many redirects.
  51. */
  52. int ERROR_TOO_MANY_REDIRECTS = 1005;
  53. /**
  54. * Error code when size of the file is unknown.
  55. */
  56. int ERROR_DOWNLOAD_SIZE_UNKNOWN = 1006;
  57. /**
  58. * Error code when passed URI is malformed.
  59. */
  60. int ERROR_MALFORMED_URI = 1007;
  61. /**
  62. * Error code when download is cancelled.
  63. */
  64. int ERROR_DOWNLOAD_CANCELLED = 1008;
  65. /**
  66. * Error code when there is connection timeout after maximum retries
  67. */
  68. int ERROR_CONNECTION_TIMEOUT_AFTER_RETRIES = 1009;
  69. int add(DownloadRequest request);
  70. int cancel(int downloadId);
  71. void cancelAll();
  72. int pause(int downloadId);
  73. void pauseAll();
  74. int query(int downloadId);
  75. void release();
  76. boolean isReleased();
  77. }