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/index/index_binding.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/utils/location_controller.dart';
|
||||
import 'package:rogapp/utils/string_values.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
// import 'package:is_lock_screen/is_lock_screen.dart';
|
||||
@ -87,25 +88,32 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
LocationController locationController = Get.find<LocationController>();
|
||||
|
||||
DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
switch (state) {
|
||||
case AppLifecycleState.resumed:
|
||||
locationController.resumePositionStream();
|
||||
//print("RESUMED");
|
||||
restoreGame();
|
||||
break;
|
||||
case AppLifecycleState.inactive:
|
||||
locationController.resumePositionStream();
|
||||
//print("INACTIVE");
|
||||
break;
|
||||
case AppLifecycleState.paused:
|
||||
locationController.resumePositionStream();
|
||||
//print("PAUSED");
|
||||
saveGameState();
|
||||
break;
|
||||
case AppLifecycleState.detached:
|
||||
locationController.resumePositionStream();
|
||||
//print("DETACHED");
|
||||
saveGameState();
|
||||
break;
|
||||
case AppLifecycleState.hidden:
|
||||
locationController.resumePositionStream();
|
||||
//print("DETACHED");
|
||||
saveGameState();
|
||||
break;
|
||||
|
||||
@ -28,12 +28,12 @@ class IndexPage extends GetView<IndexController> {
|
||||
appBar: AppBar(
|
||||
title: Text("add_location".tr),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
DatabaseService ds = DatabaseService();
|
||||
ds.updateDatabase();
|
||||
},
|
||||
icon: const Icon(Icons.ten_k_sharp)),
|
||||
// IconButton(
|
||||
// onPressed: () {
|
||||
// DatabaseService ds = DatabaseService();
|
||||
// ds.updateDatabase();
|
||||
// },
|
||||
// icon: const Icon(Icons.ten_k_sharp)),
|
||||
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
|
||||
@ -117,7 +117,9 @@ class LocationController extends GetxController {
|
||||
// print(position == null
|
||||
// ? 'Unknown'
|
||||
// : '${position.latitude.toString()}, ${position.longitude.toString()}');
|
||||
currentPosition.value = position;
|
||||
if (position?.accuracy != null && position!.accuracy <= 15) {
|
||||
currentPosition.value = position;
|
||||
}
|
||||
|
||||
// LogManager().addLog(
|
||||
// "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
|
||||
if (isStreamPaused) {
|
||||
positionStream?.resume();
|
||||
isStreamPaused = false;
|
||||
positionStream.resume();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user