├── .gitignore ├── .idea ├── gradle.xml ├── markdown-navigator.xml ├── markdown-navigator │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── README_MODULE.md ├── README_MVP.md ├── app ├── .gitignore ├── build.gradle ├── libs │ └── xUtils-2.6.14.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── efly │ │ └── flyhelper │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── efly │ │ │ └── flyhelper │ │ │ ├── AppApplication.java │ │ │ ├── MainActivity.java │ │ │ └── adapter │ │ │ └── FragmentAdapter.java │ └── res │ │ ├── drawable │ │ ├── ic_dashboard_black_24dp.xml │ │ ├── ic_home_black_24dp.xml │ │ └── ic_notifications_black_24dp.xml │ │ ├── layout │ │ └── activity_bottom_navigation.xml │ │ ├── menu │ │ └── menu_bottom_navigation.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── efly │ └── flyhelper │ └── ExampleUnitTest.java ├── base ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── ccj │ │ └── base │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── ccj │ │ │ └── base │ │ │ ├── AppManager.java │ │ │ ├── Constants.java │ │ │ ├── RouterConstants.java │ │ │ ├── adapter │ │ │ ├── CommonRcvAdapter.java │ │ │ ├── bean │ │ │ │ ├── AdapterBean.java │ │ │ │ └── AdapterGroupBean.java │ │ │ ├── item │ │ │ │ └── AdapterItem.java │ │ │ └── util │ │ │ │ ├── IAdapter.java │ │ │ │ └── ItemTypeUtil.java │ │ │ ├── api │ │ │ ├── APIService.java │ │ │ ├── RetrofitRequest.java │ │ │ └── VolleyUtils.java │ │ │ ├── base │ │ │ ├── BaseActivity.java │ │ │ ├── BaseApplication.java │ │ │ ├── BaseBean.java │ │ │ ├── BaseFragment.java │ │ │ ├── BaseModel.java │ │ │ ├── BasePresenter.java │ │ │ ├── BaseView.java │ │ │ └── Constants.java │ │ │ ├── bean │ │ │ ├── User.java │ │ │ └── UserDetail.java │ │ │ ├── utils │ │ │ ├── BitmapUtil.java │ │ │ ├── LruBitmapCache.java │ │ │ ├── SerializableUtil.java │ │ │ ├── SharedPreferenceUtil.java │ │ │ ├── TDeviceUtils.java │ │ │ ├── TLog.java │ │ │ ├── ToastUtil.java │ │ │ ├── eventbus │ │ │ │ └── EventUtils.java │ │ │ └── router │ │ │ │ ├── LoginModuleService.java │ │ │ │ ├── RounterInterceptor.java │ │ │ │ ├── RounterSerialization.java │ │ │ │ ├── RouterService.java │ │ │ │ └── RouterUtils.java │ │ │ └── view │ │ │ ├── SuperRecyclerView.java │ │ │ └── list │ │ │ ├── OnAppBarSkipListener.java │ │ │ └── OnLoadNextListener.java │ └── res │ │ ├── anim │ │ ├── anim_bottom_in.xml │ │ ├── anim_bottom_out.xml │ │ ├── dialog_enter.xml │ │ ├── dialog_exit.xml │ │ ├── footer_menu_slide_in.xml │ │ ├── footer_menu_slide_out.xml │ │ ├── in_from_bottom.xml │ │ ├── in_from_top.xml │ │ ├── out_to_bottom.xml │ │ └── out_to_top.xml │ │ ├── drawable │ │ ├── bg_bt_raise.9.png │ │ ├── bg_bt_raise_color.9.png │ │ ├── bg_bt_raise_dark.9.png │ │ ├── bg_toolbar.xml │ │ └── btn_ripple.xml │ │ ├── layout │ │ └── base_layout_tool_bar.xml │ │ ├── mipmap-hdpi │ │ ├── back.png │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ ├── back.png │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── back.png │ │ ├── ic_launcher.png │ │ └── login_bg.png │ │ ├── mipmap-xxhdpi │ │ ├── back.png │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── ccj │ └── base │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── module_home ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── ccj │ │ └── home │ │ ├── HomeFragment.java │ │ └── MainActivity.java │ ├── release │ └── AndroidManifest.xml │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ └── ic_launcher_background.xml │ ├── layout │ ├── activity_main.xml │ └── home_fragment_haojia_home.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── module_meizi ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── ccj │ │ └── meizi │ │ ├── adapter │ │ └── MeiziRcvAdapter.java │ │ ├── api │ │ ├── MeiziAPIServiceImp.java │ │ └── MeiziRetrofitImp.java │ │ ├── bean │ │ └── Meizhi.java │ │ ├── debug │ │ ├── ContainActivity.java │ │ └── MainActivity.java │ │ ├── holder │ │ └── MeiziItemHolder.java │ │ ├── ui │ │ ├── detail │ │ │ └── MeiziDetailActivity.java │ │ └── main │ │ │ ├── MeiZhiContract.java │ │ │ ├── MeiZhiFragment.java │ │ │ └── MeiZhiPresenter.java │ │ └── utils │ │ └── DateStringUtils.java │ ├── release │ └── AndroidManifest.xml │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ └── ic_launcher_background.xml │ ├── layout │ ├── activity_contain.xml │ ├── activity_main.xml │ ├── activity_meizi_detail.xml │ ├── fragment_meizi.xml │ └── item_meizi_item.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── module_user ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── ccj │ │ └── login │ │ ├── api │ │ ├── LoginAPIServiceImp.java │ │ └── LoginRetrofitImp.java │ │ ├── debug │ │ ├── LoginApplication.java │ │ └── MainActivity.java │ │ ├── service │ │ └── CheckLoginService.java │ │ └── ui │ │ ├── login │ │ ├── LoginActivity.java │ │ ├── LoginContract.java │ │ ├── LoginModel.java │ │ └── LoginPresenter.java │ │ ├── register │ │ └── RegisterActivity.java │ │ └── user │ │ └── UserFragment.java │ ├── release │ └── AndroidManifest.xml │ └── res │ ├── layout │ ├── activity_login.xml │ ├── activity_main.xml │ ├── login_fragment_register.xml │ └── user_fragment_user_home.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ ├── ic_launcher_round.png │ ├── login_bg.png │ └── pic_input_box.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── module_video ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── ccj │ │ └── video │ │ ├── VideoFragment.java │ │ ├── debug │ │ ├── MainActivity.java │ │ └── VideoApplication.java │ │ ├── service │ │ └── VideoServiceImpl.java │ │ └── ui │ │ ├── TakePhotoActivity.java │ │ ├── TakePhotoContract.java │ │ ├── TakePhotoModel.java │ │ └── TakePhotoPresenter.java │ ├── release │ └── AndroidManifest.xml │ └── res │ ├── layout │ ├── activity_main.xml │ ├── activity_take_photo.xml │ └── video_fragment_video_home.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 36 | 37 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | # clean-project-architecture 7 | 8 | 9 | 更新 2018/2/1 组件化重构,修改方式为 主容器app+业务module模式. 10 | 11 | 12 | ---- 13 | 14 | 组件化项目框架,以及主流的项目架构(MVP+RxJava+Retrofit),以后会不断完善. 15 | 16 | 17 | 18 | 19 | - [MVP传送门](https://github.com/ccj659/clean-project-architecture/blob/master/README_MVP.md) 20 | 21 | - [组件化传送门](https://github.com/ccj659/clean-project-architecture/blob/master/README_MODULE.md) 22 | 23 | 24 | 25 | 26 | 参考界面: 27 | ![](http://i.imgur.com/EnBxczU.gif) -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | repositories { 3 | jcenter() 4 | } 5 | android { 6 | 7 | compileSdkVersion rootProject.ext.compileSdkVersion 8 | buildToolsVersion rootProject.ext.buildToolsVersion 9 | defaultConfig { 10 | applicationId "com.efly.flyhelper" 11 | minSdkVersion rootProject.ext.minSdkVersion 12 | targetSdkVersion rootProject.ext.targetSdkVersion 13 | versionCode rootProject.ext.versionCode 14 | versionName rootProject.ext.versionName 15 | multiDexEnabled false 16 | 17 | //arouter 18 | javaCompileOptions { 19 | annotationProcessorOptions { 20 | arguments = [moduleName: project.getName()] 21 | } 22 | } 23 | } 24 | buildTypes { 25 | release { 26 | //更改AndroidManifest.xml中预先定义好占位符信息 27 | //manifestPlaceholders = [app_icon: "@drawable/icon"] 28 | // 不显示Log 29 | buildConfigField "boolean", "LEO_DEBUG", "false" 30 | //是否zip对齐 31 | zipAlignEnabled true 32 | // 缩减resource文件 33 | shrinkResources true 34 | //Proguard 35 | minifyEnabled true 36 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 37 | } 38 | 39 | debug { 40 | //给applicationId添加后缀“.debug” 41 | applicationIdSuffix ".debug" 42 | //manifestPlaceholders = [app_icon: "@drawable/launch_beta"] 43 | buildConfigField "boolean", "LOG_DEBUG", "true" 44 | zipAlignEnabled false 45 | shrinkResources false 46 | minifyEnabled false 47 | debuggable true 48 | } 49 | } 50 | 51 | } 52 | 53 | 54 | dependencies { 55 | compile fileTree(include: ['*.jar'], dir: 'libs') 56 | 57 | 58 | //arouter 59 | compile rootProject.ext.arouterApi 60 | annotationProcessor rootProject.ext.arouterCompiler 61 | 62 | //butterknife 63 | annotationProcessor rootProject.ext.butterknifeCompiler 64 | 65 | if (isModule.toBoolean()) { 66 | //当isDebug true,app得依赖基础库,保证app不报错 67 | compile project(':base') 68 | } else { 69 | compile project(':module_home') 70 | compile project(':module_user') 71 | compile project(':module_video') 72 | compile project(':module_meizi') 73 | 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /app/libs/xUtils-2.6.14.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/app/libs/xUtils-2.6.14.jar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -ignorewarnings # 忽略警告,避免打包时某些警告出现 5 | -dontwarn 6 | -dontskipnonpubliclibraryclasses 7 | -dontskipnonpubliclibraryclassmembers 8 | -dontpreverify 9 | -verbose # 混淆时是否记录日志 10 | #-printmapping topden.map 11 | -keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | public *; 13 | } 14 | 15 | 16 | -keep class * extends java.lang.annotation.Annotation { *; } 17 | -keep class * extends android.app.Application { *; } 18 | -keep public class * implements java.io.Serializable {*;} 19 | -keep public class * implements android.os.Parcelable {*;} 20 | 21 | 22 | 23 | -keepattributes Exceptions,InnerClasses,Signature 24 | -keepattributes SourceFile,LineNumberTable,EnclosingMethod 25 | 26 | 27 | # keep 泛型 28 | -keepattributes *Annotation* 29 | 30 | -keepclassmembers class * { 31 | public (org.json.JSONObject); 32 | } 33 | 34 | -keepclassmembers class **.R$* { 35 | public static ; 36 | } 37 | 38 | -keep public class * extends android.app.Fragment 39 | -keep public class * extends android.app.Activity 40 | -keep public class * extends android.app.Application 41 | -keep public class * extends android.app.Service 42 | -keep public class * extends android.content.BroadcastReceiver 43 | -keep public class * extends android.content.ContentProvider 44 | -keep public class * extends android.app.backup.BackupAgentHelper 45 | -keep public class * extends android.preference.Preference 46 | -keepattributes *Annotation* 47 | -keep class android.support.v4.** { *; } 48 | -keep interface android.support.v4.app.** { *; } 49 | -keep public class * extends android.support.v4.** 50 | -keep public class * extends android.support.v13.** 51 | -keep class android.support.v13.** { *; } 52 | -keep class android.support.v7.** { *; } 53 | 54 | 55 | 56 | -dontwarn javax.annotation.** 57 | -keep class javax.annotation.** { *;} 58 | 59 | 60 | #########-------------------第三方 ----------------------------------############# 61 | #recoo 62 | -keep class com.dodola.** {*;} 63 | -keep class com.lody.legend.** {*;} 64 | 65 | #-dontwarn com.dodola.rocoo.** { *; } 66 | #-keep class com.dodola.rocoo.** { *; } 67 | 68 | # ButterKnife 69 | -keep class butterknife.** { *; } 70 | -dontwarn butterknife.internal.** 71 | -keep class **$$ViewBinder { *; } 72 | -keepclasseswithmembernames class * { 73 | @butterknife.* ; 74 | } 75 | -keepclasseswithmembernames class * { 76 | @butterknife.* ; 77 | } 78 | 79 | # EventBus 80 | -keepattributes *Annotation* 81 | -keepclassmembers class ** { 82 | @org.greenrobot.eventbus.Subscribe ; 83 | } 84 | -keep enum org.greenrobot.eventbus.ThreadMode { *; } 85 | 86 | 87 | 88 | # RxJava RxAndroid 89 | -dontwarn sun.misc.** 90 | -keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { 91 | long producerIndex; 92 | long consumerIndex; 93 | } 94 | -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { 95 | rx.internal.util.atomic.LinkedQueueNode producerNode; 96 | } 97 | -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef { 98 | rx.internal.util.atomic.LinkedQueueNode consumerNode; 99 | } 100 | 101 | 102 | 103 | 104 | 105 | # Retrofit 106 | -dontwarn retrofit2.** 107 | -keep class retrofit2.** { *; } 108 | -keepattributes Signature 109 | -keepattributes Exceptions 110 | 111 | 112 | 113 | # OkHttp3 114 | -dontwarn com.squareup.okhttp3.** 115 | -keep class com.squareup.okhttp3.** { *;} 116 | -dontwarn okio.** 117 | 118 | 119 | 120 | # Gson 121 | #-keepattributes Signature-keepattributes *Annotation* 122 | -keep class sun.misc.Unsafe { *; } 123 | -keep class com.google.gson.stream.** { *; } 124 | # 使用Gson时需要配置Gson的解析对象及变量都不混淆。不然Gson会找不到变量。 125 | # 将下面替换成自己的实体类 126 | -keep class com.efly.flyhelper.bean.** { *; } 127 | 128 | 129 | 130 | # EventBus 131 | -keepattributes *Annotation* 132 | -keepclassmembers class ** { 133 | @org.greenrobot.eventbus.Subscribe ; 134 | } 135 | -keep enum org.greenrobot.eventbus.ThreadMode { *; } 136 | 137 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/efly/flyhelper/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.efly.flyhelper; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/efly/flyhelper/AppApplication.java: -------------------------------------------------------------------------------- 1 | package com.efly.flyhelper; 2 | 3 | import com.ccj.base.base.BaseApplication; 4 | 5 | /** 6 | * ARouter 这里必须在 这里初始化, 在 base里面初始化 无效,奇怪 7 | * Created by chenchangjun on 17/8/10. 8 | */ 9 | 10 | public class AppApplication extends BaseApplication { 11 | 12 | 13 | 14 | 15 | @Override 16 | public void onCreate() { 17 | super.onCreate(); 18 | 19 | } 20 | 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/efly/flyhelper/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.efly.flyhelper; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | import android.support.annotation.Nullable; 6 | import android.support.design.widget.BottomNavigationView; 7 | import android.support.v4.app.Fragment; 8 | import android.support.v4.view.ViewPager; 9 | import android.view.MenuItem; 10 | 11 | import com.alibaba.android.arouter.launcher.ARouter; 12 | import com.ccj.base.base.BaseActivity; 13 | import com.ccj.base.RouterConstants; 14 | import com.efly.flyhelper.adapter.FragmentAdapter; 15 | 16 | import java.util.LinkedList; 17 | import java.util.List; 18 | 19 | 20 | public class MainActivity extends BaseActivity { 21 | 22 | private ViewPager mPager; 23 | private List mFragments = new LinkedList<>(); 24 | private FragmentAdapter mAdapter; 25 | private BottomNavigationView navigation; 26 | 27 | private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener 28 | = new BottomNavigationView.OnNavigationItemSelectedListener() { 29 | 30 | @Override 31 | public boolean onNavigationItemSelected(@NonNull MenuItem item) { 32 | int i = item.getItemId(); 33 | if (i == R.id.navigation_home) { 34 | mPager.setCurrentItem(0); 35 | return true; 36 | } else if (i == R.id.navigation_dashboard) { 37 | mPager.setCurrentItem(1); 38 | return true; 39 | } else if (i == R.id.navigation_notifications) { 40 | mPager.setCurrentItem(2); 41 | return true; 42 | } 43 | return false; 44 | } 45 | 46 | }; 47 | 48 | @Override 49 | public void onCreate(@Nullable Bundle savedInstanceState) { 50 | super.onCreate(savedInstanceState); 51 | setContentView(R.layout.activity_bottom_navigation); 52 | mPager = (ViewPager) findViewById(R.id.container_pager); 53 | 54 | navigation = (BottomNavigationView) findViewById(R.id.navigation); 55 | initViewPager(); 56 | navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); 57 | } 58 | 59 | private void initViewPager() { 60 | 61 | 62 | Fragment home = (Fragment) ARouter.getInstance().build(RouterConstants.HOME_MUDULE_FRAGMENT_HOME_HOME).navigation(); 63 | Fragment meizi = (Fragment) ARouter.getInstance().build(RouterConstants.MEIZI_MUDULE_FRAGMENT_HOME_MEIZI).navigation(); 64 | Fragment user = (Fragment) ARouter.getInstance().build(RouterConstants.USER_MUDULE_FRAGMENT_HOME_USER).navigation(); 65 | mFragments.add(home); 66 | mFragments.add(meizi); 67 | mFragments.add(user); 68 | 69 | mAdapter = new FragmentAdapter(getSupportFragmentManager(), mFragments); 70 | mPager.setAdapter(mAdapter); 71 | } 72 | 73 | 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/efly/flyhelper/adapter/FragmentAdapter.java: -------------------------------------------------------------------------------- 1 | package com.efly.flyhelper.adapter; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v4.app.FragmentManager; 5 | import android.support.v4.app.FragmentStatePagerAdapter; 6 | 7 | import java.util.List; 8 | 9 | public class FragmentAdapter extends FragmentStatePagerAdapter { 10 | private List mFragments; 11 | 12 | public FragmentAdapter(FragmentManager fm, List mFragments) { 13 | super(fm); 14 | this.mFragments = mFragments; 15 | } 16 | 17 | @Override 18 | public Fragment getItem(int position) { 19 | return mFragments.get(position); 20 | } 21 | 22 | @Override 23 | public int getCount() { 24 | return mFragments != null ? mFragments.size() : 0; 25 | } 26 | 27 | @Override 28 | public int getItemPosition(Object object) { 29 | return android.support.v4.view.PagerAdapter.POSITION_NONE; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_dashboard_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_home_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_notifications_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_bottom_navigation.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_bottom_navigation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 13 | 14 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MVP和组件化 3 | 我的 4 | 妹子 5 | 首页 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/test/java/com/efly/flyhelper/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.efly.flyhelper; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /base/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /base/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.compileSdkVersion 5 | buildToolsVersion rootProject.ext.buildToolsVersion 6 | 7 | defaultConfig { 8 | minSdkVersion rootProject.ext.minSdkVersion 9 | targetSdkVersion rootProject.ext.targetSdkVersion 10 | versionCode rootProject.ext.versionCode 11 | versionName rootProject.ext.versionName 12 | 13 | } 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | repositories { 24 | flatDir { 25 | dirs 'aars' 26 | } 27 | } 28 | 29 | ext{ 30 | libSupportVersion = '25.3.1' 31 | } 32 | 33 | dependencies { 34 | compile fileTree(dir: 'libs', include: ['*.jar']) 35 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 36 | exclude group: 'com.android.support', module: 'support-annotations' 37 | }) 38 | 39 | compile rootProject.ext.appcompatV7 40 | compile rootProject.ext.constraintLayout 41 | 42 | 43 | 44 | //butterknife 45 | compile rootProject.ext.butterknife 46 | 47 | compile rootProject.ext.arouterApi 48 | 49 | compile rootProject.ext.eventbus 50 | 51 | 52 | 53 | 54 | 55 | /*view相关*/ 56 | compile "com.android.support:design:${libSupportVersion}" 57 | compile "com.android.support:recyclerview-v7:${libSupportVersion}" 58 | compile "com.android.support:cardview-v7:${libSupportVersion}" 59 | compile "com.android.support:support-v4:${libSupportVersion}" 60 | 61 | /*请求网络框架*/ 62 | //retrofit 63 | compile 'com.squareup.retrofit2:retrofit:2.0.2' 64 | compile 'com.squareup.okhttp3:logging-interceptor:3.1.2' 65 | compile 'com.squareup.retrofit2:converter-gson:2.0.2' 66 | compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2' 67 | 68 | //rxjava 69 | compile 'io.reactivex:rxandroid:1.1.0' 70 | compile 'io.reactivex:rxjava:1.1.0' 71 | 72 | compile 'com.google.code.gson:gson:2.4' 73 | 74 | 75 | compile 'com.mcxiaoke.volley:library:1.0.19' 76 | 77 | //图片请求 78 | compile 'com.squareup.picasso:picasso:2.5.2' 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /base/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/chenchangjun/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -keep public class com.alibaba.android.arouter.routes.**{*;} 27 | -keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;} 28 | 29 | # 如果使用了 byType 的方式获取 Service,需添加下面规则,保护接口 30 | -keep interface * implements com.alibaba.android.arouter.facade.template.IProvider 31 | 32 | # 如果使用了 单类注入,即不定义接口实现 IProvider,需添加下面规则,保护实现 33 | -keep class * implements com.alibaba.android.arouter.facade.template.IProvider -------------------------------------------------------------------------------- /base/src/androidTest/java/com/ccj/base/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.ccj.base.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /base/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/AppManager.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base; 2 | 3 | import android.app.Activity; 4 | import android.app.ActivityManager; 5 | import android.content.Context; 6 | 7 | import java.util.Stack; 8 | 9 | /** 10 | * activity堆栈式管理 11 | * 12 | */ 13 | public class AppManager { 14 | 15 | private static Stack activityStack; 16 | private static AppManager instance; 17 | 18 | private AppManager() { 19 | } 20 | 21 | 22 | 23 | /** 24 | * 单一实例 25 | */ 26 | public static AppManager getAppManager() { 27 | if (instance == null) { 28 | instance = new AppManager(); 29 | } 30 | 31 | if (activityStack == null) { 32 | activityStack = new Stack(); 33 | } 34 | 35 | return instance; 36 | } 37 | 38 | /** 39 | * 获取指定的Activity 40 | * 41 | * @author kymjs 42 | */ 43 | public static Activity getActivity(Class cls) { 44 | if (activityStack != null) 45 | for (Activity activity : activityStack) { 46 | if (activity.getClass().equals(cls)) { 47 | return activity; 48 | } 49 | } 50 | return null; 51 | } 52 | 53 | /** 54 | * 添加Activity到堆栈 55 | */ 56 | public void addActivity(Activity activity) { 57 | activityStack.add(activity); 58 | } 59 | 60 | /** 61 | * 获取当前Activity(堆栈中最后一个压入的) 62 | */ 63 | public Activity currentActivity() { 64 | Activity activity = activityStack.lastElement(); 65 | return activity; 66 | } 67 | 68 | /** 69 | * 结束当前Activity(堆栈中最后一个压入的) 70 | */ 71 | public void finishActivity() { 72 | Activity activity = activityStack.lastElement(); 73 | finishActivity(activity); 74 | } 75 | 76 | /** 77 | * 结束指定的Activity 78 | */ 79 | public void finishActivity(Activity activity) { 80 | if (activity != null && activityStack.contains(activity)) { 81 | activityStack.remove(activity); 82 | activity.finish(); 83 | } 84 | } 85 | 86 | /** 87 | * 结束指定的Activity 88 | */ 89 | public void removeActivity(Activity activity) { 90 | if (activity != null && activityStack.contains(activity)) { 91 | activityStack.remove(activity); 92 | } 93 | } 94 | 95 | /** 96 | * 结束指定类名的Activity 97 | */ 98 | public void finishActivity(Class cls) { 99 | for (Activity activity : activityStack) { 100 | if (activity.getClass().equals(cls)) { 101 | finishActivity(activity); 102 | break; 103 | } 104 | } 105 | } 106 | 107 | /** 108 | * 结束所有Activity 109 | */ 110 | public void finishAllActivity() { 111 | for (int i = 0, size = activityStack.size(); i < size; i++) { 112 | if (null != activityStack.get(i)) { 113 | finishActivity(activityStack.get(i)); 114 | } 115 | } 116 | activityStack.clear(); 117 | } 118 | 119 | /** 120 | * 退出应用程序 121 | */ 122 | public void AppExit(Context context) { 123 | 124 | try { 125 | finishAllActivity(); 126 | // System.exit(0); 127 | } catch (Exception e) { 128 | } 129 | 130 | // 获取packagemanager的实例 131 | try { 132 | ActivityManager activityMgr = (ActivityManager) context 133 | .getSystemService(Context.ACTIVITY_SERVICE); 134 | activityMgr.killBackgroundProcesses(context.getPackageName()); 135 | activityStack = null; 136 | instance=null; 137 | System.exit(0); 138 | } catch (Exception e) { 139 | System.exit(0); 140 | } 141 | 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/Constants.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base; 2 | 3 | /** 4 | * Created by chenchangjun on 17/8/10. 5 | */ 6 | 7 | public class Constants { 8 | 9 | public static final String START_LOGIN_WITH_PARAMS = "START_LOGIN_WITH_PARAMS"; 10 | public static final int REQUEST_START_LOGIN = 0x00110; 11 | public static final int RESULT_FROM_LOGIN = 0x00011; 12 | 13 | 14 | public static final String PARAMS_RESULT_FROM_LOGIN = "PARAMS_RESULT_FROM_LOGIN"; 15 | public static final String PARAMS_REQUEST_FOR_DETAIL = "PARAMS_REQUEST_FOR_DETAIL"; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/RouterConstants.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base; 2 | /** 3 | * Created by chenchangjun on 17/8/9. 4 | */ 5 | 6 | 7 | public final class RouterConstants { 8 | 9 | 10 | 11 | 12 | /** 13 | * home module 14 | */ 15 | public static final String HOME_MODULE_NAME="/homemodule/"; 16 | public static final String HOME_MUDULE_FRAGMENT_HOME_HOME = HOME_MODULE_NAME+"FRAGMENT_HOME_HOME"; 17 | 18 | 19 | /** 20 | * user module 21 | */ 22 | public static final String USER_MODULE_NAME ="/loginmodule/"; 23 | 24 | public static final String USER_MUDULE_FRAGMENT_HOME_USER = USER_MODULE_NAME+"FRAGMENT_HOME_USER"; 25 | 26 | 27 | public static final String USER_MOUDLE_ACTIVITY = USER_MODULE_NAME +"LoginActivity"; 28 | public static final String USER_SERVICE_IMPL = USER_MODULE_NAME +"LoginServiceImpl"; 29 | public static final String USER_REGISTER_FRAGMENT = USER_MODULE_NAME +"/RegisterFragment"; 30 | 31 | /** 32 | * video module 33 | */ 34 | public static final String VIDEO_MODULE_NAME="/videomodule/"; 35 | public static final String VIDEO_MUDULE_FRAGMENT_HOME_VIDEO = VIDEO_MODULE_NAME+"FRAGMENT_HOME_VIDEO"; 36 | 37 | public static final String VIDEO_MUDULE_ACTIVITY = VIDEO_MODULE_NAME+"TakePhotoActivity"; 38 | public static final String VIDEO_SERVICE_IMPL = VIDEO_MODULE_NAME+"VideoServiceImpl"; 39 | 40 | 41 | 42 | 43 | /** 44 | * meizi module 45 | */ 46 | public static final String MEIZI_MODULE_NAME="/meizimodule/"; 47 | public static final String MEIZI_MUDULE_FRAGMENT_HOME_MEIZI = MEIZI_MODULE_NAME+"FRAGMENT_HOME_MEIZI"; 48 | public static final String MEIZI_MUDULE_ACTIVITY_MEIZI_DETAIL = MEIZI_MODULE_NAME+"ACTIVITY_MEIZI_DETAIL"; 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/adapter/CommonRcvAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.adapter; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.support.annotation.NonNull; 6 | import android.support.annotation.Nullable; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.LayoutInflater; 9 | import android.view.ViewGroup; 10 | 11 | import com.ccj.base.adapter.item.AdapterItem; 12 | import com.ccj.base.adapter.util.IAdapter; 13 | import com.ccj.base.adapter.util.ItemTypeUtil; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | 19 | /** 20 | * @author ccj 21 | * @date 2017/3/23 22 | */ 23 | public abstract class CommonRcvAdapter extends RecyclerView.Adapter implements IAdapter { 24 | 25 | private List mDataList; 26 | 27 | private Object mType; 28 | 29 | private ItemTypeUtil mUtil; 30 | 31 | private int currentPos; 32 | 33 | public Activity mActivity; 34 | 35 | 36 | public CommonRcvAdapter(@Nullable List data, Activity mActivity) { 37 | if (data == null) { 38 | data = new ArrayList<>(); 39 | } 40 | mDataList = data; 41 | mUtil = new ItemTypeUtil(); 42 | this.mActivity = mActivity; 43 | } 44 | 45 | 46 | public T getItem(int position) { 47 | if (position < 0 || position > getItemCount() - 1) { 48 | return null; 49 | } 50 | return mDataList.get(position); 51 | } 52 | 53 | 54 | @Override 55 | public int getItemCount() { 56 | return mDataList == null ? 0 : mDataList.size(); 57 | } 58 | 59 | @Override 60 | public void setData(@NonNull List data) { 61 | mDataList = data; 62 | } 63 | 64 | @Override 65 | public List getData() { 66 | return mDataList; 67 | } 68 | 69 | @Override 70 | public long getItemId(int position) { 71 | return position; 72 | } 73 | 74 | /** 75 | * instead by{@link #getItemType(Object)} 76 | *

