Skip to content

Commit aaa1edd

Browse files
committed
feat: 初步完成本框架的功能
1 parent 574a514 commit aaa1edd

14 files changed

Lines changed: 110 additions & 17 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ plugins {
44
}
55

66
android {
7-
compileSdk 30
7+
compileSdk 31
88

99
defaultConfig {
1010
applicationId "com.fee.start"
1111
minSdk 21
12-
targetSdk 30
12+
targetSdk 31
1313
versionCode 1
1414
versionName "1.0"
1515

app/src/main/AndroidManifest.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
android:name=".MyApp"
1616
tools:targetApi="31" >
1717
<activity android:name=".HostProxyActivity" />
18+
19+
<activity android:name=".MainActivity"
20+
android:exported="true">
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
<category android:name="android.intent.category.LAUNCHER" />
24+
</intent-filter>
25+
</activity>
1826
</application>
1927

2028
</manifest>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.fee.start
2+
3+
import android.os.Bundle
4+
import androidx.appcompat.app.AppCompatActivity
5+
6+
/**
7+
******************(^_^)***********************<br>
8+
* Author: fee(QQ/WeiXin:1176610771)<br>
9+
* Date: 2023/3/12<br>
10+
* Time: 20:07<br>
11+
* <P>DESC:
12+
*
13+
* </p>
14+
* ******************(^_^)***********************
15+
*/
16+
class MainActivity: AppCompatActivity() {
17+
override fun onCreate(savedInstanceState: Bundle?) {
18+
super.onCreate(savedInstanceState)
19+
setContentView(R.layout.activity_main)
20+
}
21+
}

app/src/main/java/com/fee/start/MyApp.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
import com.github.androidstartup.StartupTasksManager;
1111
import com.github.androidstartup.StartupTasksOrganizer;
1212

13+
import java.util.concurrent.ArrayBlockingQueue;
14+
import java.util.concurrent.Executor;
15+
import java.util.concurrent.SynchronousQueue;
16+
import java.util.concurrent.ThreadPoolExecutor;
17+
import java.util.concurrent.TimeUnit;
18+
1319
/**
1420
* *****************(^_^)***********************<br>
1521
* User: fee(QQ/WeiXin:1176610771)<br>
@@ -24,22 +30,27 @@ public class MyApp extends Application {
2430
@Override
2531
public void onCreate() {
2632
super.onCreate();
33+
Executor executor = new ThreadPoolExecutor(1,3,1, TimeUnit.MINUTES,
34+
new SynchronousQueue<>()
35+
);
2736
StartupTasksManager.Builder
2837
.addTask(new Task1())
2938
.addTask(new Task5())
3039
.addTask(new Task3())
3140
.addTask(new Task2())
3241
.addTask(new Task4())
42+
.withTaskExecutor(executor)
43+
.withContext(this)
3344
.startUp();
3445

35-
new StartupTasksOrganizer.TasksBuilder()
36-
.addTask(new Task1())
37-
.addTask(new Task5())
38-
.addTask(new Task3())
39-
.addTask(new Task2())
40-
.addTask(new Task4())
41-
.build(this)
42-
.startUp();
46+
// new StartupTasksOrganizer.TasksBuilder()
47+
// .addTask(new Task1())
48+
// .addTask(new Task5())
49+
// .addTask(new Task3())
50+
// .addTask(new Task2())
51+
// .addTask(new Task4())
52+
// .build(this)
53+
// .startUp();
4354

4455

4556
}

app/src/main/java/com/fee/start/tasks/Task2.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.fee.start.tasks
33
import android.content.Context
44
import com.github.androidstartup.AStartupTask
55
import com.github.androidstartup.IStartupTask
6+
import java.util.concurrent.Executor
67

78
/**
89
******************(^_^)***********************<br>
@@ -24,6 +25,20 @@ class Task2: AStartupTask<Int>() {
2425
return 0
2526
}
2627

28+
/**
29+
* 标识启动任务是否依赖主线程的执行
30+
*/
31+
override fun isDependonMainThread(): Boolean {
32+
return false
33+
}
34+
35+
/**
36+
* 启动任务所依赖的任务 执行器 [Executor]
37+
*/
38+
override fun dependonTaskExecutor(): Executor? {
39+
return null
40+
}
41+
2742
override fun dependentTask(): List<Class<out IStartupTask<*>>>? {
2843
return listOf(Task1::class.java)
2944
}

app/src/main/java/com/fee/start/tasks/Task3.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ class Task3: AStartupTask<Int>() {
2424
return 0
2525
}
2626

27+
/**
28+
* 标识启动任务是否依赖主线程的执行
29+
*/
30+
override fun isDependonMainThread(): Boolean {
31+
return false
32+
}
33+
2734
override fun dependentTask(): List<Class<out IStartupTask<*>>>? {
2835
return listOf(Task1::class.java)
2936
}

app/src/main/java/com/fee/start/tasks/Task4.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ class Task4: AStartupTask<Int>() {
2424
return 0
2525
}
2626

27+
/**
28+
* 标识启动任务是否依赖主线程的执行
29+
*/
30+
override fun isDependonMainThread(): Boolean {
31+
return false
32+
}
33+
2734
override fun dependentTask(): List<Class<out IStartupTask<*>>>? {
28-
return listOf(Task1::class.java)
35+
return listOf(Task2::class.java)
2936
}
3037
}

app/src/main/java/com/fee/start/tasks/Task5.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ class Task5: AStartupTask<Int>() {
2424
return 0
2525
}
2626

27+
/**
28+
* 标识启动任务是否依赖主线程的执行
29+
*/
30+
override fun isDependonMainThread(): Boolean {
31+
return true
32+
}
33+
2734
override fun dependentTask(): List<Class<out IStartupTask<*>>>? {
28-
return listOf(Task1::class.java)
35+
return listOf(Task3::class.java,Task4::class.java)
2936
}
3037
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent">
5+
6+
</androidx.constraintlayout.widget.ConstraintLayout>

theAndroidStartup/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ plugins {
44
}
55

66
android {
7-
compileSdk 30
7+
compileSdk 31
88

99
defaultConfig {
1010
minSdk 21
11-
targetSdk 30
11+
targetSdk 31
1212

1313
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1414
consumerProguardFiles "consumer-rules.pro"

0 commit comments

Comments
 (0)