Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
cfab77e2
Commit
cfab77e2
authored
Nov 28, 2019
by
徐健
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into feature/test_home_pager
# Conflicts: # config.gradle
parents
1717b7cf
b1b6a6a5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
227 additions
and
66 deletions
+227
-66
MainActivity.kt
app/src/main/java/com/ydl/component/MainActivity.kt
+1
-2
config.gradle
config.gradle
+17
-17
ExpertSearchActivity.kt
m-consultant/src/main/java/com/yidianling/consultant/ExpertSearchActivity.kt
+3
-3
ExpertSearchAdapter.kt
m-consultant/src/main/java/com/yidianling/consultant/adapter/ExpertSearchAdapter.kt
+1
-1
ConsultAssistantDialogUtils.kt
m-consultant/src/main/java/com/yidianling/consultant/modular/singlton/ConsultAssistantDialogUtils.kt
+80
-16
FlutterCourseHomeFragment.kt
m-course/src/main/java/com/yidianling/course/FlutterCourseHomeFragment.kt
+1
-1
CourseListContainerActivity.kt
m-course/src/main/java/com/yidianling/course/courseNew/courseList/CourseListContainerActivity.kt
+8
-8
MuseActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/MuseActivity.kt
+1
-1
OkHttpConfig.java
ydl-net/src/main/java/com/ydl/ydlnet/builder/config/OkHttpConfig.java
+15
-7
RequestHandler.java
ydl-net/src/main/java/com/ydl/ydlnet/builder/interceptor/log/RequestHandler.java
+30
-0
RequestLogInterceptor.java
ydl-net/src/main/java/com/ydl/ydlnet/builder/interceptor/log/RequestLogInterceptor.java
+22
-4
build.gradle
ydl-platform/build.gradle
+2
-1
GlobalConfig.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/GlobalConfig.kt
+1
-0
HttpConfig.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/HttpConfig.kt
+0
-0
AuthBean.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/bean/AuthBean.kt
+20
-0
ApiRequestUtil.java
ydl-platform/src/main/java/com/ydl/ydlcommon/data/http/api/ApiRequestUtil.java
+12
-2
NetApiStore.java
ydl-platform/src/main/java/com/ydl/ydlcommon/data/http/api/NetApiStore.java
+13
-3
No files found.
app/src/main/java/com/ydl/component/MainActivity.kt
View file @
cfab77e2
...
...
@@ -13,7 +13,6 @@ import android.util.Log
import
com.alibaba.android.arouter.launcher.ARouter
import
com.tbruyelle.rxpermissions2.RxPermissions
import
com.umeng.analytics.MobclickAgent
import
com.umeng.commonsdk.framework.UMModuleRegister.getAppContext
import
com.ydl.audioim.YDLavManager
import
com.ydl.component.music.MusicPlayActivity
import
com.ydl.component.mvp.DemoContract
...
...
@@ -137,7 +136,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
override
fun
reLoadData
()
{
mPresenter
?.
loadUsers
()
mPresenter
.
loadHome
()
}
...
...
config.gradle
View file @
cfab77e2
...
...
@@ -43,14 +43,14 @@ ext {
// -------------- 业务模块 --------------
//第三步 若干
"m-confide"
:
"0.0.2
8
"
,
"m-consultant"
:
"0.0.
39
"
,
"m-fm"
:
"0.0.2
0
"
,
"m-user"
:
"0.0.3
3
"
,
"m-confide"
:
"0.0.2
9
"
,
"m-consultant"
:
"0.0.
44
"
,
"m-fm"
:
"0.0.2
1
"
,
"m-user"
:
"0.0.3
4
"
,
// 接入flutter的模块
"m-tests"
:
"0.0.1
1.10
"
,
"m-muse"
:
"0.0.1
7.10
"
,
"m-course"
:
"0.0.
28.1
0"
,
"m-tests"
:
"0.0.1
2
"
,
"m-muse"
:
"0.0.1
9
"
,
"m-course"
:
"0.0.
3
0"
,
//-------------- 业务模块 API 层 --------------
"m-audioim-api"
:
"0.0.5"
,
...
...
@@ -64,13 +64,13 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform"
:
"0.0.2
6
"
,
"ydl-platform"
:
"0.0.2
7
"
,
//第二步 若干
"ydl-webview"
:
"0.0.2
7
"
,
"ydl-media"
:
"0.0.1
3
"
,
"ydl-pay"
:
"0.0.1
0
"
,
"m-audioim"
:
"0.0.2
8
"
,
"ydl-webview"
:
"0.0.2
8
"
,
"ydl-media"
:
"0.0.1
4
"
,
"ydl-pay"
:
"0.0.1
1
"
,
"m-audioim"
:
"0.0.2
9
"
,
//以下 几乎不会动
"router"
:
"0.0.1"
,
...
...
@@ -104,13 +104,13 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform"
:
"0.0.2
6
"
,
"ydl-platform"
:
"0.0.2
7
"
,
//第二步 若干
"ydl-webview"
:
"0.0.2
7
"
,
"ydl-media"
:
"0.0.1
3
"
,
"ydl-pay"
:
"0.0.1
0
"
,
"m-audioim"
:
"0.0.2
8
"
,
"ydl-webview"
:
"0.0.2
8
"
,
"ydl-media"
:
"0.0.1
4
"
,
"ydl-pay"
:
"0.0.1
1
"
,
"m-audioim"
:
"0.0.2
9
"
,
//以下 几乎不会动
...
...
m-consultant/src/main/java/com/yidianling/consultant/ExpertSearchActivity.kt
View file @
cfab77e2
...
...
@@ -312,7 +312,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
image_scroll_top
.
setOnClickListener
(
this
)
// initStatus()
ConsultAssistantDialogUtils
.
INSTANCE
.
fitRequest
(
this
,
"doctor_list"
)
ConsultAssistantDialogUtils
.
INSTANCE
.
fitRequest
(
this
,
"doctor_list"
,
true
)
}
private
fun
initNetLossView
()
{
...
...
@@ -999,7 +999,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
}
else
{
updateFilterTextViewStatus
(
tvFilter
,
FILTER_STATUS_NORMAL
)
}
ConsultAssistantDialogUtils
.
INSTANCE
.
fitRequest
(
this
,
"doctor_list"
)
ConsultAssistantDialogUtils
.
INSTANCE
.
fitRequest
(
this
,
"doctor_list"
,
true
)
}
filterPopupWindow
.
isClippingEnabled
=
false
filterPopupWindow
.
showAtLocation
(
viewSep2
.
rootView
,
Gravity
.
TOP
+
Gravity
.
RIGHT
,
0
,
0
)
...
...
@@ -1478,6 +1478,6 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
override
fun
onDestroy
()
{
super
.
onDestroy
()
ConsultAssistantDialogUtils
.
INSTANCE
.
r
esetStatus
()
ConsultAssistantDialogUtils
.
INSTANCE
.
expertSearchR
esetStatus
()
}
}
m-consultant/src/main/java/com/yidianling/consultant/adapter/ExpertSearchAdapter.kt
View file @
cfab77e2
...
...
@@ -208,7 +208,7 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
//私聊文案
if
(
TextUtils
.
isEmpty
(
itemBean
.
chatBtnText
)){
holder
.
tvChat
.
text
=
"私聊"
holder
.
tvChat
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
white
))
holder
.
tvChat
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
consultant_confirm_text_color
))
holder
.
tvChat
.
background
=
ContextCompat
.
getDrawable
(
context
,
R
.
drawable
.
consultant_expert_search_chat
)
}
else
{
holder
.
tvChat
.
text
=
itemBean
.
chatBtnText
...
...
m-consultant/src/main/java/com/yidianling/consultant/modular/singlton/ConsultAssistantDialogUtils.kt
View file @
cfab77e2
...
...
@@ -2,6 +2,7 @@ package com.yidianling.consultant.modular.singlton
import
android.app.Activity
import
android.support.v7.app.AppCompatActivity
import
com.ydl.ydlcommon.utils.YdlBuryPointUtil
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.consultant.dialog.ConsultAssistantDialog
import
com.yidianling.consultant.model.SearchApi
...
...
@@ -21,16 +22,19 @@ class ConsultAssistantDialogUtils private constructor() {
}
var
consultAssistantDialogFromHomePage
:
ConsultAssistantDialog
?
=
null
// 首页展示的dialog
var
consultAssistantDialog
:
ConsultAssistantDialog
?
=
null
//咨询师列表页面展示的dialog
var
expertSearchPageHasShown
:
Boolean
=
false
// 专家咨询列表页面是否已经展示
var
consultAssistantFragmentDialog
:
ConsultAssistantDialog
?
=
null
//咨询师列表fragment页面展示的dialog
var
expertSearchPageHasShown
:
Boolean
=
false
// 专家咨询列表fragment页面是否已经展示
var
consultAssistantActivityDialog
:
ConsultAssistantDialog
?
=
null
//咨询师列表activity页面展示的dialog
var
expertSearchActivityPageHasShown
:
Boolean
=
false
// 专家咨询列表activity页面是否已经展示
var
timer
:
Timer
?
=
null
/**
*判断是否符合代码展示逻辑
* origin 展示请求来源 首页 home_index 咨询列表 doctor_list
* fromActivity 默认不是来自于咨询师列表activity
*/
fun
fitRequest
(
activity
:
Activity
,
origin
:
String
)
{
fun
fitRequest
(
activity
:
Activity
,
origin
:
String
,
fromActivity
:
Boolean
=
false
)
{
when
(
origin
)
{
"home_index"
->
{
if
(
ConsultantIn
.
isLogin
()
&&
...
...
@@ -40,7 +44,9 @@ class ConsultAssistantDialogUtils private constructor() {
}
}
"doctor_list"
->
{
shouldShowDialog
(
activity
,
origin
)
if
(!
ConsultantIn
.
isLogin
()
||
(
ConsultantIn
.
getUserImpl
().
getUserInfo
()
?.
user_type
==
1
&&
ConsultantIn
.
isLogin
()))
{
shouldShowDialog
(
activity
,
origin
,
fromActivity
=
fromActivity
)
}
}
}
...
...
@@ -49,7 +55,7 @@ class ConsultAssistantDialogUtils private constructor() {
/**
* 判断是否符合接口展示逻辑
*/
private
fun
shouldShowDialog
(
activity
:
Activity
,
origin
:
String
,
isDelay
:
Boolean
=
false
)
{
private
fun
shouldShowDialog
(
activity
:
Activity
,
origin
:
String
,
isDelay
:
Boolean
=
false
,
fromActivity
:
Boolean
=
false
)
{
// 请求接口判断导医咨询助理按钮是否展示
SearchApi
.
getSearchApi
().
getConsultAssistantRequest
(
origin
)
.
subscribeOn
(
Schedulers
.
io
())
...
...
@@ -59,7 +65,7 @@ class ConsultAssistantDialogUtils private constructor() {
if
(
origin
==
"home_index"
)
{
showFromYdlHome
(
activity
)
}
else
if
(
origin
==
"doctor_list"
)
{
show
(
activity
)
show
(
activity
,
fromActivity
)
}
}
}
...
...
@@ -78,6 +84,7 @@ class ConsultAssistantDialogUtils private constructor() {
object
:
ConsultAssistantDialog
.
OnConsultAssistantClickListener
{
override
fun
onClickAction
()
{
//获取用户uid
YdlBuryPointUtil
.
sendClick
(
"home_page_assistant_click"
)
getConsultAssistantUid
(
activity
)
}
...
...
@@ -100,8 +107,9 @@ class ConsultAssistantDialogUtils private constructor() {
/**
* 咨询师列表页展示
*/
fun
show
(
activity
:
Activity
)
{
fun
show
(
activity
:
Activity
,
fromActivity
:
Boolean
=
false
)
{
// 来自于fragment咨询师列表
if
(!
fromActivity
)
{
if
(!
expertSearchPageHasShown
&&
timer
==
null
)
{
timer
=
Timer
()
timer
!!
.
schedule
(
object
:
TimerTask
()
{
...
...
@@ -116,18 +124,36 @@ class ConsultAssistantDialogUtils private constructor() {
}
else
{
showDialog
(
activity
)
}
}
else
{
// 来自于activity咨询师列表
if
(!
expertSearchActivityPageHasShown
&&
timer
==
null
)
{
timer
=
Timer
()
timer
!!
.
schedule
(
object
:
TimerTask
()
{
override
fun
run
()
{
Observable
.
just
(
1
).
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
expertSearchActivityPageHasShown
=
true
showDialog
(
activity
,
true
)
}
}
},
5000
)
}
else
{
showDialog
(
activity
,
true
)
}
}
}
/**
* 咨询师列表页展示浮层
*/
fun
showDialog
(
activity
:
Activity
)
{
fun
showDialog
(
activity
:
Activity
,
fromActivity
:
Boolean
=
false
)
{
if
(!
fromActivity
)
{
if
(!
activity
.
isFinishing
)
{
if
(
consultAssista
ntDialog
==
null
)
{
consultAssista
ntDialog
=
ConsultAssistantDialog
(
if
(
consultAssistantFragme
ntDialog
==
null
)
{
consultAssistantFragme
ntDialog
=
ConsultAssistantDialog
(
activity
,
object
:
ConsultAssistantDialog
.
OnConsultAssistantClickListener
{
override
fun
onClickAction
()
{
YdlBuryPointUtil
.
sendClick
(
"assistant_list_click"
)
// 咨询师列表页面且未登录情况下,跳转登录页面
if
(!
ConsultantIn
.
isLogin
())
{
ConsultantIn
.
toLogin
(
activity
)
...
...
@@ -139,7 +165,29 @@ class ConsultAssistantDialogUtils private constructor() {
})
}
consultAssistantDialog
?.
show
()
consultAssistantFragmentDialog
?.
show
()
}
}
else
{
if
(!
activity
.
isFinishing
)
{
if
(
consultAssistantActivityDialog
==
null
)
{
consultAssistantActivityDialog
=
ConsultAssistantDialog
(
activity
,
object
:
ConsultAssistantDialog
.
OnConsultAssistantClickListener
{
override
fun
onClickAction
()
{
YdlBuryPointUtil
.
sendClick
(
"assistant_list_click"
)
// 咨询师列表页面且未登录情况下,跳转登录页面
if
(!
ConsultantIn
.
isLogin
())
{
ConsultantIn
.
toLogin
(
activity
)
}
else
{
//获取用户uid
getConsultAssistantUid
(
activity
)
}
}
})
}
consultAssistantActivityDialog
?.
show
()
}
}
}
...
...
@@ -148,20 +196,36 @@ class ConsultAssistantDialogUtils private constructor() {
* 咨询师列表页隐藏
*/
fun
hide
()
{
consultAssistantDialog
?.
hide
()
consultAssistant
Fragment
Dialog
?.
hide
()
}
/**
* 咨询师列表页面使用的重置本单例关于专家咨询列表页面得状态
* 释放本单例所有资源(咨询师列表fragmnet在MainActivity,
* 且在MainActivity销毁的时候,会先执行咨询师列表fragmnet
* 的ondeatroy,所以这边直接在该专家咨询列表碎片执行该方法)
*/
fun
resetStatus
()
{
consultAssistantDialogFromHomePage
?.
dismiss
()
consultAssistantDialog
?.
dismiss
()
consultAssistantFragmentDialog
?.
dismiss
()
consultAssistantActivityDialog
?.
dismiss
()
timer
?.
cancel
()
timer
=
null
expertSearchPageHasShown
=
false
expertSearchActivityPageHasShown
=
false
consultAssistantDialogFromHomePage
=
null
consultAssistantDialog
=
null
consultAssistantFragmentDialog
=
null
consultAssistantActivityDialog
=
null
}
/**
* 咨询师列表activity页面使用的重置本单例关于专家咨询列表页面得状态
*/
fun
expertSearchResetStatus
()
{
consultAssistantActivityDialog
?.
dismiss
()
timer
?.
cancel
()
timer
=
null
expertSearchActivityPageHasShown
=
false
consultAssistantActivityDialog
=
null
}
////////////////////////////////////// 咨询师列表页面的展示隐藏逻辑 代码块end ///////////////////////////////////////////////////
...
...
m-course/src/main/java/com/yidianling/course/FlutterCourseHomeFragment.kt
View file @
cfab77e2
...
...
@@ -49,7 +49,7 @@ class FlutterCourseHomeFragment : BaseFlutterFragment() {
}
override
fun
initialRoute
():
String
{
return
"
native/
course/home"
return
"course/home"
}
override
fun
setUserVisibleHint
(
isVisibleToUser
:
Boolean
)
{
...
...
m-course/src/main/java/com/yidianling/course/courseNew/courseList/CourseListContainerActivity.kt
View file @
cfab77e2
...
...
@@ -139,7 +139,7 @@ class CourseListContainerActivity : BaseActivity(), PtrHandler, LoadMoreHandler
filter_layout
.
setTextColor
(
ContextCompat
.
getColor
(
this
@CourseListContainerActivity
,
R
.
color
.
course_color_1DA1F2
R
.
color
.
main_theme
)
)
}
else
{
...
...
@@ -233,7 +233,7 @@ class CourseListContainerActivity : BaseActivity(), PtrHandler, LoadMoreHandler
classify_layout
.
setTextColor
(
ContextCompat
.
getColor
(
this
@CourseListContainerActivity
,
R
.
color
.
course_color_1DA1F2
R
.
color
.
main_theme
)
)
}
else
{
...
...
@@ -330,7 +330,7 @@ class CourseListContainerActivity : BaseActivity(), PtrHandler, LoadMoreHandler
classify_layout
.
setTextColor
(
ContextCompat
.
getColor
(
this
@CourseListContainerActivity
,
R
.
color
.
course_color_1DA1F2
R
.
color
.
main_theme
)
)
}
else
{
...
...
@@ -352,7 +352,7 @@ class CourseListContainerActivity : BaseActivity(), PtrHandler, LoadMoreHandler
classify_layout
.
setTextColor
(
ContextCompat
.
getColor
(
this
@CourseListContainerActivity
,
R
.
color
.
course_color_1DA1F2
R
.
color
.
main_theme
)
)
classify_layout
.
setCompoundDrawablesWithIntrinsicBounds
(
...
...
@@ -399,7 +399,7 @@ class CourseListContainerActivity : BaseActivity(), PtrHandler, LoadMoreHandler
filter_layout
.
setTextColor
(
ContextCompat
.
getColor
(
this
@CourseListContainerActivity
,
R
.
color
.
course_color_1DA1F2
R
.
color
.
main_theme
)
)
}
else
{
...
...
@@ -421,7 +421,7 @@ class CourseListContainerActivity : BaseActivity(), PtrHandler, LoadMoreHandler
filter_layout
.
setTextColor
(
ContextCompat
.
getColor
(
this
@CourseListContainerActivity
,
R
.
color
.
course_color_1DA1F2
R
.
color
.
main_theme
)
)
filter_layout
.
setCompoundDrawablesWithIntrinsicBounds
(
...
...
@@ -642,7 +642,7 @@ class CourseListContainerActivity : BaseActivity(), PtrHandler, LoadMoreHandler
classify_layout
.
setTextColor
(
ContextCompat
.
getColor
(
this
@CourseListContainerActivity
,
R
.
color
.
course_color_1DA1F2
R
.
color
.
main_theme
)
)
}
else
{
...
...
@@ -689,7 +689,7 @@ class CourseListContainerActivity : BaseActivity(), PtrHandler, LoadMoreHandler
filter_layout
.
setTextColor
(
ContextCompat
.
getColor
(
this
@CourseListContainerActivity
,
R
.
color
.
course_color_1DA1F2
R
.
color
.
main_theme
)
)
}
else
{
...
...
m-muse/src/main/java/com/yidianling/muse/activity/MuseActivity.kt
View file @
cfab77e2
...
...
@@ -15,7 +15,7 @@ import org.json.JSONObject
@Route
(
path
=
"/module/muse"
)
class
MuseActivity
:
BaseFlutterActivity
()
{
override
fun
initialRoute
():
String
{
return
"
native/
muse/home"
return
"muse/home"
}
override
fun
initChannelPlugin
(
jsonObject
:
JSONObject
)
{
...
...
ydl-net/src/main/java/com/ydl/ydlnet/builder/config/OkHttpConfig.java
View file @
cfab77e2
...
...
@@ -2,6 +2,7 @@ package com.ydl.ydlnet.builder.config;
import
android.content.Context
;
import
android.text.TextUtils
;
import
com.ydl.ydlnet.builder.cookie.CookieJarImpl
;
import
com.ydl.ydlnet.builder.cookie.store.CookieStore
;
import
com.ydl.ydlnet.builder.factory.ApiFactory
;
...
...
@@ -9,19 +10,22 @@ import com.ydl.ydlnet.builder.http.SSLUtils;
import
com.ydl.ydlnet.builder.interceptor.HeaderInterceptor
;
import
com.ydl.ydlnet.builder.interceptor.NetCacheInterceptor
;
import
com.ydl.ydlnet.builder.interceptor.NoNetCacheInterceptor
;
import
com.ydl.ydlnet.builder.interceptor.log.RequestHandler
;
import
com.ydl.ydlnet.builder.interceptor.log.RequestLogInterceptor
;
import
com.ydl.ydlnet.builder.manage.HttpUrlManager
;
import
com.ydl.ydlnet.client.interfaces.BuildHeadersListener
;
import
okhttp3.Cache
;
import
okhttp3.Interceptor
;
import
okhttp3.OkHttpClient
;
import
javax.net.ssl.HostnameVerifier
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
javax.net.ssl.HostnameVerifier
;
import
okhttp3.Cache
;
import
okhttp3.Interceptor
;
import
okhttp3.OkHttpClient
;
/**
* Created by haorui on 2019-09-02 .
* Des: 统一OkHttp配置信息
...
...
@@ -80,6 +84,7 @@ public class OkHttpConfig {
private
InputStream
bksFile
;
private
String
password
;
private
InputStream
[]
certificates
;
private
RequestHandler
requestHandler
;
private
Interceptor
[]
interceptors
;
private
Interceptor
[]
netInterceptors
;
private
BuildHeadersListener
buildHeadersListener
;
...
...
@@ -99,6 +104,11 @@ public class OkHttpConfig {
return
this
;
}
public
Builder
setRequestHandler
(
RequestHandler
requestHandler
)
{
this
.
requestHandler
=
requestHandler
;
return
this
;
}
public
Builder
setCache
(
boolean
isCache
)
{
this
.
isCache
=
isCache
;
return
this
;
...
...
@@ -210,9 +220,7 @@ public class OkHttpConfig {
* 配置开发环境
*/
private
void
setDebugConfig
()
{
if
(
isDebug
)
{
okHttpClientBuilder
.
addInterceptor
(
new
RequestLogInterceptor
());
}
okHttpClientBuilder
.
addInterceptor
(
new
RequestLogInterceptor
(
isDebug
,
requestHandler
));
}
...
...
ydl-net/src/main/java/com/ydl/ydlnet/builder/interceptor/log/RequestHandler.java
0 → 100644
View file @
cfab77e2
package
com
.
ydl
.
ydlnet
.
builder
.
interceptor
.
log
;
import
okhttp3.Interceptor
;
import
okhttp3.Request
;
import
okhttp3.Response
;
/**
* Created by haorui on 2019-11-26 .
* Des:
*/
public
interface
RequestHandler
{
Response
onHttpResultResponse
(
String
httpResult
,
Interceptor
.
Chain
chain
,
Response
response
);
Request
onHttpRequestBefore
(
Interceptor
.
Chain
chain
,
Request
request
);
RequestHandler
EMPTY
=
new
RequestHandler
()
{
@Override
public
Response
onHttpResultResponse
(
String
httpResult
,
Interceptor
.
Chain
chain
,
Response
response
)
{
//不管是否处理,都必须将response返回出去
return
response
;
}
@Override
public
Request
onHttpRequestBefore
(
Interceptor
.
Chain
chain
,
Request
request
)
{
//不管是否处理,都必须将request返回出去
return
request
;
}
};
}
ydl-net/src/main/java/com/ydl/ydlnet/builder/interceptor/log/RequestLogInterceptor.java
View file @
cfab77e2
package
com
.
ydl
.
ydlnet
.
builder
.
interceptor
.
log
;
import
android.support.annotation.Nullable
;
import
com.ydl.ydlnet.utils.CharacterHandler
;
import
com.ydl.ydlnet.utils.NetLogUtils
;
import
com.ydl.ydlnet.utils.UrlEncoderUtils
;
import
com.ydl.ydlnet.utils.ZipHelper
;
import
okhttp3.*
;
import
okio.Buffer
;
import
okio.BufferedSource
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
...
...
@@ -15,14 +13,27 @@ import java.net.URLDecoder;
import
java.nio.charset.Charset
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
okhttp3.Interceptor
;
import
okhttp3.MediaType
;
import
okhttp3.Request
;
import
okhttp3.RequestBody
;
import
okhttp3.Response
;
import
okhttp3.ResponseBody
;
import
okio.Buffer
;
import
okio.BufferedSource
;
/**
* Created by haorui on 2019-09-01 .
* Des: 解析框架中的网络请求和响应结果并打印
*/
public
class
RequestLogInterceptor
implements
Interceptor
{
private
DefaultFormatPrinter
mPrinter
=
new
DefaultFormatPrinter
();
private
boolean
mIsDebug
;
private
RequestHandler
mRequestHandler
;
public
RequestLogInterceptor
()
{
public
RequestLogInterceptor
(
boolean
isDebug
,
RequestHandler
requestHandler
)
{
this
.
mIsDebug
=
isDebug
;
this
.
mRequestHandler
=
requestHandler
;
}
@Override
...
...
@@ -36,6 +47,8 @@ public class RequestLogInterceptor implements Interceptor {
mPrinter
.
printFileRequest
(
request
);
}
if
(
mRequestHandler
!=
null
)
request
=
mRequestHandler
.
onHttpRequestBefore
(
chain
,
request
);
long
t1
=
System
.
nanoTime
()
;
Response
originalResponse
;
...
...
@@ -55,6 +68,10 @@ public class RequestLogInterceptor implements Interceptor {
bodyString
=
printResult
(
request
,
originalResponse
);
}
if
(
mRequestHandler
!=
null
)
mRequestHandler
.
onHttpResultResponse
(
bodyString
,
chain
,
originalResponse
);
if
(
mIsDebug
)
{
final
List
<
String
>
segmentList
=
request
.
url
().
encodedPathSegments
();
final
String
header
=
originalResponse
.
headers
().
toString
();
final
int
code
=
originalResponse
.
code
();
...
...
@@ -69,6 +86,7 @@ public class RequestLogInterceptor implements Interceptor {
mPrinter
.
printFileResponse
(
TimeUnit
.
NANOSECONDS
.
toMillis
(
t2
-
t1
),
isSuccessful
,
code
,
header
,
segmentList
,
message
,
url
);
}
}
return
originalResponse
;
}
...
...
ydl-platform/build.gradle
View file @
cfab77e2
...
...
@@ -83,7 +83,8 @@ dependencies {
api
rootProject
.
ext
.
dependencies
[
"ydl-utils"
]
api
rootProject
.
ext
.
dependencies
[
"ydl-js"
]
api
rootProject
.
ext
.
dependencies
[
"ydl-net"
]
// api rootProject.ext.dependencies["ydl-net"]
api
project
(
':ydl-net'
)
api
rootProject
.
ext
.
dependencies
[
"ydl-js"
]
api
rootProject
.
ext
.
dependencies
[
"ptr-lib-release"
]
api
(
rootProject
.
ext
.
dependencies
[
"ydl-device"
])
{
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/GlobalConfig.kt
View file @
cfab77e2
...
...
@@ -91,6 +91,7 @@ class GlobalConfig private constructor(var builder: Builder) {
}
apiFactory
.
setOkClient
(
okHttpClient
)
HttpConfig
.
getInstance
().
initAuth
()
}
}
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/HttpConfig.kt
View file @
cfab77e2
This diff is collapsed.
Click to expand it.
ydl-platform/src/main/java/com/ydl/ydlcommon/bean/AuthBean.kt
0 → 100644
View file @
cfab77e2
package
com.ydl.ydlcommon.bean
/**
* Created by haorui on 2019-11-26.
* Des:
*/
class
AuthBean
{
/**
* id : 1
* appId : android_zhuzhan
* appKey : 123456
* version : 4.0.00
*/
var
id
:
Int
=
0
var
appId
:
String
?
=
null
var
appKey
:
String
?
=
null
var
version
:
String
?
=
null
}
ydl-platform/src/main/java/com/ydl/ydlcommon/data/http/api/ApiRequestUtil.java
View file @
cfab77e2
package
com
.
ydl
.
ydlcommon
.
data
.
http
.
api
;
import
com.google.gson.Gson
;
import
com.ydl.ydlcommon.bean.AuthBean
;
import
com.ydl.ydlcommon.bean.MustUP
;
import
com.ydl.ydlcommon.data.http.BaseAPIResponse
;
import
com.ydl.ydlcommon.data.http.BaseResponse
;
...
...
@@ -8,12 +9,13 @@ import com.ydl.ydlcommon.data.http.FormatText;
import
com.ydl.ydlcommon.data.http.params.ActionDataBean
;
import
com.ydl.ydlcommon.utils.NetworkParamsUtils
;
import
com.ydl.ydlnet.YDLHttpUtils
;
import
java.util.List
;
import
io.reactivex.Observable
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
import
java.util.List
;
/**
* 模块请求工具类
* Created by hgw on 2018/1/23.
...
...
@@ -39,4 +41,12 @@ public class ApiRequestUtil {
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json; charset=utf-8"
),
new
Gson
().
toJson
(
actionDataParams
));
return
YDLHttpUtils
.
Companion
.
obtainApi
(
NetApiStore
.
class
).
actionDataCount
(
body
);
}
/**
* 获取动态密钥
* @return
*/
public
static
Observable
<
BaseAPIResponse
<
AuthBean
>>
getDynamicToken
()
{
return
YDLHttpUtils
.
Companion
.
obtainApi
(
NetApiStore
.
class
).
getDynamicToken
();
}
}
ydl-platform/src/main/java/com/ydl/ydlcommon/data/http/api/NetApiStore.java
View file @
cfab77e2
package
com
.
ydl
.
ydlcommon
.
data
.
http
.
api
;
import
com.ydl.ydlcommon.bean.AuthBean
;
import
com.ydl.ydlcommon.bean.MustUP
;
import
com.ydl.ydlcommon.data.http.BaseAPIResponse
;
import
com.ydl.ydlcommon.data.http.BaseResponse
;
import
io.reactivex.Observable
;
import
okhttp3.RequestBody
;
import
retrofit2.http.*
;
import
java.util.Map
;
import
io.reactivex.Observable
;
import
okhttp3.RequestBody
;
import
retrofit2.http.Body
;
import
retrofit2.http.FieldMap
;
import
retrofit2.http.FormUrlEncoded
;
import
retrofit2.http.Headers
;
import
retrofit2.http.POST
;
import
static
com
.
ydl
.
ydlcommon
.
base
.
config
.
AppConfigKt
.
YDL_DOMAIN
;
import
static
com
.
ydl
.
ydlcommon
.
base
.
config
.
AppConfigKt
.
YDL_DOMAIN_JAVA
;
...
...
@@ -32,4 +38,8 @@ interface NetApiStore {
@POST
(
"data/bigdata/maidian/writeMaiDianData"
)
Observable
<
BaseAPIResponse
<
String
>>
actionDataCount
(
@Body
RequestBody
body
);
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
)
@POST
(
"risk/key/info"
)
Observable
<
BaseAPIResponse
<
AuthBean
>>
getDynamicToken
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment