├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.9.png │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.9.png │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.9.png │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.9.png │ │ ├── drawable-xxxhdpi │ │ │ └── ic_launcher.9.png │ │ └── layout │ │ │ ├── activity_main.xml │ │ │ ├── include_down1.xml │ │ │ └── include_down2.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── less │ │ └── downloadmanager │ │ └── MainActivity.java ├── build.gradle └── proguard-rules.pro ├── lib_java ├── .gitignore ├── libs │ └── sqlite-jdbc-3.8.11.1.jar ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── less │ └── downloadmanager │ ├── lib │ ├── Downloader.java │ ├── util │ │ ├── TextUtils.java │ │ ├── L.java │ │ ├── Platform.java │ │ ├── IOUtils.java │ │ └── FileUtils.java │ ├── db │ │ ├── BaseDaoImpl.java │ │ ├── BaseDao.java │ │ ├── DatabaseManager.java │ │ ├── ThreadInfoDao.java │ │ └── SqlHelper.java │ ├── Config.java │ ├── Constants.java │ ├── request │ │ ├── PostBuilder.java │ │ ├── RequestCall.java │ │ ├── GetBuilder.java │ │ ├── GetRequest.java │ │ ├── RequestBuilder.java │ │ ├── FileCallBack.java │ │ ├── StringCallback.java │ │ └── Callback.java │ ├── task │ │ ├── ConnectTask.java │ │ ├── DownloadTask.java │ │ ├── SingleDownloadTask.java │ │ ├── MultiDownloadTask.java │ │ ├── ConnectTaskImpl.java │ │ └── DownloadTaskImpl.java │ ├── listenter │ │ ├── OnConnectListener.java │ │ └── OnDownloadListener.java │ ├── DownloadException.java │ ├── bean │ │ ├── DownloadInfo.java │ │ ├── ThreadInfo.java │ │ └── DownloadStatus.java │ ├── DownloadManager.java │ └── DownloaderImpl.java │ └── App.java ├── lib_android ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── less │ │ │ │ └── downloadmanager │ │ │ │ └── lib │ │ │ │ ├── Downloader.java │ │ │ │ ├── request │ │ │ │ ├── PostBuilder.java │ │ │ │ ├── RequestCall.java │ │ │ │ ├── GetBuilder.java │ │ │ │ ├── GetRequest.java │ │ │ │ ├── FileCallBack.java │ │ │ │ ├── RequestBuilder.java │ │ │ │ ├── StringCallback.java │ │ │ │ └── Callback.java │ │ │ │ ├── task │ │ │ │ ├── ConnectTask.java │ │ │ │ ├── DownloadTask.java │ │ │ │ ├── SingleDownloadTask.java │ │ │ │ ├── MultiDownloadTask.java │ │ │ │ ├── ConnectTaskImpl.java │ │ │ │ └── DownloadTaskImpl.java │ │ │ │ ├── db │ │ │ │ ├── BaseDao.java │ │ │ │ ├── BaseDaoImpl.java │ │ │ │ ├── SqlHelper.java │ │ │ │ ├── DatabaseManager.java │ │ │ │ └── ThreadInfoDao.java │ │ │ │ ├── listenter │ │ │ │ ├── OnConnectListener.java │ │ │ │ └── OnDownloadListener.java │ │ │ │ ├── Constants.java │ │ │ │ ├── util │ │ │ │ ├── IOUtils.java │ │ │ │ ├── L.java │ │ │ │ ├── Platform.java │ │ │ │ └── FileUtils.java │ │ │ │ ├── DownloadException.java │ │ │ │ ├── bean │ │ │ │ ├── DownloadInfo.java │ │ │ │ ├── ThreadInfo.java │ │ │ │ └── DownloadStatus.java │ │ │ │ ├── DownloadManager.java │ │ │ │ └── DownloaderImpl.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── less │ │ │ └── lib_android │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── less │ │ └── lib_android │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── download.db ├── screenshots └── show.png ├── libs ├── downloader-java-1.1.jar └── downloader-android-1.1.jar ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /lib_java/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /lib_android/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':lib_android', ':lib_java' 2 | -------------------------------------------------------------------------------- /download.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/download.db -------------------------------------------------------------------------------- /screenshots/show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/screenshots/show.png -------------------------------------------------------------------------------- /libs/downloader-java-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/libs/downloader-java-1.1.jar -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | DownloadManager 3 | 4 | -------------------------------------------------------------------------------- /libs/downloader-android-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/libs/downloader-android-1.1.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /lib_android/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | lib_android 3 | 4 | -------------------------------------------------------------------------------- /lib_java/libs/sqlite-jdbc-3.8.11.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/lib_java/libs/sqlite-jdbc-3.8.11.1.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/drawable-mdpi/ic_launcher.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/drawable-xxhdpi/ic_launcher.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_launcher.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/drawable-xxxhdpi/ic_launcher.9.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-dream/DownloadManager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | .idea 11 | -------------------------------------------------------------------------------- /lib_java/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | dependencies { 4 | compile fileTree(dir: 'libs', include: ['*.jar']) 5 | } 6 | 7 | sourceCompatibility = "1.7" 8 | targetCompatibility = "1.7" 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Sep 13 16:26:50 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/Downloader.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib; 2 | 3 | /** 下载执行类 */ 4 | public interface Downloader { 5 | boolean isRunning(); 6 | 7 | void start(); 8 | 9 | void pause(); 10 | 11 | void cancel(); 12 | } 13 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/Downloader.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib; 2 | 3 | /** 下载执行类 */ 4 | public interface Downloader { 5 | boolean isRunning(); 6 | 7 | void start(); 8 | 9 | void pause(); 10 | 11 | void cancel(); 12 | } 13 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/util/TextUtils.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.util; 2 | 3 | public class TextUtils { 4 | 5 | public static boolean isEmpty(String text){ 6 | if(text == null || text.length() == 0){ 7 | return true; 8 | } 9 | return false; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /lib_android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/db/BaseDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.db; 2 | 3 | /** 4 | * Created by Administrator on 2017/9/16. 5 | */ 6 | 7 | public abstract class BaseDaoImpl implements BaseDao{ 8 | protected String TAG = this.getClass().getSimpleName();// 获取真实子类的TAG名称 9 | } 10 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/Config.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib; 2 | 3 | /** 4 | * Created by Administrator on 2017/9/16. 5 | */ 6 | 7 | public class Config { 8 | public static final int DEFAULT_MAX_THREAD_NUMBER = 10;// 线程池的最大线程数量 9 | 10 | public static final int DEFAULT_THREAD_NUMBER = 3;// 每个DownLoader下载器的 线程数量 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/util/L.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.util; 2 | 3 | import com.less.downloadmanager.lib.Constants; 4 | 5 | public class L { 6 | public static void d(String msg) { 7 | if(Constants.CONFIG.DEBUG){ 8 | System.out.println(msg); 9 | } 10 | } 11 | 12 | public static void e(String msg) { 13 | if (Constants.CONFIG.DEBUG) { 14 | System.err.println(msg); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/Constants.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib; 2 | 3 | public class Constants { 4 | 5 | public static final class CONFIG { 6 | public static final boolean DEBUG = true; 7 | } 8 | 9 | public static final class HTTP { 10 | public static final int CONNECT_TIME_OUT = 10 * 1000; 11 | public static final int READ_TIME_OUT = 10 * 1000; 12 | public static final String GET = "GET"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/db/BaseDao.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.db; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by Administrator on 2017/9/16. 7 | */ 8 | 9 | public interface BaseDao { 10 | void add(T t); 11 | void delete(String tag); 12 | void update(String tag, int threadId, long finished); 13 | List find(String tag); 14 | List findAll(); 15 | boolean exists(String tag, int threadId); 16 | } 17 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/request/PostBuilder.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.request; 2 | 3 | /** 4 | * Created by Administrator on 2017/9/16. 5 | */ 6 | 7 | public class PostBuilder extends RequestBuilder{ 8 | 9 | @Override 10 | protected RequestBuilder addParams(String key, String val) { 11 | return null; 12 | } 13 | 14 | @Override 15 | public RequestCall build() { 16 | return null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/request/PostBuilder.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.request; 2 | 3 | /** 4 | * Created by Administrator on 2017/9/16. 5 | */ 6 | 7 | public class PostBuilder extends RequestBuilder{ 8 | 9 | @Override 10 | protected RequestBuilder addParams(String key, String val) { 11 | return null; 12 | } 13 | 14 | @Override 15 | public RequestCall build() { 16 | return null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/task/ConnectTask.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.task; 2 | 3 | /** 4 | * Created by Limitless on 2017/9/22. 5 | * 首次连接获取下载文件length的Task 6 | */ 7 | 8 | public interface ConnectTask extends Runnable{ 9 | void pause(); 10 | 11 | void cancel(); 12 | 13 | boolean isConnecting(); 14 | 15 | boolean isConnected(); 16 | 17 | boolean isPaused(); 18 | 19 | boolean isCanceled(); 20 | 21 | boolean isFailed(); 22 | } 23 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/task/DownloadTask.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.task; 2 | 3 | /** 4 | * Created by Limitless on 2017/9/22. 5 | * 连接Task完成之后-> 下载Task 6 | */ 7 | 8 | public interface DownloadTask extends Runnable{ 9 | void pause(); 10 | 11 | void cancel(); 12 | 13 | boolean isDownloading(); 14 | 15 | boolean isComplete(); 16 | 17 | boolean isPaused(); 18 | 19 | boolean isCanceled(); 20 | 21 | boolean isFailed(); 22 | } 23 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/task/ConnectTask.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.task; 2 | 3 | /** 4 | * Created by Limitless on 2017/9/22. 5 | * 首次连接获取下载文件length的Task 6 | */ 7 | 8 | public interface ConnectTask extends Runnable{ 9 | void pause(); 10 | 11 | void cancel(); 12 | 13 | boolean isConnecting(); 14 | 15 | boolean isConnected(); 16 | 17 | boolean isPaused(); 18 | 19 | boolean isCanceled(); 20 | 21 | boolean isFailed(); 22 | } 23 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/task/DownloadTask.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.task; 2 | 3 | /** 4 | * Created by Limitless on 2017/9/22. 5 | * 连接Task完成之后-> 下载Task 6 | */ 7 | 8 | public interface DownloadTask extends Runnable{ 9 | void pause(); 10 | 11 | void cancel(); 12 | 13 | boolean isDownloading(); 14 | 15 | boolean isComplete(); 16 | 17 | boolean isPaused(); 18 | 19 | boolean isCanceled(); 20 | 21 | boolean isFailed(); 22 | } 23 | -------------------------------------------------------------------------------- /lib_android/src/test/java/com/less/lib_android/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.less.lib_android; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/db/BaseDao.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.db; 2 | 3 | import android.database.sqlite.SQLiteDatabase; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by Administrator on 2017/9/16. 9 | */ 10 | 11 | public interface BaseDao { 12 | void add(T t); 13 | void delete(String tag); 14 | void update(String tag, int threadId, long finished); 15 | List find(String tag); 16 | List findAll(); 17 | boolean exists(String tag, int threadId); 18 | } 19 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/listenter/OnConnectListener.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.listenter; 2 | 3 | import com.less.downloadmanager.lib.DownloadException; 4 | 5 | /** 6 | * Created by Administrator on 2017/9/22. 7 | */ 8 | 9 | public interface OnConnectListener { 10 | void onConnecting(); 11 | 12 | void onConnected(long length, boolean isAcceptRanges); 13 | 14 | void onConnectPaused(); 15 | 16 | void onConnectCanceled(); 17 | 18 | void onConnectFailed(DownloadException de); 19 | } 20 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/listenter/OnConnectListener.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.listenter; 2 | 3 | import com.less.downloadmanager.lib.DownloadException; 4 | 5 | /** 6 | * Created by Administrator on 2017/9/22. 7 | */ 8 | 9 | public interface OnConnectListener { 10 | void onConnecting(); 11 | 12 | void onConnected(long length, boolean isAcceptRanges); 13 | 14 | void onConnectPaused(); 15 | 16 | void onConnectCanceled(); 17 | 18 | void onConnectFailed(DownloadException de); 19 | } 20 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/listenter/OnDownloadListener.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.listenter; 2 | 3 | import com.less.downloadmanager.lib.DownloadException; 4 | 5 | /** 6 | * Created by Administrator on 2017/9/22. 7 | */ 8 | 9 | public interface OnDownloadListener { 10 | void onDownloadConnecting(); 11 | 12 | void onDownloadProgress(long finished, long length); 13 | 14 | void onDownloadCompleted(); 15 | 16 | void onDownloadPaused(); 17 | 18 | void onDownloadCanceled(); 19 | 20 | void onDownloadFailed(DownloadException de); 21 | } 22 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/listenter/OnDownloadListener.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.listenter; 2 | 3 | import com.less.downloadmanager.lib.DownloadException; 4 | 5 | /** 6 | * Created by Administrator on 2017/9/22. 7 | */ 8 | 9 | public interface OnDownloadListener { 10 | void onDownloadConnecting(); 11 | 12 | void onDownloadProgress(long finished, long length); 13 | 14 | void onDownloadCompleted(); 15 | 16 | void onDownloadPaused(); 17 | 18 | void onDownloadCanceled(); 19 | 20 | void onDownloadFailed(DownloadException de); 21 | } 22 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/request/RequestCall.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.request; 2 | 3 | import com.less.downloadmanager.lib.DownloadManager; 4 | 5 | /** 6 | * Created by Administrator on 2017/9/18. 7 | */ 8 | 9 | public class RequestCall { 10 | public GetRequest getRequest; 11 | 12 | public RequestCall(GetRequest getRequest) { 13 | this.getRequest = getRequest; 14 | } 15 | 16 | public void execute(Callback callback) { 17 | DownloadManager.getInstance().start(this,callback);// 仍然交给DownLoadManager调用,有点EventBus的味道 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/Constants.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib; 2 | 3 | public class Constants { 4 | 5 | public static final class CONFIG { 6 | public static final boolean DEBUG = true; 7 | public static final int DEFAULT_MAX_THREAD_NUMBER = 10;// 线程池的最大线程数量 8 | public static final int DEFAULT_THREAD_NUMBER = 3;// 每个DownLoader下载器的 线程数量 9 | } 10 | 11 | public static final class HTTP { 12 | public static final int CONNECT_TIME_OUT = 10 * 1000; 13 | public static final int READ_TIME_OUT = 10 * 1000; 14 | public static final String GET = "GET"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/request/RequestCall.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.request; 2 | 3 | import android.content.Context; 4 | 5 | import com.less.downloadmanager.lib.DownloadManager; 6 | 7 | /** 8 | * Created by Administrator on 2017/9/18. 9 | */ 10 | 11 | public class RequestCall { 12 | public GetRequest getRequest; 13 | 14 | public RequestCall(GetRequest getRequest) { 15 | this.getRequest = getRequest; 16 | } 17 | 18 | public void execute(Context context,Callback callback) { 19 | DownloadManager.getInstance(context).start(this,callback);// 仍然交给DownLoadManager调用,有点EventBus的味道 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/request/GetBuilder.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.request; 2 | 3 | import java.util.HashMap; 4 | 5 | /** 6 | * Created by Administrator on 2017/9/16. 7 | */ 8 | 9 | public class GetBuilder extends RequestBuilder{ 10 | 11 | @Override 12 | protected RequestBuilder addParams(String key, String val) { 13 | if (mParams == null) { 14 | mParams = new HashMap(); 15 | } 16 | mParams.put(key,val); 17 | return this; 18 | } 19 | 20 | @Override 21 | public RequestCall build() { 22 | 23 | return new GetRequest(mUri,mFolder,mName,mTag).build(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/request/GetBuilder.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.request; 2 | 3 | import java.util.HashMap; 4 | 5 | /** 6 | * Created by Administrator on 2017/9/16. 7 | */ 8 | 9 | public class GetBuilder extends RequestBuilder{ 10 | 11 | @Override 12 | protected RequestBuilder addParams(String key, String val) { 13 | if (mParams == null) { 14 | mParams = new HashMap(); 15 | } 16 | mParams.put(key,val); 17 | return this; 18 | } 19 | 20 | @Override 21 | public RequestCall build() { 22 | 23 | return new GetRequest(mUri,mFolder,mName,mTag).build(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/request/GetRequest.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.request; 2 | 3 | import java.io.File; 4 | import java.util.Map; 5 | 6 | /** 7 | * Created by Administrator on 2017/9/18. 8 | */ 9 | 10 | public class GetRequest { // Builder模式分离为两个类 11 | public String mUri; 12 | 13 | public File mFolder; 14 | 15 | public String mName; 16 | 17 | public String mTag; 18 | 19 | protected Map mParams; 20 | 21 | public GetRequest(String uri, File folder, String name,String tag) { 22 | this.mUri = uri; 23 | this.mFolder = folder; 24 | this.mName = name; 25 | this.mTag = tag; 26 | } 27 | 28 | public RequestCall build() { 29 | return new RequestCall(this); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/request/GetRequest.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.request; 2 | 3 | import java.io.File; 4 | import java.util.Map; 5 | 6 | /** 7 | * Created by Administrator on 2017/9/18. 8 | */ 9 | 10 | public class GetRequest { // Builder模式分离为两个类 11 | public String mUri; 12 | 13 | public File mFolder; 14 | 15 | public String mName; 16 | 17 | public String mTag; 18 | 19 | protected Map mParams; 20 | 21 | public GetRequest(String uri, File folder, String name,String tag) { 22 | this.mUri = uri; 23 | this.mFolder = folder; 24 | this.mName = name; 25 | this.mTag = tag; 26 | } 27 | 28 | public RequestCall build() { 29 | return new RequestCall(this); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/util/Platform.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.util; 2 | 3 | import java.util.concurrent.Executor; 4 | import java.util.concurrent.Executors; 5 | 6 | public class Platform { 7 | private static final Platform PLATFORM = findPlatform(); 8 | private static Executor executor; 9 | public static Platform get() { 10 | return PLATFORM; 11 | } 12 | 13 | private static Platform findPlatform() { 14 | return new Platform();// 创建Java平台的线程池 15 | } 16 | 17 | public Executor makeCallbackExecutor() { 18 | if (executor == null) { 19 | executor = Executors.newCachedThreadPool(); 20 | } 21 | return executor; 22 | } 23 | 24 | /** execute 线程 */ 25 | public void execute(Runnable runnable) { 26 | makeCallbackExecutor().execute(runnable); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/util/IOUtils.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.util; 2 | 3 | import java.io.Closeable; 4 | import java.io.Flushable; 5 | import java.io.IOException; 6 | 7 | public class IOUtils { 8 | 9 | public static final void closeQuietly(Closeable closeable) { 10 | if (closeable != null) { 11 | synchronized (IOUtils.class) { 12 | try { 13 | closeable.close(); 14 | } catch (IOException e) { 15 | e.printStackTrace(); 16 | } 17 | } 18 | } 19 | } 20 | 21 | public static void flushQuietly(Flushable flushable) { 22 | if (flushable == null) return; 23 | try { 24 | flushable.flush(); 25 | } catch (Exception e) { 26 | e.printStackTrace(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/util/IOUtils.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.util; 2 | 3 | import java.io.Closeable; 4 | import java.io.Flushable; 5 | import java.io.IOException; 6 | 7 | public class IOUtils { 8 | 9 | public static final void closeQuietly(Closeable closeable) { 10 | if (closeable != null) { 11 | synchronized (IOUtils.class) { 12 | try { 13 | closeable.close(); 14 | } catch (IOException e) { 15 | e.printStackTrace(); 16 | } 17 | } 18 | } 19 | } 20 | 21 | public static void flushQuietly(Flushable flushable) { 22 | if (flushable == null) return; 23 | try { 24 | flushable.flush(); 25 | } catch (Exception e) { 26 | e.printStackTrace(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/db/BaseDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.db; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | 6 | /** 7 | * Created by Administrator on 2017/9/16. 8 | */ 9 | 10 | public abstract class BaseDaoImpl implements BaseDao{ 11 | protected String TAG = this.getClass().getSimpleName();// 获取真实子类的TAG名称 12 | public BaseDaoImpl(Context context){ 13 | mHelper = new SqlHelper(context); 14 | } 15 | private SqlHelper mHelper; 16 | 17 | protected SQLiteDatabase getWritableDatabase() { 18 | return mHelper.getWritableDatabase(); 19 | } 20 | 21 | protected SQLiteDatabase getReadableDatabase() { 22 | return mHelper.getReadableDatabase(); 23 | } 24 | 25 | public void closeDB() { 26 | mHelper.close(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/db/SqlHelper.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.db; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteOpenHelper; 6 | 7 | /** 8 | * Created by Administrator on 2017/9/16. 9 | */ 10 | 11 | public class SqlHelper extends SQLiteOpenHelper { 12 | private static final String DB_NAME = "download.db"; 13 | private static final int DB_VERSION = 1; 14 | public SqlHelper(Context context) { 15 | super(context, DB_NAME, null, DB_VERSION); 16 | } 17 | 18 | @Override 19 | public void onCreate(SQLiteDatabase db) { 20 | ThreadInfoDao.createTable(db); 21 | } 22 | 23 | @Override 24 | public void onUpgrade(SQLiteDatabase db, int i, int i1) { 25 | ThreadInfoDao.dropTable(db); 26 | ThreadInfoDao.createTable(db); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib_android/src/androidTest/java/com/less/lib_android/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.less.lib_android; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.less.lib_android.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.0" 6 | defaultConfig { 7 | applicationId "com.less.downloadmanager" 8 | minSdkVersion 14 9 | targetSdkVersion 15 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:26.+' 28 | compile project(':lib_android') 29 | } 30 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /lib_android/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/request/FileCallBack.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.request; 2 | 3 | import com.less.downloadmanager.lib.DownloadException; 4 | import com.less.downloadmanager.lib.DownloadManager; 5 | 6 | import java.io.File; 7 | 8 | /** 9 | * Created by Administrator on 2017/9/18. 10 | */ 11 | 12 | public abstract class FileCallBack extends Callback{ 13 | 14 | @Override 15 | public abstract void onStart(String tag) ; 16 | 17 | @Override 18 | public abstract void onDownloadProgress(String tag,long finished, long totalLength, int percent); 19 | 20 | @Override 21 | public abstract void onDownloadPaused(); 22 | 23 | @Override 24 | public abstract void onDownloadCanceled(); 25 | 26 | @Override 27 | public abstract void onDownloadFailed(DownloadException e); 28 | 29 | @Override 30 | public File parseResponse(File file) { 31 | // 对原始文件进行操作(暂时不作修改) 32 | // ... 33 | return file; 34 | } 35 | 36 | @Override 37 | public abstract void onDownloadCompleted(File file); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/request/RequestBuilder.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.request; 2 | 3 | import java.io.File; 4 | import java.util.Map; 5 | 6 | /** 7 | * Created by Administrator on 2017/9/16. 8 | */ 9 | 10 | public abstract class RequestBuilder { 11 | protected String mUri; 12 | 13 | protected File mFolder; 14 | 15 | protected String mName; 16 | 17 | protected String mTag; 18 | 19 | protected Map mParams; 20 | 21 | public T uri(String uri){ 22 | this.mUri = uri; 23 | return (T) this; 24 | } 25 | 26 | public T folder(File folder){ 27 | this.mFolder = folder; 28 | return (T) this; 29 | } 30 | 31 | public T name(String name) { 32 | this.mName = name; 33 | return (T) this; 34 | } 35 | 36 | public T tag(String tag) { 37 | this.mTag = tag; 38 | return (T) this; 39 | } 40 | 41 | protected abstract RequestBuilder addParams(String key, String val); 42 | 43 | public abstract RequestCall build(); 44 | } 45 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/util/L.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.util; 2 | 3 | import android.util.Log; 4 | 5 | import com.less.downloadmanager.lib.Constants; 6 | 7 | public class L { 8 | private static final String TAG = "DownloadManager"; 9 | 10 | public static void d(String msg) { 11 | d(TAG, msg); 12 | } 13 | 14 | public static void d(String tag, String msg) { 15 | if (Constants.CONFIG.DEBUG) { 16 | Log.d(tag, msg); 17 | } 18 | } 19 | 20 | public static void i(String msg) { 21 | i(TAG, msg); 22 | } 23 | 24 | public static void i(String tag, String msg) { 25 | if (Constants.CONFIG.DEBUG) { 26 | Log.i(tag, msg); 27 | } 28 | } 29 | 30 | public static void e(String tag, String msg) { 31 | if (Constants.CONFIG.DEBUG) { 32 | Log.e(tag, msg); 33 | } 34 | } 35 | 36 | public static void w(String msg) { 37 | w(TAG, msg); 38 | } 39 | 40 | public static void w(String tag, String msg) { 41 | if (Constants.CONFIG.DEBUG) { 42 | Log.w(tag, msg); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/request/RequestBuilder.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.request; 2 | 3 | import android.content.Context; 4 | 5 | import java.io.File; 6 | import java.util.Map; 7 | 8 | /** 9 | * Created by Administrator on 2017/9/16. 10 | */ 11 | 12 | public abstract class RequestBuilder { 13 | protected String mUri; 14 | 15 | protected File mFolder; 16 | 17 | protected String mName; 18 | 19 | protected String mTag; 20 | 21 | protected Map mParams; 22 | 23 | public T uri(String uri){ 24 | this.mUri = uri; 25 | return (T) this; 26 | } 27 | 28 | public T folder(File folder){ 29 | this.mFolder = folder; 30 | return (T) this; 31 | } 32 | 33 | public T name(String name) { 34 | this.mName = name; 35 | return (T) this; 36 | } 37 | 38 | public T tag(String tag) { 39 | this.mTag = tag; 40 | return (T) this; 41 | } 42 | 43 | protected abstract RequestBuilder addParams(String key, String val); 44 | 45 | public abstract RequestCall build(); 46 | } 47 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/request/FileCallBack.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib.request; 2 | 3 | import com.less.downloadmanager.lib.DownloadException; 4 | import com.less.downloadmanager.lib.DownloadManager; 5 | 6 | import java.io.File; 7 | 8 | /** 9 | * Created by Administrator on 2017/9/18. 10 | */ 11 | 12 | public abstract class FileCallBack extends Callback{ 13 | 14 | @Override 15 | public abstract void onStart(String tag) ; 16 | 17 | @Override 18 | public abstract void onDownloadProgress(String tag,long finished, long totalLength, int percent); 19 | 20 | @Override 21 | public void onDownloadPaused() { 22 | // nothing to do 23 | } 24 | 25 | @Override 26 | public void onDownloadCanceled() { 27 | // nothing to do 28 | } 29 | 30 | @Override 31 | public abstract void onDownloadFailed(DownloadException e); 32 | 33 | @Override 34 | public File parseResponse(File file) { 35 | // 对原始文件进行操作(暂时不作修改) 36 | // ... 37 | return file; 38 | } 39 | 40 | @Override 41 | public abstract void onDownloadCompleted(File file); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /lib_java/src/main/java/com/less/downloadmanager/lib/DownloadException.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib; 2 | 3 | public class DownloadException extends Exception { 4 | private String errorMessage; 5 | private int errorCode; 6 | 7 | public DownloadException() { 8 | } 9 | 10 | public DownloadException(String detailMessage) { 11 | super(detailMessage); 12 | this.errorMessage = detailMessage; 13 | } 14 | 15 | public DownloadException(int errorCode, String detailMessage) { 16 | super(detailMessage); 17 | this.errorCode = errorCode; 18 | this.errorMessage = detailMessage; 19 | } 20 | 21 | public DownloadException(int errorCode, Throwable throwable) { 22 | super(throwable); 23 | this.errorCode = errorCode; 24 | } 25 | 26 | public DownloadException(String detailMessage, Throwable throwable) { 27 | super(detailMessage, throwable); 28 | this.errorMessage = detailMessage; 29 | } 30 | 31 | public DownloadException(int errorCode, String detailMessage, Throwable throwable) { 32 | super(detailMessage, throwable); 33 | this.errorCode = errorCode; 34 | this.errorMessage = detailMessage; 35 | } 36 | 37 | public DownloadException(Throwable throwable) { 38 | super(throwable); 39 | } 40 | 41 | public String getErrorMessage() { 42 | return errorMessage; 43 | } 44 | 45 | public void setErrorMessage(String errorMessage) { 46 | this.errorMessage = errorMessage; 47 | } 48 | 49 | public int getErrorCode() { 50 | return errorCode; 51 | } 52 | 53 | public void setErrorCode(int errorCode) { 54 | this.errorCode = errorCode; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib_android/src/main/java/com/less/downloadmanager/lib/DownloadException.java: -------------------------------------------------------------------------------- 1 | package com.less.downloadmanager.lib; 2 | 3 | public class DownloadException extends Exception { 4 | private String errorMessage; 5 | private int errorCode; 6 | 7 | public DownloadException() { 8 | } 9 | 10 | public DownloadException(String detailMessage) { 11 | super(detailMessage); 12 | this.errorMessage = detailMessage; 13 | } 14 | 15 | public DownloadException(int errorCode, String detailMessage) { 16 | super(detailMessage); 17 | this.errorCode = errorCode; 18 | this.errorMessage = detailMessage; 19 | } 20 | 21 | public DownloadException(int errorCode, Throwable throwable) { 22 | super(throwable); 23 | this.errorCode = errorCode; 24 | } 25 | 26 | public DownloadException(String detailMessage, Throwable throwable) { 27 | super(detailMessage, throwable); 28 | this.errorMessage = detailMessage; 29 | } 30 | 31 | public DownloadException(int errorCode, String detailMessage, Throwable throwable) { 32 | super(detailMessage, throwable); 33 | this.errorCode = errorCode; 34 | this.errorMessage = detailMessage; 35 | } 36 | 37 | public DownloadException(Throwable throwable) { 38 | super(throwable); 39 | } 40 | 41 | public String getErrorMessage() { 42 | return errorMessage; 43 | } 44 | 45 | public void setErrorMessage(String errorMessage) { 46 | this.errorMessage = errorMessage; 47 | } 48 | 49 | public int getErrorCode() { 50 | return errorCode; 51 | } 52 | 53 | public void setErrorCode(int errorCode) { 54 | this.errorCode = errorCode; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/res/layout/include_down1.xml: -------------------------------------------------------------------------------- 1 | 6 | 15 | 16 | 20 | 21 |