diff --git a/.gitignore b/.gitignore
index eef2d45..63fc54f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,5 +39,6 @@ captures/
.idea/vcs.xml
.idea/libraries
+
# Keystore files
*.jks
diff --git a/README.md b/README.md
index c6c57c2..438a057 100644
--- a/README.md
+++ b/README.md
@@ -5,29 +5,51 @@
 |
 |
 |
+  |
# AndroidModulePattern
+
Android项目组件化示例代码
-博客:http://blog.csdn.net/guiying712/article/details/55213884
+**Android组件化方案**:http://blog.csdn.net/guiying712/article/details/55213884
+
+**Android组件化之终极方案**:http://blog.csdn.net/guiying712/article/details/78057120
+
+1. 现在的 AndroidModulePattern 使用 阿里ARouter作为路由;
+
+2. Android组件化方案已经支持 **Fragment组件化**,使用方法请下载Demo查看;
+
+3. 本项目已适配Android Studio 3.0.1版本(Google仓库会带来一定影响)
+
+
+## 集成开发模式和组件开发模式转换
+
+**1、首先打开Android项目的 gradle.properties 文件,然后将 isModule 改为你需要的开发模式(true/false),
+然后点击 "Sync Project" 按钮同步项目;**
+
+**2、 在运行之前,请先按照图中选择一个能够运行的组件;**
+
+
+## 组件功能介绍
-### app组件功能:
-1. app组件主要用于管理其他组件;
+### app组件功能(空壳工程):
+1. 配置整个项目的Gradle脚本,例如 混淆、签名等;
2. app组件中可以初始化全局的库,例如Lib.init(this);
3. 添加 multiDex 功能
+4. 业务组件管理(组装);
-### main组件功能:
+### main组件功能(业务组件):
1. 声明应用的launcherActivity----->android.intent.category.LAUNCHER;
2. 添加SplashActivity;
3. 添加LoginActivity;
4. 添加MainActivity;
-### girls/news组件功能:
+### girls/news组件功能(业务组件):
1. 这两个组件都是业务组件,根据产品的业务逻辑独立成一个组件;
-### common组件功能:
+### common组件功能(功能组件):
1. common组件是基础库,添加一些公用的类;
2. 例如:网络请求、图片加载、工具类、base类等等;
3. 声明APP需要的uses-permission;
@@ -47,4 +69,4 @@ Android项目组件化示例代码
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
- limitations under the License.
\ No newline at end of file
+ limitations under the License.
diff --git a/build.gradle b/build.gradle
index 8eb9b72..40fe932 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,61 +1,38 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- repositories {
- jcenter()
- mavenCentral()
- }
-
+ apply from: 'versions.gradle'
+ addRepos(repositories)
dependencies {
- //classpath "com.android.tools.build:gradle:$localGradlePluginVersion"
- //$localGradlePluginVersion是gradle.properties中的数据
- classpath "com.android.tools.build:gradle:$localGradlePluginVersion"
+ /* classpath deps.android_gradle_plugin*/
+ classpath deps.android_gradle_plugin
+ classpath deps.kotlin.plugin
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
}
}
allprojects {
- repositories {
- jcenter()
- mavenCentral()
- //Add the JitPack repository
- maven { url "https://jitpack.io" }
- //支持arr包
- flatDir {
- dirs 'libs'
+ addRepos(repositories)
+ // Android dependency 'com.android.support:design' has different version for the compile (25.3.1) and runtime (25.4.0) classpath.
+ // You should manually set the same version via DependencyResolution
+ subprojects {
+ project.configurations.all {
+ resolutionStrategy.eachDependency { details ->
+ if (details.requested.group == 'com.android.support'
+ && !details.requested.name.contains('multidex')) {
+ details.useVersion "27.0.2"
+ }
+ }
}
}
+
+ // 组件缓存更新时间设置(默认每次build都更新)
+ configurations.all {
+ resolutionStrategy.cacheChangingModulesFor 0, 'minutes'
+ }
}
task clean(type: Delete) {
delete rootProject.buildDir
-}
-
-// Define versions in a single place
-//时间:2017.2.13;每次修改版本号都要添加修改时间
-ext {
- // Sdk and tools
- //localBuildToolsVersion是gradle.properties中的数据
- buildToolsVersion = localBuildToolsVersion
- compileSdkVersion = 25
- minSdkVersion = 16
- targetSdkVersion = 25
- versionCode = 1
- versionName = "1.0"
- javaVersion = JavaVersion.VERSION_1_8
-
- // App dependencies version
- supportLibraryVersion = "25.3.1"
- retrofitVersion = "2.1.0"
- glideVersion = "3.7.0"
- loggerVersion = "1.15"
- eventbusVersion = "3.0.0"
- gsonVersion = "2.8.0"
- photoViewVersion = "2.0.0"
-
- //需检查升级版本
- annotationProcessor = "1.1.7"
- routerVersion = "1.2.2"
- easyRecyclerVersion = "4.4.0"
- cookieVersion = "v1.0.1"
- toastyVersion = "1.1.3"
-}
+}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index cd29d22..9b51cd5 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -18,11 +18,9 @@ org.gradle.jvmargs=-Xmx2048m
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.parallel=true
-# ΪԶ(ΪÿĵԻһ)
-localBuildToolsVersion=25.0.3
# ֵһAndroidStudio汾һ
-localGradlePluginVersion=2.3.3
+localGradlePluginVersion=3.0.1
# ÿθġisModuleֵҪ "Sync Project" ť
# isModuleǡɿģʽ͡ģʽл
-isModule=true
+isModule=false
diff --git a/keystore.properties b/keystore.properties
new file mode 100644
index 0000000..dabd93e
--- /dev/null
+++ b/keystore.properties
@@ -0,0 +1,4 @@
+storePassword=guiying712
+keyPassword=guiying712
+keyAlias=guiying712
+storeFile=/mykey.jks
\ No newline at end of file
diff --git a/lib_common/build.gradle b/lib_common/build.gradle
index 304022c..87eb2af 100644
--- a/lib_common/build.gradle
+++ b/lib_common/build.gradle
@@ -1,37 +1,76 @@
apply plugin: 'com.android.library'
android {
- compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
-
+ compileSdkVersion build_versions.target_sdk
defaultConfig {
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode rootProject.ext.versionCode
- versionName rootProject.ext.versionName
+ minSdkVersion build_versions.min_sdk
+ targetSdkVersion build_versions.target_sdk
+ versionCode 1
+ versionName "1.0"
+ }
+
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+ buildTypes {
+ release {
+ buildConfigField "boolean", "LOG_DEBUG", "true"
+ zipAlignEnabled false
+ shrinkResources false
+ minifyEnabled false
+ debuggable true
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
}
+
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- //Android Support
- compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
- compile "com.android.support:design:$rootProject.supportLibraryVersion"
- compile "com.android.support:percent:$rootProject.supportLibraryVersion"
- //网络请求相关
- compile "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
- compile "com.squareup.retrofit2:retrofit-mock:$rootProject.retrofitVersion"
- compile "com.github.franmontiel:PersistentCookieJar:$rootProject.cookieVersion"
- //稳定的
- compile "com.github.bumptech.glide:glide:$rootProject.glideVersion"
- compile "com.orhanobut:logger:$rootProject.loggerVersion"
- compile "org.greenrobot:eventbus:$rootProject.eventbusVersion"
- compile "com.google.code.gson:gson:$rootProject.gsonVersion"
- compile "com.github.chrisbanes:PhotoView:$rootProject.photoViewVersion"
-
- compile "com.jude:easyrecyclerview:$rootProject.easyRecyclerVersion"
- compile "com.github.GrenderG:Toasty:$rootProject.toastyVersion"
+ api fileTree(include: ['*.jar'], dir: 'libs')
+ // Support libraries
+ api deps.support.app_compat
+ api deps.support.v4
+ api deps.support.v13
+ api deps.support.design
+ api deps.support.cardview
+ api deps.support.percent
+ api deps.support.recyclerview
+ api deps.constraint_layout
+
+ // RxJava and retrofit
+ api deps.rx_android
+ api deps.rxjava2
+ api deps.retrofit.runtime
+ api deps.retrofit.gson
+ api deps.persistent_cookie
+
+ //Dagger
+ api deps.dagger.runtime
+ api deps.dagger.android
+ api deps.dagger.android_support
+
+ // other
+ api deps.kotlin.stdlib
+ api deps.event_bus
+ api deps.gson
+ api deps.permission
+ api deps.utils
+ api deps.glide
+
+ //view
+ api deps.photo_view
+ api deps.easy_recycler
+ api deps.material_dialog
+ api deps.logger
+ api deps.toasty
//router
- compile "com.github.mzule.activityrouter:activityrouter:$rootProject.routerVersion"
+ api deps.arouter_api
+
+ //annotationProcessor
+ annotationProcessor deps.dagger.android_support_compiler
+ annotationProcessor deps.dagger.compiler
}
diff --git a/lib_common/src/main/AndroidManifest.xml b/lib_common/src/main/AndroidManifest.xml
index 5b1cff1..8039311 100644
--- a/lib_common/src/main/AndroidManifest.xml
+++ b/lib_common/src/main/AndroidManifest.xml
@@ -1,5 +1,5 @@
+ package="com.guiying.module.common">
@@ -16,7 +16,7 @@
diff --git a/lib_common/src/main/java/com/guiying/common/base/BaseActivity.java b/lib_common/src/main/java/com/guiying/common/base/BaseActivity.java
deleted file mode 100644
index 5e9b3f5..0000000
--- a/lib_common/src/main/java/com/guiying/common/base/BaseActivity.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.guiying.common.base;
-
-import android.os.Bundle;
-import android.support.annotation.IdRes;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.view.View;
-
-import com.guiying.common.R;
-
-/**
- * Activity基类
- *
- * @author 2016/12/2 17:33
- * @version V1.0.0
- * @name BaseActivity
- */
-public abstract class BaseActivity extends AppCompatActivity {
-
- /**
- * Setup the toolbar.
- *
- * @param toolbar toolbar
- * @param hideTitle 是否隐藏Title
- */
- protected void setupToolBar(Toolbar toolbar, boolean hideTitle) {
- setSupportActionBar(toolbar);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back);
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- if (hideTitle) {
- //隐藏Title
- actionBar.setDisplayShowTitleEnabled(false);
- }
- }
- }
-
-
- /**
- * 封装的findViewByID方法
- */
- @SuppressWarnings("unchecked")
- protected T $(@IdRes int id) {
- return (T) super.findViewById(id);
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- BaseApplication.getIns().addActivity(this);
- }
-
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- BaseApplication.getIns().finishActivity(this);
- }
-
- @Override
- public boolean onSupportNavigateUp() {
- onBackPressed();
- return true;
- }
-
-}
diff --git a/lib_common/src/main/java/com/guiying/common/base/BasePresenter.java b/lib_common/src/main/java/com/guiying/common/base/BasePresenter.java
deleted file mode 100644
index c05c925..0000000
--- a/lib_common/src/main/java/com/guiying/common/base/BasePresenter.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.guiying.common.base;
-
-public interface BasePresenter {
-
- void start();
-
-}
diff --git a/lib_common/src/main/java/com/guiying/common/base/BaseView.java b/lib_common/src/main/java/com/guiying/common/base/BaseView.java
deleted file mode 100644
index debd151..0000000
--- a/lib_common/src/main/java/com/guiying/common/base/BaseView.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.guiying.common.base;
-
-public interface BaseView {
-
- void setPresenter(T presenter);
-
-}
diff --git a/lib_common/src/main/java/com/guiying/common/base/BaseActionBarActivity.java b/lib_common/src/main/java/com/guiying/module/common/base/BaseActionBarActivity.java
similarity index 80%
rename from lib_common/src/main/java/com/guiying/common/base/BaseActionBarActivity.java
rename to lib_common/src/main/java/com/guiying/module/common/base/BaseActionBarActivity.java
index a14d93d..85c8570 100644
--- a/lib_common/src/main/java/com/guiying/common/base/BaseActionBarActivity.java
+++ b/lib_common/src/main/java/com/guiying/module/common/base/BaseActionBarActivity.java
@@ -1,17 +1,11 @@
-/*
- * @ProjectName: ISMS_Petrel_MCU
- * @Copyright: 2017 HangZhou Hikvision System Technology Co., Ltd. All Right Reserved.
- * @address: http://www.hikvision.com
- * @Description: 本内容仅限于杭州海康威视系统技术公有限司内部使用,禁止转发.
- */
-
-package com.guiying.common.base;
+package com.guiying.module.common.base;
import android.os.Bundle;
+import android.support.annotation.Keep;
import android.support.annotation.StringRes;
import android.support.v7.app.ActionBar;
-import com.guiying.common.R;
+import com.guiying.module.common.R;
/**
* BaseActionBarActivity继承于BaseActivity,封装了actionBar的逻辑;
@@ -22,6 +16,7 @@
* @version V1.2.0
* @name BaseActionBarActivity
*/
+@Keep
public abstract class BaseActionBarActivity extends BaseActivity {
/*默认的ActionBar*/
diff --git a/lib_common/src/main/java/com/guiying/module/common/base/BaseActivity.java b/lib_common/src/main/java/com/guiying/module/common/base/BaseActivity.java
new file mode 100644
index 0000000..32ffebe
--- /dev/null
+++ b/lib_common/src/main/java/com/guiying/module/common/base/BaseActivity.java
@@ -0,0 +1,157 @@
+package com.guiying.module.common.base;
+
+import android.os.Bundle;
+import android.support.annotation.IdRes;
+import android.support.annotation.Keep;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.View;
+
+import com.guiying.module.common.R;
+import com.guiying.module.common.utils.Utils;
+
+/**
+ * Activity基类
+ *
+ * @author 2016/12/2 17:33
+ * @version V1.0.0
+ * @name BaseActivity
+ */
+@Keep
+public abstract class BaseActivity extends AppCompatActivity {
+
+
+ /**
+ * 封装的findViewByID方法
+ */
+ @SuppressWarnings("unchecked")
+ protected T $(@IdRes int id) {
+ return (T) super.findViewById(id);
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ ViewManager.getInstance().addActivity(this);
+ }
+
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ ViewManager.getInstance().finishActivity(this);
+ }
+
+ @Override
+ public boolean onSupportNavigateUp() {
+ onBackPressed();
+ return true;
+ }
+
+
+ /**
+ * Setup the toolbar.
+ *
+ * @param toolbar toolbar
+ * @param hideTitle 是否隐藏Title
+ */
+ protected void setupToolBar(Toolbar toolbar, boolean hideTitle) {
+ setSupportActionBar(toolbar);
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ if (hideTitle) {
+ //隐藏Title
+ actionBar.setDisplayShowTitleEnabled(false);
+ }
+ }
+ }
+
+
+ /**
+ * 添加fragment
+ *
+ * @param fragment
+ * @param frameId
+ */
+ protected void addFragment(BaseFragment fragment, @IdRes int frameId) {
+ Utils.checkNotNull(fragment);
+ getSupportFragmentManager().beginTransaction()
+ .add(frameId, fragment, fragment.getClass().getSimpleName())
+ .addToBackStack(fragment.getClass().getSimpleName())
+ .commitAllowingStateLoss();
+
+ }
+
+
+ /**
+ * 替换fragment
+ * @param fragment
+ * @param frameId
+ */
+ protected void replaceFragment(BaseFragment fragment, @IdRes int frameId) {
+ Utils.checkNotNull(fragment);
+ getSupportFragmentManager().beginTransaction()
+ .replace(frameId, fragment, fragment.getClass().getSimpleName())
+ .addToBackStack(fragment.getClass().getSimpleName())
+ .commitAllowingStateLoss();
+
+ }
+
+
+ /**
+ * 隐藏fragment
+ * @param fragment
+ */
+ protected void hideFragment(BaseFragment fragment) {
+ Utils.checkNotNull(fragment);
+ getSupportFragmentManager().beginTransaction()
+ .hide(fragment)
+ .commitAllowingStateLoss();
+
+ }
+
+
+ /**
+ * 显示fragment
+ * @param fragment
+ */
+ protected void showFragment(BaseFragment fragment) {
+ Utils.checkNotNull(fragment);
+ getSupportFragmentManager().beginTransaction()
+ .show(fragment)
+ .commitAllowingStateLoss();
+
+ }
+
+
+ /**
+ * 移除fragment
+ * @param fragment
+ */
+ protected void removeFragment(BaseFragment fragment) {
+ Utils.checkNotNull(fragment);
+ getSupportFragmentManager().beginTransaction()
+ .remove(fragment)
+ .commitAllowingStateLoss();
+
+ }
+
+
+ /**
+ * 弹出栈顶部的Fragment
+ */
+ protected void popFragment() {
+ if (getSupportFragmentManager().getBackStackEntryCount() > 1) {
+ getSupportFragmentManager().popBackStack();
+ } else {
+ finish();
+ }
+ }
+
+
+}
diff --git a/lib_common/src/main/java/com/guiying/module/common/base/BaseApplication.java b/lib_common/src/main/java/com/guiying/module/common/base/BaseApplication.java
new file mode 100644
index 0000000..5c183ee
--- /dev/null
+++ b/lib_common/src/main/java/com/guiying/module/common/base/BaseApplication.java
@@ -0,0 +1,71 @@
+package com.guiying.module.common.base;
+
+import android.app.Application;
+
+import com.guiying.module.common.utils.Utils;
+import com.orhanobut.logger.LogLevel;
+import com.orhanobut.logger.Logger;
+
+import java.util.List;
+
+/**
+ * 要想使用BaseApplication,必须在组件中实现自己的Application,并且继承BaseApplication;
+ * 组件中实现的Application必须在debug包中的AndroidManifest.xml中注册,否则无法使用;
+ * 组件的Application需置于java/debug文件夹中,不得放于主代码;
+ * 组件中获取Context的方法必须为:Utils.getContext(),不允许其他写法;
+ *
+ * @author 2016/12/2 17:02
+ * @version V1.0.0
+ * @name BaseApplication
+ */
+public class BaseApplication extends Application {
+
+ public static final String ROOT_PACKAGE = "com.guiying.module";
+
+ private static BaseApplication sInstance;
+
+ private List mAppDelegateList;
+
+
+ public static BaseApplication getIns() {
+ return sInstance;
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ sInstance = this;
+ Logger.init("pattern").logLevel(LogLevel.FULL);
+ Utils.init(this);
+ mAppDelegateList = ClassUtils.getObjectsWithInterface(this, IApplicationDelegate.class, ROOT_PACKAGE);
+ for (IApplicationDelegate delegate : mAppDelegateList) {
+ delegate.onCreate();
+ }
+
+ }
+
+ @Override
+ public void onTerminate() {
+ super.onTerminate();
+ for (IApplicationDelegate delegate : mAppDelegateList) {
+ delegate.onTerminate();
+ }
+ }
+
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ for (IApplicationDelegate delegate : mAppDelegateList) {
+ delegate.onLowMemory();
+ }
+ }
+
+ @Override
+ public void onTrimMemory(int level) {
+ super.onTrimMemory(level);
+ for (IApplicationDelegate delegate : mAppDelegateList) {
+ delegate.onTrimMemory(level);
+ }
+ }
+}
diff --git a/lib_common/src/main/java/com/guiying/module/common/base/BaseFragment.java b/lib_common/src/main/java/com/guiying/module/common/base/BaseFragment.java
new file mode 100644
index 0000000..5ec3cb5
--- /dev/null
+++ b/lib_common/src/main/java/com/guiying/module/common/base/BaseFragment.java
@@ -0,0 +1,104 @@
+package com.guiying.module.common.base;
+
+import android.content.Context;
+import android.support.annotation.IdRes;
+import android.support.annotation.Keep;
+import android.support.v4.app.Fragment;
+
+import com.guiying.module.common.utils.Utils;
+
+/**
+ * Fragment的基类
+ *
+ * @author 张华洋
+ * @name BaseFragment
+ */
+@Keep
+public abstract class BaseFragment extends Fragment {
+
+ protected BaseActivity mActivity;
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ this.mActivity = (BaseActivity) context;
+ }
+
+
+ /**
+ * 获取宿主Activity
+ *
+ * @return BaseActivity
+ */
+ protected BaseActivity getHoldingActivity() {
+ return mActivity;
+ }
+
+
+ /**
+ * 添加fragment
+ *
+ * @param fragment
+ * @param frameId
+ */
+ protected void addFragment(BaseFragment fragment, @IdRes int frameId) {
+ Utils.checkNotNull(fragment);
+ getHoldingActivity().addFragment(fragment, frameId);
+
+ }
+
+
+ /**
+ * 替换fragment
+ *
+ * @param fragment
+ * @param frameId
+ */
+ protected void replaceFragment(BaseFragment fragment, @IdRes int frameId) {
+ Utils.checkNotNull(fragment);
+ getHoldingActivity().replaceFragment(fragment, frameId);
+ }
+
+
+ /**
+ * 隐藏fragment
+ *
+ * @param fragment
+ */
+ protected void hideFragment(BaseFragment fragment) {
+ Utils.checkNotNull(fragment);
+ getHoldingActivity().hideFragment(fragment);
+ }
+
+
+ /**
+ * 显示fragment
+ *
+ * @param fragment
+ */
+ protected void showFragment(BaseFragment fragment) {
+ Utils.checkNotNull(fragment);
+ getHoldingActivity().showFragment(fragment);
+ }
+
+
+ /**
+ * 移除Fragment
+ *
+ * @param fragment
+ */
+ protected void removeFragment(BaseFragment fragment) {
+ Utils.checkNotNull(fragment);
+ getHoldingActivity().removeFragment(fragment);
+
+ }
+
+
+ /**
+ * 弹出栈顶部的Fragment
+ */
+ protected void popFragment() {
+ getHoldingActivity().popFragment();
+ }
+
+}
diff --git a/lib_common/src/main/java/com/guiying/module/common/base/BasePresenter.java b/lib_common/src/main/java/com/guiying/module/common/base/BasePresenter.java
new file mode 100644
index 0000000..be56ad9
--- /dev/null
+++ b/lib_common/src/main/java/com/guiying/module/common/base/BasePresenter.java
@@ -0,0 +1,16 @@
+package com.guiying.module.common.base;
+
+import android.support.annotation.Keep;
+
+/**
+ * Presenter的基类
+ *
+ * @author 张华洋
+ * @name BasePresenter
+ */
+@Keep
+public interface BasePresenter {
+
+ void start();
+
+}
diff --git a/lib_common/src/main/java/com/guiying/module/common/base/BaseView.java b/lib_common/src/main/java/com/guiying/module/common/base/BaseView.java
new file mode 100644
index 0000000..e1b0b21
--- /dev/null
+++ b/lib_common/src/main/java/com/guiying/module/common/base/BaseView.java
@@ -0,0 +1,17 @@
+package com.guiying.module.common.base;
+
+
+import android.support.annotation.Keep;
+
+/**
+ * View接口的基类
+ *
+ * @author 张华洋
+ * @name BaseView
+ */
+@Keep
+public interface BaseView {
+
+ void setPresenter(T presenter);
+
+}
diff --git a/lib_common/src/main/java/com/guiying/module/common/base/ClassUtils.java b/lib_common/src/main/java/com/guiying/module/common/base/ClassUtils.java
new file mode 100644
index 0000000..7e65de6
--- /dev/null
+++ b/lib_common/src/main/java/com/guiying/module/common/base/ClassUtils.java
@@ -0,0 +1,296 @@
+package com.guiying.module.common.base;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.support.annotation.Keep;
+import android.util.Log;
+
+import com.guiying.module.common.utils.Utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import dalvik.system.DexFile;
+
+/**
+ * Copy from galaxy sdk ${com.alibaba.android.galaxy.utils.ClassUtils}
+ * Scanner, find out class with any conditions, copy from google source code.
+ */
+@Keep
+public class ClassUtils {
+ private static final String TAG = "ClassUtils";
+
+ private static final String EXTRACTED_NAME_EXT = ".classes";
+ private static final String EXTRACTED_SUFFIX = ".zip";
+
+ private static final String SECONDARY_FOLDER_NAME = "code_cache" + File.separator + "secondary-dexes";
+
+ private static final String PREFS_FILE = "multidex.version";
+ private static final String KEY_DEX_NUMBER = "dex.number";
+
+ private static final int VM_WITH_MULTIDEX_VERSION_MAJOR = 2;
+ private static final int VM_WITH_MULTIDEX_VERSION_MINOR = 1;
+
+ private static SharedPreferences getMultiDexPreferences(Context context) {
+ return context.getSharedPreferences(PREFS_FILE, Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? Context.MODE_PRIVATE : Context.MODE_PRIVATE | Context.MODE_MULTI_PROCESS);
+ }
+
+
+ /**
+ * 获取单一路径下所有实现了接口的类对象
+ *
+ * @param context U know
+ * @param clazz 接口
+ * @param path 包路径
+ * @param U know
+ * @return 对象列表
+ */
+ public static List
+ getObjectsWithInterface(Context context, Class clazz, String path) {
+ List objectList = new ArrayList<>();
+ try {
+ //找出所有路径中的类名,主要用于各个组件根包名一致的情况
+ List classFileNames = getFileNameByPackageName(context, path);
+
+ for (String className : classFileNames) {
+ Class aClass = Class.forName(className);
+ if (clazz.isAssignableFrom(aClass) && !clazz.equals(aClass) && !aClass.isInterface()) {
+ objectList.add((T) Class.forName(className).getConstructor().newInstance());
+ }
+ }
+
+ if (objectList.size() == 0) {
+ Log.e(TAG, "No files were found, check your configuration please!");
+ }
+ } catch (Exception e) {
+ e.getStackTrace();
+ Log.e(TAG, "getObjectsWithInterface error, " + e.getMessage());
+ }
+
+ return objectList;
+ }
+
+
+ /**
+ * 获取多路径下所有实现了接口的类对象
+ *
+ * @param context U know
+ * @param clazz 接口
+ * @param pathList 包路径列表
+ * @param U know
+ * @return 对象列表
+ */
+ public static List getObjectsWithInterface(Context context, Class clazz, List pathList) {
+ List objectList = new ArrayList<>();
+ try {
+ for (String path : pathList) {
+ //找出所有路径中的类名,主要用于各个组件根包名不一致的情况
+ List classFileNames = getFileNameByPackageName(context, path);
+
+ for (String className : classFileNames) {
+ Class aClass = Class.forName(className);
+ if (clazz.isAssignableFrom(aClass) && !clazz.equals(aClass) && !aClass.isInterface()) {
+ objectList.add((T) Class.forName(className).getConstructor().newInstance());
+ }
+ }
+ }
+
+ if (objectList.size() == 0) {
+ Log.e(TAG, "No files were found, check your configuration please!");
+ }
+ } catch (Exception e) {
+ e.getStackTrace();
+ Log.e(TAG, "getObjectsWithInterface error, " + e.getMessage());
+ }
+
+ return objectList;
+ }
+
+
+ /**
+ * 通过指定包名,扫描包下面包含的所有的ClassName
+ *
+ * @param context U know
+ * @param packageName 包名
+ * @return 所有class的集合
+ */
+ public static List getFileNameByPackageName(Context context, String packageName) throws PackageManager.NameNotFoundException, IOException {
+ List classNames = new ArrayList<>();
+ for (String path : getSourcePaths(context)) {
+ DexFile dexfile = null;
+
+ try {
+ if (path.endsWith(EXTRACTED_SUFFIX)) {
+ //NOT use new DexFile(path), because it will throw "permission error in /data/dalvik-cache"
+ dexfile = DexFile.loadDex(path, path + ".tmp", 0);
+ } else {
+ dexfile = new DexFile(path);
+ }
+ Enumeration dexEntries = dexfile.entries();
+ while (dexEntries.hasMoreElements()) {
+ String className = dexEntries.nextElement();
+ if (className.contains(packageName)) {
+ classNames.add(className);
+ }
+ }
+ } catch (Throwable ignore) {
+ Log.e(TAG, "Scan map file in dex files made error.", ignore);
+ } finally {
+ if (null != dexfile) {
+ try {
+ dexfile.close();
+ } catch (Throwable ignore) {
+ }
+ }
+ }
+ }
+
+ Log.d(TAG, "Filter " + classNames.size() + " classes by packageName <" + packageName + ">");
+ return classNames;
+ }
+
+ /**
+ * get all the dex path
+ *
+ * @param context the application context
+ * @return all the dex path
+ * @throws PackageManager.NameNotFoundException Exception
+ * @throws IOException Exception
+ */
+ public static List getSourcePaths(Context context) throws PackageManager.NameNotFoundException, IOException {
+ ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0);
+ File sourceApk = new File(applicationInfo.sourceDir);
+
+ List sourcePaths = new ArrayList<>();
+ sourcePaths.add(applicationInfo.sourceDir); //add the default apk path
+
+ //the prefix of extracted file, ie: test.classes
+ String extractedFilePrefix = sourceApk.getName() + EXTRACTED_NAME_EXT;
+
+ //如果VM已经支持了MultiDex,就不要去Secondary Folder加载 Classesx.zip了,那里已经么有了
+ //通过是否存在sp中的multidex.version是不准确的,因为从低版本升级上来的用户,是包含这个sp配置的
+ if (!isVMMultidexCapable()) {
+ //the total dex numbers
+ int totalDexNumber = getMultiDexPreferences(context).getInt(KEY_DEX_NUMBER, 1);
+ File dexDir = new File(applicationInfo.dataDir, SECONDARY_FOLDER_NAME);
+
+ for (int secondaryNumber = 2; secondaryNumber <= totalDexNumber; secondaryNumber++) {
+ //for each dex file, ie: test.classes2.zip, test.classes3.zip...
+ String fileName = extractedFilePrefix + secondaryNumber + EXTRACTED_SUFFIX;
+ File extractedFile = new File(dexDir, fileName);
+ if (extractedFile.isFile()) {
+ sourcePaths.add(extractedFile.getAbsolutePath());
+ //we ignore the verify zip part
+ } else {
+ throw new IOException("Missing extracted secondary dex file '" + extractedFile.getPath() + "'");
+ }
+ }
+ }
+
+ if (Utils.isAppDebug()) {
+ // Search instant run support only debuggable
+ sourcePaths.addAll(tryLoadInstantRunDexFile(applicationInfo));
+ }
+ return sourcePaths;
+ }
+
+ /**
+ * Get instant run dex path, used to catch the branch usingApkSplits=false.
+ */
+ private static List tryLoadInstantRunDexFile(ApplicationInfo applicationInfo) {
+ List instantRunSourcePaths = new ArrayList<>();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && null != applicationInfo.splitSourceDirs) {
+ // add the splite apk, normally for InstantRun, and newest version.
+ instantRunSourcePaths.addAll(Arrays.asList(applicationInfo.splitSourceDirs));
+ Log.d(TAG, "Found InstantRun support");
+ } else {
+ try {
+ // This man is reflection from Google instant run sdk, he will tell me where the dex files go.
+ Class pathsByInstantRun = Class.forName("com.android.tools.fd.runtime.Paths");
+ Method getDexFileDirectory = pathsByInstantRun.getMethod("getDexFileDirectory", String.class);
+ String instantRunDexPath = (String) getDexFileDirectory.invoke(null, applicationInfo.packageName);
+
+ File instantRunFilePath = new File(instantRunDexPath);
+ if (instantRunFilePath.exists() && instantRunFilePath.isDirectory()) {
+ File[] dexFile = instantRunFilePath.listFiles();
+ for (File file : dexFile) {
+ if (null != file && file.exists() && file.isFile() && file.getName().endsWith(".dex")) {
+ instantRunSourcePaths.add(file.getAbsolutePath());
+ }
+ }
+ Log.d(TAG, "Found InstantRun support");
+ }
+
+ } catch (Exception e) {
+ Log.e(TAG, "InstantRun support error, " + e.getMessage());
+ }
+ }
+
+ return instantRunSourcePaths;
+ }
+
+ /**
+ * Identifies if the current VM has a native support for multidex, meaning there is no need for
+ * additional installation by this library.
+ *
+ * @return true if the VM handles multidex
+ */
+ private static boolean isVMMultidexCapable() {
+ boolean isMultidexCapable = false;
+ String vmName = null;
+
+ try {
+ if (isYunOS()) { // YunOS需要特殊判断
+ vmName = "'YunOS'";
+ isMultidexCapable = Integer.valueOf(System.getProperty("ro.build.version.sdk")) >= 21;
+ } else { // 非YunOS原生Android
+ vmName = "'Android'";
+ String versionString = System.getProperty("java.vm.version");
+ if (versionString != null) {
+ Matcher matcher = Pattern.compile("(\\d+)\\.(\\d+)(\\.\\d+)?").matcher(versionString);
+ if (matcher.matches()) {
+ try {
+ int major = Integer.parseInt(matcher.group(1));
+ int minor = Integer.parseInt(matcher.group(2));
+ isMultidexCapable = (major > VM_WITH_MULTIDEX_VERSION_MAJOR)
+ || ((major == VM_WITH_MULTIDEX_VERSION_MAJOR)
+ && (minor >= VM_WITH_MULTIDEX_VERSION_MINOR));
+ } catch (NumberFormatException ignore) {
+ // let isMultidexCapable be false
+ }
+ }
+ }
+ }
+ } catch (Exception ignore) {
+
+ }
+
+ Log.i(TAG, "VM with name " + vmName + (isMultidexCapable ? " has multidex support" : " does not have multidex support"));
+ return isMultidexCapable;
+ }
+
+ /**
+ * 判断系统是否为YunOS系统
+ */
+ private static boolean isYunOS() {
+ try {
+ String version = System.getProperty("ro.yunos.version");
+ String vmName = System.getProperty("java.vm.name");
+ return (vmName != null && vmName.toLowerCase().contains("lemur"))
+ || (version != null && version.trim().length() > 0);
+ } catch (Exception ignore) {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/lib_common/src/main/java/com/guiying/module/common/base/IApplicationDelegate.java b/lib_common/src/main/java/com/guiying/module/common/base/IApplicationDelegate.java
new file mode 100644
index 0000000..1ea31b6
--- /dev/null
+++ b/lib_common/src/main/java/com/guiying/module/common/base/IApplicationDelegate.java
@@ -0,0 +1,23 @@
+package com.guiying.module.common.base;
+
+import android.support.annotation.Keep;
+
+/**
+ * 类说明
+ *
+ * @author 张华洋 2017/9/20 22:23
+ * @version V2.8.3
+ * @name ApplicationDelegate
+ */
+@Keep
+public interface IApplicationDelegate {
+
+ void onCreate();
+
+ void onTerminate();
+
+ void onLowMemory();
+
+ void onTrimMemory(int level);
+
+}
diff --git a/lib_common/src/main/java/com/guiying/module/common/base/IViewDelegate.java b/lib_common/src/main/java/com/guiying/module/common/base/IViewDelegate.java
new file mode 100644
index 0000000..3c35b8e
--- /dev/null
+++ b/lib_common/src/main/java/com/guiying/module/common/base/IViewDelegate.java
@@ -0,0 +1,21 @@
+package com.guiying.module.common.base;
+
+
+import android.support.annotation.Keep;
+import android.view.View;
+
+/**
+ * 类说明
+ *
+ * @author 张华洋 2018/1/4 22:10
+ * @version V2.8.3
+ * @name IFragmentDelegate
+ */
+@Keep
+public interface IViewDelegate {
+
+ BaseFragment getFragment(String name);
+
+ View getView(String name);
+
+}
diff --git a/lib_common/src/main/java/com/guiying/common/base/InfoCallback.java b/lib_common/src/main/java/com/guiying/module/common/base/InfoCallback.java
similarity index 72%
rename from lib_common/src/main/java/com/guiying/common/base/InfoCallback.java
rename to lib_common/src/main/java/com/guiying/module/common/base/InfoCallback.java
index 0024e7a..8a5cf9b 100644
--- a/lib_common/src/main/java/com/guiying/common/base/InfoCallback.java
+++ b/lib_common/src/main/java/com/guiying/module/common/base/InfoCallback.java
@@ -1,4 +1,6 @@
-package com.guiying.common.base;
+package com.guiying.module.common.base;
+
+import android.support.annotation.Keep;
/**
* 数据回调接口
@@ -7,6 +9,7 @@
* @version V1.2.0
* @name InfoCallback
*/
+@Keep
public interface InfoCallback {
void onSuccess(T info);
diff --git a/lib_common/src/main/java/com/guiying/common/base/BaseApplication.java b/lib_common/src/main/java/com/guiying/module/common/base/ViewManager.java
similarity index 58%
rename from lib_common/src/main/java/com/guiying/common/base/BaseApplication.java
rename to lib_common/src/main/java/com/guiying/module/common/base/ViewManager.java
index 319ee04..8f221a0 100644
--- a/lib_common/src/main/java/com/guiying/common/base/BaseApplication.java
+++ b/lib_common/src/main/java/com/guiying/module/common/base/ViewManager.java
@@ -1,64 +1,82 @@
-package com.guiying.common.base;
+package com.guiying.module.common.base;
import android.app.Activity;
-import android.app.ActivityManager;
-import android.app.Application;
import android.content.Context;
+import android.support.annotation.Keep;
import android.util.Log;
-import com.guiying.common.utils.Utils;
-import com.orhanobut.logger.LogLevel;
-import com.orhanobut.logger.Logger;
-
+import java.util.ArrayList;
+import java.util.List;
import java.util.Stack;
/**
- * 要想使用BaseApplication,必须在组件中实现自己的Application,并且继承BaseApplication;
- * 组件中实现的Application必须在debug包中的AndroidManifest.xml中注册,否则无法使用;
- * 组件的Application需置于java/debug文件夹中,不得放于主代码;
- * 组件中获取Context的方法必须为:Utils.getContext(),不允许其他写法;
- * BaseApplication主要用来管理全局Activity;
+ *
*
- * @author 2016/12/2 17:02
- * @version V1.0.0
- * @name BaseApplication
+ * @author 张华洋 2017/9/26 22:26
+ * @version V1.1
+ * @name ViewManager
*/
-public class BaseApplication extends Application {
+@Keep
+public class ViewManager {
+
+ private static Stack activityStack;
+ private static List fragmentList;
+
+ public static ViewManager getInstance() {
+ return ViewManagerHolder.sInstance;
+ }
- private static BaseApplication sInstance;
+ private static class ViewManagerHolder {
+ private static final ViewManager sInstance = new ViewManager();
+ }
- private Stack activityStack;
+ private ViewManager() {
+ }
- public static BaseApplication getIns() {
- return sInstance;
+ public void addFragment(int index, BaseFragment fragment) {
+ if (fragmentList == null) {
+ fragmentList = new ArrayList<>();
+ }
+ fragmentList.add(index, fragment);
+ }
+
+
+ public BaseFragment getFragment(int index) {
+ if (fragmentList != null) {
+ return fragmentList.get(index);
+ }
+ return null;
}
- @Override
- public void onCreate() {
- super.onCreate();
- sInstance = this;
- Utils.init(this);
- Logger.init("pattern").logLevel(LogLevel.FULL);
+ public List getAllFragment() {
+ if (fragmentList != null) {
+ return fragmentList;
+ }
+ return null;
}
+
/**
* 添加指定Activity到堆栈
*/
public void addActivity(Activity activity) {
if (activityStack == null) {
- activityStack = new Stack<>();
+ activityStack = new Stack();
}
activityStack.add(activity);
}
+
/**
* 获取当前Activity
*/
public Activity currentActivity() {
- return activityStack.lastElement();
+ Activity activity = activityStack.lastElement();
+ return activity;
}
+
/**
* 结束当前Activity
*/
@@ -67,6 +85,7 @@ public void finishActivity() {
finishActivity(activity);
}
+
/**
* 结束指定的Activity
*/
@@ -78,6 +97,7 @@ public void finishActivity(Activity activity) {
}
}
+
/**
* 结束指定Class的Activity
*/
@@ -90,6 +110,7 @@ public void finishActivity(Class> cls) {
}
}
+
/**
* 结束全部的Activity
*/
@@ -102,6 +123,7 @@ public void finishAllActivity() {
activityStack.clear();
}
+
/**
* 退出应用程序
*/
@@ -109,13 +131,11 @@ public void exitApp(Context context) {
try {
finishAllActivity();
//杀死后台进程需要在AndroidManifest中声明android.permission.KILL_BACKGROUND_PROCESSES;
- ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+ android.app.ActivityManager activityManager = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.killBackgroundProcesses(context.getPackageName());
//System.exit(0);
} catch (Exception e) {
Log.e("ActivityManager", "app exit" + e.getMessage());
}
}
-
-
}
diff --git a/lib_common/src/main/java/com/guiying/module/common/glide/ImageUtils.java b/lib_common/src/main/java/com/guiying/module/common/glide/ImageUtils.java
new file mode 100644
index 0000000..6bd37ee
--- /dev/null
+++ b/lib_common/src/main/java/com/guiying/module/common/glide/ImageUtils.java
@@ -0,0 +1,133 @@
+package com.guiying.module.common.glide;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
+import android.view.View;
+import android.widget.ImageView;
+
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.load.engine.DiskCacheStrategy;
+import com.bumptech.glide.load.resource.drawable.GlideDrawable;
+import com.bumptech.glide.request.animation.GlideAnimation;
+import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
+import com.bumptech.glide.request.target.SimpleTarget;
+import com.guiying.module.common.utils.Utils;
+
+/**
+ * 图片加载工具类
+ *
+ * @name ImageUtils
+ */
+public class ImageUtils {
+
+ /**
+ * 默认加载
+ */
+ public static void loadImageView(String path, ImageView mImageView) {
+ Glide.with(mImageView.getContext()).load(path).into(mImageView);
+ }
+
+ public static void loadImageWithError(String path, int errorRes, ImageView mImageView) {
+ Glide.with(mImageView.getContext())
+ .load(path)
+ .crossFade()
+ .diskCacheStrategy(DiskCacheStrategy.SOURCE)
+ .error(errorRes)
+ .into(mImageView);
+ }
+
+ /**
+ * 设置加载中以及加载失败图片
+ */
+ public static void loadImageWithLoading(String path, ImageView mImageView, int lodingImage, int errorRes) {
+ Glide.with(mImageView.getContext()).load(path).placeholder(lodingImage).
+ error(errorRes).into(mImageView);
+ }
+
+ /**
+ * 设置加载动画
+ * api也提供了几个常用的动画:比如crossFade()
+ */
+ public static void loadImageViewAnim(String path, int anim, ImageView mImageView) {
+ Glide.with(mImageView.getContext()).load(path).animate(anim).into(mImageView);
+ }
+
+
+ /**
+ * 加载为bitmap
+ *
+ * @param path 图片地址
+ * @param listener 回调
+ */
+ public static void loadBitMap(String path, final onLoadBitmap listener) {
+ Glide.with(Utils.getContext()).load(path).asBitmap().into(new SimpleTarget() {
+
+ @Override
+ public void onResourceReady(Bitmap bitmap, GlideAnimation super Bitmap> glideAnimation) {
+ listener.onReady(bitmap);
+ }
+
+ @Override
+ public void onLoadFailed(Exception e, Drawable errorDrawable) {
+ listener.onFailed();
+ }
+ });
+ }
+
+ /**
+ * 显示加载进度
+ *
+ * @param path 图片地址
+ * @param mImageView 图片控件
+ * @param loadView 加载view
+ */
+ public static void loadImageWithProgress(String path, final ImageView mImageView, final View loadView, int errorRes) {
+ Glide.with(mImageView.getContext()).load(path).error(errorRes).into(new GlideDrawableImageViewTarget(mImageView) {
+ @Override
+ public void onResourceReady(GlideDrawable resource, GlideAnimation super GlideDrawable> animation) {
+ super.onResourceReady(resource, animation);
+ loadView.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void onLoadFailed(Exception e, Drawable errorDrawable) {
+ super.onLoadFailed(e, errorDrawable);
+ loadView.setVisibility(View.GONE);
+ }
+ });
+ }
+
+ /**
+ * 清除view上的图片
+ *
+ * @param view 视图
+ */
+ public static void clearImageView(View view) {
+ Glide.clear(view);
+ }
+
+ /**
+ * 清理磁盘缓存需要在子线程中执行
+ */
+ public static void GuideClearDiskCache(Context mContext) {
+ Glide.get(mContext).clearDiskCache();
+ }
+
+ /**
+ * 清理内存缓存可以在UI主线程中进行
+ */
+ public static void GuideClearMemory(Context mContext) {
+ Glide.get(mContext).clearMemory();
+ }
+
+ /**
+ * 加载bitmap回调
+ */
+ public interface onLoadBitmap {
+ void onReady(Bitmap resource);
+
+ void onFailed();
+ }
+
+}
\ No newline at end of file
diff --git a/lib_common/src/main/java/com/guiying/common/glide/OkHttpGlideModule.java b/lib_common/src/main/java/com/guiying/module/common/glide/OkHttpGlideModule.java
similarity index 98%
rename from lib_common/src/main/java/com/guiying/common/glide/OkHttpGlideModule.java
rename to lib_common/src/main/java/com/guiying/module/common/glide/OkHttpGlideModule.java
index ba8969a..1fedd2e 100644
--- a/lib_common/src/main/java/com/guiying/common/glide/OkHttpGlideModule.java
+++ b/lib_common/src/main/java/com/guiying/module/common/glide/OkHttpGlideModule.java
@@ -1,4 +1,4 @@
-package com.guiying.common.glide;
+package com.guiying.module.common.glide;
import android.content.Context;
diff --git a/lib_common/src/main/java/com/guiying/common/glide/OkHttpStreamFetcher.java b/lib_common/src/main/java/com/guiying/module/common/glide/OkHttpStreamFetcher.java
similarity index 95%
rename from lib_common/src/main/java/com/guiying/common/glide/OkHttpStreamFetcher.java
rename to lib_common/src/main/java/com/guiying/module/common/glide/OkHttpStreamFetcher.java
index 358afd3..efd1560 100644
--- a/lib_common/src/main/java/com/guiying/common/glide/OkHttpStreamFetcher.java
+++ b/lib_common/src/main/java/com/guiying/module/common/glide/OkHttpStreamFetcher.java
@@ -1,10 +1,10 @@
-package com.guiying.common.glide;
+package com.guiying.module.common.glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.util.ContentLengthInputStream;
-import com.guiying.common.utils.CloseUtils;
+import com.guiying.module.common.utils.CloseUtils;
import java.io.IOException;
import java.io.InputStream;
diff --git a/lib_common/src/main/java/com/guiying/common/glide/OkHttpUrlLoader.java b/lib_common/src/main/java/com/guiying/module/common/glide/OkHttpUrlLoader.java
similarity index 98%
rename from lib_common/src/main/java/com/guiying/common/glide/OkHttpUrlLoader.java
rename to lib_common/src/main/java/com/guiying/module/common/glide/OkHttpUrlLoader.java
index 89f166d..c456435 100644
--- a/lib_common/src/main/java/com/guiying/common/glide/OkHttpUrlLoader.java
+++ b/lib_common/src/main/java/com/guiying/module/common/glide/OkHttpUrlLoader.java
@@ -1,4 +1,4 @@
-package com.guiying.common.glide;
+package com.guiying.module.common.glide;
import android.content.Context;
diff --git a/lib_common/src/main/java/com/guiying/common/http/ApiService.java b/lib_common/src/main/java/com/guiying/module/common/http/ApiService.java
similarity index 97%
rename from lib_common/src/main/java/com/guiying/common/http/ApiService.java
rename to lib_common/src/main/java/com/guiying/module/common/http/ApiService.java
index fa73d0a..895b72e 100644
--- a/lib_common/src/main/java/com/guiying/common/http/ApiService.java
+++ b/lib_common/src/main/java/com/guiying/module/common/http/ApiService.java
@@ -1,4 +1,4 @@
-package com.guiying.common.http;
+package com.guiying.module.common.http;
import java.util.Map;
diff --git a/lib_common/src/main/java/com/guiying/common/http/DataParseUtil.java b/lib_common/src/main/java/com/guiying/module/common/http/DataParseUtil.java
similarity index 98%
rename from lib_common/src/main/java/com/guiying/common/http/DataParseUtil.java
rename to lib_common/src/main/java/com/guiying/module/common/http/DataParseUtil.java
index dafb631..9cbc61b 100644
--- a/lib_common/src/main/java/com/guiying/common/http/DataParseUtil.java
+++ b/lib_common/src/main/java/com/guiying/module/common/http/DataParseUtil.java
@@ -1,4 +1,4 @@
-package com.guiying.common.http;
+package com.guiying.module.common.http;
import android.text.TextUtils;
diff --git a/lib_common/src/main/java/com/guiying/common/http/DataType.java b/lib_common/src/main/java/com/guiying/module/common/http/DataType.java
similarity index 95%
rename from lib_common/src/main/java/com/guiying/common/http/DataType.java
rename to lib_common/src/main/java/com/guiying/module/common/http/DataType.java
index 906fde6..7847996 100644
--- a/lib_common/src/main/java/com/guiying/common/http/DataType.java
+++ b/lib_common/src/main/java/com/guiying/module/common/http/DataType.java
@@ -1,4 +1,4 @@
-package com.guiying.common.http;
+package com.guiying.module.common.http;
import android.support.annotation.IntDef;
diff --git a/lib_common/src/main/java/com/guiying/common/http/HttpClient.java b/lib_common/src/main/java/com/guiying/module/common/http/HttpClient.java
similarity index 96%
rename from lib_common/src/main/java/com/guiying/common/http/HttpClient.java
rename to lib_common/src/main/java/com/guiying/module/common/http/HttpClient.java
index 8ebbd04..2be900b 100644
--- a/lib_common/src/main/java/com/guiying/common/http/HttpClient.java
+++ b/lib_common/src/main/java/com/guiying/module/common/http/HttpClient.java
@@ -1,4 +1,4 @@
-package com.guiying.common.http;
+package com.guiying.module.common.http;
import android.support.annotation.NonNull;
import android.text.TextUtils;
@@ -7,11 +7,11 @@
import com.franmontiel.persistentcookiejar.PersistentCookieJar;
import com.franmontiel.persistentcookiejar.cache.SetCookieCache;
import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor;
-import com.guiying.common.R;
-import com.guiying.common.utils.NetworkUtils;
-import com.guiying.common.utils.StringUtils;
-import com.guiying.common.utils.ToastUtils;
-import com.guiying.common.utils.Utils;
+import com.guiying.module.common.R;
+import com.guiying.module.common.utils.NetworkUtils;
+import com.guiying.module.common.utils.StringUtils;
+import com.guiying.module.common.utils.ToastUtils;
+import com.guiying.module.common.utils.Utils;
import com.orhanobut.logger.Logger;
import java.io.IOException;
@@ -141,7 +141,7 @@ public void onResponse(Call call, Response response)
try {
String result = response.body().string();
parseData(result, builder.clazz, builder.bodyType, onResultListener);
- } catch (IOException e) {
+ } catch (IOException | IllegalStateException e) {
e.printStackTrace();
}
}
diff --git a/lib_common/src/main/java/com/guiying/common/http/HttpsUtils.java b/lib_common/src/main/java/com/guiying/module/common/http/HttpsUtils.java
similarity index 99%
rename from lib_common/src/main/java/com/guiying/common/http/HttpsUtils.java
rename to lib_common/src/main/java/com/guiying/module/common/http/HttpsUtils.java
index 9245b8b..314d6ce 100644
--- a/lib_common/src/main/java/com/guiying/common/http/HttpsUtils.java
+++ b/lib_common/src/main/java/com/guiying/module/common/http/HttpsUtils.java
@@ -1,10 +1,10 @@
-package com.guiying.common.http;
+package com.guiying.module.common.http;
import android.content.Context;
import android.support.annotation.RawRes;
import android.text.TextUtils;
-import com.guiying.common.utils.CloseUtils;
+import com.guiying.module.common.utils.CloseUtils;
import java.io.ByteArrayInputStream;
import java.io.IOException;
diff --git a/lib_common/src/main/java/com/guiying/common/http/LoggerInterceptor.java b/lib_common/src/main/java/com/guiying/module/common/http/LoggerInterceptor.java
similarity index 99%
rename from lib_common/src/main/java/com/guiying/common/http/LoggerInterceptor.java
rename to lib_common/src/main/java/com/guiying/module/common/http/LoggerInterceptor.java
index 46cbff8..16d0660 100644
--- a/lib_common/src/main/java/com/guiying/common/http/LoggerInterceptor.java
+++ b/lib_common/src/main/java/com/guiying/module/common/http/LoggerInterceptor.java
@@ -1,4 +1,4 @@
-package com.guiying.common.http;
+package com.guiying.module.common.http;
import android.text.TextUtils;
diff --git a/lib_common/src/main/java/com/guiying/common/http/OnResultListener.java b/lib_common/src/main/java/com/guiying/module/common/http/OnResultListener.java
similarity index 94%
rename from lib_common/src/main/java/com/guiying/common/http/OnResultListener.java
rename to lib_common/src/main/java/com/guiying/module/common/http/OnResultListener.java
index 6274b58..527f5f0 100644
--- a/lib_common/src/main/java/com/guiying/common/http/OnResultListener.java
+++ b/lib_common/src/main/java/com/guiying/module/common/http/OnResultListener.java
@@ -1,4 +1,4 @@
-package com.guiying.common.http;
+package com.guiying.module.common.http;
/**
* 在Retrofit中接口会导致泛型擦除,所以这里回调使用Class
diff --git a/lib_common/src/main/java/com/guiying/common/utils/CloseUtils.java b/lib_common/src/main/java/com/guiying/module/common/utils/CloseUtils.java
similarity index 96%
rename from lib_common/src/main/java/com/guiying/common/utils/CloseUtils.java
rename to lib_common/src/main/java/com/guiying/module/common/utils/CloseUtils.java
index dae8eca..336cde0 100644
--- a/lib_common/src/main/java/com/guiying/common/utils/CloseUtils.java
+++ b/lib_common/src/main/java/com/guiying/module/common/utils/CloseUtils.java
@@ -1,4 +1,4 @@
-package com.guiying.common.utils;
+package com.guiying.module.common.utils;
import java.io.Closeable;
import java.io.IOException;
diff --git a/lib_common/src/main/java/com/guiying/common/utils/NetworkUtils.java b/lib_common/src/main/java/com/guiying/module/common/utils/NetworkUtils.java
similarity index 99%
rename from lib_common/src/main/java/com/guiying/common/utils/NetworkUtils.java
rename to lib_common/src/main/java/com/guiying/module/common/utils/NetworkUtils.java
index 06c8800..e788077 100644
--- a/lib_common/src/main/java/com/guiying/common/utils/NetworkUtils.java
+++ b/lib_common/src/main/java/com/guiying/module/common/utils/NetworkUtils.java
@@ -1,4 +1,4 @@
-package com.guiying.common.utils;
+package com.guiying.module.common.utils;
import android.content.Context;
import android.content.Intent;
diff --git a/lib_common/src/main/java/com/guiying/module/common/utils/ScreenLockUtil.java b/lib_common/src/main/java/com/guiying/module/common/utils/ScreenLockUtil.java
new file mode 100644
index 0000000..d85c106
--- /dev/null
+++ b/lib_common/src/main/java/com/guiying/module/common/utils/ScreenLockUtil.java
@@ -0,0 +1,84 @@
+package com.guiying.module.common.utils;
+
+import android.app.Activity;
+import android.app.KeyguardManager;
+import android.app.KeyguardManager.KeyguardLock;
+import android.content.Context;
+import android.os.PowerManager;
+import android.os.PowerManager.WakeLock;
+import android.util.Log;
+
+import java.util.HashMap;
+
+/**
+ * 用于保持屏幕高亮的工具
+ */
+public class ScreenLockUtil {
+ private static final String TAG = "ScreenLockUtil";
+
+ private ScreenLockUtil() {
+ throw new UnsupportedOperationException("cannot be instantiated");
+ }
+
+ static private HashMap mWakeLockArray = new HashMap<>();
+ static private HashMap mIsUnlockArray = new HashMap<>();
+
+
+ /**
+ * 保持屏幕常亮
+ *
+ * @param activity you know
+ */
+ public static void keepScreenOn(Activity activity) {
+ WakeLock wakeLock = mWakeLockArray.get(activity);
+ if (wakeLock == null) {
+ PowerManager powerManager = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
+ wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK,
+ activity.getClass().getName());
+ }
+
+ if (!wakeLock.isHeld()) {
+ wakeLock.acquire();
+ }
+
+ mWakeLockArray.put(activity, wakeLock);
+
+ cancelLockScreen(activity);
+
+ Log.i(TAG, "开启屏幕常亮");
+ }
+
+
+ /**
+ * 取消屏幕常亮
+ *
+ * @param activity you know
+ */
+ public static void cancelKeepScreen(Activity activity) {
+ WakeLock wakeLock = mWakeLockArray.get(activity);
+ if (wakeLock != null) {
+ if (wakeLock.isHeld()) {
+ wakeLock.release();
+ }
+ }
+
+ Log.i(TAG, "取消屏幕常亮");
+ }
+
+ /**
+ * 取消锁屏限制
+ *
+ * @param activity you know
+ */
+ private static void cancelLockScreen(Activity activity) {
+ Boolean isUnlock = mIsUnlockArray.get(activity);
+ if (isUnlock != null && isUnlock) {
+ return;
+ }
+ KeyguardManager mKeyguardManager = (KeyguardManager) activity.getSystemService(Context.KEYGUARD_SERVICE);
+ KeyguardLock mKeyguardLock = mKeyguardManager.newKeyguardLock(activity.getClass().getName());
+ mKeyguardLock.disableKeyguard();
+
+ mIsUnlockArray.put(activity, true);
+ }
+}
diff --git a/lib_common/src/main/java/com/guiying/common/utils/ShellUtils.java b/lib_common/src/main/java/com/guiying/module/common/utils/ShellUtils.java
similarity index 99%
rename from lib_common/src/main/java/com/guiying/common/utils/ShellUtils.java
rename to lib_common/src/main/java/com/guiying/module/common/utils/ShellUtils.java
index 138f7d5..ff326cc 100644
--- a/lib_common/src/main/java/com/guiying/common/utils/ShellUtils.java
+++ b/lib_common/src/main/java/com/guiying/module/common/utils/ShellUtils.java
@@ -1,4 +1,4 @@
-package com.guiying.common.utils;
+package com.guiying.module.common.utils;
import java.io.BufferedReader;
import java.io.DataOutputStream;
diff --git a/lib_common/src/main/java/com/guiying/common/utils/StringUtils.java b/lib_common/src/main/java/com/guiying/module/common/utils/StringUtils.java
similarity index 99%
rename from lib_common/src/main/java/com/guiying/common/utils/StringUtils.java
rename to lib_common/src/main/java/com/guiying/module/common/utils/StringUtils.java
index ccfbd93..e09c3ae 100644
--- a/lib_common/src/main/java/com/guiying/common/utils/StringUtils.java
+++ b/lib_common/src/main/java/com/guiying/module/common/utils/StringUtils.java
@@ -1,4 +1,4 @@
-package com.guiying.common.utils;
+package com.guiying.module.common.utils;
/**
* 字符串相关工具类
diff --git a/lib_common/src/main/java/com/guiying/common/utils/ToastUtils.java b/lib_common/src/main/java/com/guiying/module/common/utils/ToastUtils.java
similarity index 99%
rename from lib_common/src/main/java/com/guiying/common/utils/ToastUtils.java
rename to lib_common/src/main/java/com/guiying/module/common/utils/ToastUtils.java
index 5b0fe84..1fd0cdb 100644
--- a/lib_common/src/main/java/com/guiying/common/utils/ToastUtils.java
+++ b/lib_common/src/main/java/com/guiying/module/common/utils/ToastUtils.java
@@ -1,4 +1,4 @@
-package com.guiying.common.utils;
+package com.guiying.module.common.utils;
import android.os.Handler;
import android.os.Looper;
diff --git a/lib_common/src/main/java/com/guiying/common/utils/Utils.java b/lib_common/src/main/java/com/guiying/module/common/utils/Utils.java
similarity index 71%
rename from lib_common/src/main/java/com/guiying/common/utils/Utils.java
rename to lib_common/src/main/java/com/guiying/module/common/utils/Utils.java
index 6c8b104..a06d64d 100644
--- a/lib_common/src/main/java/com/guiying/common/utils/Utils.java
+++ b/lib_common/src/main/java/com/guiying/module/common/utils/Utils.java
@@ -1,4 +1,5 @@
-package com.guiying.common.utils;
+package com.guiying.module.common.utils;
+
import android.app.Activity;
import android.content.Context;
@@ -7,6 +8,9 @@
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
import android.view.View;
/**
@@ -87,4 +91,26 @@ public static boolean isAppDebug() {
}
}
+
+ /**
+ * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
+ * performed by the {@code fragmentManager}.
+ */
+ public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager,
+ @NonNull Fragment fragment, int frameId) {
+ checkNotNull(fragmentManager);
+ checkNotNull(fragment);
+ FragmentTransaction transaction = fragmentManager.beginTransaction();
+ transaction.add(frameId, fragment);
+ transaction.commit();
+ }
+
+
+ public static T checkNotNull(T obj) {
+ if (obj == null) {
+ throw new NullPointerException();
+ }
+ return obj;
+ }
+
}
\ No newline at end of file
diff --git a/lib_common/src/main/java/com/guiying/common/HackyViewPager.java b/lib_common/src/main/java/com/guiying/module/common/widget/HackyViewPager.java
similarity index 80%
rename from lib_common/src/main/java/com/guiying/common/HackyViewPager.java
rename to lib_common/src/main/java/com/guiying/module/common/widget/HackyViewPager.java
index f3a1692..a9ace60 100644
--- a/lib_common/src/main/java/com/guiying/common/HackyViewPager.java
+++ b/lib_common/src/main/java/com/guiying/module/common/widget/HackyViewPager.java
@@ -1,4 +1,4 @@
-package com.guiying.common;
+package com.guiying.module.common.widget;
import android.content.Context;
import android.support.v4.view.ViewPager;
@@ -6,7 +6,10 @@
import android.view.MotionEvent;
/**
- * 解决图片缩放崩溃的问题
+ * 解决图片缩放崩溃的问题
+ * @name HackyViewPager
+ * @author 张华洋 2017/9/27 10:10
+ * @version V1.1
*/
public class HackyViewPager extends ViewPager {
diff --git a/lib_common/src/main/java/com/guiying/module/common/widget/NoScrollViewPager.java b/lib_common/src/main/java/com/guiying/module/common/widget/NoScrollViewPager.java
new file mode 100644
index 0000000..be8f2b9
--- /dev/null
+++ b/lib_common/src/main/java/com/guiying/module/common/widget/NoScrollViewPager.java
@@ -0,0 +1,41 @@
+package com.guiying.module.common.widget;
+
+import android.content.Context;
+import android.support.v4.view.ViewPager;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+
+/**
+ * 可以禁止滑动翻页的ViewPager
+ *
+ * @author 张华洋 2017/9/27 10:10
+ * @version V1.1
+ * @name NoScrollViewPager
+ */
+public class NoScrollViewPager extends ViewPager {
+
+ private boolean isPagingEnabled = true;
+
+ public NoScrollViewPager(Context context) {
+ super(context);
+ }
+
+ public NoScrollViewPager(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ return this.isPagingEnabled && super.onTouchEvent(event);
+ }
+
+ @Override
+ public boolean onInterceptTouchEvent(MotionEvent event) {
+ return this.isPagingEnabled && super.onInterceptTouchEvent(event);
+ }
+
+ public void setPagerEnabled(boolean b) {
+ this.isPagingEnabled = b;
+ }
+
+}
diff --git a/module_app/build.gradle b/module_app/build.gradle
index d3fd2bf..2776c5c 100644
--- a/module_app/build.gradle
+++ b/module_app/build.gradle
@@ -1,5 +1,13 @@
apply plugin: 'com.android.application'
+// Create a variable called keystorePropertiesFile, and initialize it to your
+// keystore.properties file, in the rootProject folder.
+def keystorePropertiesFile = rootProject.file("keystore.properties")
+// Initialize a new Properties() object called keystoreProperties.
+def keystoreProperties = new Properties()
+// Load your keystore.properties file into the keystoreProperties object.
+keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
+
static def buildTime() {
return new Date().format("yyyyMMdd");
}
@@ -7,26 +15,31 @@ static def buildTime() {
android {
signingConfigs {
release {
- keyAlias 'guiying712'
- keyPassword 'guiying712'
- storeFile file('/mykey.jks')
- storePassword 'guiying712'
+ keyAlias keystoreProperties['keyAlias']
+ keyPassword keystoreProperties['keyPassword']
+ storeFile file(keystoreProperties['storeFile'])
+ storePassword keystoreProperties['storePassword']
}
}
- compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
+ compileSdkVersion build_versions.target_sdk
defaultConfig {
- applicationId "com.guiying.androidmodulepattern"
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode rootProject.ext.versionCode
- versionName rootProject.ext.versionName
- multiDexEnabled false
+ applicationId "com.guiying.module"
+ minSdkVersion build_versions.min_sdk
+ targetSdkVersion build_versions.target_sdk
+ versionCode 1
+ versionName "1.0"
+ multiDexEnabled true
//打包时间
resValue "string", "build_time", buildTime()
}
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
buildTypes {
release {
//更改AndroidManifest.xml中预先定义好占位符信息
@@ -60,13 +73,12 @@ android {
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- annotationProcessor "com.github.mzule.activityrouter:compiler:$rootProject.annotationProcessor"
- if (isModule.toBoolean()) {
- compile project(':lib_common')
- } else {
- compile project(':module_main')
- compile project(':module_girls')
- compile project(':module_news')
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation deps.support.multidex
+ implementation project(':lib_common')
+ if (!isModule.toBoolean()) {
+ implementation project(':module_main')
+ implementation project(':module_girls')
+ implementation project(':module_news')
}
}
diff --git a/module_app/src/main/AndroidManifest.xml b/module_app/src/main/AndroidManifest.xml
index 1fe6dcd..315d6cb 100644
--- a/module_app/src/main/AndroidManifest.xml
+++ b/module_app/src/main/AndroidManifest.xml
@@ -1,28 +1,15 @@
+ package="com.guiying.module">
-
-
-
-
-
-
-
-
-
-
-
这里是整个组件化项目管理各个组件的地方,所有需要使用的组件必须在此声明
+ * 这里仅需做一些初始化的工作
*
* @author 张华洋 2017/2/15 20:14
* @version V1.2.0
@@ -36,25 +38,31 @@
resToastText = R.string.crash_toast_text,
resDialogText = R.string.crash_dialog_text,
resDialogTitle = R.string.crash_dialog_title)
-@Modules({"main", "girls", "news"})
public class MyApplication extends BaseApplication {
@Override
public void onCreate() {
super.onCreate();
+ if (Utils.isAppDebug()) {
+ //开启InstantRun之后,一定要在ARouter.init之前调用openDebug
+ ARouter.openDebug();
+ ARouter.openLog();
+ }
+ ARouter.init(this);
//崩溃日志记录初始化
ACRA.init(this);
ACRA.getErrorReporter().removeAllReportSenders();
ACRA.getErrorReporter().setReportSender(new CrashReportSender());
}
-// @Override
-// protected void attachBaseContext(Context base) {
-// super.attachBaseContext(base);
-// // dex突破65535的限制
-// MultiDex.install(this);
-// }
+
+ @Override
+ protected void attachBaseContext(Context base) {
+ super.attachBaseContext(base);
+ // dex突破65535的限制
+ MultiDex.install(this);
+ }
/**
diff --git a/module_girls/build.gradle b/module_girls/build.gradle
index fbf8446..a1838bd 100644
--- a/module_girls/build.gradle
+++ b/module_girls/build.gradle
@@ -5,16 +5,24 @@ if (isModule.toBoolean()) {
}
android {
- compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
-
+ compileSdkVersion build_versions.target_sdk
defaultConfig {
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode rootProject.ext.versionCode
- versionName rootProject.ext.versionName
+ minSdkVersion build_versions.min_sdk
+ targetSdkVersion build_versions.target_sdk
+ versionCode 1
+ versionName "1.0"
+
+ javaCompileOptions {
+ annotationProcessorOptions {
+ arguments = [ moduleName : project.getName() ]
+ }
+ }
}
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
sourceSets {
main {
@@ -29,15 +37,17 @@ android {
}
}
}
- //设置了resourcePrefix值后,所有的资源名必须以指定的字符串做前缀,否则会报错。
- //但是resourcePrefix这个值只能限定xml里面的资源,并不能限定图片资源,所有图片资源仍然需要手动去修改资源名。
- //resourcePrefix "girls_"
-
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- annotationProcessor "com.github.mzule.activityrouter:compiler:$rootProject.annotationProcessor"
- compile project(':lib_common')
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ annotationProcessor deps.arouter_compiler
+ implementation project(':lib_common')
}
diff --git a/module_girls/src/main/AndroidManifest.xml b/module_girls/src/main/AndroidManifest.xml
index 047ff58..48584ac 100644
--- a/module_girls/src/main/AndroidManifest.xml
+++ b/module_girls/src/main/AndroidManifest.xml
@@ -1,5 +1,5 @@
+ package="com.guiying.module.girls">
类说明
- *
- * @author 张华洋 2017/2/15 16:34
- * @version V1.2.0
- * @name Girls
- */
-@Module("girls")
-public class Girls {
-}
diff --git a/module_girls/src/main/java/com/guiying/girls/Constants.java b/module_girls/src/main/java/com/guiying/module/girls/Constants.java
similarity index 88%
rename from module_girls/src/main/java/com/guiying/girls/Constants.java
rename to module_girls/src/main/java/com/guiying/module/girls/Constants.java
index e2332a8..419b643 100644
--- a/module_girls/src/main/java/com/guiying/girls/Constants.java
+++ b/module_girls/src/main/java/com/guiying/module/girls/Constants.java
@@ -1,4 +1,4 @@
-package com.guiying.girls;
+package com.guiying.module.girls;
/**
* 保存项目中用到的常量
diff --git a/module_girls/src/main/java/com/guiying/module/girls/GirlsFragment.java b/module_girls/src/main/java/com/guiying/module/girls/GirlsFragment.java
new file mode 100644
index 0000000..43accad
--- /dev/null
+++ b/module_girls/src/main/java/com/guiying/module/girls/GirlsFragment.java
@@ -0,0 +1,42 @@
+package com.guiying.module.girls;
+
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.guiying.module.common.base.BaseFragment;
+
+
+/**
+ * A simple {@link Fragment} subclass.
+ */
+public class GirlsFragment extends BaseFragment {
+
+ /**
+ * Use this factory method to create a new instance of
+ * this fragment using the provided parameters.
+ *
+ * @return A new instance of fragment GirlsFragment.
+ */
+ public static GirlsFragment newInstance() {
+ return new GirlsFragment();
+ }
+
+
+ public GirlsFragment() {
+ // Required empty public constructor
+ }
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.fragment_girls, container, false);
+ }
+
+
+}
diff --git a/module_girls/src/main/java/com/guiying/module/girls/MyDelegate.java b/module_girls/src/main/java/com/guiying/module/girls/MyDelegate.java
new file mode 100644
index 0000000..dc0ecf4
--- /dev/null
+++ b/module_girls/src/main/java/com/guiying/module/girls/MyDelegate.java
@@ -0,0 +1,38 @@
+package com.guiying.module.girls;
+
+import android.support.annotation.Keep;
+
+import com.guiying.module.common.base.IApplicationDelegate;
+import com.guiying.module.common.base.ViewManager;
+
+/**
+ * 类说明
+ *
+ * @author 张华洋 2017/9/20 22:29
+ * @version V2.8.3
+ * @name MyDelegate
+ */
+@Keep
+public class MyDelegate implements IApplicationDelegate {
+
+ @Override
+ public void onCreate() {
+ //主动添加
+ ViewManager.getInstance().addFragment(0, GirlsFragment.newInstance());
+ }
+
+ @Override
+ public void onTerminate() {
+
+ }
+
+ @Override
+ public void onLowMemory() {
+
+ }
+
+ @Override
+ public void onTrimMemory(int level) {
+
+ }
+}
diff --git a/module_girls/src/main/java/com/guiying/module/girls/MyViewDelegate.java b/module_girls/src/main/java/com/guiying/module/girls/MyViewDelegate.java
new file mode 100644
index 0000000..3d4294e
--- /dev/null
+++ b/module_girls/src/main/java/com/guiying/module/girls/MyViewDelegate.java
@@ -0,0 +1,28 @@
+package com.guiying.module.girls;
+
+import android.support.annotation.Keep;
+import android.view.View;
+
+import com.guiying.module.common.base.BaseFragment;
+import com.guiying.module.common.base.IViewDelegate;
+
+/**
+ * 类说明
+ *
+ * @author 张华洋 2018/1/4 22:16
+ * @version V2.8.3
+ * @name MyViewDelegate
+ */
+@Keep
+public class MyViewDelegate implements IViewDelegate {
+
+ @Override
+ public BaseFragment getFragment(String name) {
+ return GirlsFragment.newInstance();
+ }
+
+ @Override
+ public View getView(String name) {
+ return null;
+ }
+}
diff --git a/module_girls/src/main/java/com/guiying/girls/data/GirlsDataSource.java b/module_girls/src/main/java/com/guiying/module/girls/data/GirlsDataSource.java
similarity index 71%
rename from module_girls/src/main/java/com/guiying/girls/data/GirlsDataSource.java
rename to module_girls/src/main/java/com/guiying/module/girls/data/GirlsDataSource.java
index 4e92618..3f2755d 100644
--- a/module_girls/src/main/java/com/guiying/girls/data/GirlsDataSource.java
+++ b/module_girls/src/main/java/com/guiying/module/girls/data/GirlsDataSource.java
@@ -1,6 +1,6 @@
-package com.guiying.girls.data;
+package com.guiying.module.girls.data;
-import com.guiying.girls.data.bean.GirlsParser;
+import com.guiying.module.girls.data.bean.GirlsParser;
public interface GirlsDataSource {
diff --git a/module_girls/src/main/java/com/guiying/girls/data/bean/Girls.java b/module_girls/src/main/java/com/guiying/module/girls/data/bean/Girls.java
similarity index 98%
rename from module_girls/src/main/java/com/guiying/girls/data/bean/Girls.java
rename to module_girls/src/main/java/com/guiying/module/girls/data/bean/Girls.java
index 162b6b5..26573c9 100644
--- a/module_girls/src/main/java/com/guiying/girls/data/bean/Girls.java
+++ b/module_girls/src/main/java/com/guiying/module/girls/data/bean/Girls.java
@@ -1,4 +1,4 @@
-package com.guiying.girls.data.bean;
+package com.guiying.module.girls.data.bean;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/module_girls/src/main/java/com/guiying/girls/data/bean/GirlsParser.java b/module_girls/src/main/java/com/guiying/module/girls/data/bean/GirlsParser.java
similarity index 96%
rename from module_girls/src/main/java/com/guiying/girls/data/bean/GirlsParser.java
rename to module_girls/src/main/java/com/guiying/module/girls/data/bean/GirlsParser.java
index b18db5c..d9c4d34 100644
--- a/module_girls/src/main/java/com/guiying/girls/data/bean/GirlsParser.java
+++ b/module_girls/src/main/java/com/guiying/module/girls/data/bean/GirlsParser.java
@@ -1,4 +1,4 @@
-package com.guiying.girls.data.bean;
+package com.guiying.module.girls.data.bean;
import java.util.List;
diff --git a/module_girls/src/main/java/com/guiying/girls/data/source/RemoteGirlsDataSource.java b/module_girls/src/main/java/com/guiying/module/girls/data/source/RemoteGirlsDataSource.java
similarity index 72%
rename from module_girls/src/main/java/com/guiying/girls/data/source/RemoteGirlsDataSource.java
rename to module_girls/src/main/java/com/guiying/module/girls/data/source/RemoteGirlsDataSource.java
index ae343f3..457f412 100644
--- a/module_girls/src/main/java/com/guiying/girls/data/source/RemoteGirlsDataSource.java
+++ b/module_girls/src/main/java/com/guiying/module/girls/data/source/RemoteGirlsDataSource.java
@@ -1,12 +1,12 @@
-package com.guiying.girls.data.source;
+package com.guiying.module.girls.data.source;
-import com.guiying.common.http.DataType;
-import com.guiying.common.http.HttpClient;
-import com.guiying.common.http.OnResultListener;
-import com.guiying.girls.Constants;
-import com.guiying.girls.data.GirlsDataSource;
-import com.guiying.girls.data.bean.GirlsParser;
+import com.guiying.module.common.http.DataType;
+import com.guiying.module.common.http.HttpClient;
+import com.guiying.module.common.http.OnResultListener;
+import com.guiying.module.girls.Constants;
+import com.guiying.module.girls.data.GirlsDataSource;
+import com.guiying.module.girls.data.bean.GirlsParser;
diff --git a/module_girls/src/main/java/com/guiying/girls/girl/GirlActivity.java b/module_girls/src/main/java/com/guiying/module/girls/girl/GirlActivity.java
similarity index 82%
rename from module_girls/src/main/java/com/guiying/girls/girl/GirlActivity.java
rename to module_girls/src/main/java/com/guiying/module/girls/girl/GirlActivity.java
index 6a000d0..bd1dd78 100644
--- a/module_girls/src/main/java/com/guiying/girls/girl/GirlActivity.java
+++ b/module_girls/src/main/java/com/guiying/module/girls/girl/GirlActivity.java
@@ -1,13 +1,14 @@
-package com.guiying.girls.girl;
+package com.guiying.module.girls.girl;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.WindowManager;
-import com.guiying.common.HackyViewPager;
-import com.guiying.common.base.BaseActivity;
-import com.guiying.girls.Constants;
-import com.guiying.girls.data.bean.Girls;
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.guiying.module.common.base.BaseActivity;
+import com.guiying.module.common.widget.HackyViewPager;
+import com.guiying.module.girls.Constants;
+import com.guiying.module.girls.data.bean.Girls;
import java.util.List;
@@ -18,6 +19,7 @@
* @version V1.1
* @name GirlActivity
*/
+@Route(path = "/girls/detail")
public class GirlActivity extends BaseActivity {
@Override
diff --git a/module_girls/src/main/java/com/guiying/girls/girl/GirlAdapter.java b/module_girls/src/main/java/com/guiying/module/girls/girl/GirlAdapter.java
similarity index 93%
rename from module_girls/src/main/java/com/guiying/girls/girl/GirlAdapter.java
rename to module_girls/src/main/java/com/guiying/module/girls/girl/GirlAdapter.java
index 6c2bb1d..dce7361 100644
--- a/module_girls/src/main/java/com/guiying/girls/girl/GirlAdapter.java
+++ b/module_girls/src/main/java/com/guiying/module/girls/girl/GirlAdapter.java
@@ -1,4 +1,4 @@
-package com.guiying.girls.girl;
+package com.guiying.module.girls.girl;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
@@ -8,8 +8,8 @@
import com.bumptech.glide.Glide;
import com.github.chrisbanes.photoview.PhotoView;
-import com.guiying.girls.R;
-import com.guiying.girls.data.bean.Girls;
+import com.guiying.module.girls.R;
+import com.guiying.module.girls.data.bean.Girls;
import java.util.List;
diff --git a/module_girls/src/main/java/com/guiying/girls/main/GirlsActivity.java b/module_girls/src/main/java/com/guiying/module/girls/main/GirlsActivity.java
similarity index 70%
rename from module_girls/src/main/java/com/guiying/girls/main/GirlsActivity.java
rename to module_girls/src/main/java/com/guiying/module/girls/main/GirlsActivity.java
index b0a0851..9a64571 100644
--- a/module_girls/src/main/java/com/guiying/girls/main/GirlsActivity.java
+++ b/module_girls/src/main/java/com/guiying/module/girls/main/GirlsActivity.java
@@ -1,12 +1,12 @@
-package com.guiying.girls.main;
+package com.guiying.module.girls.main;
import android.os.Bundle;
-import com.github.mzule.activityrouter.annotation.Router;
-import com.guiying.common.base.BaseActionBarActivity;
-import com.guiying.girls.R;
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.guiying.module.common.base.BaseActionBarActivity;
+import com.guiying.module.girls.R;
-@Router("girls")
+@Route(path = "/girls/list")
public class GirlsActivity extends BaseActionBarActivity {
private GirlsView mView;
diff --git a/module_girls/src/main/java/com/guiying/girls/main/GirlsAdapter.java b/module_girls/src/main/java/com/guiying/module/girls/main/GirlsAdapter.java
similarity index 93%
rename from module_girls/src/main/java/com/guiying/girls/main/GirlsAdapter.java
rename to module_girls/src/main/java/com/guiying/module/girls/main/GirlsAdapter.java
index eefbad0..6ee991a 100644
--- a/module_girls/src/main/java/com/guiying/girls/main/GirlsAdapter.java
+++ b/module_girls/src/main/java/com/guiying/module/girls/main/GirlsAdapter.java
@@ -1,4 +1,4 @@
-package com.guiying.girls.main;
+package com.guiying.module.girls.main;
import android.content.Context;
import android.view.View;
@@ -7,8 +7,8 @@
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.guiying.girls.R;
-import com.guiying.girls.data.bean.Girls;
+import com.guiying.module.girls.R;
+import com.guiying.module.girls.data.bean.Girls;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
diff --git a/module_girls/src/main/java/com/guiying/girls/main/GirlsContract.java b/module_girls/src/main/java/com/guiying/module/girls/main/GirlsContract.java
similarity index 76%
rename from module_girls/src/main/java/com/guiying/girls/main/GirlsContract.java
rename to module_girls/src/main/java/com/guiying/module/girls/main/GirlsContract.java
index d4cd0d5..fd57180 100644
--- a/module_girls/src/main/java/com/guiying/girls/main/GirlsContract.java
+++ b/module_girls/src/main/java/com/guiying/module/girls/main/GirlsContract.java
@@ -1,8 +1,8 @@
-package com.guiying.girls.main;
+package com.guiying.module.girls.main;
-import com.guiying.common.base.BasePresenter;
-import com.guiying.common.base.BaseView;
-import com.guiying.girls.data.bean.Girls;
+import com.guiying.module.common.base.BasePresenter;
+import com.guiying.module.common.base.BaseView;
+import com.guiying.module.girls.data.bean.Girls;
import java.util.List;
diff --git a/module_girls/src/main/java/com/guiying/girls/main/GirlsPresenter.java b/module_girls/src/main/java/com/guiying/module/girls/main/GirlsPresenter.java
similarity index 84%
rename from module_girls/src/main/java/com/guiying/girls/main/GirlsPresenter.java
rename to module_girls/src/main/java/com/guiying/module/girls/main/GirlsPresenter.java
index 8a3bca0..a94fa8b 100644
--- a/module_girls/src/main/java/com/guiying/girls/main/GirlsPresenter.java
+++ b/module_girls/src/main/java/com/guiying/module/girls/main/GirlsPresenter.java
@@ -1,8 +1,8 @@
-package com.guiying.girls.main;
+package com.guiying.module.girls.main;
-import com.guiying.girls.data.GirlsDataSource;
-import com.guiying.girls.data.bean.GirlsParser;
-import com.guiying.girls.data.source.RemoteGirlsDataSource;
+import com.guiying.module.girls.data.GirlsDataSource;
+import com.guiying.module.girls.data.bean.GirlsParser;
+import com.guiying.module.girls.data.source.RemoteGirlsDataSource;
/**
* 类说明
diff --git a/module_girls/src/main/java/com/guiying/girls/main/GirlsView.java b/module_girls/src/main/java/com/guiying/module/girls/main/GirlsView.java
similarity index 94%
rename from module_girls/src/main/java/com/guiying/girls/main/GirlsView.java
rename to module_girls/src/main/java/com/guiying/module/girls/main/GirlsView.java
index 1c23e23..dc83d90 100644
--- a/module_girls/src/main/java/com/guiying/girls/main/GirlsView.java
+++ b/module_girls/src/main/java/com/guiying/module/girls/main/GirlsView.java
@@ -1,4 +1,4 @@
-package com.guiying.girls.main;
+package com.guiying.module.girls.main;
import android.content.Context;
import android.content.Intent;
@@ -11,11 +11,11 @@
import android.view.ViewStub;
import android.widget.FrameLayout;
-import com.guiying.common.utils.Utils;
-import com.guiying.girls.Constants;
-import com.guiying.girls.R;
-import com.guiying.girls.data.bean.Girls;
-import com.guiying.girls.girl.GirlActivity;
+import com.guiying.module.common.utils.Utils;
+import com.guiying.module.girls.Constants;
+import com.guiying.module.girls.R;
+import com.guiying.module.girls.data.bean.Girls;
+import com.guiying.module.girls.girl.GirlActivity;
import com.jude.easyrecyclerview.EasyRecyclerView;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
diff --git a/module_girls/src/main/java/debug/GirlsApplication.java b/module_girls/src/main/java/debug/GirlsApplication.java
index b93eb55..052a4e6 100644
--- a/module_girls/src/main/java/debug/GirlsApplication.java
+++ b/module_girls/src/main/java/debug/GirlsApplication.java
@@ -1,8 +1,8 @@
package debug;
-import com.guiying.common.base.BaseApplication;
-import com.guiying.common.http.HttpClient;
-import com.guiying.common.http.OnResultListener;
+import com.guiying.module.common.base.BaseApplication;
+import com.guiying.module.common.http.HttpClient;
+import com.guiying.module.common.http.OnResultListener;
import com.orhanobut.logger.Logger;
/**
diff --git a/module_girls/src/main/module/AndroidManifest.xml b/module_girls/src/main/module/AndroidManifest.xml
index 4ae8556..f283bb9 100644
--- a/module_girls/src/main/module/AndroidManifest.xml
+++ b/module_girls/src/main/module/AndroidManifest.xml
@@ -1,6 +1,6 @@
+ package="com.guiying.module.girls">
+ tools:context=".girls.main.GirlsActivity">
+
+
+
+
+
diff --git a/module_main/build.gradle b/module_main/build.gradle
index 61955fc..a1838bd 100644
--- a/module_main/build.gradle
+++ b/module_main/build.gradle
@@ -5,16 +5,24 @@ if (isModule.toBoolean()) {
}
android {
- compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
-
+ compileSdkVersion build_versions.target_sdk
defaultConfig {
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode rootProject.ext.versionCode
- versionName rootProject.ext.versionName
+ minSdkVersion build_versions.min_sdk
+ targetSdkVersion build_versions.target_sdk
+ versionCode 1
+ versionName "1.0"
+
+ javaCompileOptions {
+ annotationProcessorOptions {
+ arguments = [ moduleName : project.getName() ]
+ }
+ }
}
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
sourceSets {
main {
@@ -29,14 +37,17 @@ android {
}
}
}
- //设置了resourcePrefix值后,所有的资源名必须以指定的字符串做前缀,否则会报错。
- //但是resourcePrefix这个值只能限定xml里面的资源,并不能限定图片资源,所有图片资源仍然需要手动去修改资源名。
- //resourcePrefix "girls_"
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- annotationProcessor "com.github.mzule.activityrouter:compiler:$rootProject.annotationProcessor"
- compile project(':lib_common')
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ annotationProcessor deps.arouter_compiler
+ implementation project(':lib_common')
}
diff --git a/module_main/src/main/AndroidManifest.xml b/module_main/src/main/AndroidManifest.xml
index 4249b68..db12695 100644
--- a/module_main/src/main/AndroidManifest.xml
+++ b/module_main/src/main/AndroidManifest.xml
@@ -1,14 +1,20 @@
+
+ package="com.guiying.module.main">
-
+
+
+
+
-
+
\ No newline at end of file
diff --git a/module_main/src/main/java/com/guiying/main/Main.java b/module_main/src/main/java/com/guiying/main/Main.java
deleted file mode 100644
index 87e625b..0000000
--- a/module_main/src/main/java/com/guiying/main/Main.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.guiying.main;
-
-import com.github.mzule.activityrouter.annotation.Module;
-
-/**
- * 声明主要组件
- *
- * 这个组件是应用默认启动的组件
- *
- * @author 张华洋 2017/4/1 12:39
- * @version V1.2.0
- * @name Main
- */
-
-@Module("main")
-public class Main {
-}
diff --git a/module_main/src/main/java/com/guiying/main/MainActivity.java b/module_main/src/main/java/com/guiying/main/MainActivity.java
deleted file mode 100644
index 8ac0a15..0000000
--- a/module_main/src/main/java/com/guiying/main/MainActivity.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.guiying.main;
-
-import android.os.Bundle;
-import android.view.KeyEvent;
-import android.view.View;
-import android.widget.Button;
-
-import com.github.mzule.activityrouter.router.Routers;
-import com.guiying.common.base.BaseActivity;
-import com.guiying.common.base.BaseApplication;
-import com.guiying.common.utils.ToastUtils;
-
-public class MainActivity extends BaseActivity implements View.OnClickListener {
-
- private long exitTime = 0;
- protected Button newsButton;
- protected Button girlsButton;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- newsButton = (Button) findViewById(R.id.news_button);
- newsButton.setOnClickListener(MainActivity.this);
- girlsButton = (Button) findViewById(R.id.girls_button);
- girlsButton.setOnClickListener(MainActivity.this);
- }
-
- @Override
- public void onClick(View view) {
- if (view.getId() == R.id.news_button) {
- Routers.open(MainActivity.this, "module://news");
- } else if (view.getId() == R.id.girls_button) {
- Routers.open(MainActivity.this, "module://girls");
- }
- }
-
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
- //两秒之内按返回键就会退出
- if ((System.currentTimeMillis() - exitTime) > 2000) {
- ToastUtils.showShortToast(getString(R.string.app_exit_hint));
- exitTime = System.currentTimeMillis();
- } else {
- BaseApplication.getIns().exitApp(this);
- }
- return true;
- }
- return super.onKeyDown(keyCode, event);
- }
-
-}
diff --git a/module_main/src/main/java/com/guiying/module/main/BottomNavigationActivity.java b/module_main/src/main/java/com/guiying/module/main/BottomNavigationActivity.java
new file mode 100644
index 0000000..51c27cf
--- /dev/null
+++ b/module_main/src/main/java/com/guiying/module/main/BottomNavigationActivity.java
@@ -0,0 +1,86 @@
+package com.guiying.module.main;
+
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.design.widget.BottomNavigationView;
+import android.view.MenuItem;
+
+import com.guiying.module.common.base.BaseActivity;
+import com.guiying.module.common.base.BaseFragment;
+import com.guiying.module.common.base.ClassUtils;
+import com.guiying.module.common.base.IViewDelegate;
+import com.guiying.module.common.base.ViewManager;
+import com.guiying.module.common.widget.NoScrollViewPager;
+
+import java.util.List;
+
+/**
+ *
+ *
+ * @author 张华洋 2017/9/27 10:23
+ * @version V1.1
+ * @name BottomNavigationActivity
+ */
+public class BottomNavigationActivity extends BaseActivity {
+
+ private NoScrollViewPager mPager;
+ private List mFragments;
+ private FragmentAdapter mAdapter;
+
+ private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
+ = new BottomNavigationView.OnNavigationItemSelectedListener() {
+
+ @Override
+ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
+ int i = item.getItemId();
+ if (i == R.id.navigation_home) {
+ mPager.setCurrentItem(0);
+ return true;
+ } else if (i == R.id.navigation_dashboard) {
+ mPager.setCurrentItem(1);
+ return true;
+ } else if (i == R.id.navigation_notifications) {
+ mPager.setCurrentItem(2);
+ return true;
+ }
+ return false;
+ }
+
+ };
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_bottom_navigation);
+ BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
+ navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
+ initViewPager();
+ }
+
+ private void initViewPager() {
+ mFragments = ViewManager.getInstance().getAllFragment();//这几个Fragment是主动添加到ViewManager中的
+ BaseFragment newsFragment = getNewsFragment();//主动寻找
+ mFragments.add(newsFragment);
+ mPager = (NoScrollViewPager) findViewById(R.id.container_pager);
+ mAdapter = new FragmentAdapter(getSupportFragmentManager(), mFragments);
+ mPager.setPagerEnabled(false);
+ mPager.setAdapter(mAdapter);
+ }
+
+
+ /**
+ * 在News模块中寻找实现的Fragment
+ *
+ * @return Fragment
+ */
+ private BaseFragment getNewsFragment() {
+ BaseFragment newsFragment = null;
+ List viewDelegates = ClassUtils.getObjectsWithInterface(this, IViewDelegate.class, "com.guiying.module.news");
+ if (viewDelegates != null && !viewDelegates.isEmpty()) {
+ newsFragment = viewDelegates.get(0).getFragment("");
+ }
+ return newsFragment;
+ }
+
+}
diff --git a/module_main/src/main/java/com/guiying/module/main/FragmentAdapter.java b/module_main/src/main/java/com/guiying/module/main/FragmentAdapter.java
new file mode 100644
index 0000000..dc5b82b
--- /dev/null
+++ b/module_main/src/main/java/com/guiying/module/main/FragmentAdapter.java
@@ -0,0 +1,40 @@
+package com.guiying.module.main;
+
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentStatePagerAdapter;
+
+import com.guiying.module.common.base.BaseFragment;
+
+import java.util.List;
+
+/**
+ * Fragments适配器
+ *
+ * @author 张华洋 2017/9/27 10:14
+ * @version V1.1
+ * @name ResourcePagerAdapter
+ */
+public class FragmentAdapter extends FragmentStatePagerAdapter {
+ private List mFragments;
+
+ public FragmentAdapter(FragmentManager fm, List mFragments) {
+ super(fm);
+ this.mFragments = mFragments;
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ return mFragments.get(position);
+ }
+
+ @Override
+ public int getCount() {
+ return mFragments != null ? mFragments.size() : 0;
+ }
+
+ @Override
+ public int getItemPosition(Object object) {
+ return android.support.v4.view.PagerAdapter.POSITION_NONE;
+ }
+}
diff --git a/module_main/src/main/java/com/guiying/module/main/MainActivity.java b/module_main/src/main/java/com/guiying/module/main/MainActivity.java
new file mode 100644
index 0000000..db0fb8b
--- /dev/null
+++ b/module_main/src/main/java/com/guiying/module/main/MainActivity.java
@@ -0,0 +1,62 @@
+package com.guiying.module.main;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.guiying.module.common.base.BaseActivity;
+import com.guiying.module.common.base.ViewManager;
+import com.guiying.module.common.utils.ToastUtils;
+
+/**
+ * 类说明
+ *
+ * @author 张华洋 2017/7/1 13:13
+ * @version V1.2.0
+ * @name MainActivity
+ */
+public class MainActivity extends BaseActivity implements View.OnClickListener {
+
+ private long mExitTime = 0;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ findViewById(R.id.news_button).setOnClickListener(this);
+ findViewById(R.id.girls_button).setOnClickListener(this);
+ findViewById(R.id.fragment_button).setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View view) {
+ if (view.getId() == R.id.news_button) {
+ //跳转到NewsCenterActivity
+ ARouter.getInstance().build("/news/center").navigation();
+ } else if (view.getId() == R.id.girls_button) {
+ //跳转到GirlsActivity
+ ARouter.getInstance().build("/girls/list").navigation();
+ } else if (view.getId() == R.id.fragment_button) {
+ startActivity(new Intent(this, BottomNavigationActivity.class));
+ }
+ }
+
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
+ //两秒之内按返回键就会退出
+ if ((System.currentTimeMillis() - mExitTime) > 2000) {
+ ToastUtils.showShortToast(getString(R.string.app_exit_hint));
+ mExitTime = System.currentTimeMillis();
+ } else {
+ ViewManager.getInstance().exitApp(this);
+ }
+ return true;
+ }
+ return super.onKeyDown(keyCode, event);
+ }
+
+}
diff --git a/module_main/src/main/java/debug/MainApplication.java b/module_main/src/main/java/debug/MainApplication.java
index 293f166..24509f5 100644
--- a/module_main/src/main/java/debug/MainApplication.java
+++ b/module_main/src/main/java/debug/MainApplication.java
@@ -1,8 +1,8 @@
package debug;
-import com.guiying.common.base.BaseApplication;
-import com.guiying.common.http.HttpClient;
-import com.guiying.common.http.OnResultListener;
+import com.guiying.module.common.base.BaseApplication;
+import com.guiying.module.common.http.HttpClient;
+import com.guiying.module.common.http.OnResultListener;
import com.orhanobut.logger.Logger;
/**
diff --git a/module_main/src/main/module/AndroidManifest.xml b/module_main/src/main/module/AndroidManifest.xml
index fc3933a..0443b12 100644
--- a/module_main/src/main/module/AndroidManifest.xml
+++ b/module_main/src/main/module/AndroidManifest.xml
@@ -1,6 +1,6 @@
+ package="com.guiying.module.main">
-
+
@@ -18,4 +18,4 @@
-
\ No newline at end of file
+
diff --git a/module_main/src/main/res/drawable/ic_dashboard_black_24dp.xml b/module_main/src/main/res/drawable/ic_dashboard_black_24dp.xml
new file mode 100644
index 0000000..ae6a446
--- /dev/null
+++ b/module_main/src/main/res/drawable/ic_dashboard_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/module_main/src/main/res/drawable/ic_home_black_24dp.xml b/module_main/src/main/res/drawable/ic_home_black_24dp.xml
new file mode 100644
index 0000000..0c36320
--- /dev/null
+++ b/module_main/src/main/res/drawable/ic_home_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/module_main/src/main/res/drawable/ic_notifications_black_24dp.xml b/module_main/src/main/res/drawable/ic_notifications_black_24dp.xml
new file mode 100644
index 0000000..0262382
--- /dev/null
+++ b/module_main/src/main/res/drawable/ic_notifications_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/module_main/src/main/res/layout/activity_bottom_navigation.xml b/module_main/src/main/res/layout/activity_bottom_navigation.xml
new file mode 100644
index 0000000..060e7be
--- /dev/null
+++ b/module_main/src/main/res/layout/activity_bottom_navigation.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
diff --git a/module_main/src/main/res/layout/activity_main.xml b/module_main/src/main/res/layout/activity_main.xml
index e5e21fe..c4c16f8 100644
--- a/module_main/src/main/res/layout/activity_main.xml
+++ b/module_main/src/main/res/layout/activity_main.xml
@@ -9,7 +9,7 @@
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
- tools:context="com.guiying.main.MainActivity">
+ tools:context="com.guiying.module.main.MainActivity">
+
+
+
diff --git a/module_main/src/main/res/menu/navigation.xml b/module_main/src/main/res/menu/navigation.xml
new file mode 100644
index 0000000..f4de4f8
--- /dev/null
+++ b/module_main/src/main/res/menu/navigation.xml
@@ -0,0 +1,19 @@
+
+
diff --git a/module_main/src/main/res/values/strings.xml b/module_main/src/main/res/values/strings.xml
index 01beb45..ca0b880 100644
--- a/module_main/src/main/res/values/strings.xml
+++ b/module_main/src/main/res/values/strings.xml
@@ -2,5 +2,9 @@
main组件
再按一次退出程序
+ Fragment组件化
+ news
+ girls
+ 预留
diff --git a/module_news/build.gradle b/module_news/build.gradle
index 00f6fec..a1838bd 100644
--- a/module_news/build.gradle
+++ b/module_news/build.gradle
@@ -5,14 +5,23 @@ if (isModule.toBoolean()) {
}
android {
- compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
-
+ compileSdkVersion build_versions.target_sdk
defaultConfig {
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode rootProject.ext.versionCode
- versionName rootProject.ext.versionName
+ minSdkVersion build_versions.min_sdk
+ targetSdkVersion build_versions.target_sdk
+ versionCode 1
+ versionName "1.0"
+
+ javaCompileOptions {
+ annotationProcessorOptions {
+ arguments = [ moduleName : project.getName() ]
+ }
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
@@ -29,15 +38,16 @@ android {
}
}
- //设置了resourcePrefix值后,所有的资源名必须以指定的字符串做前缀,否则会报错。
- //但是resourcePrefix这个值只能限定xml里面的资源,并不能限定图片资源,所有图片资源仍然需要手动去修改资源名。
- //resourcePrefix "girls_"
-
-
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- annotationProcessor "com.github.mzule.activityrouter:compiler:$rootProject.annotationProcessor"
- compile project(':lib_common')
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ annotationProcessor deps.arouter_compiler
+ implementation project(':lib_common')
}
diff --git a/module_news/src/main/AndroidManifest.xml b/module_news/src/main/AndroidManifest.xml
index 6873b60..14b08f4 100644
--- a/module_news/src/main/AndroidManifest.xml
+++ b/module_news/src/main/AndroidManifest.xml
@@ -1,5 +1,5 @@
+ package="com.guiying.module.news">
类说明
+ *
+ * @author 张华洋 2017/9/20 22:29
+ * @version V2.8.3
+ * @name MyDelegate
+ */
+@Keep
+public class MyDelegate implements IApplicationDelegate {
+
+ @Override
+ public void onCreate() {
+ Logger.init("pattern");
+ //主动添加
+ ViewManager.getInstance().addFragment(0, NewsFragment.newInstance());
+ }
+
+ @Override
+ public void onTerminate() {
+
+ }
+
+ @Override
+ public void onLowMemory() {
+
+ }
+
+ @Override
+ public void onTrimMemory(int level) {
+
+ }
+}
diff --git a/module_news/src/main/java/com/guiying/module/news/MyViewDelegate.java b/module_news/src/main/java/com/guiying/module/news/MyViewDelegate.java
new file mode 100644
index 0000000..0620bb5
--- /dev/null
+++ b/module_news/src/main/java/com/guiying/module/news/MyViewDelegate.java
@@ -0,0 +1,28 @@
+package com.guiying.module.news;
+
+import android.support.annotation.Keep;
+import android.view.View;
+
+import com.guiying.module.common.base.BaseFragment;
+import com.guiying.module.common.base.IViewDelegate;
+
+/**
+ * 类说明
+ *
+ * @author 张华洋 2018/1/4 22:16
+ * @version V2.8.3
+ * @name MyViewDelegate
+ */
+@Keep
+public class MyViewDelegate implements IViewDelegate {
+
+ @Override
+ public BaseFragment getFragment(String name) {
+ return NewsFragment.newInstance();
+ }
+
+ @Override
+ public View getView(String name) {
+ return null;
+ }
+}
diff --git a/module_news/src/main/java/com/guiying/module/news/NewsFragment.java b/module_news/src/main/java/com/guiying/module/news/NewsFragment.java
new file mode 100644
index 0000000..93c039a
--- /dev/null
+++ b/module_news/src/main/java/com/guiying/module/news/NewsFragment.java
@@ -0,0 +1,43 @@
+package com.guiying.module.news;
+
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.guiying.module.common.base.BaseFragment;
+
+
+/**
+ * A simple {@link Fragment} subclass.
+ */
+public class NewsFragment extends BaseFragment {
+
+ /**
+ * Use this factory method to create a new instance of
+ * this fragment using the provided parameters.
+ *
+ * @return A new instance of fragment NewsFragment.
+ */
+ public static NewsFragment newInstance() {
+ return new NewsFragment();
+ }
+
+
+
+ public NewsFragment() {
+ // Required empty public constructor
+ }
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.fragment_news, container, false);
+ }
+
+
+}
diff --git a/module_news/src/main/java/com/guiying/news/data/NewsDataSource.java b/module_news/src/main/java/com/guiying/module/news/data/NewsDataSource.java
similarity index 72%
rename from module_news/src/main/java/com/guiying/news/data/NewsDataSource.java
rename to module_news/src/main/java/com/guiying/module/news/data/NewsDataSource.java
index 07d6fbd..8990f08 100644
--- a/module_news/src/main/java/com/guiying/news/data/NewsDataSource.java
+++ b/module_news/src/main/java/com/guiying/module/news/data/NewsDataSource.java
@@ -1,8 +1,8 @@
-package com.guiying.news.data;
+package com.guiying.module.news.data;
-import com.guiying.common.base.InfoCallback;
-import com.guiying.news.data.bean.MessageDetail;
-import com.guiying.news.data.bean.StoryList;
+import com.guiying.module.common.base.InfoCallback;
+import com.guiying.module.news.data.bean.MessageDetail;
+import com.guiying.module.news.data.bean.StoryList;
/**
* 类说明
diff --git a/module_news/src/main/java/com/guiying/news/data/bean/MessageDetail.java b/module_news/src/main/java/com/guiying/module/news/data/bean/MessageDetail.java
similarity index 98%
rename from module_news/src/main/java/com/guiying/news/data/bean/MessageDetail.java
rename to module_news/src/main/java/com/guiying/module/news/data/bean/MessageDetail.java
index b853f15..204bb82 100644
--- a/module_news/src/main/java/com/guiying/news/data/bean/MessageDetail.java
+++ b/module_news/src/main/java/com/guiying/module/news/data/bean/MessageDetail.java
@@ -1,4 +1,4 @@
-package com.guiying.news.data.bean;
+package com.guiying.module.news.data.bean;
import java.util.List;
diff --git a/module_news/src/main/java/com/guiying/news/data/bean/Story.java b/module_news/src/main/java/com/guiying/module/news/data/bean/Story.java
similarity index 97%
rename from module_news/src/main/java/com/guiying/news/data/bean/Story.java
rename to module_news/src/main/java/com/guiying/module/news/data/bean/Story.java
index 7b7cef2..af488ca 100644
--- a/module_news/src/main/java/com/guiying/news/data/bean/Story.java
+++ b/module_news/src/main/java/com/guiying/module/news/data/bean/Story.java
@@ -1,4 +1,4 @@
-package com.guiying.news.data.bean;
+package com.guiying.module.news.data.bean;
/**
* 日报新闻实体类
diff --git a/module_news/src/main/java/com/guiying/news/data/bean/StoryList.java b/module_news/src/main/java/com/guiying/module/news/data/bean/StoryList.java
similarity index 92%
rename from module_news/src/main/java/com/guiying/news/data/bean/StoryList.java
rename to module_news/src/main/java/com/guiying/module/news/data/bean/StoryList.java
index 99f3f5e..58ba7e0 100644
--- a/module_news/src/main/java/com/guiying/news/data/bean/StoryList.java
+++ b/module_news/src/main/java/com/guiying/module/news/data/bean/StoryList.java
@@ -1,4 +1,4 @@
-package com.guiying.news.data.bean;
+package com.guiying.module.news.data.bean;
import java.util.List;
diff --git a/module_news/src/main/java/com/guiying/news/data/source/RemoteNewsDataSource.java b/module_news/src/main/java/com/guiying/module/news/data/source/RemoteNewsDataSource.java
similarity index 80%
rename from module_news/src/main/java/com/guiying/news/data/source/RemoteNewsDataSource.java
rename to module_news/src/main/java/com/guiying/module/news/data/source/RemoteNewsDataSource.java
index 51075f2..05d4d84 100644
--- a/module_news/src/main/java/com/guiying/news/data/source/RemoteNewsDataSource.java
+++ b/module_news/src/main/java/com/guiying/module/news/data/source/RemoteNewsDataSource.java
@@ -1,13 +1,13 @@
-package com.guiying.news.data.source;
+package com.guiying.module.news.data.source;
-import com.guiying.common.base.InfoCallback;
-import com.guiying.common.http.DataType;
-import com.guiying.common.http.HttpClient;
-import com.guiying.common.http.OnResultListener;
-import com.guiying.news.Constants;
-import com.guiying.news.data.NewsDataSource;
-import com.guiying.news.data.bean.MessageDetail;
-import com.guiying.news.data.bean.StoryList;
+import com.guiying.module.common.base.InfoCallback;
+import com.guiying.module.common.http.DataType;
+import com.guiying.module.common.http.HttpClient;
+import com.guiying.module.common.http.OnResultListener;
+import com.guiying.module.news.Constants;
+import com.guiying.module.news.data.NewsDataSource;
+import com.guiying.module.news.data.bean.MessageDetail;
+import com.guiying.module.news.data.bean.StoryList;
/**
* 类说明
diff --git a/module_news/src/main/java/com/guiying/news/detail/NewsDetailActivity.java b/module_news/src/main/java/com/guiying/module/news/detail/NewsDetailActivity.java
similarity index 74%
rename from module_news/src/main/java/com/guiying/news/detail/NewsDetailActivity.java
rename to module_news/src/main/java/com/guiying/module/news/detail/NewsDetailActivity.java
index 2317f9d..1539ad9 100644
--- a/module_news/src/main/java/com/guiying/news/detail/NewsDetailActivity.java
+++ b/module_news/src/main/java/com/guiying/module/news/detail/NewsDetailActivity.java
@@ -1,8 +1,9 @@
-package com.guiying.news.detail;
+package com.guiying.module.news.detail;
import android.os.Bundle;
-import com.guiying.common.base.BaseActivity;
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.guiying.module.common.base.BaseActivity;
/**
* 类说明
@@ -11,6 +12,7 @@
* @version V1.2.0
* @name NewsDetailActivity
*/
+@Route(path = "/news/detail")
public class NewsDetailActivity extends BaseActivity {
@Override
diff --git a/module_news/src/main/java/com/guiying/news/detail/NewsDetailContract.java b/module_news/src/main/java/com/guiying/module/news/detail/NewsDetailContract.java
similarity index 71%
rename from module_news/src/main/java/com/guiying/news/detail/NewsDetailContract.java
rename to module_news/src/main/java/com/guiying/module/news/detail/NewsDetailContract.java
index fb0f422..6a21ef5 100644
--- a/module_news/src/main/java/com/guiying/news/detail/NewsDetailContract.java
+++ b/module_news/src/main/java/com/guiying/module/news/detail/NewsDetailContract.java
@@ -1,8 +1,8 @@
-package com.guiying.news.detail;
+package com.guiying.module.news.detail;
-import com.guiying.common.base.BasePresenter;
-import com.guiying.common.base.BaseView;
-import com.guiying.news.data.bean.MessageDetail;
+import com.guiying.module.common.base.BasePresenter;
+import com.guiying.module.common.base.BaseView;
+import com.guiying.module.news.data.bean.MessageDetail;
/**
* 类说明
diff --git a/module_news/src/main/java/com/guiying/news/detail/NewsDetailPresenter.java b/module_news/src/main/java/com/guiying/module/news/detail/NewsDetailPresenter.java
similarity index 78%
rename from module_news/src/main/java/com/guiying/news/detail/NewsDetailPresenter.java
rename to module_news/src/main/java/com/guiying/module/news/detail/NewsDetailPresenter.java
index f2b718c..f517ae7 100644
--- a/module_news/src/main/java/com/guiying/news/detail/NewsDetailPresenter.java
+++ b/module_news/src/main/java/com/guiying/module/news/detail/NewsDetailPresenter.java
@@ -1,9 +1,9 @@
-package com.guiying.news.detail;
+package com.guiying.module.news.detail;
-import com.guiying.common.base.InfoCallback;
-import com.guiying.news.data.NewsDataSource;
-import com.guiying.news.data.bean.MessageDetail;
-import com.guiying.news.data.source.RemoteNewsDataSource;
+import com.guiying.module.common.base.InfoCallback;
+import com.guiying.module.news.data.NewsDataSource;
+import com.guiying.module.news.data.bean.MessageDetail;
+import com.guiying.module.news.data.source.RemoteNewsDataSource;
/**
* 类说明
diff --git a/module_news/src/main/java/com/guiying/news/detail/NewsDetailView.java b/module_news/src/main/java/com/guiying/module/news/detail/NewsDetailView.java
similarity index 96%
rename from module_news/src/main/java/com/guiying/news/detail/NewsDetailView.java
rename to module_news/src/main/java/com/guiying/module/news/detail/NewsDetailView.java
index 164f1fb..6be1e58 100644
--- a/module_news/src/main/java/com/guiying/news/detail/NewsDetailView.java
+++ b/module_news/src/main/java/com/guiying/module/news/detail/NewsDetailView.java
@@ -1,4 +1,4 @@
-package com.guiying.news.detail;
+package com.guiying.module.news.detail;
import android.content.Context;
import android.graphics.Bitmap;
@@ -17,8 +17,8 @@
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
-import com.guiying.news.R;
-import com.guiying.news.data.bean.MessageDetail;
+import com.guiying.module.news.R;
+import com.guiying.module.news.data.bean.MessageDetail;
/**
* 类说明
diff --git a/module_news/src/main/java/com/guiying/news/main/NewsCenterActivity.java b/module_news/src/main/java/com/guiying/module/news/main/NewsCenterActivity.java
similarity index 86%
rename from module_news/src/main/java/com/guiying/news/main/NewsCenterActivity.java
rename to module_news/src/main/java/com/guiying/module/news/main/NewsCenterActivity.java
index ee24aa6..af806e2 100644
--- a/module_news/src/main/java/com/guiying/news/main/NewsCenterActivity.java
+++ b/module_news/src/main/java/com/guiying/module/news/main/NewsCenterActivity.java
@@ -1,13 +1,13 @@
-package com.guiying.news.main;
+package com.guiying.module.news.main;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
-import com.github.mzule.activityrouter.annotation.Router;
-import com.guiying.common.base.BaseActivity;
-import com.guiying.news.R;
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.guiying.module.common.base.BaseActivity;
+import com.guiying.module.news.R;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -15,7 +15,14 @@
import java.util.List;
import java.util.Locale;
-@Router("news")
+/**
+ * 类说明
+ *
+ * @author 张华洋 2017/4/20 22:26
+ * @version V1.2.0
+ * @name NewsCenterActivity
+ */
+@Route(path = "/news/center")
public class NewsCenterActivity extends BaseActivity {
protected Toolbar mToolBar;
diff --git a/module_news/src/main/java/com/guiying/news/main/NewsListAdapter.java b/module_news/src/main/java/com/guiying/module/news/main/NewsListAdapter.java
similarity index 91%
rename from module_news/src/main/java/com/guiying/news/main/NewsListAdapter.java
rename to module_news/src/main/java/com/guiying/module/news/main/NewsListAdapter.java
index c8e8ce6..76e452f 100644
--- a/module_news/src/main/java/com/guiying/news/main/NewsListAdapter.java
+++ b/module_news/src/main/java/com/guiying/module/news/main/NewsListAdapter.java
@@ -1,4 +1,4 @@
-package com.guiying.news.main;
+package com.guiying.module.news.main;
import android.content.Context;
import android.content.Intent;
@@ -9,9 +9,9 @@
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.guiying.news.R;
-import com.guiying.news.data.bean.Story;
-import com.guiying.news.detail.NewsDetailActivity;
+import com.guiying.module.news.R;
+import com.guiying.module.news.data.bean.Story;
+import com.guiying.module.news.detail.NewsDetailActivity;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
@@ -22,8 +22,6 @@
* @version V1.2.0
* @name NewsListAdapter
*/
-
-
public class NewsListAdapter extends RecyclerArrayAdapter {
public NewsListAdapter(Context context) {
diff --git a/module_news/src/main/java/com/guiying/news/main/NewsListContract.java b/module_news/src/main/java/com/guiying/module/news/main/NewsListContract.java
similarity index 71%
rename from module_news/src/main/java/com/guiying/news/main/NewsListContract.java
rename to module_news/src/main/java/com/guiying/module/news/main/NewsListContract.java
index 782c2a7..6a7106d 100644
--- a/module_news/src/main/java/com/guiying/news/main/NewsListContract.java
+++ b/module_news/src/main/java/com/guiying/module/news/main/NewsListContract.java
@@ -1,8 +1,8 @@
-package com.guiying.news.main;
+package com.guiying.module.news.main;
-import com.guiying.common.base.BasePresenter;
-import com.guiying.common.base.BaseView;
-import com.guiying.news.data.bean.StoryList;
+import com.guiying.module.common.base.BasePresenter;
+import com.guiying.module.common.base.BaseView;
+import com.guiying.module.news.data.bean.StoryList;
/**
* 类说明
diff --git a/module_news/src/main/java/com/guiying/news/main/NewsListPresenter.java b/module_news/src/main/java/com/guiying/module/news/main/NewsListPresenter.java
similarity index 78%
rename from module_news/src/main/java/com/guiying/news/main/NewsListPresenter.java
rename to module_news/src/main/java/com/guiying/module/news/main/NewsListPresenter.java
index 96b9f20..8ac69db 100644
--- a/module_news/src/main/java/com/guiying/news/main/NewsListPresenter.java
+++ b/module_news/src/main/java/com/guiying/module/news/main/NewsListPresenter.java
@@ -1,9 +1,9 @@
-package com.guiying.news.main;
+package com.guiying.module.news.main;
-import com.guiying.common.base.InfoCallback;
-import com.guiying.news.data.NewsDataSource;
-import com.guiying.news.data.bean.StoryList;
-import com.guiying.news.data.source.RemoteNewsDataSource;
+import com.guiying.module.common.base.InfoCallback;
+import com.guiying.module.news.data.NewsDataSource;
+import com.guiying.module.news.data.bean.StoryList;
+import com.guiying.module.news.data.source.RemoteNewsDataSource;
/**
* 类说明
diff --git a/module_news/src/main/java/com/guiying/news/main/NewsListView.java b/module_news/src/main/java/com/guiying/module/news/main/NewsListView.java
similarity index 95%
rename from module_news/src/main/java/com/guiying/news/main/NewsListView.java
rename to module_news/src/main/java/com/guiying/module/news/main/NewsListView.java
index 70ce0d1..254aca0 100644
--- a/module_news/src/main/java/com/guiying/news/main/NewsListView.java
+++ b/module_news/src/main/java/com/guiying/module/news/main/NewsListView.java
@@ -1,4 +1,4 @@
-package com.guiying.news.main;
+package com.guiying.module.news.main;
import android.content.Context;
import android.support.v4.content.ContextCompat;
@@ -6,8 +6,8 @@
import android.support.v7.widget.LinearLayoutManager;
import android.util.AttributeSet;
-import com.guiying.news.R;
-import com.guiying.news.data.bean.StoryList;
+import com.guiying.module.news.R;
+import com.guiying.module.news.data.bean.StoryList;
import com.jude.easyrecyclerview.EasyRecyclerView;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.jude.easyrecyclerview.decoration.DividerDecoration;
diff --git a/module_news/src/main/java/com/guiying/news/main/NewsListViewAdapter.java b/module_news/src/main/java/com/guiying/module/news/main/NewsListViewAdapter.java
similarity index 98%
rename from module_news/src/main/java/com/guiying/news/main/NewsListViewAdapter.java
rename to module_news/src/main/java/com/guiying/module/news/main/NewsListViewAdapter.java
index dbd36af..4fe1893 100644
--- a/module_news/src/main/java/com/guiying/news/main/NewsListViewAdapter.java
+++ b/module_news/src/main/java/com/guiying/module/news/main/NewsListViewAdapter.java
@@ -1,4 +1,4 @@
-package com.guiying.news.main;
+package com.guiying.module.news.main;
import android.support.v4.view.PagerAdapter;
import android.view.View;
diff --git a/module_news/src/main/java/com/guiying/news/News.java b/module_news/src/main/java/com/guiying/news/News.java
deleted file mode 100644
index fb73939..0000000
--- a/module_news/src/main/java/com/guiying/news/News.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.guiying.news;
-
-import com.github.mzule.activityrouter.annotation.Module;
-
-/**
- * 类说明
- *
- * @author 张华洋 2017/2/15 16:31
- * @version V1.2.0
- * @name news
- */
-@Module("news")
-public class News {
-}
diff --git a/module_news/src/main/java/debug/LauncherActivity.java b/module_news/src/main/java/debug/LauncherActivity.java
index 02fdca3..373f765 100644
--- a/module_news/src/main/java/debug/LauncherActivity.java
+++ b/module_news/src/main/java/debug/LauncherActivity.java
@@ -4,7 +4,7 @@
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
-import com.guiying.news.detail.NewsDetailActivity;
+import com.guiying.module.news.detail.NewsDetailActivity;
/**
* 组件开发模式下,用于传递数据的启动Activity,集成模式下无效
diff --git a/module_news/src/main/java/debug/NewsApplication.java b/module_news/src/main/java/debug/NewsApplication.java
index e6af33e..8bcfdcb 100644
--- a/module_news/src/main/java/debug/NewsApplication.java
+++ b/module_news/src/main/java/debug/NewsApplication.java
@@ -1,11 +1,11 @@
package debug;
-import com.guiying.common.base.BaseApplication;
-import com.guiying.common.http.DataType;
-import com.guiying.common.http.HttpClient;
-import com.guiying.common.http.OnResultListener;
-import com.guiying.news.Constants;
-import com.guiying.news.data.bean.StoryList;
+import com.guiying.module.common.base.BaseApplication;
+import com.guiying.module.common.http.DataType;
+import com.guiying.module.common.http.HttpClient;
+import com.guiying.module.common.http.OnResultListener;
+import com.guiying.module.news.Constants;
+import com.guiying.module.news.data.bean.StoryList;
import com.orhanobut.logger.Logger;
/**
diff --git a/module_news/src/main/module/AndroidManifest.xml b/module_news/src/main/module/AndroidManifest.xml
index 000e4ab..d16a659 100644
--- a/module_news/src/main/module/AndroidManifest.xml
+++ b/module_news/src/main/module/AndroidManifest.xml
@@ -1,6 +1,6 @@
+ package="com.guiying.module.news">
+
+
+
+
+
diff --git a/module_news/src/main/res/values/strings.xml b/module_news/src/main/res/values/strings.xml
index ae57d42..3ac24fd 100644
--- a/module_news/src/main/res/values/strings.xml
+++ b/module_news/src/main/res/values/strings.xml
@@ -3,4 +3,7 @@
News
+
+ Hello blank fragment
+
diff --git a/screenshots/Screenshot_1.png b/screenshots/Screenshot_1.png
index 024993d..4edf537 100644
Binary files a/screenshots/Screenshot_1.png and b/screenshots/Screenshot_1.png differ
diff --git a/screenshots/Screenshot_4.png b/screenshots/Screenshot_4.png
new file mode 100644
index 0000000..3c7b130
Binary files /dev/null and b/screenshots/Screenshot_4.png differ
diff --git a/screenshots/develper.PNG b/screenshots/develper.PNG
new file mode 100644
index 0000000..9d6b8b6
Binary files /dev/null and b/screenshots/develper.PNG differ
diff --git a/settings.gradle b/settings.gradle
index a7e0b34..4e334dd 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,5 +1,6 @@
-include ':module_app',
+include ':lib_common',
+ ':module_app',
':module_main',
':module_girls',
- ':module_news',
- ':lib_common'
+ ':module_news'
+
diff --git a/versions.gradle b/versions.gradle
new file mode 100644
index 0000000..4a8a289
--- /dev/null
+++ b/versions.gradle
@@ -0,0 +1,121 @@
+/**
+ * Shared file between builds so that they can all use the same dependencies and
+ * maven repositories.
+ **/
+ext.deps = [:]
+
+def versions = [:]
+versions.android_gradle_plugin = "3.0.1"
+versions.kotlin = "1.1.51"
+versions.support = "27.0.2"
+versions.multidex = "1.0.2"
+versions.constraint_layout = "1.0.2"
+versions.dagger = "2.11"
+versions.glide = "3.8.0"
+versions.rxjava2 = "2.1.7"
+versions.rx_android = "2.0.1"
+versions.retrofit = "2.3.0"
+versions.event_bus = "3.1.1"
+versions.photo_view = "2.0.0"
+versions.persistent_cookie = "v1.0.1"
+versions.gson = "2.8.2"
+versions.qmui = "1.0.4"
+versions.flow_layout = "1.0.3"
+versions.swipe_recycler = "1.1.3"
+versions.easy_recycler = "4.4.2"
+versions.permission = "1.1.2"
+versions.utils = "1.10.0"
+versions.top_snackbar = "1.1.1"
+versions.litepal = "1.6.1"
+versions.toasty = "1.1.3"
+versions.logger = "1.15"
+versions.material_dialog = "0.9.6.0"
+//Arouter
+versions.arouter_compiler = "1.1.4"
+versions.arouter_api = "1.3.1"
+
+
+
+def deps = [:]
+
+def support = [:]
+support.annotations = "com.android.support:support-annotations:$versions.support"
+support.app_compat = "com.android.support:appcompat-v7:$versions.support"
+support.v13 = "com.android.support:support-v13:$versions.support"
+support.percent = "com.android.support:percent:$versions.support"
+support.recyclerview = "com.android.support:recyclerview-v7:$versions.support"
+support.cardview = "com.android.support:cardview-v7:$versions.support"
+support.design = "com.android.support:design:$versions.support"
+support.v4 = "com.android.support:support-v4:$versions.support"
+support.core_utils = "com.android.support:support-core-utils:$versions.support"
+support.multidex = "com.android.support:multidex:$versions.multidex"
+deps.support = support
+
+
+def retrofit = [:]
+retrofit.runtime = "com.squareup.retrofit2:retrofit:$versions.retrofit"
+retrofit.adapter = "com.squareup.retrofit2:adapter-rxjava2:$versions.retrofi"
+retrofit.gson = "com.squareup.retrofit2:converter-gson:$versions.retrofit"
+deps.retrofit = retrofit
+
+
+def dagger = [:]
+dagger.runtime = "com.google.dagger:dagger:$versions.dagger"
+dagger.android = "com.google.dagger:dagger-android:$versions.dagger"
+dagger.android_support = "com.google.dagger:dagger-android-support:$versions.dagger"
+dagger.compiler = "com.google.dagger:dagger-compiler:$versions.dagger"
+dagger.android_support_compiler = "com.google.dagger:dagger-android-processor:$versions.dagger"
+deps.dagger = dagger
+
+
+def kotlin = [:]
+kotlin.stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jre7:$versions.kotlin"
+kotlin.test = "org.jetbrains.kotlin:kotlin-test-junit:$versions.kotlin"
+kotlin.plugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
+deps.kotlin = kotlin
+
+//view
+deps.constraint_layout = "com.android.support.constraint:constraint-layout:$versions.constraint_layout"
+deps.qmui = "com.qmuiteam:qmui:$versions.qmui"
+deps.flow_layout = "com.zhy:flowlayout-lib:$versions.flow_layout"
+deps.swipe_recycler = "com.yanzhenjie:recyclerview-swipe:$versions.swipe_recycler"
+deps.easy_recycler = "com.jude:easyrecyclerview:$versions.easy_recycler"
+deps.photo_view = "com.github.chrisbanes:PhotoView:$versions.photo_view"
+deps.material_dialog = "com.afollestad.material-dialogs:core:$versions.material_dialog"
+
+deps.android_gradle_plugin = "com.android.tools.build:gradle:$versions.android_gradle_plugin"
+deps.rxjava2 = "io.reactivex.rxjava2:rxjava:$versions.rxjava2"
+deps.rx_android = "io.reactivex.rxjava2:rxandroid:$versions.rx_android"
+//other
+deps.glide = "com.github.bumptech.glide:glide:$versions.glide"
+deps.event_bus = "org.greenrobot:eventbus:$versions.event_bus"
+deps.persistent_cookie = "com.github.franmontiel:PersistentCookieJar:$versions.persistent_cookie"
+deps.gson = "com.google.code.gson:gson:$versions.gson"
+deps.permission = "com.yanzhenjie:permission:$versions.permission"
+deps.utils = "com.blankj:utilcode:$versions.utils"
+deps.top_snackbar ="com.androidadvance:topsnackbar:$versions.top_snackbar"
+deps.litepal = "org.litepal.android:core:$versions.litepal"
+deps.toasty = "com.github.GrenderG:Toasty:$versions.toasty"
+deps.logger = "com.orhanobut:logger:$versions.logger"
+deps.arouter_api = "com.alibaba:arouter-api:$versions.arouter_api"
+deps.arouter_compiler = "com.alibaba:arouter-compiler:$versions.arouter_compiler"
+
+ext.deps = deps
+
+def build_versions = [:]
+build_versions.min_sdk = 16
+build_versions.target_sdk = 27
+build_versions.build_tools = "27.0.2"
+ext.build_versions = build_versions
+
+
+def addRepos(RepositoryHandler handler) {
+ handler.google()
+ handler.jcenter()
+ handler.mavenCentral()
+ //Add the JitPack repository
+ handler.maven { url "https://jitpack.io" }
+ handler.maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
+}
+
+ext.addRepos = this.&addRepos