Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
HBHAndroid
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
1
Merge Requests
1
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
杨秀秀
HBHAndroid
Commits
1963544a
Commit
1963544a
authored
Jan 12, 2024
by
小费同学阿
💬
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev1.0' into dev1.0
parents
f2f50925
0f193b53
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
334 additions
and
5 deletions
+334
-5
ApiService.kt
.../src/main/java/com/xx/hbhconsumer/data/http/ApiService.kt
+16
-0
BaseRespons.kt
...src/main/java/com/xx/hbhconsumer/data/http/BaseRespons.kt
+37
-0
LoginRequest.kt
.../java/com/xx/hbhconsumer/data/http/requst/LoginRequest.kt
+10
-0
VersionBean.kt
.../java/com/xx/hbhconsumer/data/http/respons/VersionBean.kt
+6
-0
StaticData.kt
...ain/java/com/xx/hbhconsumer/data/staticdata/StaticData.kt
+78
-2
LoginActivity.kt
...rc/main/java/com/xx/hbhconsumer/ui/login/LoginActivity.kt
+18
-0
LoginViewModel.java
...main/java/com/xx/hbhconsumer/ui/login/LoginViewModel.java
+167
-1
StoreServicesActivity.java
...x/hbhconsumer/ui/storeservices/StoreServicesActivity.java
+2
-2
No files found.
consumer/src/main/java/com/xx/hbhconsumer/data/http/ApiService.kt
View file @
1963544a
...
@@ -39,6 +39,7 @@ import com.xx.hbhconsumer.data.http.respons.ShopBean
...
@@ -39,6 +39,7 @@ import com.xx.hbhconsumer.data.http.respons.ShopBean
import
com.xx.hbhconsumer.data.http.respons.ShopDetailBean
import
com.xx.hbhconsumer.data.http.respons.ShopDetailBean
import
com.xx.hbhconsumer.data.http.respons.ShopGoodsBean
import
com.xx.hbhconsumer.data.http.respons.ShopGoodsBean
import
com.xx.hbhconsumer.data.http.respons.UserInfoBean
import
com.xx.hbhconsumer.data.http.respons.UserInfoBean
import
com.xx.hbhconsumer.data.http.respons.VersionBean
import
io.reactivex.rxjava3.core.Observable
import
io.reactivex.rxjava3.core.Observable
import
me.goldze.mvvmhabit.http.BasePageResponse
import
me.goldze.mvvmhabit.http.BasePageResponse
import
me.goldze.mvvmhabit.http.BaseResponse
import
me.goldze.mvvmhabit.http.BaseResponse
...
@@ -61,7 +62,22 @@ import retrofit2.http.Url
...
@@ -61,7 +62,22 @@ import retrofit2.http.Url
interface
ApiService
{
interface
ApiService
{
/**
* 获取版本
*/
@Headers
(
"Content-type:application/json"
)
@POST
(
"app/system/version/current"
)
open
fun
getLineVersion
(
@Body
requestBody
:
RequestBody
):
Observable
<
BaseResponse
<
VersionBean
>>
/**
* 下载文件
*
* @param url
* @return
*/
@Streaming
@GET
fun
download
(
@Url
url
:
String
?):
Observable
<
ResponseBody
>
/**
/**
* 根据字典类型查询字典数据信息
* 根据字典类型查询字典数据信息
...
...
consumer/src/main/java/com/xx/hbhconsumer/data/http/BaseRespons.kt
View file @
1963544a
...
@@ -2,13 +2,18 @@ package com.xx.hbhconsumer.data.http
...
@@ -2,13 +2,18 @@ package com.xx.hbhconsumer.data.http
import
com.xx.hbhconsumer.data.http.respons.Filebean
import
com.xx.hbhconsumer.data.http.respons.Filebean
import
com.xx.hbhconsumer.utils.RetrofitClient
import
com.xx.hbhconsumer.utils.RetrofitClient
import
io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import
io.reactivex.rxjava3.core.Observable
import
io.reactivex.rxjava3.core.Observable
import
io.reactivex.rxjava3.schedulers.Schedulers
import
me.goldze.mvvmhabit.base.BaseModel
import
me.goldze.mvvmhabit.base.BaseModel
import
me.goldze.mvvmhabit.http.BaseResponse
import
me.goldze.mvvmhabit.http.BaseResponse
import
okhttp3.MediaType
import
okhttp3.MediaType
import
okhttp3.MultipartBody
import
okhttp3.MultipartBody
import
okhttp3.RequestBody
import
okhttp3.RequestBody
import
okhttp3.ResponseBody
import
java.io.File
import
java.io.File
import
java.io.FileOutputStream
import
java.io.IOException
open
class
BaseRespons
:
BaseModel
()
{
open
class
BaseRespons
:
BaseModel
()
{
...
@@ -18,6 +23,13 @@ open class BaseRespons : BaseModel() {
...
@@ -18,6 +23,13 @@ open class BaseRespons : BaseModel() {
apiService
=
RetrofitClient
.
getInstance
().
create
(
ApiService
::
class
.
java
)
apiService
=
RetrofitClient
.
getInstance
().
create
(
ApiService
::
class
.
java
)
}
}
fun
downFile
(
url
:
String
,
name
:
String
):
Observable
<
ResponseBody
>
{
return
apiService
.
download
(
url
).
subscribeOn
(
Schedulers
.
io
())
.
unsubscribeOn
(
Schedulers
.
io
()).
doOnNext
{
body
->
saveFile
(
body
,
name
)
}.
observeOn
(
AndroidSchedulers
.
mainThread
())
}
fun
upLoadFile
(
file
:
File
):
Observable
<
BaseResponse
<
List
<
Filebean
>>>
fun
upLoadFile
(
file
:
File
):
Observable
<
BaseResponse
<
List
<
Filebean
>>>
{
{
val
files
:
MutableList
<
File
>
=
ArrayList
()
val
files
:
MutableList
<
File
>
=
ArrayList
()
...
@@ -41,5 +53,30 @@ open class BaseRespons : BaseModel() {
...
@@ -41,5 +53,30 @@ open class BaseRespons : BaseModel() {
return
apiService
.
upLoadFiles
(
parts
)
return
apiService
.
upLoadFiles
(
parts
)
}
}
open
fun
saveFile
(
body
:
ResponseBody
,
writeUrl
:
String
)
{
val
buf
=
ByteArray
(
2048
)
var
len
:
Int
try
{
val
file
=
File
(
writeUrl
)
val
fileBasePath
=
writeUrl
.
substring
(
0
,
writeUrl
.
lastIndexOf
(
"/"
))
val
filePath
=
File
(
fileBasePath
)
//创建目录
if
(!
filePath
.
exists
())
{
filePath
.
mkdirs
()
}
if
(!
file
.
exists
())
{
file
.
createNewFile
()
}
val
fos
=
FileOutputStream
(
file
)
val
secInputstream
=
body
.
byteStream
()
while
(
secInputstream
.
read
(
buf
).
also
{
len
=
it
}
!=
-
1
)
{
fos
.
write
(
buf
,
0
,
len
)
}
secInputstream
.
close
()
fos
.
close
()
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
}
}
}
\ No newline at end of file
consumer/src/main/java/com/xx/hbhconsumer/data/http/requst/LoginRequest.kt
View file @
1963544a
...
@@ -2,12 +2,22 @@ package com.xx.hbhconsumer.data.http.requst
...
@@ -2,12 +2,22 @@ package com.xx.hbhconsumer.data.http.requst
import
com.xx.hbhconsumer.data.http.respons.UserInfoBean
import
com.xx.hbhconsumer.data.http.respons.UserInfoBean
import
com.xx.hbhconsumer.data.http.BaseRespons
import
com.xx.hbhconsumer.data.http.BaseRespons
import
com.xx.hbhconsumer.data.http.respons.VersionBean
import
com.xx.xxviewlibrary.model.VersionBody
import
io.reactivex.rxjava3.core.Observable
import
io.reactivex.rxjava3.core.Observable
import
me.goldze.mvvmhabit.http.ApiParams
import
me.goldze.mvvmhabit.http.ApiParams
import
me.goldze.mvvmhabit.http.BaseResponse
import
me.goldze.mvvmhabit.http.BaseResponse
class
LoginRequest
:
BaseRespons
()
{
class
LoginRequest
:
BaseRespons
()
{
fun
checkVersion
():
Observable
<
BaseResponse
<
VersionBean
>>
{
return
apiService
.
getLineVersion
(
ApiParams
<
VersionBody
>().
setParams
(
VersionBody
(
"2"
,
"2"
)
)
)
}
/**
/**
* 登陆
* 登陆
*/
*/
...
...
consumer/src/main/java/com/xx/hbhconsumer/data/http/respons/VersionBean.kt
0 → 100644
View file @
1963544a
package
com.xx.hbhconsumer.data.http.respons
class
VersionBean
(
var
appVersion
:
String
,
var
pushFlag
:
String
,
//是否强制推送 0-不强制 1-强制
var
versionFile
:
String
)
{
}
\ No newline at end of file
consumer/src/main/java/com/xx/hbhconsumer/data/staticdata/StaticData.kt
View file @
1963544a
package
com.xx.
hbhconsumer
.data.staticdata
package
com.xx.
merchanthbh
.data.staticdata
object
StaticData
{
object
StaticData
{
/**
* 当前版本号*/
@JvmField
@JvmField
var
sUserType
=
"02"
var
appVersionNumber
=
""
@JvmField
var
sUserType
=
"02"
/**
* 登录-强制更新状态位 0-不能登录 1-可登录
*/
@JvmField
var
updateLogin
:
Int
=
1
/**
* 订单详情-状态位 订单状态 1-待付款 2-已完成 3-已关闭
*/
@JvmField
var
statusData
:
Int
=
0
/**
* 反馈详情-状态位 是否有图片状态 0-有 1-没有
*/
@JvmField
var
imageFilesData
:
Int
=
0
/**
* 店员列表-状态位 是否有数据 0-有 1-没有
*/
@JvmField
var
AssistantData
:
Int
=
0
/**
* 消息列表-状态位 是否有数据 0-有 1-没有
*/
@JvmField
var
messageData
:
Int
=
0
/**
* 积分列表-状态位 是否有数据 0-有 1-没有
*/
@JvmField
var
PointData
:
Int
=
0
/**
* 订单详情-状态位 订单状态 1-待付款 2-已完成 3-已关闭
*/
lateinit
var
filePath
:
String
/**
* 活动中心-状态位 flag 0-未读 1-已读
*/
@JvmField
var
flag
:
Int
=
0
/**
* 登录人角色 personType 0-店长 1-店员
*/
@JvmField
var
personType
:
Int
=
1
/**
5 用户协议
4 积分说明
3 隐私条款
2 服务条款
1 会员体系
*/
@JvmField
var
Protocols
:
List
<
String
>
=
ArrayList
();
/**
* 支付方式
*/
@JvmField
var
PayWay
:
Map
<
String
,
String
>
=
mapOf
(
"ALIPAY"
to
"支付宝"
,
"WECHAT"
to
"微信"
,
"UNION_PAY"
to
"银联云闪付"
)
}
}
\ No newline at end of file
consumer/src/main/java/com/xx/hbhconsumer/ui/login/LoginActivity.kt
View file @
1963544a
package
com.xx.hbhconsumer.ui.login
package
com.xx.hbhconsumer.ui.login
import
android.content.Intent
import
android.net.Uri
import
android.os.Bundle
import
android.os.Bundle
import
android.provider.Settings
import
androidx.lifecycle.Observer
import
androidx.lifecycle.Observer
import
androidx.recyclerview.widget.GridLayoutManager
import
androidx.recyclerview.widget.GridLayoutManager
import
com.jakewharton.rxbinding3.widget.checked
import
com.jakewharton.rxbinding3.widget.checked
import
com.jakewharton.rxbinding3.widget.checkedChanges
import
com.jakewharton.rxbinding3.widget.checkedChanges
import
com.tbruyelle.rxpermissions3.RxPermissions
import
com.xx.hbhconsumer.BR
import
com.xx.hbhconsumer.BR
import
com.xx.hbhconsumer.R
import
com.xx.hbhconsumer.R
import
com.xx.hbhconsumer.adapter.CollectionGoodsAdapter
import
com.xx.hbhconsumer.adapter.CollectionGoodsAdapter
...
@@ -29,6 +33,20 @@ class LoginActivity() : BaseActivity<ActivityLoginBinding, LoginViewModel>() {
...
@@ -29,6 +33,20 @@ class LoginActivity() : BaseActivity<ActivityLoginBinding, LoginViewModel>() {
override
fun
initData
()
{
override
fun
initData
()
{
super
.
initData
()
super
.
initData
()
//检查版本
viewModel
.
rxPermissions
=
RxPermissions
(
this
)
viewModel
.
checkVersion
(
binding
.
root
.
rootView
)
//安装新版本
viewModel
.
openInstall
.
observe
(
this
,
Observer
<
String
?>
{
fun
onChanged
(
s
:
String
)
{
if
(
"1"
==
s
)
{
val
packageURI
=
Uri
.
parse
(
"package:"
+
applicationContext
.
packageName
)
val
intent
=
Intent
(
Settings
.
ACTION_MANAGE_UNKNOWN_APP_SOURCES
,
packageURI
)
startActivityForResult
(
intent
,
1002
)
}
}
})
viewModel
.
consentAgreementFlag
.
observe
(
this
,
viewModel
.
consentAgreementFlag
.
observe
(
this
,
Observer
<
Boolean
>
{
consentAgreementFlag
->
Observer
<
Boolean
>
{
consentAgreementFlag
->
if
(
binding
.
rbLoginAgreement
.
isSelected
)
{
if
(
binding
.
rbLoginAgreement
.
isSelected
)
{
...
...
consumer/src/main/java/com/xx/hbhconsumer/ui/login/LoginViewModel.java
View file @
1963544a
...
@@ -2,17 +2,27 @@ package com.xx.hbhconsumer.ui.login;
...
@@ -2,17 +2,27 @@ package com.xx.hbhconsumer.ui.login;
import
static
me
.
goldze
.
mvvmhabit
.
utils
.
Utils
.
Interceptor_TOKEN
;
import
static
me
.
goldze
.
mvvmhabit
.
utils
.
Utils
.
Interceptor_TOKEN
;
import
android.Manifest
;
import
android.app.Application
;
import
android.app.Application
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.View
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.NonNull
;
import
androidx.core.content.FileProvider
;
import
androidx.databinding.ObservableField
;
import
androidx.databinding.ObservableField
;
import
androidx.lifecycle.MutableLiveData
;
import
androidx.lifecycle.MutableLiveData
;
import
com.tbruyelle.rxpermissions3.RxPermissions
;
import
com.xx.hbhconsumer.data.http.requst.LoginRequest
;
import
com.xx.hbhconsumer.data.http.requst.LoginRequest
;
import
com.xx.hbhconsumer.data.http.respons.CollectionBean
;
import
com.xx.hbhconsumer.data.http.respons.CollectionBean
;
import
com.xx.hbhconsumer.data.http.respons.UserInfoBean
;
import
com.xx.hbhconsumer.data.http.respons.UserInfoBean
;
import
com.xx.hbhconsumer.data.http.respons.VersionBean
;
import
com.xx.hbhconsumer.data.local.LocalData
;
import
com.xx.hbhconsumer.data.local.LocalData
;
import
com.xx.hbhconsumer.ui.main.MainActivity
;
import
com.xx.hbhconsumer.ui.main.MainActivity
;
import
com.xx.hbhconsumer.ui.privacyclause.PrivacyClauseActivity
;
import
com.xx.hbhconsumer.ui.privacyclause.PrivacyClauseActivity
;
...
@@ -20,12 +30,19 @@ import com.xx.hbhconsumer.ui.pwd.ForgetPwdActivity;
...
@@ -20,12 +30,19 @@ import com.xx.hbhconsumer.ui.pwd.ForgetPwdActivity;
import
com.xx.hbhconsumer.ui.pwd.PwdActivity
;
import
com.xx.hbhconsumer.ui.pwd.PwdActivity
;
import
com.xx.hbhconsumer.ui.register.RegisterActivity
;
import
com.xx.hbhconsumer.ui.register.RegisterActivity
;
import
com.xx.hbhconsumer.ui.useragreement.UserAgreementActivity
;
import
com.xx.hbhconsumer.ui.useragreement.UserAgreementActivity
;
import
com.xx.merchanthbh.data.staticdata.StaticData
;
import
com.xx.xxviewlibrary.comm.CommTextDialog
;
import
com.xx.xxviewlibrary.comm.RefuseDialogBean
;
import
com.xx.xxviewlibrary.utils.CommUtilsKt
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
io.reactivex.rxjava3.core.Observer
;
import
io.reactivex.rxjava3.disposables.Disposable
;
import
io.reactivex.rxjava3.disposables.Disposable
;
import
io.reactivex.rxjava3.functions.Consumer
;
import
io.reactivex.rxjava3.functions.Consumer
;
import
io.reactivex.rxjava3.schedulers.Schedulers
;
import
me.goldze.mvvmhabit.base.BaseViewModel
;
import
me.goldze.mvvmhabit.base.BaseViewModel
;
import
me.goldze.mvvmhabit.binding.command.BindingAction
;
import
me.goldze.mvvmhabit.binding.command.BindingAction
;
import
me.goldze.mvvmhabit.binding.command.BindingCommand
;
import
me.goldze.mvvmhabit.binding.command.BindingCommand
;
...
@@ -33,15 +50,18 @@ import me.goldze.mvvmhabit.http.ApiDisposableObserver;
...
@@ -33,15 +50,18 @@ import me.goldze.mvvmhabit.http.ApiDisposableObserver;
import
me.goldze.mvvmhabit.utils.RxUtils
;
import
me.goldze.mvvmhabit.utils.RxUtils
;
import
me.goldze.mvvmhabit.utils.StringUtils
;
import
me.goldze.mvvmhabit.utils.StringUtils
;
import
me.goldze.mvvmhabit.utils.ToastUtils
;
import
me.goldze.mvvmhabit.utils.ToastUtils
;
import
okhttp3.ResponseBody
;
public
class
LoginViewModel
extends
BaseViewModel
<
LoginRequest
>
{
public
class
LoginViewModel
extends
BaseViewModel
<
LoginRequest
>
{
RxPermissions
rxPermissions
;
public
MutableLiveData
<
Boolean
>
consentAgreementFlag
=
new
MutableLiveData
<>(
false
);
public
MutableLiveData
<
Boolean
>
consentAgreementFlag
=
new
MutableLiveData
<>(
false
);
//用户名的绑定
//用户名的绑定
public
ObservableField
<
String
>
userName
=
new
ObservableField
<>(
""
);
public
ObservableField
<
String
>
userName
=
new
ObservableField
<>(
""
);
//密码的绑定
//密码的绑定
public
ObservableField
<
String
>
password
=
new
ObservableField
<>(
""
);
public
ObservableField
<
String
>
password
=
new
ObservableField
<>(
""
);
public
MutableLiveData
<
String
>
openInstall
=
new
MutableLiveData
<>(
""
);
public
LoginViewModel
(
@NonNull
Application
application
,
LoginRequest
model
)
{
public
LoginViewModel
(
@NonNull
Application
application
,
LoginRequest
model
)
{
super
(
application
,
model
);
super
(
application
,
model
);
}
}
...
@@ -201,7 +221,153 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
...
@@ -201,7 +221,153 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
});
});
}
}
/**
* 获取最新APK版本号
*
* @param view
*/
public
void
checkVersion
(
View
view
)
{
Log
.
v
(
"版本更新"
,
"版本更新"
);
model
.
checkVersion
().
compose
(
RxUtils
.
schedulersTransformer
())
//线程调度
.
doOnSubscribe
(
LoginViewModel
.
this
)
.
doOnSubscribe
(
new
Consumer
<
Disposable
>()
{
@Override
public
void
accept
(
Disposable
disposable
)
throws
Exception
{
}
}).
subscribe
(
new
ApiDisposableObserver
<
VersionBean
>()
{
@Override
public
void
onSuccess
(
VersionBean
resultBean
)
{
/*强制更新标识位变更--重置用户登录*/
StaticData
.
updateLogin
=
1
;
Log
.
v
(
"当前版本号"
,
resultBean
.
getAppVersion
());
StaticData
.
appVersionNumber
=
resultBean
.
getAppVersion
();
if
(
CommUtilsKt
.
checkVersionUpdata
(
CommUtilsKt
.
getVersion
(
view
.
getContext
()),
resultBean
.
getAppVersion
()))
{
if
(
resultBean
.
getPushFlag
().
equals
(
"1"
))
{
showCommTextDialog
(
new
RefuseDialogBean
(
"有新版本,是否更新?"
,
"去更新"
,
null
,
"更新提示"
),
new
CommTextDialog
.
onAcceptCallBack
()
{
@Override
public
void
refuseBack
()
{
finish
();
}
@Override
public
void
acceptBack
()
{
/*强制更新标识位变更--禁止用户登录*/
StaticData
.
updateLogin
=
0
;
rxPermissions
.
request
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
.
subscribe
(
granted
->
{
if
(
granted
)
{
// 处理权限已授予的情况
updataApk
(
view
.
getContext
(),
resultBean
.
getVersionFile
(),
view
.
getContext
().
getFilesDir
().
getPath
()
+
resultBean
.
getVersionFile
().
substring
(
resultBean
.
getVersionFile
().
lastIndexOf
(
"/"
)));
}
else
{
// 处理权限被拒绝的情况
ToastUtils
.
showShort
(
"请开启文件相关权限"
);
}
});
}
});
}
else
{
showCommTextDialog
(
new
RefuseDialogBean
(
"有新版本,是否更新?"
,
"去更新"
,
"取消"
,
"更新提示"
),
new
CommTextDialog
.
onAcceptCallBack
()
{
@Override
public
void
refuseBack
()
{
/*强制更新标识位变更--重置用户登录*/
StaticData
.
updateLogin
=
1
;
}
@Override
public
void
acceptBack
()
{
/*强制更新标识位变更--可以用户登录*/
StaticData
.
updateLogin
=
0
;
rxPermissions
.
request
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
.
unsubscribeOn
(
Schedulers
.
io
())
// 使订阅不可取消
.
subscribe
(
granted
->
{
if
(
granted
)
{
updataApk
(
view
.
getContext
(),
resultBean
.
getVersionFile
(),
view
.
getContext
().
getFilesDir
().
getPath
()
+
resultBean
.
getVersionFile
().
substring
(
resultBean
.
getVersionFile
().
lastIndexOf
(
"/"
)));
}
else
{
ToastUtils
.
showShort
(
"请开启文件相关权限"
);
}
});
}
});
}
}
else
{
/*强制更新标识位变更--重置用户登录*/
StaticData
.
updateLogin
=
1
;
ToastUtils
.
showShort
(
"版本已是最新!"
);
}
}
@Override
public
void
onError
(
String
Error
)
{
/*强制更新标识位变更--重置用户登录*/
StaticData
.
updateLogin
=
1
;
}
});
}
/**
* 下载APK
*
* @param context
* @param url 下载地址
* @param name 文件名字
*/
public
void
updataApk
(
Context
context
,
String
url
,
String
name
)
{
/*执行传参方法*/
showDialog
(
"正在下载..."
);
model
.
downFile
(
url
,
name
).
subscribe
(
new
Observer
<
ResponseBody
>()
{
@Override
public
void
onSubscribe
(
@io
.
reactivex
.
rxjava3
.
annotations
.
NonNull
Disposable
d
)
{
Log
.
e
(
"下载"
,
"onSubscribe"
);
}
@Override
public
void
onNext
(
@io
.
reactivex
.
rxjava3
.
annotations
.
NonNull
ResponseBody
responseBody
)
{
}
@Override
public
void
onError
(
@io
.
reactivex
.
rxjava3
.
annotations
.
NonNull
Throwable
e
)
{
ToastUtils
.
showShort
(
"下载失败"
);
dismissDialog
();
}
@Override
public
void
onComplete
()
{
Log
.
e
(
"下载要成功"
,
"onComplete"
);
dismissDialog
();
ToastUtils
.
showShort
(
"下载成功"
);
installApk
(
context
,
name
);
}
});
}
//跳转安装APP
private
void
installApk
(
Context
context
,
String
path
)
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
File
file
=
new
File
(
Uri
.
parse
(
path
).
getPath
());
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
intent
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
Uri
uri
=
FileProvider
.
getUriForFile
(
context
,
"com.xx.merchanthbh.fileProvider"
,
file
);
intent
.
setDataAndType
(
uri
,
"application/vnd.android.package-archive"
);
}
else
{
intent
.
setDataAndType
(
Uri
.
fromFile
(
file
),
"application/vnd.android.package-archive"
);
}
context
.
startActivity
(
intent
);
}
}
}
consumer/src/main/java/com/xx/hbhconsumer/ui/storeservices/StoreServicesActivity.java
View file @
1963544a
...
@@ -52,11 +52,11 @@ public class StoreServicesActivity extends BaseActivity<ActivityStoreServicesBin
...
@@ -52,11 +52,11 @@ public class StoreServicesActivity extends BaseActivity<ActivityStoreServicesBin
switch
(
tab
.
getPosition
())
{
switch
(
tab
.
getPosition
())
{
case
0
:
case
0
:
viewModel
.
basic
=
"
1
"
;
viewModel
.
basic
=
"
6
"
;
viewModel
.
loadAgreement
();
viewModel
.
loadAgreement
();
break
;
break
;
case
1
:
case
1
:
viewModel
.
basic
=
"
2
"
;
viewModel
.
basic
=
"
7
"
;
viewModel
.
loadAgreement
();
viewModel
.
loadAgreement
();
break
;
break
;
}
}
...
...
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