修改安卓下载apK超时问题,下载UI调整
This commit is contained in:
parent
fb8e556303
commit
d372be171d
@ -21,7 +21,7 @@ class ChatMsgInventWishItem extends StatelessWidget {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (!(message.isSelf ?? false)) {
|
||||
showGiftPannel(giftData['id'].toString());
|
||||
// showGiftPannel(giftData['id'].toString());
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
|
||||
@ -42,7 +42,7 @@ class _CustomDialogState extends State<UpdateDialog> {
|
||||
child: Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
child: Container(
|
||||
height: 317.sp,
|
||||
height: 317.sp + (isShowWeb ? 40.sp : 0),
|
||||
padding: const EdgeInsets.all(1.0),
|
||||
child: Stack(
|
||||
children: [
|
||||
@ -115,7 +115,7 @@ class _CustomDialogState extends State<UpdateDialog> {
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 4.sp),
|
||||
margin: EdgeInsets.only(top: 10.sp),
|
||||
child: CircularProgressIndicator(
|
||||
value: myProgress,
|
||||
backgroundColor: Colors.grey,
|
||||
@ -138,7 +138,7 @@ class _CustomDialogState extends State<UpdateDialog> {
|
||||
}
|
||||
},
|
||||
child:isShowWeb? Container(
|
||||
margin: EdgeInsets.only(top: 4.sp),
|
||||
margin: EdgeInsets.only(top: 10.sp),
|
||||
child: Text(
|
||||
"下载太慢?试试游览器下载吧。",
|
||||
style: TextStyle(
|
||||
@ -247,6 +247,7 @@ class _CustomDialogState extends State<UpdateDialog> {
|
||||
//SmartDialog.showLoading();
|
||||
var filePath = await getApplicationSupportDirectoryPath();
|
||||
filePath = filePath + "leyuan.apk";
|
||||
DioManager.instance.setReceiveTimeout(300);
|
||||
var data = await DioManager.instance
|
||||
.download(downloadUrl, filePath, (received, total) {
|
||||
double progress = received / total * 100;
|
||||
@ -260,6 +261,7 @@ class _CustomDialogState extends State<UpdateDialog> {
|
||||
// SmartDialog.dismiss();
|
||||
print(error);
|
||||
});
|
||||
DioManager.instance.setReceiveTimeout(30);
|
||||
await AppInstaller.installApk(filePath, actionRequired: false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,17 @@ class DioManager {
|
||||
// _dio!.interceptors.add(ConnectivityInterceptor());
|
||||
}
|
||||
|
||||
setReceiveTimeout (int time) {
|
||||
_dio!.options = BaseOptions(
|
||||
// 请求基地址
|
||||
baseUrl: baseUrl,
|
||||
// 连接服务器超时时间,单位是毫秒
|
||||
connectTimeout: const Duration(seconds: 30),
|
||||
// 接收数据的最长时限
|
||||
receiveTimeout: Duration(seconds: time),
|
||||
);
|
||||
}
|
||||
|
||||
Future download(String urlPath, String savePath,
|
||||
ProgressCallback progressCallback) async {
|
||||
return await _dio!
|
||||
|
||||
Loading…
Reference in New Issue
Block a user