Skip to content

Commit 7f65423

Browse files
authored
Merge pull request #3 from SuperXFan/develop
Develop
2 parents 010faab + b2f350c commit 7f65423

File tree

115 files changed

+1174
-359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1174
-359
lines changed

.idea/gradle.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
apply plugin: 'com.android.application'
2-
apply plugin: 'com.neenbedankt.android-apt' // 注释处理
2+
//apply plugin: 'com.neenbedankt.android-apt' // 注释处理
33

44
android {
5-
compileSdkVersion 25
6-
buildToolsVersion "25.0.2"
5+
compileSdkVersion COMPILE_SDK_VERSION.toInteger()
6+
buildToolsVersion SUPPORT_VERSION
77
defaultConfig {
88
applicationId "cc.ewell.baseframe"
9-
minSdkVersion 15
10-
targetSdkVersion 22
11-
versionCode Integer.parseInt(project.VERSION_CODE)
12-
versionName project.VERSION_NAME
9+
minSdkVersion MIN_SDK_VERSION.toInteger()
10+
targetSdkVersion TARGET_SDT_VERSION.toInteger()
11+
versionCode VERSION_CODE.toInteger()
12+
versionName VERSION_NAME
1313
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1414

1515
multiDexEnabled true
1616

1717
ndk {
1818
abiFilters "armeabi", "armeabi-v7a", "x86_64"
1919
}
20+
21+
javaCompileOptions {
22+
annotationProcessorOptions {
23+
includeCompileClasspath = true//annotationProcessor 注解需要 dagger
24+
arguments = [ moduleName : project.getName() ]//arouter每个module需要
25+
}
26+
}
2027
}
2128

2229
lintOptions{
@@ -44,30 +51,35 @@ android {
4451
dexOptions {
4552
javaMaxHeapSize "1g"
4653
}
54+
buildToolsVersion '27.0.3'
4755
}
4856

4957
dependencies {
50-
compile fileTree(include: ['*.jar'], dir: 'libs')
58+
implementation fileTree(include: ['*.jar'], dir: 'libs')
5159
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
5260
exclude group: 'com.android.support', module: 'support-annotations'
5361
})
5462
testCompile 'junit:junit:4.12'
5563

56-
compile project(':common')
64+
implementation project(':common')
65+
implementation project(':login')
5766

5867
// Dagger
5968
//必须配置,dagger缺少 javax.annotation包
60-
compile 'com.android.support:multidex:1.0.0'
61-
compile 'com.google.dagger:dagger:2.7'
62-
// compile 'com.android.support:appcompat-v7:23.4.0'
63-
testCompile 'junit:junit:4.12'
64-
apt 'com.google.dagger:dagger-compiler:2.7'
69+
implementation 'com.android.support:multidex:1.0.0'
70+
annotationProcessor 'com.google.dagger:dagger-compiler:2.7'
71+
implementation 'com.google.dagger:dagger:2.7'
6572
provided 'javax.annotation:jsr250-api:1.0'
6673
provided 'javax.annotation:javax.annotation-api:1.3'
6774
//必须配置,dagger缺少 javax.annotation包
6875
provided 'org.projectlombok:lombok:1.16.2'
69-
compile 'com.android.support:multidex:1.0.0'
70-
compile 'com.google.dagger:dagger:2.7'
76+
implementation 'com.android.support:multidex:1.0.0'
77+
implementation 'com.google.dagger:dagger:2.7'
78+
79+
//butterknife
80+
implementation 'com.jakewharton:butterknife:8.4.0'
81+
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
7182

72-
compile 'com.jakewharton:butterknife:7.0.1'
83+
//arouter每个module需要
84+
annotationProcessor 'com.alibaba:arouter-compiler:1.1.4'
7385
}

app/proguard-rules.pro

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,10 @@
318318
<init>(android.view.View);
319319
}
320320

321+
#ARouter
322+
-keep public class com.alibaba.android.arouter.routes.**{*;}
323+
-keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}
324+
# 如果使用了 byType 的方式获取 Service,需添加下面规则,保护接口
325+
-keep interface * implements com.alibaba.android.arouter.facade.template.IProvider
326+
# 如果使用了 单类注入,即不定义接口实现 IProvider,需添加下面规则,保护实现
327+
-keep class * implements com.alibaba.android.arouter.facade.template.IProvider

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="cc.ewell.baseframe">
44

5+
<uses-permission android:name="android.permission.INTERNET" />
6+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7+
58
<application
69
android:name="cc.ewell.baseframe.EApplication"
710
android:allowBackup="true"
@@ -14,26 +17,8 @@
1417

1518

