diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index b81116c..ba8c05a 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -109,19 +109,19 @@ android { // 应用信息配置 - productFlavors { - // 智夜生活 - zhiying { - applicationId "cn.zhios.zhiying" - versionCode 59 - dimension "app" - versionName '1.3.19' - // 签名信息 - signingConfig signingConfigs.zhiying - } - } - - // 打包脚本 +// productFlavors { +// // 智夜生活 +// zhiying { +// applicationId "cn.zhios.zhiying" +// versionCode 59 +// dimension "app" +// versionName '1.3.19' +// // 签名信息 +// signingConfig signingConfigs.zhiying +// } +// } +// +// // 打包脚本 // android.applicationVariants.all { variant -> // if (variant.buildType.name != "debug") { // variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk") @@ -136,18 +136,18 @@ android { // } // } // } -// -// configurations.all { -// resolutionStrategy.eachDependency { DependencyResolveDetails details -> -// def requested = details.requested -// if (requested.group == 'com.android.support') { -// if (!requested.name.startsWith("multidex")) { -// details.useVersion '28.0.3' -// } -// } -// resolutionStrategy.force 'com.android.support:support-v4:28.0.0' -// } -// } + + configurations.all { + resolutionStrategy.eachDependency { DependencyResolveDetails details -> + def requested = details.requested + if (requested.group == 'com.android.support') { + if (!requested.name.startsWith("multidex")) { + details.useVersion '28.0.3' + } + } + resolutionStrategy.force 'com.android.support:support-v4:28.0.0' + } + } } @@ -185,9 +185,10 @@ dependencies { implementation 'com.alibaba.sdk.android:AlibcTradeBiz:4.0.0.16@aar' implementation 'com.alibaba.sdk.android:nb_trade:4.0.0.16@aar' implementation 'com.alibaba:fastjson:1.2.41@jar' - implementation 'com.amap.api:location:5.2.0' + implementation (name: 'kaduofensdk', ext: 'aar') + } diff --git a/example/android/app/libs/kaduofensdk.aar b/example/android/app/libs/kaduofensdk.aar new file mode 100644 index 0000000..1833e79 Binary files /dev/null and b/example/android/app/libs/kaduofensdk.aar differ diff --git a/example/android/build.gradle b/example/android/build.gradle index fce6d9c..7ba321d 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -2,6 +2,9 @@ buildscript { repositories { google() jcenter() + flatDir { + dirs 'libs' + } } dependencies { @@ -18,6 +21,9 @@ allprojects { maven { url "http://repo.baichuan-android.taobao.com/content/groups/BaichuanRepositories/" } + flatDir { + dirs 'libs' + } } } diff --git a/example/lib/main.dart b/example/lib/main.dart index d00d3e2..dbd0ff4 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -107,6 +107,7 @@ class _MyAppState extends State { child: child, ); }, + navigatorObservers: [lifeObserver], theme: ThemeData( fontFamily: 'PingFang', primaryColor: HexColor.fromHex('#FF4242'), diff --git a/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart index a604198..1899de4 100644 --- a/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart +++ b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart @@ -20,9 +20,19 @@ class IntellectCreate { static IntellectSearchSetModel _setModel; static bool isRequest = false; + //是否检查粘贴板 + static bool check = false; + + static setCheck(bool isCheck){ + check=isCheck; + } + ///判断规则 static checkAndCreate(AppLifecycleState state, BuildContext context) async { - if (state == AppLifecycleState.resumed && !isRequest) { + + + if (state == AppLifecycleState.resumed && !isRequest &&check) { + print("读取粘贴版"); isRequest = true; Timer(Duration(milliseconds: 2000), () { @@ -96,7 +106,11 @@ class IntellectCreate { ///弹起存在不存在商品的弹窗 if (!Constants.isShowIntellectDialog) { Constants.isShowIntellectDialog = true; - await showDialog(context: context, child: IntellectSearchNoGoodsDialog(setModel: _setModel,)); + await showDialog( + context: context, + child: IntellectSearchNoGoodsDialog( + setModel: _setModel, + )); Constants.isShowIntellectDialog = false; } } else if (data.toString() == "403032") { @@ -162,6 +176,6 @@ class IntellectCreate { } } } - requestDialog(context, content,setModel); + requestDialog(context, content, setModel); } } diff --git a/lib/pages/home_page/home_page.dart b/lib/pages/home_page/home_page.dart index 18123ef..f7dbbe6 100644 --- a/lib/pages/home_page/home_page.dart +++ b/lib/pages/home_page/home_page.dart @@ -59,7 +59,7 @@ class HomePage extends StatefulWidget { _HomePageState createState() => _HomePageState(); } -class _HomePageState extends State with WidgetsBindingObserver, TickerProviderStateMixin { +class _HomePageState extends LifeState with WidgetsBindingObserver, TickerProviderStateMixin { int _currentIndex = 0; List> _data = List(); static const EventChannel _eventChannel = const EventChannel('JAVA_TO_FLUTTER'); @@ -389,4 +389,59 @@ class _HomePageState extends State with WidgetsBindingObserver, Ticker ) ])); } + + @override + void onPaused() { + print("首页调用不可见"); + IntellectCreate.setCheck(false); + } + + @override + void onResume() { + print("首页调用可见"); + IntellectCreate.setCheck(true); + } +} + +final RouteObserver lifeObserver = RouteObserver(); + +abstract class LifeState extends State + with RouteAware { + @override + void initState() { + super.initState(); + } + + @override + void didChangeDependencies() { + lifeObserver.subscribe(this, ModalRoute.of(context)); + super.didChangeDependencies(); + } + + @override + void dispose() { + lifeObserver.unsubscribe(this); + super.dispose(); + } + + + void didPop() { + onPaused(); + } + + void didPopNext() { + onResume(); + } + + void didPush() { + onResume(); + } + + void didPushNext() { + onPaused(); + } + + void onResume(); + + void onPaused(); }