1.修复网络监听多次回调多次启动计时器问题
This commit is contained in:
parent
23e35c5bd8
commit
4072fe7c8d
@ -399,7 +399,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Distribution";
|
CODE_SIGN_IDENTITY = "Apple Distribution";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
CODE_SIGN_STYLE = Manual;
|
CODE_SIGN_STYLE = Manual;
|
||||||
CURRENT_PROJECT_VERSION = 5;
|
CURRENT_PROJECT_VERSION = 6;
|
||||||
DART_OBFUSCATION = true;
|
DART_OBFUSCATION = true;
|
||||||
DEVELOPMENT_TEAM = TW3K3253KL;
|
DEVELOPMENT_TEAM = TW3K3253KL;
|
||||||
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TW3K3253KL;
|
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TW3K3253KL;
|
||||||
@ -545,7 +545,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Distribution";
|
CODE_SIGN_IDENTITY = "Apple Distribution";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
CODE_SIGN_STYLE = Manual;
|
CODE_SIGN_STYLE = Manual;
|
||||||
CURRENT_PROJECT_VERSION = 5;
|
CURRENT_PROJECT_VERSION = 6;
|
||||||
DART_OBFUSCATION = true;
|
DART_OBFUSCATION = true;
|
||||||
DEVELOPMENT_TEAM = TW3K3253KL;
|
DEVELOPMENT_TEAM = TW3K3253KL;
|
||||||
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TW3K3253KL;
|
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TW3K3253KL;
|
||||||
@ -581,7 +581,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Distribution";
|
CODE_SIGN_IDENTITY = "Apple Distribution";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
CODE_SIGN_STYLE = Manual;
|
CODE_SIGN_STYLE = Manual;
|
||||||
CURRENT_PROJECT_VERSION = 5;
|
CURRENT_PROJECT_VERSION = 6;
|
||||||
DART_OBFUSCATION = true;
|
DART_OBFUSCATION = true;
|
||||||
DEVELOPMENT_TEAM = TW3K3253KL;
|
DEVELOPMENT_TEAM = TW3K3253KL;
|
||||||
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TW3K3253KL;
|
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TW3K3253KL;
|
||||||
|
|||||||
@ -47,11 +47,14 @@ class InterstitialAdManager {
|
|||||||
|
|
||||||
/// 初始化
|
/// 初始化
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
|
try {
|
||||||
MaxConfiguration? configuration = await AppLovinMAX.initialize(applovinKey);
|
MaxConfiguration? configuration = await AppLovinMAX.initialize(applovinKey);
|
||||||
if (configuration != null) {
|
if (configuration != null) {
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
_attachAdListeners();
|
_attachAdListeners();
|
||||||
loadAllAd();
|
}
|
||||||
|
} catch (e) {
|
||||||
|
LogPrint.d(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +90,7 @@ class InterstitialAdManager {
|
|||||||
LogPrint.d('插页广告显示失败adUnitId:${ad.adUnitId},code:${error.code},message:${error.message}');
|
LogPrint.d('插页广告显示失败adUnitId:${ad.adUnitId},code:${error.code},message:${error.message}');
|
||||||
isShowingAd = false;
|
isShowingAd = false;
|
||||||
|
|
||||||
if (onTap != null) onTap!();
|
_handleOnTap();
|
||||||
},
|
},
|
||||||
onAdClickedCallback: (ad) {},
|
onAdClickedCallback: (ad) {},
|
||||||
onAdHiddenCallback: (ad) {
|
onAdHiddenCallback: (ad) {
|
||||||
@ -95,7 +98,7 @@ class InterstitialAdManager {
|
|||||||
isShowingAd = false;
|
isShowingAd = false;
|
||||||
AppLovinMAX.loadInterstitial(ad.adUnitId);
|
AppLovinMAX.loadInterstitial(ad.adUnitId);
|
||||||
|
|
||||||
if (onTap != null) onTap!();
|
_handleOnTap();
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -105,6 +108,9 @@ class InterstitialAdManager {
|
|||||||
if (!adSwitch) {
|
if (!adSwitch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!isInitialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
AppLovinMAX.loadInterstitial(launchAdId);
|
AppLovinMAX.loadInterstitial(launchAdId);
|
||||||
for (var id in adIds) {
|
for (var id in adIds) {
|
||||||
AppLovinMAX.loadInterstitial(id);
|
AppLovinMAX.loadInterstitial(id);
|
||||||
@ -119,11 +125,11 @@ class InterstitialAdManager {
|
|||||||
}
|
}
|
||||||
bool adSwitch = UPCache.getInstance().get<bool>('adSwitch') ?? false;
|
bool adSwitch = UPCache.getInstance().get<bool>('adSwitch') ?? false;
|
||||||
if (!adSwitch) {
|
if (!adSwitch) {
|
||||||
if (this.onTap != null) this.onTap!();
|
_handleOnTap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isInitialized) {
|
if (!isInitialized) {
|
||||||
if (this.onTap != null) this.onTap!();
|
_handleOnTap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var adId = launchAdId;
|
var adId = launchAdId;
|
||||||
@ -135,13 +141,20 @@ class InterstitialAdManager {
|
|||||||
if (isReady) {
|
if (isReady) {
|
||||||
if (isShowingAd) {
|
if (isShowingAd) {
|
||||||
LogPrint.d('尝试在已显示广告的情况下显示广告');
|
LogPrint.d('尝试在已显示广告的情况下显示广告');
|
||||||
if (this.onTap != null) this.onTap!();
|
_handleOnTap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AppLovinMAX.showInterstitial(adId);
|
AppLovinMAX.showInterstitial(adId);
|
||||||
} else {
|
} else {
|
||||||
if (this.onTap != null) this.onTap!();
|
_handleOnTap();
|
||||||
AppLovinMAX.loadInterstitial(adId);
|
AppLovinMAX.loadInterstitial(adId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _handleOnTap() {
|
||||||
|
if (onTap != null) {
|
||||||
|
onTap!();
|
||||||
|
onTap = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ class RemindDialog extends StatelessWidget {
|
|||||||
label,
|
label,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isConfirm ? Colors.red : const Color(0xFF666666),
|
color: isConfirm ? Colors.black : const Color(0xFF666666),
|
||||||
fontSize: 16.sp,
|
fontSize: 16.sp,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -3,10 +3,15 @@
|
|||||||
// Description: facebook管理
|
// Description: facebook管理
|
||||||
|
|
||||||
import 'package:facebook_app_events/facebook_app_events.dart';
|
import 'package:facebook_app_events/facebook_app_events.dart';
|
||||||
|
import 'package:wallpaperx/common/utils/log_print.dart';
|
||||||
|
|
||||||
class FacebookManager {
|
class FacebookManager {
|
||||||
static void init() {
|
static Future<void> init() async {
|
||||||
FacebookAppEvents().setAdvertiserTracking(enabled: true);
|
try {
|
||||||
FacebookAppEvents().setAutoLogAppEventsEnabled(true);
|
await FacebookAppEvents().setAdvertiserTracking(enabled: true);
|
||||||
|
await FacebookAppEvents().setAutoLogAppEventsEnabled(true);
|
||||||
|
} catch (e) {
|
||||||
|
LogPrint.d(e.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,7 +4,7 @@ const appName = 'Visual Wallpaper';
|
|||||||
|
|
||||||
/// 保底逻辑:本地设定截止日期(提交日期+3天,网络时间超过,则默认展示所有广告)
|
/// 保底逻辑:本地设定截止日期(提交日期+3天,网络时间超过,则默认展示所有广告)
|
||||||
DateTime getGuaranteedDate () {
|
DateTime getGuaranteedDate () {
|
||||||
DateTime? commitDate = DateUtils.getDateTime('2024-08-14 18:30:00');
|
DateTime? commitDate = DateUtils.getDateTime('2024-08-15 18:30:00');
|
||||||
if (commitDate != null) {
|
if (commitDate != null) {
|
||||||
return commitDate.add(const Duration(days: 3));
|
return commitDate.add(const Duration(days: 3));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -6,7 +6,9 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:wallpaperx/ads/interstitial_ad_manage.dart';
|
import 'package:wallpaperx/ads/interstitial_ad_manage.dart';
|
||||||
|
import 'package:wallpaperx/common/components/dialog/remind_dialog.dart';
|
||||||
import 'package:wallpaperx/common/utils/log_print.dart';
|
import 'package:wallpaperx/common/utils/log_print.dart';
|
||||||
import 'package:wallpaperx/common/utils/shared_util.dart';
|
import 'package:wallpaperx/common/utils/shared_util.dart';
|
||||||
import 'package:wallpaperx/firebase/firebase_remote_config_manager.dart';
|
import 'package:wallpaperx/firebase/firebase_remote_config_manager.dart';
|
||||||
@ -22,18 +24,18 @@ class NetworkConnectivityService extends GetxService {
|
|||||||
subscription = Connectivity().onConnectivityChanged.listen((List<ConnectivityResult> result) async {
|
subscription = Connectivity().onConnectivityChanged.listen((List<ConnectivityResult> result) async {
|
||||||
LogPrint.d('当前网络连接类型:$result');
|
LogPrint.d('当前网络连接类型:$result');
|
||||||
if (result.contains(ConnectivityResult.none)) {
|
if (result.contains(ConnectivityResult.none)) {
|
||||||
|
_checkNetworkDialog();
|
||||||
if (Get.isRegistered<LaunchController>() && !isShowNetworkDialog) {
|
|
||||||
LaunchController.to.openNetworkDialog();
|
|
||||||
isShowNetworkDialog = true;
|
isShowNetworkDialog = true;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (Get.isRegistered<LaunchController>()) {
|
if (Get.isRegistered<LaunchController>()) {
|
||||||
if (isShowNetworkDialog) {
|
if (LaunchController.to.timer == null) {
|
||||||
Get.back();
|
|
||||||
}
|
|
||||||
LaunchController.to.startTimer();
|
LaunchController.to.startTimer();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (Get.isDialogOpen != null && Get.isDialogOpen! && isShowNetworkDialog) {
|
||||||
|
Get.back();
|
||||||
|
isShowNetworkDialog = false;
|
||||||
|
}
|
||||||
bool adSwitch = UPCache.getInstance().get<bool>('adSwitch') ?? false;
|
bool adSwitch = UPCache.getInstance().get<bool>('adSwitch') ?? false;
|
||||||
if (adSwitch) {
|
if (adSwitch) {
|
||||||
InterstitialAdManager().loadAllAd();
|
InterstitialAdManager().loadAllAd();
|
||||||
@ -48,4 +50,18 @@ class NetworkConnectivityService extends GetxService {
|
|||||||
subscription?.cancel();
|
subscription?.cancel();
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _checkNetworkDialog() {
|
||||||
|
Get.dialog(
|
||||||
|
barrierDismissible: false,
|
||||||
|
RemindDialog(
|
||||||
|
content: 'No network connection\nPlease check the current network',
|
||||||
|
showCancelBtn: false,
|
||||||
|
enableBack: false,
|
||||||
|
confirmOnTap: () {
|
||||||
|
openAppSettings();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -40,9 +40,9 @@ void main() async {
|
|||||||
debugPrint("Firebase initialization error: $e");
|
debugPrint("Firebase initialization error: $e");
|
||||||
}
|
}
|
||||||
|
|
||||||
FacebookManager.init();
|
await FacebookManager.init();
|
||||||
|
|
||||||
InterstitialAdManager().init();
|
await InterstitialAdManager().init();
|
||||||
|
|
||||||
// EasyLoading配置
|
// EasyLoading配置
|
||||||
configLoading();
|
configLoading();
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
|
||||||
import 'package:wallpaperx/ads/interstitial_ad_manage.dart';
|
import 'package:wallpaperx/ads/interstitial_ad_manage.dart';
|
||||||
import 'package:wallpaperx/common/components/dialog/remind_dialog.dart';
|
|
||||||
import 'package:wallpaperx/common/utils/shared_util.dart';
|
import 'package:wallpaperx/common/utils/shared_util.dart';
|
||||||
import 'package:wallpaperx/global/app_config.dart';
|
import 'package:wallpaperx/global/app_config.dart';
|
||||||
import 'package:wallpaperx/global/network_connectivity_service.dart';
|
import 'package:wallpaperx/global/network_connectivity_service.dart';
|
||||||
@ -11,7 +9,7 @@ import 'package:wallpaperx/routes/app_pages.dart';
|
|||||||
|
|
||||||
class LaunchController extends GetxController with GetSingleTickerProviderStateMixin {
|
class LaunchController extends GetxController with GetSingleTickerProviderStateMixin {
|
||||||
static LaunchController get to => Get.find<LaunchController>();
|
static LaunchController get to => Get.find<LaunchController>();
|
||||||
Timer? _timer;
|
Timer? timer;
|
||||||
/// 进度总时长
|
/// 进度总时长
|
||||||
var timeTotal = 15.0 * 1000;
|
var timeTotal = 15.0 * 1000;
|
||||||
/// 当前进度
|
/// 当前进度
|
||||||
@ -32,20 +30,6 @@ class LaunchController extends GetxController with GetSingleTickerProviderStateM
|
|||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void openNetworkDialog() {
|
|
||||||
Get.dialog(
|
|
||||||
barrierDismissible: false,
|
|
||||||
RemindDialog(
|
|
||||||
content: 'Please check if the wireless or cellular network is turned on?',
|
|
||||||
showCancelBtn: false,
|
|
||||||
enableBack: false,
|
|
||||||
confirmOnTap: () {
|
|
||||||
openAppSettings();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 检查是否到保底日期
|
/// 检查是否到保底日期
|
||||||
Future<void> _checkGuaranteedDate() async {
|
Future<void> _checkGuaranteedDate() async {
|
||||||
bool adSwitch = UPCache.getInstance().get<bool>('adSwitch') ?? false;
|
bool adSwitch = UPCache.getInstance().get<bool>('adSwitch') ?? false;
|
||||||
@ -58,7 +42,7 @@ class LaunchController extends GetxController with GetSingleTickerProviderStateM
|
|||||||
|
|
||||||
/// 开始定时器
|
/// 开始定时器
|
||||||
void startTimer() {
|
void startTimer() {
|
||||||
_timer = Timer.periodic(const Duration(milliseconds: 10), (Timer t) async {
|
timer = Timer.periodic(const Duration(milliseconds: 10), (Timer t) async {
|
||||||
if (currentProcess.value + changeValue >= timeTotal) {
|
if (currentProcess.value + changeValue >= timeTotal) {
|
||||||
currentProcess.value = timeTotal;
|
currentProcess.value = timeTotal;
|
||||||
_stopTimer();
|
_stopTimer();
|
||||||
@ -71,8 +55,8 @@ class LaunchController extends GetxController with GetSingleTickerProviderStateM
|
|||||||
|
|
||||||
/// 停止定时器
|
/// 停止定时器
|
||||||
void _stopTimer() {
|
void _stopTimer() {
|
||||||
_timer?.cancel();
|
timer?.cancel();
|
||||||
_timer = null;
|
timer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 修改进度变化值
|
/// 修改进度变化值
|
||||||
|
|||||||
@ -2,7 +2,7 @@ name: wallpaperx
|
|||||||
description: "A new Flutter project."
|
description: "A new Flutter project."
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 1.2.0+5
|
version: 1.2.0+6
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.4.1 <4.0.0'
|
sdk: '>=3.4.1 <4.0.0'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user