Fix Android issues
This commit is contained in:
@ -44,6 +44,9 @@ import 'package:path_provider/path_provider.dart';
|
||||
// 目的地に関連する状態管理とロジックを担当するクラスです。
|
||||
//
|
||||
class DestinationController extends GetxController {
|
||||
Timer? _checkForCheckinTimer;
|
||||
final int _checkInterval = 3000; // ミリ秒単位でチェック間隔を設定
|
||||
|
||||
late LocationSettings locationSettings; // 位置情報の設定を保持する変数です。
|
||||
|
||||
//late TeamController teamController = TeamController();
|
||||
@ -1019,15 +1022,16 @@ class DestinationController extends GetxController {
|
||||
// 2024-8-24 ... 佐伯呼び出しが必要なのか?
|
||||
//
|
||||
Future<void> checkForCheckin() async {
|
||||
//print("--- Start of checkForCheckin function ---");
|
||||
dbService.updateDatabase();
|
||||
await Future.delayed(const Duration(milliseconds: 3000));
|
||||
game_started = true;
|
||||
if (!game_started) {
|
||||
game_started = true;
|
||||
dbService.updateDatabase();
|
||||
}
|
||||
|
||||
try {
|
||||
// ここで、エラー
|
||||
if( indexController.locations.isNotEmpty ) {
|
||||
indexController.locations[0].features.forEach((fs) async {
|
||||
for (var fs in indexController.locations[0].features) {
|
||||
//indexController.locations[0].features.forEach((fs) async {
|
||||
GeoJSONMultiPoint mp = fs!.geometry as GeoJSONMultiPoint;
|
||||
LatLng pt = LatLng(mp.coordinates[0][1], mp.coordinates[0][0]);
|
||||
|
||||
@ -1045,10 +1049,11 @@ class DestinationController extends GetxController {
|
||||
await startTimerLocation(fs, distFs);
|
||||
// Note: You cannot break out of forEach. If you need to stop processing, you might have to reconsider using forEach.
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (gps_push_started == false) {
|
||||
unawaited(pushGPStoServer());
|
||||
pushGPStoServer();
|
||||
//unawaited(pushGPStoServer());
|
||||
}
|
||||
}
|
||||
//print("--- 123 ---- $skip_gps----");
|
||||
@ -1071,14 +1076,19 @@ class DestinationController extends GetxController {
|
||||
// "^^^^^^^^ ${DateFormat('kk:mm:ss \n EEE d MMM').format(DateTime.now())}");
|
||||
try {
|
||||
gps_push_started = true;
|
||||
ExternalService().pushGPS();
|
||||
await ExternalService().pushGPS();
|
||||
} catch (e) {
|
||||
print("An error occurred in pushGPStoServer: $e");
|
||||
//print("An error occurred: $e");
|
||||
//await pushGPStoServer();
|
||||
} finally {
|
||||
//print("--- End of pushGPStoServer function, calling recursively ---");
|
||||
await Future.delayed(const Duration(seconds: 5 * 60));
|
||||
await pushGPStoServer();
|
||||
if (gps_push_started) {
|
||||
Future.delayed(Duration(minutes: 5), pushGPStoServer);
|
||||
}
|
||||
|
||||
//print("--- End of pushGPStoServer function, calling recursively ---");
|
||||
//await Future.delayed(const Duration(seconds: 5 * 60));
|
||||
//await pushGPStoServer();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1332,12 +1342,13 @@ class DestinationController extends GetxController {
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
startCheckForCheckinTimer();
|
||||
|
||||
|
||||
/*
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await PermissionController.checkAndRequestPermissions();
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
startGPSCheckTimer();
|
||||
|
||||
@ -1415,6 +1426,18 @@ class DestinationController extends GetxController {
|
||||
//checkGPSDataReceived();
|
||||
}
|
||||
|
||||
void startCheckForCheckinTimer() {
|
||||
_checkForCheckinTimer = Timer.periodic(Duration(milliseconds: _checkInterval), (_) {
|
||||
checkForCheckin();
|
||||
});
|
||||
}
|
||||
|
||||
void stopCheckForCheckinTimer() {
|
||||
_checkForCheckinTimer?.cancel();
|
||||
_checkForCheckinTimer = null;
|
||||
}
|
||||
|
||||
|
||||
void restartGPS(){
|
||||
// GPSデータのListenを再開する処理を追加
|
||||
Future.delayed(const Duration(seconds: 5), () {
|
||||
@ -1427,8 +1450,9 @@ class DestinationController extends GetxController {
|
||||
//
|
||||
@override
|
||||
void onClose() {
|
||||
gpsCheckTimer?.cancel();
|
||||
locationController.stopPositionStream();
|
||||
stopCheckForCheckinTimer();
|
||||
//gpsCheckTimer?.cancel();
|
||||
//locationController.stopPositionStream();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user