Skip to content

Commit

Permalink
抽取成module
Browse files Browse the repository at this point in the history
  • Loading branch information
WeDoX committed Jan 18, 2021
1 parent e241eaa commit 2d5eb84
Show file tree
Hide file tree
Showing 28 changed files with 204 additions and 65 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
//
api 'com.zhy:okhttputils:2.6.2'
api 'com.squareup.okhttp3:okhttp:3.2.0'
implementation project(':jdm3u8downloader')

}
32 changes: 24 additions & 8 deletions app/src/main/java/com/onedream/m3u8downloader/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@

import androidx.appcompat.app.AppCompatActivity;

import com.onedream.m3u8downloader.bean.JDDownloadMessage;
import com.onedream.m3u8downloader.bean.JDDownloadProgress;
import com.onedream.m3u8downloader.bean.JDDownloadQueue;
import com.onedream.m3u8downloader.common.JDDownloadQueueState;
import com.onedream.m3u8downloader.listener.JDM3U8DownloaderContract;
import com.onedream.m3u8downloader.utils.JDM3U8FileCacheUtils;
import com.onedream.m3u8downloader.utils.JDM3U8LogHelper;
import com.onedream.jdm3u8downloader.JDM3U8Downloader;
import com.onedream.jdm3u8downloader.bean.JDDownloadMessage;
import com.onedream.jdm3u8downloader.bean.JDDownloadProgress;
import com.onedream.jdm3u8downloader.bean.JDDownloadQueue;
import com.onedream.jdm3u8downloader.common.JDDownloadQueueState;
import com.onedream.jdm3u8downloader.listener.JDM3U8DownloaderContract;
import com.onedream.jdm3u8downloader.utils.JDM3U8FileCacheUtils;
import com.onedream.jdm3u8downloader.utils.JDM3U8LogHelper;

import java.io.File;

Expand All @@ -22,6 +23,20 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//
initView();
initData();
initEvent();
}

private void initView() {

}

private void initData() {

}