77 | * 通过数据得到obj的类型的type 78 | * 然后,通过{@link ItemTypeUtil}来转换位int类型的type 79 | */ 80 | @Deprecated 81 | @Override 82 | public int getItemViewType(int position) { 83 | this.currentPos = position; 84 | mType = getItemType(mDataList.get(position)); 85 | return mUtil.getIntType(mType); 86 | } 87 | 88 | @Override 89 | public Object getItemType(T t) { 90 | return -1; // default 91 | } 92 | 93 | @Override 94 | public RcvAdapterItem onCreateViewHolder(ViewGroup parent, int viewType) { 95 | return new RcvAdapterItem(parent.getContext(), parent, createItem(mType)); 96 | } 97 | 98 | @Override 99 | public void onBindViewHolder(RcvAdapterItem holder, int position) { 100 | 101 | holder.item.handleData(getConvertedData(mDataList.get(position), mType), position); 102 | 103 | 104 | } 105 | 106 | @NonNull 107 | @Override 108 | public Object getConvertedData(T data, Object type) { 109 | return data; 110 | } 111 | 112 | @Override 113 | public int getCurrentPosition() { 114 | return currentPos; 115 | } 116 | 117 | /////////////////////////////////////////////////////////////////////////// 118 | // 内部用到的viewHold 119 | /////////////////////////////////////////////////////////////////////////// 120 | 121 | public static class RcvAdapterItem extends RecyclerView.ViewHolder { 122 | 123 | protected AdapterItem item; 124 | 125 | boolean isNew = true; // debug中才用到 126 | 127 | RcvAdapterItem(Context context, ViewGroup parent, AdapterItem item) { 128 | super(LayoutInflater.from(context).inflate(item.getLayoutResId(), parent, false)); 129 | this.item = item; 130 | this.item.bindViews(itemView); 131 | this.item.setViews(); 132 | } 133 | 134 | } 135 | 136 | /////////////////////////////////////////////////////////////////////////// 137 | // For debug 138 | /////////////////////////////////////////////////////////////////////////// 139 | 140 | private void debug(RcvAdapterItem holder) { 141 | boolean debug = false; 142 | if (debug) { 143 | holder.itemView.setBackgroundColor(holder.isNew ? 0xffff0000 : 0xff00ff00); 144 | holder.isNew = false; 145 | } 146 | } 147 | 148 | } 149 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/adapter/bean/AdapterBean.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.adapter.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 数据bean 7 | * 为了不同viewItem 分别对应不同的bean,
8 | * 避免不同item的字段都杂糅的同一个类中的情况,比如{ mobile中的 CommonRowsBean}
9 | * 根据Holder建立一个新的bean, 自定义的bean要继承AdapterBean,在bean中添置所需字段,供holder调用,比如(mobile中 BrandRcvAdapter中的holder)
10 | *

11 | * Created by chenchangjun on 17/12/28. 12 | */ 13 | 14 | public abstract class AdapterBean implements Serializable { 15 | 16 | //唯一标示! 17 | 18 | 19 | public abstract void setCell_type(int cell_type); 20 | 21 | 22 | public abstract int getCell_type(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/adapter/bean/AdapterGroupBean.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.adapter.bean; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * 类似于 view和 viewgroup 的概念 这里是 viewgroup 8 | * Created by chenchangjun on 18/1/4. 9 | */ 10 | 11 | public abstract class AdapterGroupBean extends AdapterBean implements Serializable { 12 | 13 | 14 | //唯一标示! 15 | 16 | public abstract List getList(); 17 | 18 | public abstract String getTitle(); 19 | 20 | public abstract T getRedirect_data(); 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/adapter/item/AdapterItem.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.adapter.item; 2 | 3 | import android.support.annotation.LayoutRes; 4 | import android.view.View; 5 | 6 | /** 7 | * @author ccj 8 | * @date 2017/3/21 9 | */ 10 | public interface AdapterItem { 11 | 12 | 13 | /** 14 | * @return item布局文件的layoutId 15 | */ 16 | @LayoutRes 17 | int getLayoutResId(); 18 | 19 | /** 20 | * 初始化views 21 | */ 22 | void bindViews(final View root); 23 | 24 | /** 25 | * 设置view的参数 26 | * 设置监听等,只执行一次 27 | */ 28 | void setViews(); 29 | 30 | /** 31 | * 根据数据来设置item的内部views 32 | * 33 | * @param t 数据list内部的model 34 | * @param position 当前adapter调用item的位置 35 | */ 36 | void handleData(T t, int position); 37 | 38 | } -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/adapter/util/IAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.adapter.util; 2 | 3 | import android.support.annotation.Keep; 4 | import android.support.annotation.NonNull; 5 | 6 | import com.ccj.base.adapter.item.AdapterItem; 7 | 8 | import java.util.List; 9 | 10 | 11 | /** 12 | * @author ccj 13 | * @date 2017/3/22 14 | * 通用的adapter必须实现的接口,作为方法名统一的一个规范 15 | */ 16 | public interface IAdapter { 17 | 18 | /** 19 | * @param data 设置数据源 20 | */ 21 | void setData(@NonNull List data); 22 | 23 | List getData(); 24 | 25 | /** 26 | * @param t list中的一条数据 27 | * @return 强烈建议返回string, int, bool类似的基础对象做type,不要返回data中的某个对象 28 | */ 29 | Object getItemType(T t); 30 | 31 | /** 32 | * 当缓存中无法得到所需item时才会调用 33 | * 34 | * @param type 通过{@link #getItemType(Object)}得到的type 35 | * @return 任意类型的 AdapterItem 36 | */ 37 | @Keep 38 | @NonNull 39 | AdapterItem createItem(Object type); 40 | 41 | /** 42 | * 如果放入item的最终数据和list中的每一条数据类型是不同的,可以通过此方法进行转换 43 | * 44 | * @param data 从原始的list中取得得数据 45 | * @param type item的类型 46 | * @return 放入adapterItem的最终数据 47 | */ 48 | @Keep 49 | @NonNull 50 | Object getConvertedData(T data, Object type); 51 | 52 | /** 53 | * 通知adapter更新当前页面的所有数据 54 | */ 55 | void notifyDataSetChanged(); 56 | 57 | /** 58 | * 得到当前要渲染的最后一个item的position 59 | */ 60 | int getCurrentPosition(); 61 | } 62 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/adapter/util/ItemTypeUtil.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.adapter.util; 2 | 3 | import android.support.annotation.VisibleForTesting; 4 | 5 | import java.util.HashMap; 6 | 7 | /** 8 | * @author ccj 9 | * @date 2017/3/22 10 | */ 11 | @VisibleForTesting 12 | /*package*/ public class ItemTypeUtil { 13 | 14 | private HashMap typePool; 15 | 16 | public void setTypePool(HashMap typePool) { 17 | this.typePool = typePool; 18 | } 19 | 20 | /** 21 | * @param type item的类型 22 | * @return 通过object类型的type来得到int类型的type 23 | */ 24 | public int getIntType(Object type) { 25 | if (typePool == null) { 26 | typePool = new HashMap<>(); 27 | } 28 | 29 | if (!typePool.containsKey(type)) { 30 | typePool.put(type, typePool.size()); 31 | } 32 | return typePool.get(type); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/api/APIService.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.api; 2 | 3 | 4 | import retrofit2.Retrofit; 5 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; 6 | import retrofit2.converter.gson.GsonConverterFactory; 7 | 8 | /** 9 | * 调用后台的接口,架构网络层采用Retroft+Rxjava+gson 10 | * Created by ccj on 2016/7/1. 11 | * 12 | */ 13 | public class APIService { 14 | 15 | private static final String TAG = "APIService"; 16 | 17 | //get请求 18 | public static final String URL_GANK_IO = "http://gank.io";//gank.io 中的妹子API 19 | 20 | 21 | /** 22 | * 基础地址 23 | * 初始化 retroft 24 | */ 25 | protected static final Retrofit sRetrofit = new Retrofit.Builder() 26 | .baseUrl( URL_GANK_IO ) 27 | .addConverterFactory(GsonConverterFactory.create()) 28 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) // 使用RxJava作为回调适配器 29 | .build(); 30 | 31 | // protected static final RetrofitRequest apiManager = sRetrofit.create(RetrofitRequest.class); 32 | 33 | 34 | 35 | /**********************仿照上面的方法,进行请求数据****************************/ 36 | 37 | 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/api/RetrofitRequest.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.api; 2 | 3 | 4 | /** 5 | * 6 | * Created by ccj on 2016/7/6. 7 | */ 8 | public interface RetrofitRequest { 9 | 10 | 11 | boolean isTest=false; //是否在测试环境下 12 | //发布之前更改 13 | String BASE_URL_TEST = "/flyapptest/";//测试服务器 14 | String BASE_URL_OFFICAL = "/flyapp/";//正式服务器 15 | 16 | String BASE_URL = isTest?BASE_URL_TEST:BASE_URL_OFFICAL;//发布服务器 17 | 18 | } 19 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/api/VolleyUtils.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.api; 2 | 3 | import android.content.Context; 4 | import android.text.TextUtils; 5 | 6 | import com.android.volley.Request; 7 | import com.android.volley.RequestQueue; 8 | import com.android.volley.toolbox.ImageLoader; 9 | import com.android.volley.toolbox.Volley; 10 | import com.ccj.base.base.BaseApplication; 11 | import com.ccj.base.utils.LruBitmapCache; 12 | 13 | 14 | /** 15 | * volley留做备用 16 | * Created by ccj on 2016/12/4. 17 | */ 18 | public class VolleyUtils { 19 | 20 | public static final String TAG = VolleyUtils.class.getSimpleName(); 21 | public static final Context context = BaseApplication.getInstance(); 22 | public static VolleyUtils volleyUtils; 23 | private RequestQueue requestQueue; 24 | private ImageLoader imageLoader; 25 | 26 | // The best way to maintain volley core objects and request queue is, making them global by creating a singleton class. 27 | public static VolleyUtils getInstance() { 28 | if (volleyUtils == null) { 29 | volleyUtils = new VolleyUtils(); 30 | } 31 | return volleyUtils; 32 | } 33 | 34 | //Default constructor 35 | private VolleyUtils() { 36 | getRequestQueue(); 37 | getImageLoader(); 38 | } 39 | 40 | public RequestQueue getRequestQueue() { 41 | 42 | if (requestQueue == null) { 43 | requestQueue = Volley.newRequestQueue(context); 44 | } 45 | return requestQueue; 46 | } 47 | 48 | public ImageLoader getImageLoader() { 49 | getRequestQueue(); 50 | if (imageLoader == null) { 51 | imageLoader = new ImageLoader(requestQueue, new LruBitmapCache()); 52 | } 53 | return imageLoader; 54 | } 55 | 56 | public void addToRequestQueue(Request req, String tag) { 57 | //Set default tag if empty 58 | req.setTag(TextUtils.isEmpty(tag) ? TAG : tag); 59 | getRequestQueue().add(req); 60 | } 61 | 62 | public void addToRequestQueue(Request req) { 63 | req.setTag(TAG); 64 | getRequestQueue().add(req); 65 | } 66 | 67 | public void cancelPendingRequests(Object tag) { 68 | if (requestQueue != null) { 69 | requestQueue.cancelAll(tag); 70 | } 71 | } 72 | 73 | 74 | 75 | } 76 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.base; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.support.v4.app.Fragment; 8 | import android.support.v4.app.FragmentManager; 9 | import android.support.v7.app.AppCompatActivity; 10 | import android.support.v7.widget.Toolbar; 11 | import android.util.Log; 12 | import android.view.View; 13 | 14 | import com.ccj.base.AppManager; 15 | import com.ccj.base.R; 16 | 17 | import java.util.List; 18 | 19 | 20 | /** 21 | * base 来进行 toolbar dialog 初始化,activity栈的添加,删除等 22 | * Created by ccj on 2016/7/5. 23 | */ 24 | public class BaseActivity 25 | extends AppCompatActivity implements BaseView { 26 | 27 | private static final String TAG = "BaseActivity"; 28 | public T mPresenter; 29 | protected ProgressDialog progressDialog; 30 | protected Toolbar toolbar; 31 | protected Context mContext; 32 | private int fragmentIndex = 0; 33 | 34 | @Override 35 | public void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | AppManager.getAppManager().addActivity(this); 38 | mContext = this; 39 | initDialog(); 40 | 41 | } 42 | 43 | public void initToolBar() { 44 | toolbar = (Toolbar) findViewById(R.id.toolbar); 45 | setSupportActionBar(toolbar); 46 | toolbar.setBackgroundColor(getResources().getColor(R.color.tool_bar_white)); 47 | toolbar.setNavigationIcon(R.mipmap.back); 48 | toolbar.setNavigationOnClickListener(new View.OnClickListener() { 49 | @Override 50 | public void onClick(View v) { 51 | finish(); 52 | } 53 | }); 54 | } 55 | 56 | public Toolbar getToolbar() { 57 | return toolbar; 58 | } 59 | 60 | /** 61 | * 资源释放 62 | */ 63 | @Override 64 | protected void onDestroy() { 65 | super.onDestroy(); 66 | if (mPresenter != null) 67 | mPresenter.onDestroy(); 68 | AppManager.getAppManager().finishActivity(this); 69 | } 70 | 71 | private void initDialog() { 72 | progressDialog = new ProgressDialog(this); 73 | progressDialog.setMessage(getResources().getString(R.string.show_loading_msg)); 74 | } 75 | 76 | public void showLoading() { 77 | progressDialog.show(); 78 | } 79 | 80 | public void dismissLoading() { 81 | progressDialog.dismiss(); 82 | } 83 | 84 | 85 | @Override 86 | public void initView() { 87 | 88 | } 89 | 90 | 91 | /** 92 | * 解决fragment onActivityResult不调用 93 | * 94 | * @param requestCode 95 | * @param resultCode 96 | * @param data 97 | */ 98 | @Override 99 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 100 | FragmentManager fm = getSupportFragmentManager(); 101 | //if (index != 0) { 102 | if (fm.getFragments() == null) { 103 | Log.w(TAG, "Activity result fragment fragmentIndex out of range: 0x" 104 | + Integer.toHexString(requestCode)); 105 | return; 106 | } 107 | for (int i = 0; i frags = frag.getChildFragmentManager().getFragments(); 133 | if (frags != null) { 134 | for (Fragment f : frags) { 135 | if (f != null) 136 | handleResult(f, requestCode, resultCode, data); 137 | } 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/base/BaseApplication.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.base; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.content.res.Resources; 6 | import android.view.Gravity; 7 | import android.widget.Toast; 8 | 9 | import com.alibaba.android.arouter.launcher.ARouter; 10 | import com.ccj.base.utils.SharedPreferenceUtil; 11 | 12 | /** 13 | * 获取上下文,Toast,以及各种初始化 14 | * Created by Administrator on 2016/7/5. 15 | */ 16 | public class BaseApplication extends Application { 17 | 18 | private static String lastToast = ""; 19 | private static long lastToastTime; 20 | private static Context context; 21 | private static Resources resource; 22 | private static BaseApplication baseApplication; 23 | 24 | public static synchronized BaseApplication getInstance() { 25 | return baseApplication; 26 | } 27 | 28 | @Override 29 | protected void attachBaseContext(Context base) { 30 | super.attachBaseContext(base); 31 | 32 | } 33 | 34 | @Override 35 | public void onCreate() { 36 | super.onCreate(); 37 | initARouter(); 38 | context = getBaseContext(); 39 | baseApplication = this; 40 | SharedPreferenceUtil.initSharedPreference(getApplicationContext()); 41 | } 42 | 43 | /** 44 | * ARouter 在每个模式下都需要,此时, 45 | * 由于每个module的application只有在module模式下才启用,所以可以这样设置--> 46 | * 可以将各module都继承BaseApplication 47 | */ 48 | private void initARouter() { 49 | //if (BuildConfig.DEBUG) { 50 | // 这两行必须写在init之前,否则这些配置在init过程中将无效 51 | ARouter.openLog(); // 打印日志 52 | ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险) 53 | ARouter.printStackTrace(); // 打印日志的时候打印线程堆栈 54 | // } 55 | ARouter.init(this); // 尽可能早,推荐在Application中初始化 56 | } 57 | 58 | 59 | /** 60 | * 防抖动 弹窗 61 | * 62 | * @param message 63 | * @param duration 64 | * @param icon 65 | * @param gravity 66 | */ 67 | public static void showToast(String message, int duration, int icon, 68 | int gravity) { 69 | Toast.makeText(getContext(),message,duration).show(); 70 | } 71 | 72 | 73 | 74 | 75 | public static Context getContext() { 76 | return context; 77 | } 78 | 79 | public static void setContext(Context context) { 80 | BaseApplication.context = context; 81 | } 82 | 83 | public static Resources getResource() { 84 | return resource; 85 | } 86 | 87 | public static void setResource(Resources resource) { 88 | BaseApplication.resource = resource; 89 | } 90 | 91 | 92 | public static void showShortToast(String message) { 93 | showToast(message, Toast.LENGTH_SHORT, 0, Gravity.BOTTOM); 94 | } 95 | 96 | public static void showLongToast(String message) { 97 | showToast(message, Toast.LENGTH_LONG, 0, Gravity.BOTTOM); 98 | } 99 | 100 | public static void showToast(String message) { 101 | showToast(message, Toast.LENGTH_LONG, 0, Gravity.BOTTOM); 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/base/BaseBean.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.base; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by Administrator on 2016/7/6. 7 | */ 8 | public class BaseBean implements Serializable { 9 | 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/base/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.base; 2 | 3 | import android.app.Dialog; 4 | import android.app.ProgressDialog; 5 | import android.content.Context; 6 | import android.os.Bundle; 7 | import android.support.annotation.Nullable; 8 | import android.support.v4.app.Fragment; 9 | import android.util.DisplayMetrics; 10 | import android.view.LayoutInflater; 11 | 12 | 13 | /** 14 | * Created by Administrator on 2016/7/5. 15 | */ 16 | public abstract class BaseFragment extends Fragment implements BaseView { 17 | private static final String TAG="BaseFragment"; 18 | private LayoutInflater mInflater; 19 | private Dialog dialog; 20 | public T mPresenter; 21 | protected float mDensity; 22 | protected int mDensityDpi; 23 | protected int mWidth; 24 | protected int mAvatarSize; 25 | private Context mContext; 26 | 27 | @Override 28 | public void onCreate(@Nullable Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | getScreen(); 31 | } 32 | 33 | 34 | public void showLoading() { 35 | if (dialog == null) { 36 | dialog = new ProgressDialog(getActivity()); 37 | } 38 | dialog.setTitle("正在加载..."); 39 | dialog.show(); 40 | } 41 | 42 | public void dismissLoading() { 43 | if (dialog != null) { 44 | dialog.dismiss(); 45 | } 46 | } 47 | 48 | private void getScreen() { 49 | DisplayMetrics dm = new DisplayMetrics(); 50 | getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); 51 | mDensity = dm.density; 52 | mDensityDpi = dm.densityDpi; 53 | mWidth = dm.widthPixels; 54 | mAvatarSize = (int) (50 * mDensity); 55 | } 56 | 57 | /** 58 | * 解绑的时候 清除 59 | */ 60 | @Override 61 | public void onDetach() { 62 | if (mPresenter != null) { 63 | mPresenter.onDestroy(); 64 | } 65 | 66 | super.onDetach(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/base/BaseModel.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.base; 2 | 3 | /** 4 | * Created by Administrator on 2016/7/14. 5 | */ 6 | public interface BaseModel { 7 | 8 | /** 9 | * 默认的开始,在activity中初始化 10 | */ 11 | void start(); 12 | 13 | /** 14 | * 在activity中的ondestoy 调用 在此方法中将资源至null, 15 | * 此处略嫌麻烦,但是如果把presenter层搞成抽象类,在里面添加成员变量和方法体, 16 | * 就有点失去了味道,所以还是选择了这种方式代替下列注释的部分. 17 | * 18 | */ 19 | 20 | void onDestroy(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/base/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.base; 2 | 3 | /** 4 | * Created by Administrator on 2016/7/7. 5 | */ 6 | public interface BasePresenter { 7 | /** 8 | * 默认的开始,在activity中初始化 9 | */ 10 | void start(); 11 | 12 | /** 13 | * 在activity中的ondestoy 调用 在此方法中将资源至null, 14 | * 此处略嫌麻烦,但是如果把presenter层搞成抽象类,在里面添加成员变量和方法体, 15 | * 就有点失去了味道,所以还是选择了这种方式代替下列注释的部分. 16 | * 17 | */ 18 | void onDestroy(); 19 | } 20 | 21 | /* 22 | public abstract class BasePresenter { 23 | public Context context; 24 | public E mModel; 25 | public T mView; 26 | public Source mSource = new Source(); 27 | 28 | public void setVM(T v, E m) { 29 | this.mView = v; 30 | this.mModel = m; 31 | this.onStart(); 32 | } 33 | 34 | public abstract void onStart(); 35 | 36 | public void onDestroy() { 37 | mSource.clear(); 38 | } 39 | }*/ 40 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/base/BaseView.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.base; 2 | 3 | /** 4 | * Created by Administrator on 2016/7/6. 5 | */ 6 | public interface BaseView { 7 | 8 | 9 | void initView(); 10 | } 11 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/base/Constants.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.base; 2 | 3 | /** 4 | * 静态常量 5 | */ 6 | public class Constants { 7 | 8 | public static final int REQUST_FOR_LOGIN = 0x0001; 9 | public static final int RESULT_FOR_LOGIN = 0x0002; 10 | 11 | 12 | public static final int IMAGES_ACTIVITY_REQUEST_CODE = 300; 13 | } 14 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/bean/UserDetail.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.bean; 2 | 3 | /** 4 | * Created by Administrator on 2016/8/10. 5 | */ 6 | public class UserDetail { 7 | 8 | 9 | 10 | public String Users_PersonName; 11 | 12 | 13 | 14 | public String Users_CellPhoneNum; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/utils/LruBitmapCache.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.utils; 2 | 3 | import android.graphics.Bitmap; 4 | import android.support.v4.util.LruCache; 5 | 6 | import com.android.volley.toolbox.ImageLoader; 7 | 8 | /** 9 | * 图片缓存池 10 | * Created by ccj on 2016/1/6. 11 | */ 12 | public class LruBitmapCache implements ImageLoader.ImageCache { 13 | private LruCache mCache; 14 | 15 | public LruBitmapCache() { 16 | int maxSize = 10 * 1024 * 1024; 17 | 18 | mCache = new LruCache(maxSize) { 19 | @Override 20 | protected int sizeOf(String key, Bitmap value) { 21 | return value.getRowBytes() * value.getHeight(); 22 | } 23 | }; 24 | } 25 | 26 | @Override 27 | public Bitmap getBitmap(String url) { 28 | return mCache.get(url); 29 | } 30 | 31 | @Override 32 | public void putBitmap(String url, Bitmap bitmap) { 33 | mCache.put(url, bitmap); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/utils/SerializableUtil.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.utils; 2 | 3 | import android.util.Base64; 4 | 5 | import java.io.ByteArrayInputStream; 6 | import java.io.ByteArrayOutputStream; 7 | import java.io.IOException; 8 | import java.io.ObjectInputStream; 9 | import java.io.ObjectOutputStream; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by ccj on 2015/12/7. 14 | * 将 对象转为 字符串,易于保存 上传等 15 | * 16 | */ 17 | public class SerializableUtil { 18 | 19 | public static String objToStr(Object obj) throws IOException { 20 | if (obj == null) { 21 | return ""; 22 | } 23 | //实例化一个ByteArrayOutputStream对象,用来装载压缩后的字节文件 24 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 25 | //然后将得到的字符数据装载到ObjectOutputStream 26 | ObjectOutputStream oos = new ObjectOutputStream(baos); 27 | //writeObject 方法负责写入特定类的对象的状态,以便相应的readObject可以还原它 28 | oos.writeObject(obj); 29 | //最后,用Base64.encode将字节文件转换成Base64编码,并以String形式保存 30 | String listString = new String(Base64.encode(baos.toByteArray(), Base64.DEFAULT)); 31 | //关闭oos 32 | oos.close(); 33 | return listString; 34 | 35 | } 36 | 37 | 38 | //将序列化的数据还原成Object 39 | 40 | public static Object strToObj(String str) throws IOException { 41 | byte[] mByte = Base64.decode(str.getBytes(), Base64.DEFAULT); 42 | ByteArrayInputStream bais = new ByteArrayInputStream(mByte); 43 | ObjectInputStream ois = new ObjectInputStream(bais); 44 | try { 45 | 46 | return ois.readObject(); 47 | } catch (ClassNotFoundException e) { 48 | e.printStackTrace(); 49 | } 50 | return null; 51 | } 52 | 53 | public static String listToString(List list) throws IOException { 54 | //实例化一个ByteArrayOutputStream对象,用来装载压缩后的字节文件 55 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 56 | //然后将得到的字符数据装载到ObjectOutputStream 57 | ObjectOutputStream oos = new ObjectOutputStream(baos); 58 | //writeObject 方法负责写入特定类的对象的状态,以便相应的readObject可以还原它 59 | oos.writeObject(list); 60 | //最后,用Base64.encode将字节文件转换成Base64编码,并以String形式保存 61 | String listString = new String(Base64.encode(baos.toByteArray(), Base64.DEFAULT)); 62 | //关闭oos 63 | oos.close(); 64 | return listString; 65 | } 66 | 67 | 68 | public static List stringToList(String str) throws IOException { 69 | byte[] mByte = Base64.decode(str.getBytes(), Base64.DEFAULT); 70 | ByteArrayInputStream bais = new ByteArrayInputStream(mByte); 71 | ObjectInputStream ois = new ObjectInputStream(bais); 72 | List stringList = null; 73 | try { 74 | stringList = (List) ois.readObject(); 75 | } catch (ClassNotFoundException e) { 76 | e.printStackTrace(); 77 | } 78 | return stringList; 79 | } 80 | 81 | 82 | } 83 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/utils/TLog.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.utils; 2 | 3 | import android.util.Log; 4 | 5 | public class TLog { 6 | public static final String LOG_TAG = "TLog-->"; 7 | public static boolean DEBUG = true;//是否处在debug 8 | 9 | public TLog() { 10 | } 11 | 12 | public static final void analytics(String log) { 13 | if (DEBUG) 14 | Log.d(LOG_TAG, log); 15 | } 16 | 17 | public static final void error(String log) { 18 | if (DEBUG) 19 | Log.e(LOG_TAG, "" + log); 20 | } 21 | 22 | public static final void log(String log) { 23 | if (DEBUG) 24 | Log.e(LOG_TAG, log); 25 | } 26 | 27 | public static final void log(String tag, String log) { 28 | if (DEBUG) 29 | Log.e(tag, log); 30 | } 31 | 32 | public static final void logI(String log) { 33 | if (DEBUG) 34 | Log.i(LOG_TAG, log); 35 | } 36 | 37 | public static final void warn(String log) { 38 | if (DEBUG) 39 | Log.w(LOG_TAG, log); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/utils/ToastUtil.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.utils; 2 | 3 | import com.ccj.base.base.BaseApplication; 4 | 5 | public class ToastUtil { 6 | 7 | 8 | public static void show( String text) { 9 | android.widget.Toast.makeText(BaseApplication.getContext(), text, android.widget.Toast.LENGTH_SHORT).show(); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/utils/eventbus/EventUtils.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.utils.eventbus; 2 | 3 | 4 | /** 5 | * 事件总线 用于组件或线程通信,可替代回调,广播等 6 | * Created by ccj on 2016/4/14. 7 | */ 8 | public class EventUtils { 9 | /** 10 | * 传递String类型的event 11 | * 12 | */ 13 | public static class StringEvent{ 14 | private String mMsg; 15 | public StringEvent(String msg) { 16 | // TODO Auto-generated constructor stub 17 | this.mMsg = msg; 18 | } 19 | public String getMsg(){ 20 | return mMsg; 21 | } 22 | } 23 | 24 | public static class intEvent{ 25 | private int mMsg; 26 | public intEvent(int msg) { 27 | // TODO Auto-generated constructor stub 28 | this.mMsg = msg; 29 | } 30 | public int getMsg(){ 31 | return mMsg; 32 | } 33 | } 34 | 35 | /** 36 | * object类型(即传统的所有类型,都可以强转进行传递事件) 37 | * 38 | */ 39 | 40 | public static class ObjectEvent{ 41 | private Object object; 42 | public ObjectEvent(Object object) { 43 | // TODO Auto-generated constructor stub 44 | this.object = object; 45 | } 46 | public Object getMsg(){ 47 | return object; 48 | } 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/utils/router/LoginModuleService.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.utils.router; 2 | 3 | import com.alibaba.android.arouter.facade.template.IProvider; 4 | 5 | /** 6 | * 示例:子模块间调用方法 7 | * Created by chenchangjun on 17/8/14. 8 | */ 9 | 10 | public interface LoginModuleService extends IProvider { 11 | 12 | 13 | boolean checkLoginState(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/utils/router/RounterInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.utils.router; 2 | 3 | import android.content.Context; 4 | 5 | import com.alibaba.android.arouter.facade.Postcard; 6 | import com.alibaba.android.arouter.facade.annotation.Interceptor; 7 | import com.alibaba.android.arouter.facade.callback.InterceptorCallback; 8 | import com.alibaba.android.arouter.facade.template.IInterceptor; 9 | 10 | /** 11 | * // 比较经典的应用就是在跳转过程中处理登陆事件,这样就不需要在目标页重复做登陆检查 12 | // 拦截器会在跳转之间执行,多个拦截器会按优先级顺序依次执行 13 | * Created by chenchangjun on 17/8/9. 14 | */ 15 | 16 | @Interceptor(priority = 8, name = "测试用拦截器") 17 | public class RounterInterceptor implements IInterceptor { 18 | 19 | 20 | 21 | 22 | @Override 23 | public void process(Postcard postcard, InterceptorCallback callback) { 24 | 25 | callback.onContinue(postcard); // 处理完成,交还控制权 26 | // callback.onInterrupt(new RuntimeException("我觉得有点异常")); // 觉得有问题,中断路由流程 27 | 28 | // 以上两种至少需要调用其中一种,否则不会继续路由 29 | } 30 | 31 | @Override 32 | public void init(Context context) { 33 | // 拦截器的初始化,会在sdk初始化的时候调用该方法,仅会调用一次 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/utils/router/RounterSerialization.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.utils.router; 2 | 3 | import android.content.Context; 4 | 5 | import com.alibaba.android.arouter.facade.annotation.Route; 6 | import com.alibaba.android.arouter.facade.service.SerializationService; 7 | 8 | import java.lang.reflect.Type; 9 | 10 | /** 11 | * Created by chenchangjun on 17/8/9. 12 | */ 13 | @Route(path = "/router/RounterSerialization") 14 | public class RounterSerialization implements SerializationService { 15 | 16 | 17 | @Override 18 | public T json2Object(String json, Class clazz) { 19 | return null; 20 | } 21 | 22 | @Override 23 | public String object2Json(Object instance) { 24 | return null; 25 | } 26 | 27 | /** 28 | * Parse json to object 29 | * 30 | * @param input json string 31 | * @param clazz object type 32 | * @return instance of object 33 | */ 34 | @Override 35 | public T parseObject(String input, Type clazz) { 36 | return null; 37 | } 38 | 39 | @Override 40 | public void init(Context context) { 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/utils/router/RouterService.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.utils.router; 2 | 3 | import com.alibaba.android.arouter.facade.template.IProvider; 4 | 5 | /** 6 | * Created by chenchangjun on 17/8/9. 7 | */ 8 | 9 | public interface RouterService extends IProvider { 10 | 11 | 12 | String start(String name); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/utils/router/RouterUtils.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.utils.router; 2 | 3 | import android.app.Activity; 4 | 5 | import com.alibaba.android.arouter.launcher.ARouter; 6 | 7 | //https://github.com/alibaba/ARouter 8 | public class RouterUtils { 9 | 10 | 11 | 12 | public static void inject(Object obj){ 13 | ARouter.getInstance().inject(obj); 14 | 15 | } 16 | 17 | /** 18 | * 跳转 19 | * 得到 跳转对象 20 | * @param path 21 | * @return 22 | */ 23 | public static Object navigation(String path) { 24 | // 构建标准的路由请求 25 | return ARouter.getInstance().build(path).navigation(); 26 | } 27 | 28 | 29 | 30 | public void startActivityForResult(Activity activity,String path,int requestCode,String argKey,Object argValue) { 31 | ARouter.getInstance().build(path). 32 | withObject(argKey, argValue). 33 | navigation(activity, requestCode); 34 | } 35 | 36 | public void startActivityForCallback() { 37 | // 使用两个参数的navigation方法,可以获取单次跳转的结果 38 | //ARouter.getInstance().build("/test/1").navigation(this, new NavigationCallback() ); 39 | } 40 | 41 | 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/view/list/OnAppBarSkipListener.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.view.list; 2 | 3 | 4 | /** 5 | * 控制监听好价 toolbar显示隐藏抖动 6 | */ 7 | public interface OnAppBarSkipListener { 8 | void isSkip(boolean iskip); 9 | 10 | } -------------------------------------------------------------------------------- /base/src/main/java/com/ccj/base/view/list/OnLoadNextListener.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base.view.list; 2 | 3 | /** 4 | */ 5 | public interface OnLoadNextListener { 6 | public void onLoadNext(); 7 | public void autoShowOrHideToolbar(boolean show); 8 | } 9 | -------------------------------------------------------------------------------- /base/src/main/res/anim/anim_bottom_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /base/src/main/res/anim/anim_bottom_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /base/src/main/res/anim/dialog_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /base/src/main/res/anim/dialog_exit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /base/src/main/res/anim/footer_menu_slide_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /base/src/main/res/anim/footer_menu_slide_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /base/src/main/res/anim/in_from_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /base/src/main/res/anim/in_from_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /base/src/main/res/anim/out_to_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /base/src/main/res/anim/out_to_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /base/src/main/res/drawable/bg_bt_raise.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/drawable/bg_bt_raise.9.png -------------------------------------------------------------------------------- /base/src/main/res/drawable/bg_bt_raise_color.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/drawable/bg_bt_raise_color.9.png -------------------------------------------------------------------------------- /base/src/main/res/drawable/bg_bt_raise_dark.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/drawable/bg_bt_raise_dark.9.png -------------------------------------------------------------------------------- /base/src/main/res/drawable/bg_toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /base/src/main/res/drawable/btn_ripple.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /base/src/main/res/layout/base_layout_tool_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 19 | 20 | -------------------------------------------------------------------------------- /base/src/main/res/mipmap-hdpi/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/mipmap-hdpi/back.png -------------------------------------------------------------------------------- /base/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /base/src/main/res/mipmap-mdpi/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/mipmap-mdpi/back.png -------------------------------------------------------------------------------- /base/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /base/src/main/res/mipmap-xhdpi/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/mipmap-xhdpi/back.png -------------------------------------------------------------------------------- /base/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /base/src/main/res/mipmap-xhdpi/login_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/mipmap-xhdpi/login_bg.png -------------------------------------------------------------------------------- /base/src/main/res/mipmap-xxhdpi/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/mipmap-xxhdpi/back.png -------------------------------------------------------------------------------- /base/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /base/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/base/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /base/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | 8 | 11 | #FF78909C 12 | #FF03A9F4 13 | #FF78909C 14 | #FF03A9F4 15 | #FF0288D1 16 | @color/primary_dark 17 | 18 | 19 | #bc1717 20 | #dd4b39 21 | @android:color/white 22 | #6699ff 23 | #3366cc 24 | #f2f2f2 25 | #00000000 26 | #ffcc00 27 | 28 | @android:color/white 29 | @android:color/black 30 | #2b8cff 31 | #ff3824 32 | #929292 33 | #f8f8f9 34 | #c9c9c9 35 | #70dbdb 36 | #dddddd 37 | #00000000 38 | 39 | 40 | @android:color/white 41 | #dcdcdc 42 | 43 | 44 | -------------------------------------------------------------------------------- /base/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 16dp 7 | 16dp 8 | 9 | 10 | 100dp 11 | 48dp 12 | 13 | 14 | 15 | 8.0dip 16 | 5dp 17 | 10dp 18 | 20dp 19 | 30dp 20 | 2dp 21 | 80dp 22 | 2dp 23 | 1dp 24 | 25 | 5dp 26 | 10dp 27 | 28 | 16sp 29 | 18sp 30 | 22sp 31 | 32 | 400dp 33 | 200dp 34 | 18sp 35 | 36 | -------------------------------------------------------------------------------- /base/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Android组件化 3 | 没有更多了 4 | 5 | 6 | 7 | 点击屏幕,重新加载 8 | 暂无内容 9 | 加载中… 10 | 内容加载失败\r\n点击重新加载 11 | 没有可用的网络 12 | 没有可用的网络 13 | 正在加载... 14 | 15 | 16 | -------------------------------------------------------------------------------- /base/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 31 | 35 | 36 | 52 | 53 | 56 | 57 | 58 | 59 | 60 | 61 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /base/src/test/java/com/ccj/base/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.ccj.base; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | //butterknife 7 | mavenCentral() 8 | maven { 9 | url 'https://maven.google.com/' 10 | name 'Google' 11 | } 12 | } 13 | dependencies { 14 | classpath 'com.android.tools.build:gradle:2.3.2' 15 | 16 | //butterknife 17 | classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0' 18 | } 19 | } 20 | 21 | allprojects { 22 | repositories { 23 | jcenter() 24 | maven { 25 | url 'https://maven.google.com/' 26 | name 'Google' 27 | } 28 | } 29 | } 30 | 31 | task clean(type: Delete) { 32 | delete rootProject.buildDir 33 | } 34 | 35 | 36 | def androidSupportVersion = '25.3.1' 37 | def butterknifeVersion = '8.4.0' 38 | 39 | 40 | // Define versions in a single place 41 | //时间:2017.2.13;每次修改版本号都要添加修改时间 42 | ext { 43 | // Sdk and tools 44 | //localBuildToolsVersion是gradle.properties中的数据 45 | buildToolsVersion = localBuildToolsVersion 46 | compileSdkVersion = 25 47 | minSdkVersion = 16 48 | targetSdkVersion = 25 49 | versionCode = 1 50 | versionName = "1.0" 51 | javaVersion = JavaVersion.VERSION_1_8 52 | 53 | // App dependencies version 54 | appcompatV7 = "com.android.support:appcompat-v7:$androidSupportVersion" 55 | constraintLayout = 'com.android.support.constraint:constraint-layout:1.0.2' 56 | 57 | eventbusVersion = "3.0.0" 58 | 59 | //arouter 60 | arouterApi = 'com.alibaba:arouter-api:1.3.1' 61 | arouterCompiler = 'com.alibaba:arouter-compiler:1.1.4' 62 | 63 | //butterknife 64 | butterknife = "com.jakewharton:butterknife:$butterknifeVersion" 65 | butterknifeCompiler = "com.jakewharton:butterknife-compiler:$butterknifeVersion" 66 | 67 | //eventbusVersion 68 | eventbus= "org.greenrobot:eventbus:$eventbusVersion" 69 | 70 | cookieVersion = "v1.0.1" 71 | toastyVersion = "1.1.3" 72 | 73 | 74 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 9 | #org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Tue Jul 05 10:55:37 CST 2016 16 | 17 | localBuildToolsVersion=25.0.3 18 | localGradlePluginVersion=2.3.3 19 | 20 | 21 | # true代表模块开发,false代表合并到主app. 22 | isModule=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccj659/clean-project-architecture/3b367d5ca83dda49a18476f67d1df722180f6d79/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /module_home/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /module_home/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | if (isModule.toBoolean()) { 3 | apply plugin: 'com.android.application' 4 | } else { 5 | apply plugin: 'com.android.library' 6 | } 7 | //butterknife 8 | apply plugin: 'com.jakewharton.butterknife' 9 | 10 | android { 11 | compileSdkVersion rootProject.ext.compileSdkVersion 12 | buildToolsVersion rootProject.ext.buildToolsVersion 13 | 14 | defaultConfig { 15 | 16 | if (isModule.toBoolean()) { 17 | applicationId "com.ccj.home" 18 | } 19 | 20 | minSdkVersion rootProject.ext.minSdkVersion 21 | targetSdkVersion rootProject.ext.targetSdkVersion 22 | versionCode rootProject.ext.versionCode 23 | versionName rootProject.ext.versionName 24 | 25 | 26 | // resourcePrefix "haojia_" 27 | 28 | 29 | //arouter 30 | javaCompileOptions { 31 | annotationProcessorOptions { 32 | arguments = [moduleName: project.getName()] 33 | } 34 | } 35 | } 36 | 37 | buildTypes { 38 | release { 39 | minifyEnabled false 40 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 41 | } 42 | } 43 | sourceSets { 44 | main { 45 | if (isModule.toBoolean()) { 46 | manifest.srcFile 'src/main/AndroidManifest.xml' 47 | } else { 48 | manifest.srcFile 'src/main/release/AndroidManifest.xml' 49 | java { 50 | exclude 'debug/**' 51 | } 52 | } 53 | } 54 | } 55 | 56 | } 57 | 58 | dependencies { 59 | compile fileTree(dir: 'libs', include: ['*.jar']) 60 | 61 | 62 | //butterknife 63 | annotationProcessor rootProject.ext.butterknifeCompiler 64 | 65 | //arouter 66 | compile rootProject.ext.arouterApi 67 | annotationProcessor rootProject.ext.arouterCompiler 68 | 69 | compile project(':base') 70 | 71 | } 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /module_home/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /module_home/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /module_home/src/main/java/com/ccj/home/HomeFragment.java: -------------------------------------------------------------------------------- 1 | package com.ccj.home; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.Fragment; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.Button; 11 | import android.widget.TextView; 12 | 13 | import com.alibaba.android.arouter.facade.annotation.Route; 14 | import com.alibaba.android.arouter.launcher.ARouter; 15 | import com.ccj.base.Constants; 16 | import com.ccj.base.RouterConstants; 17 | import com.ccj.base.base.BaseApplication; 18 | 19 | /** 20 | * Created by chenchangjun on 18/1/25. 21 | */ 22 | @Route(path = RouterConstants.HOME_MUDULE_FRAGMENT_HOME_HOME) 23 | public class HomeFragment extends Fragment implements View.OnClickListener { 24 | 25 | 26 | TextView button; 27 | Button button2; 28 | Button button3; 29 | Button button4; 30 | private View view; 31 | 32 | @Nullable 33 | @Override 34 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { 35 | if (view == null) { 36 | view = inflater.inflate(R.layout.home_fragment_haojia_home, null); 37 | } 38 | return view; 39 | } 40 | 41 | @Override 42 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 43 | super.onViewCreated(view, savedInstanceState); 44 | button2= (Button) view.findViewById(R.id.button2); 45 | button3= (Button) view.findViewById(R.id.button3); 46 | button4= (Button) view.findViewById(R.id.button4); 47 | 48 | button2.setOnClickListener(this); 49 | button3.setOnClickListener(this); 50 | button4.setOnClickListener(this); 51 | 52 | } 53 | 54 | 55 | 56 | /** 57 | * Called when a view has been clicked. 58 | * 59 | * @param v The view that was clicked. 60 | */ 61 | @Override 62 | public void onClick(View v) { 63 | int i = v.getId(); 64 | if (i == R.id.button2) { 65 | navigateToLogin(); 66 | } else if (i == R.id.button3) { 67 | navigateMeiziDetail(); 68 | } else if (i == R.id.button4) { 69 | navigateTakePhoto(); 70 | 71 | } 72 | } 73 | 74 | 75 | 76 | 77 | private void navigateMeiziDetail() { 78 | ARouter.getInstance().build(RouterConstants.MEIZI_MUDULE_ACTIVITY_MEIZI_DETAIL). 79 | withString(Constants.PARAMS_REQUEST_FOR_DETAIL, "http://7xi8d6.com1.z0.glb.clouddn.com/20180129074038_O3ydq4_Screenshot.jpeg"). 80 | navigation(getActivity()); 81 | 82 | } 83 | 84 | 85 | private void navigateToLogin() { 86 | ARouter.getInstance().build(RouterConstants.USER_MOUDLE_ACTIVITY). 87 | withString(Constants.START_LOGIN_WITH_PARAMS, "I am params from HomeFragment"). 88 | navigation(getActivity(), Constants.REQUEST_START_LOGIN); 89 | } 90 | 91 | private void navigateTakePhoto() { 92 | ARouter.getInstance(). 93 | build(RouterConstants.VIDEO_MUDULE_ACTIVITY). 94 | withString(Constants.START_LOGIN_WITH_PARAMS, "I am params from HomeFragment"). 95 | navigation(); 96 | 97 | } 98 | 99 | 100 | @Override 101 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 102 | super.onActivityResult(requestCode, resultCode, data); 103 | if (requestCode == Constants.REQUEST_START_LOGIN) { 104 | 105 | if (data == null) { 106 | return; 107 | } 108 | String str = data.getStringExtra(Constants.PARAMS_RESULT_FROM_LOGIN); 109 | 110 | if (str == null) { 111 | return; 112 | } 113 | 114 | button.setText(str); 115 | BaseApplication.showToast(str); 116 | } 117 | 118 | } 119 | 120 | } -------------------------------------------------------------------------------- /module_home/src/main/java/com/ccj/home/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.ccj.home; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | 6 | public class MainActivity extends AppCompatActivity { 7 | 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | setContentView(R.layout.activity_main); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /module_home/src/main/release/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /module_home/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /module_home/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /module_home/src/main/res/layout/home_fragment_haojia_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 18 | 19 |