Commit 4fc05a61ce01420612499429eed0f707bfa534fe

Authored by YangShuai
1 parent 556ee8b2

1 base提交maven

app/strike/src/main/java/com/cnlive/strike/MyFragment1.java
@@ -2,6 +2,7 @@ package com.cnlive.strike; @@ -2,6 +2,7 @@ package com.cnlive.strike;
2 2
3 3
4 import android.os.Bundle; 4 import android.os.Bundle;
  5 +import android.util.Log;
5 import android.view.LayoutInflater; 6 import android.view.LayoutInflater;
6 import android.view.View; 7 import android.view.View;
7 import android.view.ViewGroup; 8 import android.view.ViewGroup;
@@ -11,6 +12,11 @@ import androidx.annotation.Nullable; @@ -11,6 +12,11 @@ import androidx.annotation.Nullable;
11 12
12 import com.cnlive.core.libs.base.frame.fragment.BaseFragment; 13 import com.cnlive.core.libs.base.frame.fragment.BaseFragment;
13 import com.cnlive.core.libs.base.util.StatusBarConfig; 14 import com.cnlive.core.libs.base.util.StatusBarConfig;
  15 +import com.cnlive.core.network.HttpConn;
  16 +import com.cnlive.core.network.NetCallBack;
  17 +import com.cnlive.strike.network.BaseRequest;
  18 +import com.cnlive.strike.network.api.ApiService;
  19 +import com.cnlive.strike.network.bean.TestBean;
