forked from iqiyi/Qigsaw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQigsawApplication.java
102 lines (79 loc) · 3.83 KB
/
QigsawApplication.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.iqiyi.qigsaw.sample;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.multidex.MultiDex;
import android.util.Log;
import com.iqiyi.android.qigsaw.core.SplitActivityLifecycleCallbacks;
import com.iqiyi.android.qigsaw.core.SplitConfiguration;
import com.iqiyi.android.qigsaw.core.Qigsaw;
import com.iqiyi.android.qigsaw.core.splitload.SplitLoad;
import com.iqiyi.android.qigsaw.core.splitreport.SplitBriefInfo;
import com.iqiyi.qigsaw.sample.downloader.SampleDownloader;
import com.iqiyi.qigsaw.sample.reporter.SampleLogger;
import com.iqiyi.qigsaw.sample.reporter.SampleSplitInstallReporter;
import com.iqiyi.qigsaw.sample.reporter.SampleSplitLoadReporter;
import com.iqiyi.qigsaw.sample.reporter.SampleSplitUninstallReporter;
import com.iqiyi.qigsaw.sample.reporter.SampleSplitUpdateReporter;
public class QigsawApplication extends Application {
// private static final String[] forbiddenWorkProcesses = {":qigsaw"};
private static final String TAG = "QigsawApplication";
private static final String[] workProcesses = {":qigsaw"};
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(base);
//Using QigsawConfig.java to get same info about splits, for example
Log.d(TAG, String.format("There are %d splits in your app!", QigsawConfig.DYNAMIC_FEATURES.length));
SplitConfiguration configuration = SplitConfiguration.newBuilder()
.splitLoadMode(SplitLoad.MULTIPLE_CLASSLOADER)
.workProcesses(workProcesses)
// .forbiddenWorkProcesses(forbiddenWorkProcesses)
.logger(new SampleLogger())
.verifySignature(true)
.loadReporter(new SampleSplitLoadReporter(this))
.installReporter(new SampleSplitInstallReporter(this))
.uninstallReporter(new SampleSplitUninstallReporter(this))
.updateReporter(new SampleSplitUpdateReporter(this))
.obtainUserConfirmationDialogClass(SampleObtainUserConfirmationDialog.class)
.build();
Qigsaw.install(this, new SampleDownloader(), configuration);
}
@Override
public void onCreate() {
super.onCreate();
Qigsaw.onApplicationCreated();
Qigsaw.registerSplitActivityLifecycleCallbacks(new SplitActivityLifecycleCallbacks() {
@Override
public void onSplitActivityCreated(@NonNull SplitBriefInfo briefInfo, @NonNull Activity activity, @Nullable Bundle savedInstanceState) {
}
@Override
public void onSplitActivityStarted(@NonNull SplitBriefInfo briefInfo, @NonNull Activity activity) {
}
@Override
public void onSplitActivityResumed(@NonNull SplitBriefInfo briefInfo, @NonNull Activity activity) {
}
@Override
public void onSplitActivityPaused(@NonNull SplitBriefInfo briefInfo, @NonNull Activity activity) {
}
@Override
public void onSplitActivityStopped(@NonNull SplitBriefInfo briefInfo, @NonNull Activity activity) {
}
@Override
public void onSplitActivitySaveInstanceState(@NonNull SplitBriefInfo briefInfo, @NonNull Activity activity, @NonNull Bundle outState) {
}
@Override
public void onSplitActivityDestroyed(@NonNull SplitBriefInfo briefInfo, @NonNull Activity activity) {
}
});
}
@Override
public Resources getResources() {
Qigsaw.onApplicationGetResources(super.getResources());
return super.getResources();
}
}