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