Skip to content

Commit 8d5909f

Browse files
committed
重构为模块化
1 parent 23a3e96 commit 8d5909f

File tree

332 files changed

+4570
-1
lines changed

Some content is hidden

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

332 files changed

+4570
-1
lines changed

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ captures/
3939
.idea/gradle.xml
4040
.idea/dictionaries
4141
.idea/libraries
42+
.idea/caches
43+
.idea/misc.xml
44+
.idea/modules.xml
45+
.idea/runConfigurations.xml
46+
4247

4348
# Keystore files
4449
*.jks
@@ -53,3 +58,31 @@ google-services.json
5358
freeline.py
5459
freeline/
5560
freeline_project_description.json
61+
.idea/caches/
62+
.idea/codeStyles/Project.xml
63+
.idea/runConfigurations.xml
64+
app/.gitignore
65+
app/build.gradle
66+
app/proguard-rules.pro
67+
app/src/
68+
build.gradle
69+
gradle.properties
70+
gradle/
71+
gradlew
72+
gradlew.bat
73+
module-basic/src/main/res/drawable/
74+
module-env/libs/
75+
module-env/src/main/res/drawable/
76+
module-resource/libs/
77+
module-resource/src/main/res/mipmap-hdpi/
78+
module-resource/src/main/res/mipmap-mdpi/
79+
module-resource/src/main/res/mipmap-xhdpi/
80+
module-resource/src/main/res/mipmap-xxhdpi/
81+
module-resource/src/main/res/mipmap-xxxhdpi/
82+
module-sdk/.gitignore
83+
module-sdk/build.gradle
84+
module-sdk/proguard-rules.pro
85+
module-sdk/src/
86+
module-widget/libs/
87+
module-widget/src/main/res/drawable/
88+
settings.gradle

.idea/codeStyles/codeStyleConfig.xml

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

.idea/modules.xml

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

.idea/vcs.xml

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

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# android-cnblogs
2-
the cnblogs website android application. https://www.cnblogs.com
2+
the android application of the cnblogs website. https://www.cnblogs.com
3+

debug.keystore

2.12 KB
Binary file not shown.

dependencies.gradle

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// 项目依赖统一配置管理
2+
ext {
3+
4+
// Android 扩展配置
5+
android = [
6+
compileSdkVersion: 27,
7+
targetSdkVersion : 27,
8+
minSdkVersion : 17,
9+
supportVersion : '27.1.1'
10+
]
11+
12+
// 依赖配置
13+
dependencies = [
14+
appcompat : 'com.android.support:appcompat-v7:' + ext.android.supportVersion,
15+
design : 'com.android.support:design:' + ext.android.supportVersion,
16+
annotations : 'com.android.support:support-annotations:' + ext.android.supportVersion,
17+
cardview : 'com.android.support:cardview-v7:' + ext.android.supportVersion,
18+
rxjava : 'io.reactivex.rxjava2:rxjava:2.1.0',
19+
rxandroid : 'io.reactivex.rxjava2:rxandroid:2.0.1',
20+
butterknife : 'com.jakewharton:butterknife:9.0.0-SNAPSHOT',
21+
arouter : 'com.alibaba:arouter-api:1.3.1',
22+
eventBus : 'org.greenrobot:eventbus:3.1.1',
23+
jsoup : 'org.jsoup:jsoup:1.10.1',
24+
raeSwift : 'com.rae.swift:rae-library:1.0.1',
25+
raeOkhttpExt : 'com.squareup.okhttp3:okhttp-ext:3.9.0',
26+
raeSession : 'com.github.raee:AndroidSessionManager:1.0.0',
27+
okhttpUrlconnection: 'com.squareup.okhttp3:okhttp-urlconnection:3.9.0',
28+
retrofit : 'com.squareup.retrofit2:retrofit:2.3.0',
29+
activeandroid : 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT',
30+
retrofitRxAdapter : 'com.squareup.retrofit2:adapter-rxjava2:2.2.0',
31+
gson : 'com.google.code.gson:gson:2.8.0',
32+
bugly : 'com.tencent.bugly:crashreport_upgrade:1.3.4',
33+
rxlifecycle : 'com.trello.rxlifecycle2:rxlifecycle-android-lifecycle:2.2.1',
34+
skin : 'skin.support:skin-support:2.1.2',
35+
skinDesign : 'skin.support:skin-support-design:1.2.5',
36+
raeDesignExt : 'com.rae.widget:design-ext:1.0.1',
37+
ptr : 'in.srain.cube:ultra-ptr:1.0.11',
38+
recyclerView : 'com.github.raee:XRecyclerView:1.3.3',
39+
roundedImage : 'com.makeramen:roundedimageview:2.3.0',
40+
multidex : 'com.android.support:multidex:1.0.3',
41+
]
42+
43+
// 注解配置
44+
annotationProcessors = [
45+
butterknife: 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT',
46+
arouter : 'com.alibaba:arouter-compiler:1.1.4',
47+
]
48+
}

