diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index 34fe2eda..c9e4bc24 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -335,6 +335,7 @@ class _CommunityDynamic extends State { child: MImage( subjectInfo.images[0], fit: BoxFit.cover, + radius: BorderRadius.circular(2), width: MediaQuery.of(context).size.width / 1.5, height: MediaQuery.of(context).size.width / 1.5, errorSrc: "assets/image/default_2_1.png", @@ -365,6 +366,7 @@ class _CommunityDynamic extends State { subjectInfo.images[position], fit: BoxFit.cover, aspectRatio: 1, + radius: BorderRadius.circular(1), errorSrc: "assets/image/default_2_1.png", fadeSrc: "assets/image/default_2_1.png", ), diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index c6397f88..59e35f52 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -7,9 +7,7 @@ import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/main.dart'; import 'package:huixiang/mine/mine_view/mine_order.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/comunity_comment.dart'; import 'package:huixiang/retrofit/data/rank.dart'; -import 'package:huixiang/retrofit/data/sign_info.dart'; import 'package:huixiang/retrofit/data/social_info.dart'; import 'package:huixiang/retrofit/data/user_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; @@ -34,7 +32,7 @@ class MinePage extends StatefulWidget { } } -class _MinePage extends State with AutomaticKeepAliveClientMixin { +class _MinePage extends State with AutomaticKeepAliveClientMixin ,WidgetsBindingObserver{ ApiService apiService; UserInfo userInfo; List ranks = []; @@ -55,12 +53,31 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { @override void dispose() { super.dispose(); - if (_refreshController != null) _refreshController.dispose(); + if (_refreshController != null) + _refreshController.dispose(); + WidgetsBinding.instance.removeObserver(this); //销毁观察者 + } + + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + print("-didChangeAppLifecycleState-" + state.toString()); + switch (state) { + case AppLifecycleState.inactive: // 处于这种状态的应用程序应该假设它们可能在任何时候暂停。 + break; + case AppLifecycleState.resumed: //从后台切换前台,界面可见 + querySocialInfo(); + break; + case AppLifecycleState.paused: // 界面不可见,后台 + break; + case AppLifecycleState.detached: // APP结束时调用 + break; + } } @override void initState() { super.initState(); + WidgetsBinding.instance.addObserver(this); querySocialInfo(); eventBus.on().listen((event) { @@ -117,6 +134,11 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { EasyLoading.dismiss(); } + _onRefresh(){ + queryUserInfo(); + querySocialInfo(); + } + ///个人社交信息(粉丝/关注数量/成就数量) querySocialInfo() async { SharedPreferences value = await SharedPreferences.getInstance(); @@ -128,9 +150,12 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { ); BaseData baseData = - await apiService.socialInfo().catchError((onError) {}); + await apiService.socialInfo().catchError((onError) { + _refreshController.refreshFailed(); + }); if (baseData != null && baseData.isSuccess) { infoNumber = baseData.data; + _refreshController.refreshCompleted(); } EasyLoading.dismiss(); } @@ -150,7 +175,9 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { header: MyHeader(), physics: BouncingScrollPhysics(), onRefresh: () { - setState(() {}); + setState(() { + _onRefresh(); + }); }, child: SingleChildScrollView( child: Container(