14 20
15 21
16 public class MyFragment1 extends BaseFragment { 22 public class MyFragment1 extends BaseFragment {
@@ -26,6 +32,33 @@ public class MyFragment1 extends BaseFragment { @@ -26,6 +32,33 @@ public class MyFragment1 extends BaseFragment {
26 super.initView(); 32 super.initView();
27 setStatusBarColor(R.color.qmui_config_color_red, 0); 33 setStatusBarColor(R.color.qmui_config_color_red, 0);
28 setStatusBarTextColor(StatusBarConfig.BLACK); 34 setStatusBarTextColor(StatusBarConfig.BLACK);
  35 + baseView.findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() {
  36 + @Override
  37 + public void onClick(View v) {
  38 + //单个请求
  39 + HttpConn.action(
  40 + BaseRequest
  41 + .init()
  42 + .setUrl("http://gank.io/api/data/")
  43 + .service(ApiService.class)
  44 + .getTest(), new NetCallBack<TestBean>() {
  45 + @Override
  46 + public void onRequestState(int state) {
29 47
  48 + }
  49 +
  50 + @Override
  51 + public void onSuccess(TestBean data) {
  52 + Log.e(TAG, "onSuccess: " + data.getResults().size());
  53 + }
  54 +
  55 + @Override
  56 + public void onFailure(String errCode, String errMsg) {
  57 + Log.e(TAG, "onFailure: " + errMsg);
  58 + }
  59 +
  60 + });
  61 + }
  62 + });
30 } 63 }
31 } 64 }
build.gradle
@@ -14,7 +14,6 @@ buildscript { @@ -14,7 +14,6 @@ buildscript {
14 } 14 }
15 dependencies { 15 dependencies {
16 classpath 'com.android.tools.build:gradle:3.5.1' 16 classpath 'com.android.tools.build:gradle:3.5.1'
17 -  
18 // NOTE: Do not place your application dependencies here; they belong 17 // NOTE: Do not place your application dependencies here; they belong
19 // in the individual module build.gradle files 18 // in the individual module build.gradle files
20 classpath "com.alibaba:arouter-register:1.0.2" 19 classpath "com.alibaba:arouter-register:1.0.2"
@@ -109,7 +108,8 @@ allprojects { @@ -109,7 +108,8 @@ allprojects {
109 imput("implementation", project, moudle.core_base) 108 imput("implementation", project, moudle.core_base)
110 109
111 //Tripartite Base 110 //Tripartite Base
112 - for (String moudle : base_librarys) imput('implementation', project, moudle) 111 +// for (String moudle : base_librarys) imput('implementation', project, moudle)
  112 + for (String moudle : base_librarys) imput('api', project, moudle)
113 for (String moudle : base_compilers) imput('annotationProcessor', project, moudle) 113 for (String moudle : base_compilers) imput('annotationProcessor', project, moudle)
114 114
115 } 115 }
@@ -118,11 +118,22 @@ allprojects { @@ -118,11 +118,22 @@ allprojects {
118 google() 118 google()
119 jcenter() 119 jcenter()
120 maven { 120 maven {
121 - url mixedUrl  
122 - credentials { username = mavenUsername; password = mavenPassword } 121 + url maven.mixedUrl
  122 + credentials { username = nexusId; password = nexusPw }
  123 + }
  124 + //------------------ 资源库配置 END------------------
  125 + maven {
  126 + url 'https://dl.bintray.com/granzon/cnlive'
  127 + }
  128 + maven {
  129 + url 'https://dl.bintray.com/granzon/cnliveLibs'
  130 + }
  131 + maven {
  132 + url "https://jitpack.io"
  133 + }
  134 + maven {
  135 + url 'http://developer.huawei.com/repo'
123 } 136 }
124 - maven { url 'https://jitpack.io' }  
125 - maven { url 'http://developer.huawei.com/repo' }  
126 } 137 }
127 } 138 }
128 task clean(type: Delete) { 139 task clean(type: Delete) {
@@ -131,6 +142,6 @@ task clean(type: Delete) { @@ -131,6 +142,6 @@ task clean(type: Delete) {
131 142
132 //配置全局变量 143 //配置全局变量
133 ext { 144 ext {
134 - libEmoj='2.0.9' 145 + libEmoj = '2.0.9'
135 libMediaPicker = '1.5.8' 146 libMediaPicker = '1.5.8'
136 } 147 }
config.gradle
1 ext { 1 ext {
2 - mixedUrl = "http://android.nexus.cnlive.com/repository/cnlive-mixed/"  
3 - mavenUsername = "developer"  
4 - mavenPassword = "android_2019" 2 + //Nexus 访问账号
  3 + nexusId = "developer"
  4 + nexusPw = "android_2019"
5 5
6 //Nexus 发布配置 6 //Nexus 发布配置
7 maven = [ 7 maven = [
@@ -46,6 +46,17 @@ ext { @@ -46,6 +46,17 @@ ext {
46 espresso: 'androidx.test.espresso:espresso-core:3.2.0' 46 espresso: 'androidx.test.espresso:espresso-core:3.2.0'
47 ] 47 ]
48 48
  49 + //Maven Base库配置
  50 + moudle_cnlive_base = [
  51 + //编译方式
  52 + debug : false,
  53 + //版本号
  54 + version: "0.0.2",
  55 + //Lib库前缀
  56 + packeg : "com.cnlive.core",
  57 + //Lib库名称
  58 + name : "base"
  59 + ]
49 library = [ 60 library = [
50 61
51 //fragment滑动返回( https://github.com/YoKeyword/Fragmentation ,源码导入修改) 62 //fragment滑动返回( https://github.com/YoKeyword/Fragmentation ,源码导入修改)
@@ -54,15 +65,15 @@ ext { @@ -54,15 +65,15 @@ ext {
54 fragmentationx : 'me.yokeyword:fragmentationx:1.0.2', 65 fragmentationx : 'me.yokeyword:fragmentationx:1.0.2',
55 //log日志 66 //log日志
56 logger : 'com.orhanobut:logger:2.2.0', 67 logger : 'com.orhanobut:logger:2.2.0',
57 -// //空祖对话框 https://github.com/kongzue/DialogV3  
58 -// kongzueDailog : 'com.kongzue.dialog_v3x:dialog:3.1.6', 68 + //空祖对话框 https://github.com/kongzue/DialogV3 (源码导入,修改)
  69 + kongzueDailog : 'com.kongzue.dialog_v3x:dialog:3.1.6',
59 //视讯云加密 70 //视讯云加密
60 libCnencipher : 'com.cnlive:lib-cnencipher:1.1.1', 71 libCnencipher : 'com.cnlive:lib-cnencipher:1.1.1',
61 //视频库 72 //视频库
62 libVideoQiniu : 'com.cnlive.libs:video_qiniu:1.0.6', 73 libVideoQiniu : 'com.cnlive.libs:video_qiniu:1.0.6',
63 //视讯云播放器 74 //视讯云播放器
64 libCnVideo : 'com.cnlive:lib_cnvideo2.0:3.3.11', 75 libCnVideo : 'com.cnlive:lib_cnvideo2.0:3.3.11',
65 - //权限 76 +// //权限
66 easypermissions : 'pub.devrel:easypermissions:1.0.0', 77 easypermissions : 'pub.devrel:easypermissions:1.0.0',
67 //MVP 78 //MVP
68 mvp : 'com.hannesdorfmann.mosby3:mvp:3.0.4', 79 mvp : 'com.hannesdorfmann.mosby3:mvp:3.0.4',
@@ -102,65 +113,48 @@ ext { @@ -102,65 +113,48 @@ ext {
102 cardviewV7 : 'com.android.support:cardview-v7:28.0.0', 113 cardviewV7 : 'com.android.support:cardview-v7:28.0.0',
103 dataBinding : 'com.android.databinding.library:3.5.1' 114 dataBinding : 'com.android.databinding.library:3.5.1'
104 ] 115 ]
105 -// library_jar = [  
106 -// pinyin4j: ('libs/pinyin4j-2.5.0.jar')  
107 -// ]  
108 //基础三方库 116 //基础三方库
109 base_librarys = [ 117 base_librarys = [
110 -// library.fragmentation_swipeback,  
111 -// library.fragmentationx,  
112 -library.logger,  
113 -//对话框  
114 -// library.kongzueDailog,  
115 -//视讯云加密库  
116 -library.libCnencipher,  
117 -//视频库  
118 -library.libVideoQiniu,  
119 -//视讯云播放器  
120 -library.libCnVideo,  
121 -//权限  
122 -library.easypermissions,  
123 -//EvenBus  
124 -library.eventBus,  
125 -//QMUI  
126 -library.qmui,  
127 -library.qmui_arch,  
128 -//mvp 118 + library.logger,
  119 + //视讯云加密库
  120 + library.libCnencipher,
  121 + //视频库
  122 + library.libVideoQiniu,
  123 + //视讯云播放器
  124 + library.libCnVideo,
  125 + //权限
  126 + library.easypermissions,
  127 + //EvenBus
  128 + library.eventBus,
  129 + //QMUI
  130 + library.qmui,
  131 + library.qmui_arch,
  132 + //mvp
129 // library.mvp, 133 // library.mvp,
130 // library.mvp_lce, 134 // library.mvp_lce,
131 // library.mvp_nullobject_presenter, 135 // library.mvp_nullobject_presenter,
132 // library.mvp_viewstate, 136 // library.mvp_viewstate,
133 -//图片加载Glide  
134 -glide.api,  
135 -glide.transformations,  
136 -//兼容旧版  
137 -// library.supportV4,  
138 -// library.appcompatV7,  
139 -// library.design,  
140 -// library.supportV13,  
141 -// library.recyclerviewV7,  
142 -// library.cardviewV7,  
143 -// library.dataBinding,  
144 -//使用androidx  
145 -androidx.appcompat,  
146 -androidx.constraintlayout,  
147 -androidx.multidex,  
148 -//其他库  
149 -library.rxjava,  
150 -library.rxandroid,  
151 -library.retrofit,  
152 -library.retrofitConverterGson,  
153 -library.retrofitAdapterRxjava2,  
154 -library.okhttp,  
155 -library.okhttpLoggingInterceptor,  
156 -library.greendao,  
157 -//管理rxjava生命周期  
158 -// library.rx  
159 -router.api,  
160 -  
161 -test.junit,  
162 -test.runner,  
163 -test.espresso 137 + //图片加载Glide
  138 + glide.api,
  139 + glide.transformations,
  140 + //使用androidx
  141 + androidx.appcompat,
  142 + androidx.constraintlayout,
  143 + androidx.multidex,
  144 + //其他库
  145 + library.rxjava,
  146 + library.rxandroid,
  147 + library.retrofit,
  148 + library.retrofitConverterGson,
  149 + library.retrofitAdapterRxjava2,
  150 + library.okhttp,
  151 + library.okhttpLoggingInterceptor,
  152 + //数据库
  153 + library.greendao,
  154 + router.api,
  155 + test.junit,
  156 + test.runner,
  157 + test.espresso
164 ] 158 ]
165 159
166 base_compilers = [ 160 base_compilers = [
@@ -170,10 +164,6 @@ test.espresso @@ -170,10 +164,6 @@ test.espresso
170 router.compiler 164 router.compiler
171 ] 165 ]
172 166
173 -// base_jar = [  
174 -// library_jar.pinyin4j  
175 -// ]  
176 -  
177 //正式签名配置 167 //正式签名配置
178 Properties properties = new Properties() 168 Properties properties = new Properties()
179 properties.load(project.rootProject.file('local.properties').newDataInputStream()) 169 properties.load(project.rootProject.file('local.properties').newDataInputStream())
core/base/base_maven_push.gradle 0 → 100644
  1 +apply plugin: 'maven'
  2 +
  3 +uploadArchives() {
  4 + repositories {
  5 + mavenDeployer {
  6 + def lib = moudle_cnlive_base
  7 + //发布环境(正式/测试)
  8 + android.defaultPublishConfig lib.debug ? "debug" : "release"
  9 + //发布渠道(地址/账号)
  10 + repository(url: maven.mixedUrl) {
  11 + authentication(userName: maven.username, password: maven.password)
  12 + }
  13 + //发布信息(包名/别名/版本)
  14 + pom.project {
  15 + groupId lib.packeg
  16 + artifactId lib.name
  17 + version = lib.debug ? lib.version.concat("-SNAPSHOT") : lib.version
  18 + }
  19 + pom.whenConfigured { pom ->
  20 + pom.dependencies.clear()
  21 + }
  22 +
  23 + }
  24 + }
  25 +}
0 \ No newline at end of file 26 \ No newline at end of file
core/base/build.gradle
1 apply plugin: 'com.android.library' 1 apply plugin: 'com.android.library'
2 - 2 +apply from: './base_maven_push.gradle'
3 android { 3 android {
4 // compileSdkVersion 29 4 // compileSdkVersion 29
5 // buildToolsVersion "29.0.2" 5 // buildToolsVersion "29.0.2"
@@ -27,6 +27,5 @@ android { @@ -27,6 +27,5 @@ android {
27 dependencies { 27 dependencies {
28 implementation fileTree(include: ['*.jar'], dir: 'libs') 28 implementation fileTree(include: ['*.jar'], dir: 'libs')
29 api files('libs/pinyin4j-2.5.0.jar') 29 api files('libs/pinyin4j-2.5.0.jar')
30 -  
31 implementation 'androidx.legacy:legacy-support-v4:1.0.0' 30 implementation 'androidx.legacy:legacy-support-v4:1.0.0'
32 } 31 }
core/base/src/main/java/com/cnlive/core/libs/base/frame/activity/BaseActivity.java
@@ -272,7 +272,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V @@ -272,7 +272,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
272 } 272 }
273 //activity管理 273 //activity管理
274 AppManager.getInstance().deleteActivity(me); 274 AppManager.getInstance().deleteActivity(me);
275 - //清除所有订阅 275 + //清除当前订阅
276 SubscriptionManager.getInstance().cancel(TAG); 276 SubscriptionManager.getInstance().cancel(TAG);
277 } 277 }
278 278
core/base/src/main/java/com/cnlive/core/libs/base/frame/fragment/BaseFragment.java
@@ -23,6 +23,7 @@ import com.alibaba.android.arouter.launcher.ARouter; @@ -23,6 +23,7 @@ import com.alibaba.android.arouter.launcher.ARouter;
23 import com.cnlive.core.libs.base.frame.activity.BaseActivity; 23 import com.cnlive.core.libs.base.frame.activity.BaseActivity;
24 import com.cnlive.core.libs.base.frame.presenter.BasePresenter; 24 import com.cnlive.core.libs.base.frame.presenter.BasePresenter;
25 import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener; 25 import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener;
  26 +import com.cnlive.core.libs.base.network.manager.SubscriptionManager;
26 import com.cnlive.core.libs.base.util.ParameterCache; 27 import com.cnlive.core.libs.base.util.ParameterCache;
27 import com.cnlive.core.libs.base.util.ReflectUtil; 28 import com.cnlive.core.libs.base.util.ReflectUtil;
28 import com.cnlive.core.libs.base.frame.view.BaseView; 29 import com.cnlive.core.libs.base.frame.view.BaseView;
@@ -97,6 +98,8 @@ public abstract class BaseFragment&lt;V extends BaseView, P extends BasePresenter&lt;V @@ -97,6 +98,8 @@ public abstract class BaseFragment&lt;V extends BaseView, P extends BasePresenter&lt;V
97 @Override 98 @Override
98 public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 99 public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
99 super.onViewCreated(view, savedInstanceState); 100 super.onViewCreated(view, savedInstanceState);
  101 + //创建订阅映射
  102 + SubscriptionManager.getInstance().setCurrentDisposables(TAG);
100 mSwipeDelegate.onViewCreated(view, savedInstanceState); 103 mSwipeDelegate.onViewCreated(view, savedInstanceState);
101 if (null != getMvpView() && null != getPresenter()) { 104 if (null != getMvpView() && null != getPresenter()) {
102 initBindingData(); 105 initBindingData();
@@ -190,6 +193,8 @@ public abstract class BaseFragment&lt;V extends BaseView, P extends BasePresenter&lt;V @@ -190,6 +193,8 @@ public abstract class BaseFragment&lt;V extends BaseView, P extends BasePresenter&lt;V
190 public void onDestroy() { 193 public void onDestroy() {
191 mDelegate.onDestroy(); 194 mDelegate.onDestroy();
192 mSwipeDelegate.onDestroyView(); 195 mSwipeDelegate.onDestroyView();
  196 + //清除当前订阅
  197 + SubscriptionManager.getInstance().cancel(TAG);
193 super.onDestroy(); 198 super.onDestroy();
194 if (null != baseBinding) { 199 if (null != baseBinding) {
195 baseBinding.unbind(); 200 baseBinding.unbind();