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