updated to resume in hibernate and set gps accuray to 15m
This commit is contained in:
@ -4,6 +4,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
import 'package:rogapp/pages/index/index_binding.dart';
|
import 'package:rogapp/pages/index/index_binding.dart';
|
||||||
import 'package:rogapp/routes/app_pages.dart';
|
import 'package:rogapp/routes/app_pages.dart';
|
||||||
|
import 'package:rogapp/utils/location_controller.dart';
|
||||||
import 'package:rogapp/utils/string_values.dart';
|
import 'package:rogapp/utils/string_values.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
// import 'package:is_lock_screen/is_lock_screen.dart';
|
// import 'package:is_lock_screen/is_lock_screen.dart';
|
||||||
@ -87,25 +88,32 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
|
LocationController locationController = Get.find<LocationController>();
|
||||||
|
|
||||||
DestinationController destinationController =
|
DestinationController destinationController =
|
||||||
Get.find<DestinationController>();
|
Get.find<DestinationController>();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case AppLifecycleState.resumed:
|
case AppLifecycleState.resumed:
|
||||||
|
locationController.resumePositionStream();
|
||||||
//print("RESUMED");
|
//print("RESUMED");
|
||||||
restoreGame();
|
restoreGame();
|
||||||
break;
|
break;
|
||||||
case AppLifecycleState.inactive:
|
case AppLifecycleState.inactive:
|
||||||
|
locationController.resumePositionStream();
|
||||||
//print("INACTIVE");
|
//print("INACTIVE");
|
||||||
break;
|
break;
|
||||||
case AppLifecycleState.paused:
|
case AppLifecycleState.paused:
|
||||||
|
locationController.resumePositionStream();
|
||||||
//print("PAUSED");
|
//print("PAUSED");
|
||||||
saveGameState();
|
saveGameState();
|
||||||
break;
|
break;
|
||||||
case AppLifecycleState.detached:
|
case AppLifecycleState.detached:
|
||||||
|
locationController.resumePositionStream();
|
||||||
//print("DETACHED");
|
//print("DETACHED");
|
||||||
saveGameState();
|
saveGameState();
|
||||||
break;
|
break;
|
||||||
case AppLifecycleState.hidden:
|
case AppLifecycleState.hidden:
|
||||||
|
locationController.resumePositionStream();
|
||||||
//print("DETACHED");
|
//print("DETACHED");
|
||||||
saveGameState();
|
saveGameState();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -28,12 +28,12 @@ class IndexPage extends GetView<IndexController> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("add_location".tr),
|
title: Text("add_location".tr),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
// IconButton(
|
||||||
onPressed: () {
|
// onPressed: () {
|
||||||
DatabaseService ds = DatabaseService();
|
// DatabaseService ds = DatabaseService();
|
||||||
ds.updateDatabase();
|
// ds.updateDatabase();
|
||||||
},
|
// },
|
||||||
icon: const Icon(Icons.ten_k_sharp)),
|
// icon: const Icon(Icons.ten_k_sharp)),
|
||||||
|
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
|||||||
@ -117,7 +117,9 @@ class LocationController extends GetxController {
|
|||||||
// print(position == null
|
// print(position == null
|
||||||
// ? 'Unknown'
|
// ? 'Unknown'
|
||||||
// : '${position.latitude.toString()}, ${position.longitude.toString()}');
|
// : '${position.latitude.toString()}, ${position.longitude.toString()}');
|
||||||
|
if (position?.accuracy != null && position!.accuracy <= 15) {
|
||||||
currentPosition.value = position;
|
currentPosition.value = position;
|
||||||
|
}
|
||||||
|
|
||||||
// LogManager().addLog(
|
// LogManager().addLog(
|
||||||
// "GPS : ${position!.latitude.toString()}, ${position.longitude.toString()} - ${DateTime.now().hour}:${DateTime.now().minute}:${DateTime.now().second}:${DateTime.now().microsecond}");
|
// "GPS : ${position!.latitude.toString()}, ${position.longitude.toString()} - ${DateTime.now().hour}:${DateTime.now().minute}:${DateTime.now().second}:${DateTime.now().microsecond}");
|
||||||
@ -125,8 +127,8 @@ class LocationController extends GetxController {
|
|||||||
|
|
||||||
// Resume stream if it was paused previously
|
// Resume stream if it was paused previously
|
||||||
if (isStreamPaused) {
|
if (isStreamPaused) {
|
||||||
positionStream?.resume();
|
|
||||||
isStreamPaused = false;
|
isStreamPaused = false;
|
||||||
|
positionStream.resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user