Skip to content

Commit 2c3cb62

Browse files
committed
Merge branch 'tasks'
# Conflicts: # mvchelper_library/src/main/java/com/shizhefei/task/TaskHelper.java
2 parents 81b3cbb + c37a1c6 commit 2c3cb62

File tree

36 files changed

+1010
-290
lines changed

36 files changed

+1010
-290
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,16 @@ Activity负责调度,代码如下
732732
//taskHelper.destory();//执行释放操作
733733
//taskHelper.cancelAll();//取消全部
734734

735+
## 4.结构
736+
task 任务,子类IAsyncTask异步任务,ITask同步任务
737+
ICallback task开始、progress、结果的事件回调
738+
ResponseSender 用于task执行的结果通知给ICallback
739+
TaskExecutor task执行者,实现类SyncDataSourceExecutor,AsyncDataSourceExecutor,SyncTaskExecutor,AsyncTaskExecutor
740+
TaskExecutors 负责创建TaskExecutor
741+
TaskHelper 执行多个TaskExecutor
742+
743+
taskHelper 调用TaskExecutors创建TaskExecutor,TaskExecutor执行task,通过ResponseSender通知ICallback
744+
735745
## 注意:
736746
1.权限:
737747
android.permission.INTERNET

app/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 25
5-
buildToolsVersion "25.0.0"
5+
buildToolsVersion '27.0.3'
66