module-basic/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

module-basic/build.gradle

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion rootProject.ext.android.compileSdkVersion
5+
defaultConfig {
6+
minSdkVersion rootProject.ext.android.minSdkVersion
7+
targetSdkVersion rootProject.ext.android.targetSdkVersion
8+
versionCode 1
9+
versionName "1.0"
10+
}
11+
12+
buildTypes {
13+
release {
14+
minifyEnabled false
15+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
16+
}
17+
}
18+
19+
}
20+
21+
dependencies {
22+
23+
/* 基础模块尽量少依赖其他项目,造成不必要的耦合 */
24+
25+
implementation rootProject.ext.dependencies.appcompat
26+
implementation rootProject.ext.dependencies.butterknife
27+
implementation rootProject.ext.dependencies.rxlifecycle
28+
implementation rootProject.ext.dependencies.multidex
29+
30+
api(rootProject.ext.dependencies.arouter, {
31+
exclude group: 'com.android.support'
32+
})
33+
34+
35+
}

module-basic/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.rae.cnblogs.basic">
3+
4+
<application
5+
android:allowBackup="true"
6+
android:label="@string/app_name"
7+
android:supportsRtl="true" />
8+
</manifest>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.rae.cnblogs.basic;
2+
3+
import android.app.Application;
4+
import android.content.Context;
5+
import android.support.multidex.MultiDex;
6+
7+
/**
8+
* 应用程序
9+
*/
10+
public class BasicApplication extends Application {
11+
12+
@Override
13+
public void onCreate() {
14+
super.onCreate();
15+
}
16+
17+
@Override
18+
protected void attachBaseContext(Context base) {
19+
// 解决Tinker存在的BUG,一定要在这之前初始化
20+
MultiDex.install(base);
21+
super.attachBaseContext(base);
22+
}
23+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.rae.cnblogs.basic;
2+
3+
import android.content.Context;
4+
5+
/**
6+
* MVP Presenter
7+
* Created by ChenRui on 2018/4/18.
8+
*/
9+
public abstract class BasicPresenter<V extends IPresenterView> implements IPresenter {
10+
11+
private final V mView;
12+
13+
private LifecycleProvider mLifecycleProvider;
14+
15+
public BasicPresenter(V view) {
16+
this.mView = checkNotNull(view);
17+
mLifecycleProvider = new LifecycleProvider(view);
18+
}
19+
20+
public V getView() {
21+
return mView;
22+
}
23+
24+
protected Context getContext() {
25+
return mView.getContext();
26+
}
27+
28+
@Override
29+
public void start() {
30+
onStart();
31+
}
32+
33+
@Override
34+
public void destroy() {
35+
mLifecycleProvider.dispose();
36+
onDestroy();
37+
}
38+
39+
/**
40+
* 释放数据
41+
*/
42+
protected void onDestroy() {
43+
}
44+
45+
/**
46+
* 加载数据
47+
*/
48+
protected abstract void onStart();
49+
50+
/**
51+
* 检查是否为空,如果为空抛出异常
52+
*/
53+
private <T> T checkNotNull(T object) {
54+
if (object == null) {
55+
throw new NullPointerException("object is null ");
56+
}
57+
return object;
58+
}
59+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.rae.cnblogs.basic;
2+
3+
/**
4+
* 公共的Presenter接口
5+
* Created by ChenRui on 2018/4/18.
6+
*/
7+
public interface IPresenter {
8+
9+
/**
10+
* 开始加载数据
11+
*/
12+
void start();
13+
14+
/**
15+
* 释放数据
16+
*/
17+
void destroy();
18+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.rae.cnblogs.basic;
2+
3+
import android.arch.lifecycle.Lifecycle;
4+
import android.arch.lifecycle.LifecycleOwner;
5+
import android.content.Context;
6+
import android.support.annotation.NonNull;
7+
import android.support.annotation.Nullable;
8+
9+
/**
10+
* 公共的Presenter接口
11+
* Created by ChenRui on 2018/4/18.
12+
*/
13+
public interface IPresenterView extends LifecycleOwner {
14+
15+
@NonNull
16+
@Override
17+
Lifecycle getLifecycle();
18+
19+
@Nullable
20+
Context getContext();
21+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.rae.cnblogs.basic;
2+
3+
import android.arch.lifecycle.Lifecycle;
4+
import android.arch.lifecycle.LifecycleOwner;
5+
import android.support.annotation.NonNull;
6+
7+
import com.trello.lifecycle2.android.lifecycle.AndroidLifecycle;
8+
9+
import io.reactivex.Observable;
10+
import io.reactivex.disposables.CompositeDisposable;
11+
import io.reactivex.disposables.Disposable;
12+
import io.reactivex.functions.Consumer;
13+
14+
/**
15+
* 生命周期提供者,用于提供Presenter和View之间的关联
16+
*/
17+
public class LifecycleProvider {
18+
19+
// 生命周期绑定
20+
private final com.trello.rxlifecycle2.LifecycleProvider<Lifecycle.Event> mLifecycleProvider;
21+
22+
23+
@NonNull
24+
private CompositeDisposable mCompositeDisposable;
25+
26+
public LifecycleProvider(LifecycleOwner view) {
27+
this(AndroidLifecycle.createLifecycleProvider(view));
28+
}
29+
30+
public LifecycleProvider(com.trello.rxlifecycle2.LifecycleProvider<Lifecycle.Event> mLifecycleProvider) {
31+
this.mLifecycleProvider = mLifecycleProvider;
32+
mCompositeDisposable = new CompositeDisposable();
33+
}
34+
35+
/**
36+
* 关联到生命周期里面去
37+
*/
38+
public <T> Observable<T> with(Observable<T> observable) {
39+
observable = observable.doOnSubscribe(new Consumer<Disposable>() {
40+
@Override
41+
public void accept(Disposable disposable) {
42+
mCompositeDisposable.add(disposable);
43+
}
44+
});
45+
return observable.compose(mLifecycleProvider.<T>bindToLifecycle());
46+
}
47+
48+
/**
49+
* 释放所有,生命周期会自动释放
50+
*/
51+
public void dispose() {
52+
mCompositeDisposable.clear();
53+
}
54+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.rae.cnblogs.basic.activity;
2+
3+
import android.content.Context;
4+
import android.support.annotation.Nullable;
5+
import android.support.v7.app.AppCompatActivity;
6+
7+
import com.rae.cnblogs.basic.IPresenterView;
8+
9+
/**
10+
* 基类
11+
* Created by ChenRui on 2016/12/1 21:35.
12+
*/
13+
public abstract class BasicActivity extends AppCompatActivity implements IPresenterView {
14+
@Nullable
15+
@Override
16+
public Context getContext() {
17+
return this;
18+
}
19+
}

0 commit comments

Comments
 (0)