Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
72748b4f
Commit
72748b4f
authored
Nov 13, 2018
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UPDATE
parent
45b1bc40
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
194 additions
and
42 deletions
+194
-42
src/main/java/tech/starwin/LibConfig.java
+1
-1
src/main/java/tech/starwin/broadcast/InstallReferrerReceiver.java
+64
-0
src/main/java/tech/starwin/mvp/beans/DisplayBean.java
+9
-0
src/main/java/tech/starwin/mvp/presenter/UserPresenter.java
+2
-9
src/main/java/tech/starwin/network/FirebaseHeaderInterceptor.java
+64
-0
src/main/java/tech/starwin/network/ServiceGenerator.java
+1
-0
src/main/java/tech/starwin/utils/PreferencesManager.java
+14
-0
src/main/java/tech/starwin/utils/collection/UploadManager.java
+25
-19
src/main/java/tech/starwin/utils/ui_utils/AnimatorGenerator.java
+3
-3
src/main/java/tech/starwin/utils/ui_utils/QMUIHelper.java
+1
-4
src/main/java/tech/starwin/widget/PageStateLayout.java
+4
-4
src/main/java/tech/starwin/widget/SpanButton.java
+5
-1
src/main/java/tech/starwin/widget/TitleSpan.java
+1
-1
No files found.
src/main/java/tech/starwin/LibConfig.java
View file @
72748b4f
...
...
@@ -35,7 +35,7 @@ import static com.facebook.accountkit.internal.AccountKitController.getApplicati
public
class
LibConfig
{
/**
*
存储 App Module的
BuildConfig 数据
* BuildConfig 数据
*/
private
static
Context
CONTEXT
;
public
static
boolean
DEBUG
;
...
...
src/main/java/tech/starwin/broadcast/InstallReferrerReceiver.java
0 → 100644
View file @
72748b4f
package
tech
.
starwin
.
broadcast
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.collection.UploadManager
;
/**
* 监听并保存安装referrer
* 测试方法:
* 1 进到adb shell
* 2 打开GAv4的log:setprop log.tag.GAv4 VERBOSE
* 3 发送广播通知:
* am broadcast -a com.android.vending.INSTALL_REFERRER -n com.mango.cash/com.daunkredit.program
* .sulu.broadcast.InstallReferrerReceiver --es "referrer"
* "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=11&PARTNER_ID=111
* &PARTNER_CLICK_ID=222"
*/
public
class
InstallReferrerReceiver
extends
BroadcastReceiver
{
public
static
String
install_referrer_store_key
=
"GA_install_referrer_store_key"
;
public
void
onReceive
(
Context
context
,
Intent
data
)
{
PreferencesManager
.
get
().
saveInstallReferrer
(
getReferrerValue
(
data
.
getExtras
()));
}
private
String
getReferrerValue
(
Bundle
bundle
)
{
String
referrerValue
=
""
;
try
{
if
(
bundle
!=
null
)
{
referrerValue
=
bundle
.
getString
(
"referrer"
);
}
if
(
referrerValue
==
null
)
{
referrerValue
=
""
;
}
if
(
TextUtils
.
isEmpty
(
referrerValue
))
{
}
else
{
}
}
catch
(
Exception
e
)
{
UploadManager
.
uploadException
(
e
,
"InstallReferrerReceiver.getReferrerValue"
);
}
try
{
referrerValue
=
URLDecoder
.
decode
(
referrerValue
,
"utf-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
Log
.
i
(
"InstallReferrerReceiver"
,
"referrer "
+
referrerValue
);
return
referrerValue
;
}
}
src/main/java/tech/starwin/mvp/beans/DisplayBean.java
View file @
72748b4f
...
...
@@ -8,6 +8,7 @@ import java.io.Serializable;
public
class
DisplayBean
implements
Serializable
{
private
String
description
;
private
String
customerMobile
;
private
String
loginType
;
public
String
getDescription
()
{
return
description
;
...
...
@@ -24,4 +25,12 @@ public class DisplayBean implements Serializable {
public
void
setCustomerMobile
(
String
customerMobile
)
{
this
.
customerMobile
=
customerMobile
;
}
public
String
getLoginType
()
{
return
loginType
;
}
public
void
setLoginType
(
String
loginType
)
{
this
.
loginType
=
loginType
;
}
}
src/main/java/tech/starwin/mvp/presenter/UserPresenter.java
View file @
72748b4f
...
...
@@ -358,16 +358,9 @@ public class UserPresenter extends BasePresenter<UserApi> {
}
/**
* 获取客户
热线电话
* 获取客户
自定义配置
*/
public
void
getHotlineNumber
(
String
action
)
{
handleRequest
(
action
,
apiService
.
display
());
}
/**
* 获取公司介绍
*/
public
void
getAboutUsMsg
(
String
action
)
{
public
void
getCustomerConfig
(
String
action
)
{
handleRequest
(
action
,
apiService
.
display
());
}
...
...
src/main/java/tech/starwin/network/FirebaseHeaderInterceptor.java
0 → 100644
View file @
72748b4f
package
tech
.
starwin
.
network
;
import
java.io.IOException
;
import
okhttp3.Headers
;
import
okhttp3.Interceptor
;
import
okhttp3.Request
;
import
okhttp3.Response
;
import
tech.starwin.LibConfig
;
import
tech.starwin.utils.GeneralUtils
;
import
tech.starwin.utils.LoginManager
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.collection.UploadManager
;
/**
* Created by XLEO on 2018/1/30.
*/
public
class
FirebaseHeaderInterceptor
implements
Interceptor
{
@Override
public
Response
intercept
(
Chain
chain
)
throws
IOException
{
Request
newRequest
=
chain
.
request
();
try
{
if
(
newRequest
!=
null
)
{
Request
.
Builder
builder
=
chain
.
request
().
newBuilder
();
builder
.
addHeader
(
"X-REFERRER"
,
PreferencesManager
.
get
().
getInstallReferrer
())
// .addHeader("X-REFERRER-SDK", FirebaseAnalytics.getInstance(LibConfig.getContext()).)
.
addHeader
(
"X-ANDROID-ID"
,
GeneralUtils
.
getAndroidID
(
LibConfig
.
getContext
()));
//登录后的上传
if
(!
existHeader
(
newRequest
.
headers
(),
"X-AUTH-TOKEN"
)
&&
LoginManager
.
get
().
getToken
()
!=
null
)
{
builder
.
addHeader
(
"X-AUTH-TOKEN"
,
LoginManager
.
get
().
getToken
());
}
newRequest
=
builder
.
build
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
UploadManager
.
uploadException
(
e
,
"FirebaseHeaderInterceptor.intercept"
);
}
return
chain
.
proceed
(
newRequest
);
}
private
static
boolean
existHeader
(
Headers
headers
,
String
header
)
{
if
(
headers
==
null
||
headers
.
names
()
==
null
||
header
==
null
||
headers
.
size
()
==
0
||
header
.
length
()
==
0
)
{
return
false
;
}
return
headers
.
names
().
contains
(
header
);
}
private
static
String
install_referrer_uploaded_key
=
"install_referrer_uploaded_key"
;
private
static
String
install_referrer_uploaded_with_token_key
=
"install_referrer_uploaded_with_token_key"
;
}
src/main/java/tech/starwin/network/ServiceGenerator.java
View file @
72748b4f
...
...
@@ -30,6 +30,7 @@ public class ServiceGenerator {
.
writeTimeout
(
TIME_OUT
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
TIME_OUT
,
TimeUnit
.
SECONDS
)
.
addInterceptor
(
new
DefaultHeaderAddInterceptor
())
.
addInterceptor
(
new
FirebaseHeaderInterceptor
())
.
build
();
serviceMap
=
new
HashMap
<>();
...
...
src/main/java/tech/starwin/utils/PreferencesManager.java
View file @
72748b4f
...
...
@@ -100,6 +100,9 @@ public class PreferencesManager {
}
/**
* 手机默认短信应用的包名
*/
public
void
saveDefaultSmsPackage
(
String
pkgName
)
{
saveData
(
"default_sms_pkg"
,
pkgName
);
}
...
...
@@ -109,6 +112,17 @@ public class PreferencesManager {
}
/**
* 存取 install referrer
*/
public
void
saveInstallReferrer
(
String
referrer
)
{
saveData
(
"install_referrer"
,
referrer
);
}
public
String
getInstallReferrer
()
{
return
getString
(
"install_referrer"
,
""
);
}
/**
* 存取活体识别截图
*/
public
void
saveVerificationData
(
byte
[]
data
)
{
...
...
src/main/java/tech/starwin/utils/collection/UploadManager.java
View file @
72748b4f
...
...
@@ -4,9 +4,10 @@ import android.Manifest;
import
android.content.Context
;
import
android.support.annotation.NonNull
;
import
android.text.TextUtils
;
import
android.util.
Log
;
import
android.util.
Base64
;
import
com.annimon.stream.Stream
;
import
com.annimon.stream.function.BiFunction
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
...
...
@@ -25,9 +26,7 @@ import java.util.List;
import
java.util.UUID
;
import
io.reactivex.Observable
;
import
io.reactivex.Observer
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.functions.Function
;
import
io.reactivex.schedulers.Schedulers
;
import
tech.starwin.LibConfig
;
...
...
@@ -39,7 +38,6 @@ import tech.starwin.utils.GeneralUtils;
import
tech.starwin.utils.LogUtils
;
import
tech.starwin.utils.LoginManager
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.RetryWithDelay
;
import
tech.starwin.utils.context_utils.PermissionsHelper
;
/**
...
...
@@ -56,7 +54,7 @@ public class UploadManager {
}
/**
*
上传贷款相关数据
*
申请贷款时需要上传的数据(联系人、通话记录、短信记录 等)
*/
public
static
void
uploadCollectInfo
(
String
sessionId
)
{
if
(
TextUtils
.
isEmpty
(
sessionId
))
{
...
...
@@ -87,7 +85,7 @@ public class UploadManager {
/**
*
上传搜集的用户数据(联系人、通话记录、短信记录 等)
*
开始上传
*/
public
static
void
startUpload
(
List
<
CollectInfoEntity
>
infoList
,
String
sessionId
)
throws
RuntimeException
{
Socket
socket
=
null
;
...
...
@@ -100,11 +98,24 @@ public class UploadManager {
ins
=
socket
.
getInputStream
();
List
<
String
>
datas
=
Stream
.
of
(
infoList
)
.
map
(
t
->
GZipUtil
.
compress
(
t
.
getBody
(),
"utf-8"
))
.
map
(
t
->
android
.
util
.
Base64
.
encodeToString
(
t
,
0
))
.
reduce
(
new
ArrayList
<>(),
(
array
,
t
)
->
{
array
.
add
(
t
);
return
array
;
.
map
(
new
com
.
annimon
.
stream
.
function
.
Function
<
CollectInfoEntity
,
byte
[]>()
{
@Override
public
byte
[]
apply
(
CollectInfoEntity
collectInfoEntity
)
{
return
GZipUtil
.
compress
(
collectInfoEntity
.
getBody
(),
"utf-8"
);
}
})
.
map
(
new
com
.
annimon
.
stream
.
function
.
Function
<
byte
[],
String
>()
{
@Override
public
String
apply
(
byte
[]
bytes
)
{
return
Base64
.
encodeToString
(
bytes
,
0
);
}
})
.
reduce
(
new
ArrayList
<>(),
new
BiFunction
<
ArrayList
<
String
>,
String
,
ArrayList
<
String
>>()
{
@Override
public
ArrayList
<
String
>
apply
(
ArrayList
<
String
>
array
,
String
value
)
{
array
.
add
(
value
);
return
array
;
}
});
...
...
@@ -253,14 +264,9 @@ public class UploadManager {
return
array
;
}
public
interface
OnUploadListener
{
void
onSuccess
(
String
sessionId
);
void
onFailed
(
String
sessionId
,
Throwable
e
);
}
/**
* 上传异常信息
* */
public
static
void
uploadException
(
Throwable
ex
,
@NonNull
String
tag
)
{
Observable
.
just
(
true
)
...
...
src/main/java/tech/starwin/utils/AnimatorGenerator.java
→
src/main/java/tech/starwin/utils/
ui_utils/
AnimatorGenerator.java
View file @
72748b4f
package
tech
.
starwin
.
utils
;
package
tech
.
starwin
.
utils
.
ui_utils
;
import
android.animation.ObjectAnimator
;
import
android.animation.ValueAnimator
;
...
...
@@ -68,11 +68,11 @@ public class AnimatorGenerator {
closeAnimator
.
addUpdateListener
(
listener
);
}
public
void
open
()
{
public
void
start
()
{
openAnimator
.
start
();
}
public
void
close
()
{
public
void
revert
()
{
closeAnimator
.
start
();
}
...
...
src/main/java/tech/starwin/utils/ui_utils/QMUIHelper.java
View file @
72748b4f
...
...
@@ -10,14 +10,11 @@ import android.support.annotation.DrawableRes;
import
android.support.annotation.StringRes
;
import
android.support.v4.content.ContextCompat
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageButton
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
com.qmuiteam.qmui.widget.QMUIEmptyView
;
import
com.qmuiteam.qmui.widget.QMUITabSegment
;
import
com.qmuiteam.qmui.widget.QMUITopBar
;
import
com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView
;
import
com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView
;
...
...
@@ -57,7 +54,7 @@ public class QMUIHelper {
emptyView
.
setBackgroundColor
(
Color
.
WHITE
);
//给targetView 套壳
final
PageStateLayout
pageStateLayout
=
new
PageStateLayout
.
Builder
(
targetView
)
.
set
Custom
View
(
emptyView
)
.
set
State
View
(
emptyView
)
.
setOnRetryListener
(
listener
)
.
create
();
//不同状态的UI处理
...
...
src/main/java/tech/starwin/widget/PageStateLayout.java
View file @
72748b4f
...
...
@@ -21,7 +21,7 @@ import java.util.Map;
/**
* Created by SiKang on 2018/10/12.
* 页面状态展示 loading、错误、无数据、重新请求 等
* 通过 set
Custom
View() 指定一个View,在view和父布局之间,嵌套一层FrameLayout,并加入自定义的展示界面
* 通过 set
State
View() 指定一个View,在view和父布局之间,嵌套一层FrameLayout,并加入自定义的展示界面
*/
public
class
PageStateLayout
extends
FrameLayout
{
private
View
mStateView
;
...
...
@@ -41,7 +41,7 @@ public class PageStateLayout extends FrameLayout {
super
(
context
,
attrs
,
defStyleAttr
);
}
private
void
set
Custom
View
(
@NonNull
View
view
)
{
private
void
set
State
View
(
@NonNull
View
view
)
{
mStateView
=
view
;
viewHolder
=
new
ViewHolder
(
view
);
addView
(
mStateView
);
...
...
@@ -111,8 +111,8 @@ public class PageStateLayout extends FrameLayout {
pageStateLayout
.
addView
(
view
);
}
public
Builder
set
Custom
View
(
@NonNull
View
view
)
{
pageStateLayout
.
set
Custom
View
(
view
);
public
Builder
set
State
View
(
@NonNull
View
view
)
{
pageStateLayout
.
set
State
View
(
view
);
return
this
;
}
...
...
src/main/java/tech/starwin/widget/SpanButton.java
View file @
72748b4f
...
...
@@ -12,7 +12,8 @@ import android.widget.TextView;
/**
* Created by SiKang on 2018/10/24.
* 行按钮
* 行按钮,用于 文字 + 图标 的itemList型布局(避免Layout 和 child 分开处理的复杂操作)
* 提供 setText() 和 setOnclick(),默认将第一个TextView类型的 child 作为 setText() 对象
*/
public
class
SpanButton
extends
LinearLayout
{
private
TextWatcher
watcher
;
...
...
@@ -51,6 +52,9 @@ public class SpanButton extends LinearLayout {
bindTextWatcher
(
child
);
}
/**
* 为第一个为TextView类型的child setText
*/
public
void
setText
(
String
text
)
{
if
(!
TextUtils
.
isEmpty
(
text
))
{
for
(
int
i
=
0
;
i
<
getChildCount
();
i
++)
{
...
...
src/main/java/tech/starwin/widget/TitleSpan.java
View file @
72748b4f
...
...
@@ -15,7 +15,7 @@ import android.widget.TextView;
* Created by SiKang on 2018/10/25.
* 标题 + 文本 布局
* 第一个Child 默认为Title
* 当EditText/TextView中有内容输入时,显示Title, 反之隐藏
(无输入内容时直接用hintText展示
)
* 当EditText/TextView中有内容输入时,显示Title, 反之隐藏
Title显示 hintText
)
*/
public
class
TitleSpan
extends
LinearLayout
{
public
TitleSpan
(
Context
context
)
{
...
...
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