Skip to content

Commit 7301a8d

Browse files
committed
1:重新上传common、news、girls三个库。
1 parent e6070ae commit 7301a8d

66 files changed

Lines changed: 3323 additions & 4 deletions

Some content is hidden

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

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# AndroidModulePattern
22
Android项目组件化示例代码
3+
4+
博客:http://blog.csdn.net/guiying712/article/details/55213884

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ dependencies {
5656
compile project(':girls')
5757
compile project(':news')
5858
} else {
59-
//compile project(':common')
59+
compile project(':common')
6060
}
6161
//router
6262
apt "com.github.mzule.activityrouter:compiler:$rootProject.aptCompilerVersion"
-2.15 KB
Binary file not shown.

common/.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Built application files
2+
*.apk
3+
*.ap_
4+
5+
# Files for the ART/Dalvik VM
6+
*.dex
7+
8+
# Java class files
9+
*.class
10+
11+
# Generated files
12+
bin/
13+
gen/
14+
out/
15+
16+
# Gradle files
17+
.gradle/
18+
build/
19+
20+
# Local configuration file (sdk path, etc)
21+
local.properties
22+
23+
# Proguard folder generated by Eclipse
24+
proguard/
25+
26+
# Log Files
27+
*.log
28+
29+
# Android Studio Navigation editor temp files
30+
.navigation/
31+
32+
# Android Studio captures folder
33+
captures/
34+
35+
# Intellij
36+
*.iml
37+
.idea/workspace.xml
38+
.idea/vcs.xml
39+
40+
# Keystore files
41+
*.jks

common/build.gradle

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion rootProject.ext.compileSdkVersion
5+
buildToolsVersion rootProject.ext.buildToolsVersion
6+
7+
defaultConfig {
8+
minSdkVersion rootProject.ext.minSdkVersion
9+
targetSdkVersion rootProject.ext.targetSdkVersion
10+
versionCode rootProject.ext.versionCode
11+
versionName rootProject.ext.versionName
12+
}
13+
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
//Android Support
25+
compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
26+
compile "com.android.support:design:$rootProject.supportLibraryVersion"
27+
compile "com.android.support:percent:$rootProject.supportLibraryVersion"
28+
//网络请求相关
29+
compile "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
30+
compile "com.squareup.retrofit2:retrofit-mock:$rootProject.retrofitVersion"
31+
compile "com.github.franmontiel:PersistentCookieJar:$rootProject.cookieVersion"
32+
//稳定的
33+
compile "com.github.bumptech.glide:glide:$rootProject.glideVersion"
34+
compile "com.orhanobut:logger:$rootProject.loggerVersion"
35+
compile "org.greenrobot:eventbus:$rootProject.eventbusVersion"
36+
compile "com.google.code.gson:gson:$rootProject.gsonVersion"
37+
//不稳定的
38+
compile "com.github.mzule.activityrouter:activityrouter:$rootProject.routerVersion"
39+
compile "com.jude:easyrecyclerview:$rootProject.easyRecyclerVersion"
40+
}

common/libs/simple-xml-core.jar

525 KB
Binary file not shown.

common/proguard-rules.pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in D:\SDK/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.guiying.common">
3+
4+
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
5+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
6+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
7+
<uses-permission android:name="android.permission.INTERNET" />
8+
<uses-permission android:name="android.permission.WAKE_LOCK" />
9+
<uses-permission android:name="android.permission.WRITE_OWNER_DATA" />
10+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
11+
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
12+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
13+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
14+
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
15+
<uses-permission android:name="android.permission.PHONE_STATE" />
16+
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
17+
<uses-permission android:name="android.permission.CAMERA" />
18+
<uses-permission android:name="android.permission.VIBRATE" />
19+
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
20+
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
21+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
22+
<uses-permission android:name="android.permission.FLASHLIGHT" />
23+
<uses-permission android:name="android.permission.CALL_PHONE" />
24+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
25+
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
26+
<uses-permission android:name="com.videogo.open.permission.C2D_MESSAGE" />
27+
<uses-permission android:name="android.permission.GET_TASKS" />
28+
29+
<uses-feature android:name="android.hardware.camera" />
30+
<uses-feature android:name="android.hardware.camera.autofocus" />
31+
32+
<application>
33+
<!--<meta-data-->
34+
<!--android:name="com.common.loader.OkHttpGlideModule"-->
35+
<!--android:value="GlideModule" />-->
36+
37+
</application>
38+
39+
</manifest>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.guiying.common.base;
2+
3+
import android.content.Intent;
4+
import android.os.Bundle;
5+
import android.support.annotation.IdRes;
6+
import android.support.v7.app.AppCompatActivity;
7+
import android.view.View;
8+
9+
/**
10+
* <p>Activity基类 </p>
11+
*
12+
* @author 2016/12/2 17:33
13+
* @version V1.0.0
14+
* @name BaseActivity
15+
*/
16+
public abstract class BaseActivity extends AppCompatActivity {
17+
18+
/**
19+
* 处理Intent,防止开发人员没做Intent判空
20+
*/
21+
protected void handleIntent(Intent intent) {
22+
}
23+
24+
/**
25+
* 封装的findViewByID方法
26+
*/
27+
@SuppressWarnings("unchecked")
28+
protected <T extends View> T $(@IdRes int id) {
29+
return (T) super.findViewById(id);
30+
}
31+
32+
@Override
33+
protected void onCreate(Bundle savedInstanceState) {
34+
super.onCreate(savedInstanceState);
35+
BaseApplication.getIns().addActivity(this);
36+
//强制在基类Intent判空
37+
if (null != getIntent()) {
38+
handleIntent(getIntent());
39+
}
40+
}
41+
42+
@Override
43+
protected void onDestroy() {
44+
super.onDestroy();
45+
BaseApplication.getIns().finishActivity(this);
46+
}
47+
48+
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
package com.guiying.common.base;
2+
3+
import android.app.Activity;
4+
import android.app.Application;
5+
import android.content.Context;
6+
import android.content.pm.ApplicationInfo;
7+
import android.content.pm.PackageManager;
8+
import android.util.Log;
9+
10+
import com.guiying.common.utils.StringUtils;
11+
import com.guiying.common.utils.Utils;
12+
import com.orhanobut.logger.LogLevel;
13+
import com.orhanobut.logger.Logger;
14+
15+
import java.util.Stack;
16+
17+
/**
18+
* 要想使用BaseApplication,必须在组件中实现自己的Application,并且继承BaseApplication;
19+
* 组件中实现的Application必须在AndroidManifest.xml中注册,否则无法使用;
20+
* 组件的Application需置于java/debug文件夹中,不得放于主代码;
21+
* 组件中获取Context的方法必须为:Utils.getContext(),不允许其他写法;
22+
* BaseApplication主要有如下功能:
23+
* 1、全局获取Context;
24+
* 2、用来管理全局Activity;
25+
*
26+
* @author 2016/12/2 17:02
27+
* @version V1.0.0
28+
* @name BaseApplication
29+
*/
30+
public class BaseApplication extends Application {
31+
32+
private static BaseApplication sInstance;
33+
34+
private static Stack<Activity> activityStack;
35+
36+
public static BaseApplication getIns() {
37+
return sInstance;
38+
}
39+
40+
@Override
41+
public void onCreate() {
42+
super.onCreate();
43+
sInstance = this;
44+
Context context = this.getApplicationContext();
45+
Utils.init(context);
46+
if (isAppDebug(context)) {
47+
//只有debug模式才会打印日志
48+
Logger.init("Petrel").logLevel(LogLevel.FULL);
49+
} else {
50+
Logger.init("Petrel").logLevel(LogLevel.NONE);
51+
}
52+
}
53+
54+
/**
55+
* 添加指定Activity到堆栈
56+
*/
57+
public void addActivity(Activity activity) {
58+
if (activityStack == null) {
59+
activityStack = new Stack<>();
60+
}
61+
activityStack.add(activity);
62+
}
63+
64+
/**
65+
* 获取当前Activity
66+
*/
67+
public Activity currentActivity() {
68+
return activityStack.lastElement();
69+
}
70+
71+
/**
72+
* 结束当前Activity
73+
*/
74+
public void finishActivity() {
75+
Activity activity = activityStack.lastElement();
76+
finishActivity(activity);
77+
}
78+
79+
/**
80+
* 结束指定的Activity
81+
*/
82+
public void finishActivity(Activity activity) {
83+
if (activity != null) {
84+
activityStack.remove(activity);
85+
activity.finish();
86+
activity = null;
87+
}
88+
}
89+
90+
/**
91+
* 结束指定Class的Activity
92+
*/
93+
public void finishActivity(Class<?> cls) {
94+
for (Activity activity : activityStack) {
95+
if (activity.getClass().equals(cls)) {
96+
finishActivity(activity);
97+
return;
98+
}
99+
}
100+
}
101+
102+
/**
103+
* 结束全部的Activity
104+
*/
105+
public void finishAllActivity() {
106+
for (int i = 0, size = activityStack.size(); i < size; i++) {
107+
if (null != activityStack.get(i)) {
108+
activityStack.get(i).finish();
109+
}
110+
}
111+
activityStack.clear();
112+
}
113+
114+
/**
115+
* 退出应用程序
116+
*/
117+
public void exitApp(Context context) {
118+
try {
119+
finishAllActivity();
120+
android.app.ActivityManager activityMgr = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
121+
activityMgr.restartPackage(context.getPackageName());
122+
System.exit(0);
123+
} catch (Exception e) {
124+
Log.e("ActivityManager", "app exit" + e.getMessage());
125+
}
126+
}
127+
128+
/**
129+
* 判断App是否是Debug版本
130+
*
131+
* @param context 上下文
132+
* @return {@code true}: 是<br>{@code false}: 否
133+
*/
134+
public static boolean isAppDebug(Context context) {
135+
if (StringUtils.isSpace(context.getPackageName())) return false;
136+
try {
137+
PackageManager pm = context.getPackageManager();
138+
ApplicationInfo ai = pm.getApplicationInfo(context.getPackageName(), 0);
139+
return ai != null && (ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
140+
} catch (PackageManager.NameNotFoundException e) {
141+
e.printStackTrace();
142+
return false;
143+
}
144+
}
145+
146+
}

0 commit comments

Comments
 (0)