fixed timer issue
This commit is contained in:
@ -25,8 +25,8 @@ void restoreGame() async {
|
|||||||
destinationController.isInRog.value = pref.getBool("is_in_rog") ?? false;
|
destinationController.isInRog.value = pref.getBool("is_in_rog") ?? false;
|
||||||
destinationController.rogainingCounted.value =
|
destinationController.rogainingCounted.value =
|
||||||
pref.getBool("rogaining_counted") ?? false;
|
pref.getBool("rogaining_counted") ?? false;
|
||||||
print(
|
//print(
|
||||||
"--restored -- destinationController.isInRog.value ${pref.getBool("is_in_rog")} -- ${pref.getBool("rogaining_counted")}");
|
// "--restored -- destinationController.isInRog.value ${pref.getBool("is_in_rog")} -- ${pref.getBool("rogaining_counted")}");
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
@ -88,22 +88,22 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
|||||||
Get.find<DestinationController>();
|
Get.find<DestinationController>();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case AppLifecycleState.resumed:
|
case AppLifecycleState.resumed:
|
||||||
print("RESUMED");
|
//print("RESUMED");
|
||||||
restoreGame();
|
restoreGame();
|
||||||
break;
|
break;
|
||||||
case AppLifecycleState.inactive:
|
case AppLifecycleState.inactive:
|
||||||
print("INACTIVE");
|
//print("INACTIVE");
|
||||||
break;
|
break;
|
||||||
case AppLifecycleState.paused:
|
case AppLifecycleState.paused:
|
||||||
print("PAUSED");
|
//print("PAUSED");
|
||||||
saveGameState();
|
saveGameState();
|
||||||
break;
|
break;
|
||||||
case AppLifecycleState.detached:
|
case AppLifecycleState.detached:
|
||||||
print("DETACHED");
|
//print("DETACHED");
|
||||||
saveGameState();
|
saveGameState();
|
||||||
break;
|
break;
|
||||||
case AppLifecycleState.hidden:
|
case AppLifecycleState.hidden:
|
||||||
print("DETACHED");
|
//print("DETACHED");
|
||||||
saveGameState();
|
saveGameState();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ class Destination {
|
|||||||
bool checkin = json['checkedin'] == 0 ? false : true;
|
bool checkin = json['checkedin'] == 0 ? false : true;
|
||||||
bool forcedCheckin = json['forced_checkin'] == 0 ? false : true;
|
bool forcedCheckin = json['forced_checkin'] == 0 ? false : true;
|
||||||
|
|
||||||
print("-----tags model----- ${json}");
|
//print("-----tags model----- ${json}");
|
||||||
|
|
||||||
return Destination(
|
return Destination(
|
||||||
name: json['name'],
|
name: json['name'],
|
||||||
|
|||||||
@ -284,7 +284,7 @@ class CameraPage extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
print("---- photos ${destination.photos} ----");
|
//print("---- photos ${destination.photos} ----");
|
||||||
if (buyPointPhoto == true) {
|
if (buyPointPhoto == true) {
|
||||||
//print("--- buy point camera ${destination.toString()}");
|
//print("--- buy point camera ${destination.toString()}");
|
||||||
return BuyPointCamera(destination: destination);
|
return BuyPointCamera(destination: destination);
|
||||||
|
|||||||
@ -37,7 +37,8 @@ class DestinationController extends GetxController {
|
|||||||
double currentLat = 0.0;
|
double currentLat = 0.0;
|
||||||
double currentLon = 0.0;
|
double currentLon = 0.0;
|
||||||
|
|
||||||
bool gps_push_started = false;
|
static bool gps_push_started = false;
|
||||||
|
static bool game_started = false;
|
||||||
|
|
||||||
bool skip_10s = false;
|
bool skip_10s = false;
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ class DestinationController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> startTimer(Destination d, double distance) async {
|
Future<void> startTimer(Destination d, double distance) async {
|
||||||
print("=== passed dest is ${d.location_id} ${d.checkedin} ====");
|
//print("=== passed dest is ${d.location_id} ${d.checkedin} ====");
|
||||||
skipGps = true;
|
skipGps = true;
|
||||||
//print("---- in startTimer ----");
|
//print("---- in startTimer ----");
|
||||||
|
|
||||||
@ -514,11 +515,12 @@ class DestinationController extends GetxController {
|
|||||||
is_checkin: isCheckin,
|
is_checkin: isCheckin,
|
||||||
created_at: DateTime.now().millisecondsSinceEpoch);
|
created_at: DateTime.now().millisecondsSinceEpoch);
|
||||||
var res = await db.insertGps(gps_data);
|
var res = await db.insertGps(gps_data);
|
||||||
print("==gps res == ${res}");
|
//print("==gps res == ${res}");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> checkForCheckin() async {
|
Future<void> checkForCheckin() async {
|
||||||
print("--- Start of checkForCheckin function ---");
|
//print("--- Start of checkForCheckin function ---");
|
||||||
|
game_started = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//print("--- 000 ---- $skip_gps----");
|
//print("--- 000 ---- $skip_gps----");
|
||||||
@ -587,15 +589,17 @@ class DestinationController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> pushGPStoServer() async {
|
Future<void> pushGPStoServer() async {
|
||||||
|
// print(
|
||||||
|
// "^^^^^^^^ ${DateFormat('kk:mm:ss \n EEE d MMM').format(DateTime.now())}");
|
||||||
try {
|
try {
|
||||||
await Future.delayed(const Duration(minutes: 5));
|
|
||||||
gps_push_started = true;
|
gps_push_started = true;
|
||||||
ExternalService().pushGPS();
|
ExternalService().pushGPS();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//print("An error occurred: $e");
|
//print("An error occurred: $e");
|
||||||
await pushGPStoServer();
|
//await pushGPStoServer();
|
||||||
} finally {
|
} finally {
|
||||||
//print("--- End of pushGPStoServer function, calling recursively ---");
|
//print("--- End of pushGPStoServer function, calling recursively ---");
|
||||||
|
await Future.delayed(const Duration(seconds: 5 * 60));
|
||||||
await pushGPStoServer();
|
await pushGPStoServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -702,7 +706,9 @@ class DestinationController extends GetxController {
|
|||||||
|
|
||||||
Future<void> startGame() async {
|
Future<void> startGame() async {
|
||||||
//print("------ starting game ------");
|
//print("------ starting game ------");
|
||||||
await checkForCheckin();
|
if (game_started == false) {
|
||||||
|
await checkForCheckin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -718,13 +724,13 @@ class DestinationController extends GetxController {
|
|||||||
|
|
||||||
Destination des = festuretoDestination(gfs);
|
Destination des = festuretoDestination(gfs);
|
||||||
|
|
||||||
print("=== gfs == ${des.toMap()}");
|
//print("=== gfs == ${des.toMap()}");
|
||||||
|
|
||||||
double distanceToDest = double.infinity;
|
double distanceToDest = double.infinity;
|
||||||
var distance = const Distance();
|
var distance = const Distance();
|
||||||
distanceToDest = distance.as(LengthUnit.Meter,
|
distanceToDest = distance.as(LengthUnit.Meter,
|
||||||
LatLng(currentLat, currentLon), LatLng(des.lat!, des.lon!));
|
LatLng(currentLat, currentLon), LatLng(des.lat!, des.lon!));
|
||||||
print("==== dist==${distanceToDest}");
|
//print("==== dist==${distanceToDest}");
|
||||||
return distanceToDest;
|
return distanceToDest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -744,7 +750,7 @@ class DestinationController extends GetxController {
|
|||||||
if (distanceToDest <= 500) {
|
if (distanceToDest <= 500) {
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
print("==== forced dist ==${distanceToDest}");
|
//print("==== forced dist ==${distanceToDest}");
|
||||||
return _retValue;
|
return _retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ class _GpsPageState extends State<GpsPage> {
|
|||||||
var data = await db.getGPSData(team_name, event_code);
|
var data = await db.getGPSData(team_name, event_code);
|
||||||
gpsData.value = data;
|
gpsData.value = data;
|
||||||
|
|
||||||
print("--- gps data ${data} ----");
|
//print("--- gps data ${data} ----");
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getMarkerShape(GpsData i) {
|
Widget getMarkerShape(GpsData i) {
|
||||||
|
|||||||
@ -268,7 +268,7 @@ class IndexController extends GetxController {
|
|||||||
} else {
|
} else {
|
||||||
rogMode.value = 1;
|
rogMode.value = 1;
|
||||||
}
|
}
|
||||||
print('--- c rog mode --- ${rogMode.value}');
|
//print('--- c rog mode --- ${rogMode.value}');
|
||||||
Get.toNamed(AppPages.INDEX);
|
Get.toNamed(AppPages.INDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -344,13 +344,15 @@ class ExternalService {
|
|||||||
|
|
||||||
String timestampToTimeString(int timestamp) {
|
String timestampToTimeString(int timestamp) {
|
||||||
// Convert timestamp to DateTime and format it as needed
|
// Convert timestamp to DateTime and format it as needed
|
||||||
var dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
|
var dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp);
|
||||||
|
//print("^^^^ time ${dateTime}");
|
||||||
// Format dateTime to a time string (e.g., '12:00:00')
|
// Format dateTime to a time string (e.g., '12:00:00')
|
||||||
// Adjust the format as needed
|
// Adjust the format as needed
|
||||||
return "${dateTime.hour}:${dateTime.minute}:${dateTime.second}";
|
return "${dateTime.hour}:${dateTime.minute}:${dateTime.second}";
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> pushGPS() async {
|
Future<bool> pushGPS() async {
|
||||||
|
//print("^^^^ pushed ^^^");
|
||||||
final IndexController indexController = Get.find<IndexController>();
|
final IndexController indexController = Get.find<IndexController>();
|
||||||
|
|
||||||
//int userId = indexController.currentUser[0]["user"]["id"];
|
//int userId = indexController.currentUser[0]["user"]["id"];
|
||||||
@ -383,7 +385,7 @@ class ExternalService {
|
|||||||
}).toList(),
|
}).toList(),
|
||||||
};
|
};
|
||||||
|
|
||||||
print("calling push gps step 2 ${payload}");
|
//print("calling push gps step 2 ${payload}");
|
||||||
|
|
||||||
String urlS =
|
String urlS =
|
||||||
'https://rogaining.sumasen.net/gifuroge/get_waypoint_datas_from_rogapp';
|
'https://rogaining.sumasen.net/gifuroge/get_waypoint_datas_from_rogapp';
|
||||||
@ -395,15 +397,15 @@ class ExternalService {
|
|||||||
body: json.encode(payload),
|
body: json.encode(payload),
|
||||||
);
|
);
|
||||||
|
|
||||||
print("GPS Data res ${response.statusCode}");
|
//print("GPS Data res ${response.statusCode}");
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
// Handle success
|
// Handle success
|
||||||
// make local data as synced
|
// make local data as synced
|
||||||
await GpsDatabaseHelper.instance.setSyncData(gpsDataList);
|
await GpsDatabaseHelper.instance.setSyncData(gpsDataList);
|
||||||
print("GPS Data sent successfully");
|
//print("GPS Data sent successfully");
|
||||||
} else {
|
} else {
|
||||||
// Handle error
|
// Handle error
|
||||||
print("Failed to send data");
|
//print("Failed to send data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Future.value(false);
|
return Future.value(false);
|
||||||
|
|||||||
@ -174,7 +174,7 @@ class LocationService {
|
|||||||
'$serverUrl/api/inbound?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
|
'$serverUrl/api/inbound?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print('++++++++$url');
|
//print('++++++++$url');
|
||||||
final response = await http.get(
|
final response = await http.get(
|
||||||
Uri.parse(url),
|
Uri.parse(url),
|
||||||
headers: <String, String>{
|
headers: <String, String>{
|
||||||
|
|||||||
@ -50,7 +50,7 @@ class GpsDatabaseHelper {
|
|||||||
nextOrder = nextOrder ?? 0;
|
nextOrder = nextOrder ?? 0;
|
||||||
nextOrder = nextOrder + 1;
|
nextOrder = nextOrder + 1;
|
||||||
gps.id = nextOrder;
|
gps.id = nextOrder;
|
||||||
print("---- insering ${gps.toMap()}");
|
//print("---- insering ${gps.toMap()}");
|
||||||
int res = await db.insert(
|
int res = await db.insert(
|
||||||
'gps',
|
'gps',
|
||||||
gps.toMap(),
|
gps.toMap(),
|
||||||
@ -68,7 +68,7 @@ class GpsDatabaseHelper {
|
|||||||
orderBy: 'created_at');
|
orderBy: 'created_at');
|
||||||
List<GpsData> gpsDatas =
|
List<GpsData> gpsDatas =
|
||||||
gpss.isNotEmpty ? gpss.map((e) => GpsData.fromMap(e)).toList() : [];
|
gpss.isNotEmpty ? gpss.map((e) => GpsData.fromMap(e)).toList() : [];
|
||||||
print("--------- db list $gpsDatas");
|
//print("--------- db list $gpsDatas");
|
||||||
return gpsDatas;
|
return gpsDatas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GeoJsonFeature<dynamic> gf = indexController.currentFeature[0];
|
GeoJsonFeature<dynamic> gf = indexController.currentFeature[0];
|
||||||
print("=== photo sss ${gf.properties!["photos"]}");
|
//print("=== photo sss ${gf.properties!["photos"]}");
|
||||||
if (gf.properties!["photos"] == null || gf.properties!["photos"] == "") {
|
if (gf.properties!["photos"] == null || gf.properties!["photos"] == "") {
|
||||||
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user