77
defaultConfig {
88
applicationId "com.shizhefei.mvc.demo"
@@ -55,7 +55,7 @@ dependencies {
5555
compile project(':mvchelper_testcase')
5656
compile project(':mvccoolhelper')
5757

58-
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
59-
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
60-
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
58+
compile 'com.squareup.leakcanary:leakcanary-android:1.5'
59+
// releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
60+
// testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
6161
}

app/src/main/java/com/shizhefei/test/controllers/MainActivity.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@
2121
import android.util.Log;
2222
import android.view.View;
2323

24+
import com.shizhefei.mvc.RequestHandle;
25+
import com.shizhefei.mvc.ResponseSender;
2426
import com.shizhefei.task.Code;
27+
import com.shizhefei.task.IAsyncTask;
2528
import com.shizhefei.task.ICallback;
2629
import com.shizhefei.task.TaskHandle;
2730
import com.shizhefei.task.TaskHelper;
31+
import com.shizhefei.task.function.Func1;
2832
import com.shizhefei.task.imp.MemoryCacheStore;
33+
import com.shizhefei.task.tasks.LinkTask;
34+
import com.shizhefei.task.tasks.Tasks;
2935
import com.shizhefei.test.controllers.mvchelpers.CoolActivity;
3036
import com.shizhefei.test.controllers.mvchelpers.NormalActivity;
3137
import com.shizhefei.test.controllers.mvchelpers.PullrefshActivity;
@@ -214,7 +220,7 @@ public void onClickTaskDemo(View view) {
214220
* @param view
215221
*/
216222
public void onClickTaskOpDemo(View view) {
217-
startActivity(new Intent(getApplicationContext(), TaskOpActivity.class));
223+
startActivity(new Intent(getApplicationContext(), TaskOpActivity.class));
218224
}
219225

220226

build.gradle

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ buildscript {
66
// maven {
77
// url "https://plugins.gradle.org/m2/"
88
// }
9+
google()
910
}
1011
dependencies {
11-
classpath 'com.android.tools.build:gradle:2.2.3'
12-
classpath 'com.novoda:bintray-release:0.3.4'
12+
classpath 'com.android.tools.build:gradle:3.1.4'
1313
// classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.9"
1414
// NOTE: Do not place your application dependencies here; they belong
1515
// in the individual module build.gradle files
@@ -19,6 +19,7 @@ buildscript {
1919
allprojects {
2020
repositories {
2121
jcenter()
22+
google()
2223
}
2324
}
2425

mvccoolhelper/build.gradle

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
apply plugin: 'com.android.library'
2-
apply plugin: 'com.novoda.bintray-release'//添加
32

43
android {
5-
compileSdkVersion 23
6-
buildToolsVersion "23.0.3"
4+
compileSdkVersion 25
5+
buildToolsVersion '27.0.3'
76

87
defaultConfig {
98
minSdkVersion 9
@@ -26,16 +25,16 @@ android {
2625
dependencies {
2726
compile fileTree(include: ['*.jar'], dir: 'libs')
2827
provided 'com.shizhefei:CoolRefreshView:1.0.1'
29-
provided 'com.android.support:support-v4:23.4.0'
28+
provided 'com.android.support:support-v4:25.0.1'
3029
compile project(':mvchelper_library')
3130
}
3231

33-
//添加
34-
publish {
35-
userOrg = 'luckyjayce'//bintray.com用户名
36-
groupId = 'com.shizhefei'//jcenter上的路径
37-
artifactId = 'MVCHelper-CoolRefresh'//项目名称
38-
publishVersion = rootProject.ext.VERSION_NAME//版本号
39-
desc = '实现下拉刷新,滚动底部自动加载更多,分页加载,自动切换显示网络失败布局,暂无数据布局,支持任意view,支持切换主流下拉刷新框架,真正的android MVC架构,listview,RecyclerView,refresh,loadmore'//描述,不重要
40-
website = 'https://github.com/LuckyJayce/MVCHelper'//网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了
41-
}
32+
////添加
33+
//publish {
34+
// userOrg = 'luckyjayce'//bintray.com用户名
35+
// groupId = 'com.shizhefei'//jcenter上的路径
36+
// artifactId = 'MVCHelper-CoolRefresh'//项目名称
37+
// publishVersion = rootProject.ext.VERSION_NAME//版本号
38+
// desc = '实现下拉刷新,滚动底部自动加载更多,分页加载,自动切换显示网络失败布局,暂无数据布局,支持任意view,支持切换主流下拉刷新框架,真正的android MVC架构,listview,RecyclerView,refresh,loadmore'//描述,不重要
39+
// website = 'https://github.com/LuckyJayce/MVCHelper'//网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了
40+
//}

mvchelper_library/build.gradle

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
apply plugin: 'com.android.library'
2-
apply plugin: 'com.novoda.bintray-release'//添加
32
android {
4-
compileSdkVersion 24
5-
buildToolsVersion "23.0.3"
3+
compileSdkVersion 25
4+
buildToolsVersion '27.0.3'
65

76
defaultConfig {
87
minSdkVersion 9
@@ -25,15 +24,15 @@ android {
2524
dependencies {
2625
compile fileTree(include: ['*.jar'], dir: 'libs')
2726
testCompile 'junit:junit:4.12'
28-
provided 'com.android.support:recyclerview-v7:24.0.0'
27+
provided 'com.android.support:recyclerview-v7:25.0.1'
2928
}
3029

31-
//添加
32-
publish {
33-
userOrg = 'luckyjayce'//bintray.com用户名
34-
groupId = 'com.shizhefei'//jcenter上的路径
35-
artifactId = 'MVCHelper-Library'//项目名称
36-
publishVersion = rootProject.ext.VERSION_NAME//版本号
37-
desc = '实现下拉刷新,滚动底部自动加载更多,分页加载,自动切换显示网络失败布局,暂无数据布局,支持任意view,支持切换主流下拉刷新框架,真正的android MVC架构,listview,RecyclerView,refresh,loadmore'//描述,不重要
38-
website = 'https://github.com/LuckyJayce/MVCHelper'//网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了
39-
}
30+
////添加
31+
//publish {
32+
// userOrg = 'luckyjayce'//bintray.com用户名
33+
// groupId = 'com.shizhefei'//jcenter上的路径
34+
// artifactId = 'MVCHelper-Library'//项目名称
35+
// publishVersion = rootProject.ext.VERSION_NAME//版本号
36+
// desc = '实现下拉刷新,滚动底部自动加载更多,分页加载,自动切换显示网络失败布局,暂无数据布局,支持任意view,支持切换主流下拉刷新框架,真正的android MVC架构,listview,RecyclerView,refresh,loadmore'//描述,不重要
37+
// website = 'https://github.com/LuckyJayce/MVCHelper'//网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了
38+
//}

mvchelper_library/src/main/java/com/shizhefei/task/TaskExecutors.java

+10-16
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.os.Handler;
44
import android.os.Looper;
5-
import android.util.Log;
65

76
import com.shizhefei.mvc.IAsyncDataSource;
87
import com.shizhefei.mvc.IDataSource;
@@ -137,11 +136,6 @@ protected DATA doInBackground(Object... params) {
137136
try {
138137
return executeImp(responseSender);
139138
} catch (Exception e) {
140-
if (e instanceof InterruptedException) {
141-
Log.d("TaskHelper", realTask.toString() + e);
142-
} else {
143-
e.printStackTrace();
144-
}
145139
responseSender.sendError(e);
146140
}
147141
return null;
@@ -394,11 +388,11 @@ public boolean isRunning() {
394388
private void onPreExecute() {
395389
if (Looper.myLooper() != Looper.getMainLooper()) {
396390
handler.post(new Runnable() {
397-
@Override
398-
public void run() {
399-
onPreExecuteMainThread();
400-
}
401-
});
391+
@Override
392+
public void run() {
393+
onPreExecuteMainThread();
394+
}
395+
});
402396
} else {
403397
onPreExecuteMainThread();
404398
}
@@ -420,11 +414,11 @@ public void run() {
420414
private void onPostExecute(final Code code, final Exception exception, final DATA data) {
421415
if (Looper.myLooper() != Looper.getMainLooper()) {
422416
handler.post(new Runnable() {
423-
@Override
424-
public void run() {
425-
onPostExecuteMainThread(code, exception, data);
426-
}
427-
});
417+
@Override
418+
public void run() {
419+
onPostExecuteMainThread(code, exception, data);
420+
}
421+
});
428422
} else {
429423
onPostExecuteMainThread(code, exception, data);
430424
}

0 commit comments

Comments
 (0)