private void initEvent() {
findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -34,11 +49,12 @@ public void onClick(View v) {
private void startDownloadM3U8() {
JDDownloadQueue downloadQueue = new JDDownloadQueue();
downloadQueue.setMovie_id(10);
downloadQueue.setSingleRate(false);
downloadQueue.setMovie_download_url("http://yi.jingdianzuida.com/20190905/yM4FKbnk/index.m3u8");
downloadQueue.setMovie_title("摩羯阿婆");
downloadQueue.setMovie_num_index(1);
downloadQueue.setMovie_num_title("第一集");
downloadQueue.setState(JDDownloadQueueState.STATE_DOWNLOAD_QUEUE);
downloadQueue.setState(JDDownloadQueueState.STATE_DOWNLOAD_QUEUE);//这个比较终于要

String PATH_MOVIE = JDM3U8FileCacheUtils.createRootDownloadPath(MainActivity.this) + File.separator + "download" + File.separator + "movie" + File.separator;

Expand Down
1 change: 1 addition & 0 deletions jdm3u8downloader/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
37 changes: 37 additions & 0 deletions jdm3u8downloader/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"


defaultConfig {
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
//
api 'com.zhy:okhttputils:2.6.2'
api 'com.squareup.okhttp3:okhttp:3.2.0'
}
Empty file.
21 changes: 21 additions & 0 deletions jdm3u8downloader/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.onedream.jdm3u8downloader;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();

assertEquals("com.onedream.jdm3u8downloader.test", appContext.getPackageName());
}
}
2 changes: 2 additions & 0 deletions jdm3u8downloader/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.onedream.jdm3u8downloader" />
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.onedream.m3u8downloader;
package com.onedream.jdm3u8downloader;

import android.os.AsyncTask;
import android.os.ConditionVariable;
import android.text.TextUtils;

import androidx.annotation.NonNull;

import com.onedream.m3u8downloader.base.JDM3U8BaseDownloader;
import com.onedream.m3u8downloader.bean.JDDownloadMessage;
import com.onedream.m3u8downloader.bean.JDDownloadProgress;
import com.onedream.m3u8downloader.bean.JDDownloadQueue;
import com.onedream.m3u8downloader.bean.JDM3U8SingleRateUrlBean;
import com.onedream.m3u8downloader.bean.JDM3U8TsBean;
import com.onedream.m3u8downloader.common.JDDownloadQueueState;
import com.onedream.m3u8downloader.common.JDM3U8DownloadHintMessage;
import com.onedream.m3u8downloader.common.JDM3U8TsDownloadState;
import com.onedream.m3u8downloader.listener.JDM3U8DownloaderContract;
import com.onedream.m3u8downloader.listener.JDM3U8DownloaderFileCallBack;
import com.onedream.m3u8downloader.utils.JDM3U8FileCacheUtils;
import com.onedream.m3u8downloader.utils.JDM3U8LogHelper;
import com.onedream.jdm3u8downloader.base.JDM3U8BaseDownloader;
import com.onedream.jdm3u8downloader.bean.JDDownloadMessage;
import com.onedream.jdm3u8downloader.bean.JDDownloadProgress;
import com.onedream.jdm3u8downloader.bean.JDDownloadQueue;
import com.onedream.jdm3u8downloader.bean.JDM3U8SingleRateUrlBean;
import com.onedream.jdm3u8downloader.bean.JDM3U8TsBean;
import com.onedream.jdm3u8downloader.common.JDDownloadQueueState;
import com.onedream.jdm3u8downloader.common.JDM3U8DownloadHintMessage;
import com.onedream.jdm3u8downloader.common.JDM3U8TsDownloadState;
import com.onedream.jdm3u8downloader.listener.JDM3U8DownloaderContract;
import com.onedream.jdm3u8downloader.listener.JDM3U8DownloaderFileCallBack;
import com.onedream.jdm3u8downloader.utils.JDM3U8FileCacheUtils;
import com.onedream.jdm3u8downloader.utils.JDM3U8LogHelper;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

Expand Down Expand Up @@ -283,6 +283,11 @@ public void pauseDownload() {
}

public void startDownload() {
super.startDownloadMultiRateM3U8(downloadQueue.getMovie_download_url());
if (downloadQueue.isSingleRate()) {
super.startDownloadSingleRateM3U8(downloadQueue.getMovie_download_url());
} else {
super.startDownloadMultiRateM3U8(downloadQueue.getMovie_download_url());
}

}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.onedream.m3u8downloader;
package com.onedream.jdm3u8downloader;

import android.os.AsyncTask;

import com.onedream.m3u8downloader.base.JDM3U8BaseDownloader;
import com.onedream.m3u8downloader.bean.JDM3U8SingleRateUrlBean;
import com.onedream.m3u8downloader.bean.JDM3U8TsBean;
import com.onedream.m3u8downloader.common.JDM3U8TsDownloadState;
import com.onedream.m3u8downloader.utils.JDM3U8LogHelper;
import com.onedream.jdm3u8downloader.base.JDM3U8BaseDownloader;
import com.onedream.jdm3u8downloader.bean.JDM3U8SingleRateUrlBean;
import com.onedream.jdm3u8downloader.bean.JDM3U8TsBean;
import com.onedream.jdm3u8downloader.common.JDM3U8TsDownloadState;
import com.onedream.jdm3u8downloader.utils.JDM3U8LogHelper;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.onedream.m3u8downloader.base;
package com.onedream.jdm3u8downloader.base;


import android.text.TextUtils;

import androidx.annotation.NonNull;

import com.onedream.m3u8downloader.common.JDM3U8DownloadHintMessage;
import com.onedream.m3u8downloader.bean.JDM3U8SingleRateUrlBean;
import com.onedream.m3u8downloader.bean.JDM3U8TsBean;
import com.onedream.m3u8downloader.listener.JDM3U8DownloaderContract;
import com.onedream.m3u8downloader.utils.JDM3U8AnalysisUtils;
import com.onedream.m3u8downloader.utils.JDM3U8FileCacheUtils;
import com.onedream.jdm3u8downloader.common.JDM3U8DownloadHintMessage;
import com.onedream.jdm3u8downloader.bean.JDM3U8SingleRateUrlBean;
import com.onedream.jdm3u8downloader.bean.JDM3U8TsBean;
import com.onedream.jdm3u8downloader.listener.JDM3U8DownloaderContract;
import com.onedream.jdm3u8downloader.utils.JDM3U8AnalysisUtils;
import com.onedream.jdm3u8downloader.utils.JDM3U8FileCacheUtils;

import java.io.File;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onedream.m3u8downloader.bean;
package com.onedream.jdm3u8downloader.bean;

/**
* @author jdallen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.onedream.m3u8downloader.bean;
package com.onedream.jdm3u8downloader.bean;

import com.onedream.m3u8downloader.common.JDDownloadQueueState;
import com.onedream.jdm3u8downloader.common.JDDownloadQueueState;

/**
* @author jdallen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.onedream.m3u8downloader.bean;
package com.onedream.jdm3u8downloader.bean;

import com.onedream.m3u8downloader.common.JDDownloadQueueState;
import com.onedream.jdm3u8downloader.common.JDDownloadQueueState;

/**
* 下载队列实体
* 下载队列实体
*
* @author jdallen
* @since 2020/4/3
*/
public class JDDownloadQueue {
private boolean isSingleRate = true;//默认为但码率的
private long movie_id;
private int movie_num_index;
private String movie_title;
Expand Down Expand Up @@ -36,6 +38,14 @@ public JDDownloadQueue(long movie_id, int movie_num_index, String movie_title, S
this.state = state;
}

public boolean isSingleRate() {
return isSingleRate;
}

public void setSingleRate(boolean singleRate) {
isSingleRate = singleRate;
}

public long getMovie_id() {
return movie_id;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.onedream.m3u8downloader.bean;
package com.onedream.jdm3u8downloader.bean;

import android.text.TextUtils;


import com.onedream.m3u8downloader.utils.JDM3U8FileCacheUtils;
import com.onedream.m3u8downloader.utils.JDM3U8AnalysisUtils;
import com.onedream.m3u8downloader.utils.JDM3U8LogHelper;
import com.onedream.jdm3u8downloader.utils.JDM3U8FileCacheUtils;
import com.onedream.jdm3u8downloader.utils.JDM3U8AnalysisUtils;
import com.onedream.jdm3u8downloader.utils.JDM3U8LogHelper;

import java.io.File;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.onedream.m3u8downloader.bean;
package com.onedream.jdm3u8downloader.bean;


import com.onedream.m3u8downloader.utils.JDM3U8AnalysisUtils;
import com.onedream.m3u8downloader.utils.JDM3U8LogHelper;
import com.onedream.jdm3u8downloader.utils.JDM3U8AnalysisUtils;
import com.onedream.jdm3u8downloader.utils.JDM3U8LogHelper;

/**
* @author jdallen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onedream.m3u8downloader.common;
package com.onedream.jdm3u8downloader.common;

/**
* @author jdallen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onedream.m3u8downloader.common;
package com.onedream.jdm3u8downloader.common;

/**
* @author jdallen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onedream.m3u8downloader.common;
package com.onedream.jdm3u8downloader.common;

import androidx.annotation.IntDef;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.onedream.m3u8downloader.listener;
package com.onedream.jdm3u8downloader.listener;


import com.onedream.m3u8downloader.bean.JDDownloadMessage;
import com.onedream.m3u8downloader.bean.JDDownloadProgress;
import com.onedream.m3u8downloader.bean.JDDownloadQueue;
import com.onedream.jdm3u8downloader.bean.JDDownloadMessage;
import com.onedream.jdm3u8downloader.bean.JDDownloadProgress;
import com.onedream.jdm3u8downloader.bean.JDDownloadQueue;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.onedream.m3u8downloader.listener;
package com.onedream.jdm3u8downloader.listener;


import com.onedream.m3u8downloader.utils.JDM3U8CloseUtils;
import com.onedream.jdm3u8downloader.utils.JDM3U8CloseUtils;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.Callback;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onedream.m3u8downloader.utils;
package com.onedream.jdm3u8downloader.utils;

import android.text.TextUtils;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onedream.m3u8downloader.utils;
package com.onedream.jdm3u8downloader.utils;

import java.io.Closeable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onedream.m3u8downloader.utils;
package com.onedream.jdm3u8downloader.utils;

import android.content.Context;
import android.os.Environment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onedream.m3u8downloader.utils;
package com.onedream.jdm3u8downloader.utils;

import android.util.Log;

Expand Down
Loading

0 comments on commit 2d5eb84

Please sign in to comment.