Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_freeworld
Project
Project
Details
Activity
Releases
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
android
android_freeworld
Commits
2fd69fc0
Commit
2fd69fc0
authored
Jul 13, 2021
by
mengcuiguang2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
49d0ee24
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
88 deletions
+29
-88
LoginActivity.kt
app/src/main/java/com/mints/street/login/LoginActivity.kt
+1
-1
LoginViewModel.kt
app/src/main/java/com/mints/street/login/LoginViewModel.kt
+25
-35
RetrofitClient.java
...in/java/com/mints/street/netwrok/base/RetrofitClient.java
+1
-50
gradle.properties
gradle.properties
+2
-1
build.gradle
mvvmhabit/build.gradle
+0
-1
No files found.
app/src/main/java/com/mints/street/login/LoginActivity.kt
View file @
2fd69fc0
...
...
@@ -47,7 +47,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
override
fun
initViewObservable
()
{
super
.
initViewObservable
()
viewModel
.
data
.
observe
(
this
,
Observer
<
String
>{
ToastUtils
.
showLong
(
"初始化成功"
)
//
ToastUtils.showLong("初始化成功")
})
}
...
...
app/src/main/java/com/mints/street/login/LoginViewModel.kt
View file @
2fd69fc0
...
...
@@ -2,17 +2,12 @@ package com.mints.street.login
import
android.app.Application
import
androidx.lifecycle.MutableLiveData
import
android.text.TextUtils
import
androidx.lifecycle.viewModelScope
import
com.mints.street.bean.AwardBean
import
com.mints.street.bean.UserBean
import
com.mints.street.common.DeviceInfo
import
com.mints.street.manager.UserManager
import
com.mints.street.model.ApiModel
import
com.mints.street.netwrok.base.HttpSubscribeImpl
import
com.mints.street.utils.DeviceUuidFactory
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
me.goldze.mvvmhabit.base.BaseViewModel
import
me.goldze.mvvmhabit.http.BaseResponse
import
me.goldze.mvvmhabit.utils.KLog
...
...
@@ -51,6 +46,7 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
}
fun
login
(
mobile
:
String
,
smsCode
:
String
)
{
showDialog
()
val
vo
=
HashMap
<
String
,
Any
>()
vo
[
"mobile"
]
=
mobile
vo
[
"smsCode"
]
=
smsCode
...
...
@@ -60,13 +56,14 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
object
:
HttpSubscribeImpl
<
BaseResponse
<
UserBean
>>(
this
@LoginViewModel
,
true
)
{
override
fun
onBusinessSuccess
(
response
:
BaseResponse
<
UserBean
>)
{
data
.
value
=
response
.
message
KLog
.
e
(
"login"
,
response
.
result
.
toString
())
ToastUtils
.
showShort
(
"登录信息="
+
response
.
result
.
ConsumerBean
().
idcode
)
dismissDialog
()
this
@LoginViewModel
.
saveTerminalInfo
()
UserManager
.
INSTANCE
.
saveUserInfo
(
response
.
result
)
this
@LoginViewModel
.
saveTerminalInfo
()
data
.
value
=
response
.
message
KLog
.
e
(
"login"
,
response
.
result
.
toString
())
ToastUtils
.
showShort
(
"登录信息="
+
response
.
result
.
consumer
?.
idcode
)
}
override
fun
onError
(
e
:
Throwable
)
{
...
...
@@ -81,10 +78,6 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
* 提交设备信息
*/
fun
saveTerminalInfo
()
{
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
val
appInfoMap
=
deviceInfo
.
getAppInfoMap
()
launch
(
Dispatchers
.
Main
)
{
val
vo
=
hashMapOf
<
String
,
Any
>()
val
macAddress
:
String
=
deviceInfo
.
getMacAddress
()
val
mac
=
macAddress
.
replace
(
":"
,
""
)
...
...
@@ -100,7 +93,6 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
vo
[
"uuid"
]
=
DeviceUuidFactory
().
deviceUuid
vo
[
"osversion"
]
=
deviceInfo
.
oSVersion
vo
[
"appversion"
]
=
deviceInfo
.
versionName
vo
[
"appPkgList"
]
=
appInfoMap
ApiModel
.
saveTerminalInfo
(
lifecycleProvider
,
vo
).
safeSubscribe
(
object
:
HttpSubscribeImpl
<
BaseResponse
<
Any
>>(
...
...
@@ -110,6 +102,4 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
}
})
}
}
}
}
\ No newline at end of file
app/src/main/java/com/mints/street/netwrok/base/RetrofitClient.java
View file @
2fd69fc0
...
...
@@ -31,7 +31,7 @@ import retrofit2.Retrofit;
import
retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
;
/**
* Created by
jeme on 2019/1/31
* Created by
mcg
*/
public
class
RetrofitClient
{
...
...
@@ -50,38 +50,10 @@ public class RetrofitClient {
OkHttpClient
.
Builder
clientBuilder
=
new
OkHttpClient
.
Builder
()
.
cookieJar
(
new
CookieJarImpl
(
new
PersistentCookieStore
(
mContext
)))
// .cache(cache)
// .addInterceptor()
// .addInterceptor(new CacheInterceptor(mContext))
// .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
.
connectTimeout
(
mHttpConfig
.
getTimeOut
(),
TimeUnit
.
SECONDS
)
.
writeTimeout
(
mHttpConfig
.
getTimeOut
(),
TimeUnit
.
SECONDS
)
.
readTimeout
(
mHttpConfig
.
getTimeOut
(),
TimeUnit
.
SECONDS
)
.
connectionPool
(
new
ConnectionPool
(
8
,
15
,
TimeUnit
.
SECONDS
));
// 这里你可以根据自己的机型设置同时连接的个数和时间,我这里8个,和每个保持时间为10s
// if (configuation.getInterceptors() != null) {
// for (Interceptor interceptor : configuation.getInterceptors()) {
// clientBuilder.addInterceptor(interceptor);
// }
// }
// if(BuildConfig.IS_DEV) {
// clientBuilder.addInterceptor(new LoggingInterceptor
// .Builder()
// //是否开启日志打印
// .loggable(BuildConfig.DEBUG)
// //打印的等级
// .setLevel(Level.BASIC)
// // 打印类型
// .log(Platform.INFO)
// // request的Tag
// .request("Request")
// // Response的Tag
// .response("Request")
//// .addHeader("log-header", "I am the log request header.") // 添加打印头, 注意 key 和 value 都不能是中文
// .build()
// );
// }
if
(
BuildConfig
.
DEBUG
)
{
HttpLoggingInterceptor
logging
=
new
HttpLoggingInterceptor
(
message
->
{
...
...
@@ -122,25 +94,4 @@ public class RetrofitClient {
}
return
mRetrofit
.
create
(
service
);
}
/**
* /**
* execute your customer API
* For example:
* MyApiService service =
* RetrofitClient.getInstance(MainActivity.this).create(MyApiService.class);
* <p>
* RetrofitClient.getInstance(MainActivity.this)
* .execute(service.lgon("name", "password"), subscriber)
* * @param subscriber
*/
public
static
<
T
>
T
execute
(
Observable
<
T
>
observable
,
Observer
<
T
>
subscriber
)
{
observable
.
subscribeOn
(
Schedulers
.
io
())
.
unsubscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
subscriber
);
return
null
;
}
}
gradle.properties
View file @
2fd69fc0
...
...
@@ -21,7 +21,8 @@ android.enableJetifier=true
isBuildModule
=
false
DEBUG_URL
=
"http://test.mints-id.com/map-api/"
RELEASE_URL
=
"https://api.mints-id.com/gc-api/"
#RELEASE_URL="https://api.mints-id.com/map-api/"
RELEASE_URL
=
"http://test.mints-id.com/map-api/"
RELEASE_KEY_PASSWORD
=
mints.street
RELEASE_KEY_ALIAS
=
mints_street
...
...
mvvmhabit/build.gradle
View file @
2fd69fc0
...
...
@@ -70,7 +70,6 @@ dependencies {
//Google LiveData和ViewModel组件
api
rootProject
.
ext
.
dependencies
[
"lifecycle-extensions"
]
kapt
rootProject
.
ext
.
dependencies
[
"lifecycle-compiler"
]
api
"androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
//api "com.jeme:gif:1.0.5@aar"
//使用aar库引用
...
...
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