1619
<!-- 下面是APP中自己写的Activity -->
17-
<!-- ************************* Fan Start **************************** -->
18-
<activity
19-
android:name="cc.ewell.baseframe.ui.login.LoginActivity"
20-
android:screenOrientation="portrait"
21-
android:theme="@style/AppTheme.Fullscreen"
22-
android:windowSoftInputMode="adjustPan|stateHidden" />
23-
2420

2521
<!-- ************************* Super Fan Start **************************** -->
26-
<activity
27-
android:name="cc.ewell.baseframe.ui.splash.SplashActivity"
28-
android:screenOrientation="portrait"
29-
android:theme="@style/AppTheme.Fullscreen">
30-
<intent-filter>
31-
<action android:name="android.intent.action.MAIN" />
32-
33-
<category android:name="android.intent.category.LAUNCHER" />
34-
</intent-filter>
35-
</activity>
36-
<!-- ************************* DC Start **************************** -->
3722

3823

3924
</application>

app/src/main/java/cc/ewell/baseframe/EApplication.java

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
import android.content.pm.ApplicationInfo;
66
import android.support.multidex.MultiDex;
77

8+
import com.alibaba.android.arouter.launcher.ARouter;
9+
10+
import cc.ewell.common.AppConfig;
11+
import cc.ewell.common.ApplicationComponent;
12+
import cc.ewell.common.ApplicationModule;
13+
import cc.ewell.common.BaseApp;
14+
815

916
/**
1017
* Created by fan on 2016/8/9.
1118
*/
12-
public class EApplication extends Application{
19+
public class EApplication extends BaseApp{
1320

14-
private ApplicationComponent mApplicationComponent;
15-
1621
@Override
1722
protected void attachBaseContext(Context base) {
1823
super.attachBaseContext(base);
@@ -22,29 +27,27 @@ protected void attachBaseContext(Context base) {
2227
@Override
2328
public void onCreate() {
2429
super.onCreate();
25-
initInjector();
26-
}
2730

31+
// 初始化 ARouter
32+
if (isDebug()) { // 这两行必须写在init之前,否则这些配置在init过程中将无效
33+
ARouter.openLog(); // 打印日志
34+
ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
35+
}
36+
ARouter.init(this);
2837

29-
/**
30-
* 连接器初始化
31-
*/
32-
private void initInjector() {
33-
mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build();
34-
mApplicationComponent.inject(this);
38+
//初始化
39+
initModuleApp(this);
40+
initModuleData(this);
3541
}
3642

37-
3843
/**
39-
* 获取Component
40-
*
44+
* 判断是否在debug模式
4145
* @return
4246
*/
43-
public ApplicationComponent getApplicationComponent() {
44-
return mApplicationComponent;
47+
private boolean isDebug() {
48+
return BuildConfig.DEBUG;
4549
}
4650

47-
4851
/**
4952
* 判断当前应用是否处于Debug模式
5053
*
@@ -61,4 +64,43 @@ public boolean isApplicationDebuggable() {
6164
}
6265

6366

67+
/**
68+
* Application 初始化
69+
*/
70+
@Override
71+
public void initModuleApp(Application application) {
72+
for (String moduleApp : AppConfig.moduleApps) {
73+
try {
74+
Class clazz = Class.forName(moduleApp);
75+
BaseApp baseApp = (BaseApp) clazz.newInstance();
76+
baseApp.initModuleApp(this);
77+
} catch (ClassNotFoundException e) {
78+
e.printStackTrace();
79+
} catch (IllegalAccessException e) {
80+
e.printStackTrace();
81+
} catch (InstantiationException e) {
82+
e.printStackTrace();
83+
}
84+
}
85+
}
86+
87+
/**
88+
* 所有 Application 初始化后的自定义操作
89+
*/
90+
@Override
91+
public void initModuleData(Application application) {
92+
for (String moduleApp : AppConfig.moduleApps) {
93+
try {
94+
Class clazz = Class.forName(moduleApp);
95+
BaseApp baseApp = (BaseApp) clazz.newInstance();
96+
baseApp.initModuleData(this);
97+
} catch (ClassNotFoundException e) {
98+
e.printStackTrace();
99+
} catch (IllegalAccessException e) {
100+
e.printStackTrace();
101+
} catch (InstantiationException e) {
102+
e.printStackTrace();
103+
}
104+
}
105+
}
64106
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
业务部分

app/src/main/java/cc/ewell/baseframe/constants/Constant.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77
*/
88
public class Constant {
99

10-
// SharedPreference 文件名
11-
public static final String SHARED_PREFERENCE_NAME = "baseframe_share_preference_path";
1210
}

app/src/main/java/cc/ewell/baseframe/constants/DBConstant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
public class DBConstant {
99

1010

11-
public static final String DATA_BASE_NAME = "cloud_doctor.db";
11+
public static final String DATA_BASE_NAME = "baseframe.db";
1212

1313
}

0 commit comments

Comments
 (0)