update to add resume app from sleep
This commit is contained in:
@ -2,12 +2,10 @@ import 'dart:io';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/model/rog.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/utils/database_helper.dart';
|
||||
import 'package:sqflite/sqlite_api.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
import '../utils/const.dart';
|
||||
@ -35,7 +33,7 @@ class ExternalService {
|
||||
|
||||
Map<String, dynamic> _res = {};
|
||||
|
||||
int user_id = indexController.currentUser[0]["user"]["id"];
|
||||
int userId = indexController.currentUser[0]["user"]["id"];
|
||||
//print("--- Pressed -----");
|
||||
String _team = indexController.currentUser[0]["user"]['team_name'];
|
||||
//print("--- _team : ${_team}-----");
|
||||
@ -47,7 +45,7 @@ class ExternalService {
|
||||
id:1,
|
||||
team_name: _team,
|
||||
event_code : _event_code,
|
||||
user_id: user_id,
|
||||
user_id: userId,
|
||||
cp_number: -1,
|
||||
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
|
||||
image: null,
|
||||
@ -57,7 +55,7 @@ class ExternalService {
|
||||
}
|
||||
else {
|
||||
String url = 'https://rogaining.sumasen.net/gifuroge/start_from_rogapp';
|
||||
print('++++++++${url}');
|
||||
print('++++++++$url');
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -73,17 +71,17 @@ class ExternalService {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
_res = json.decode(utf8.decode(response.bodyBytes));
|
||||
print('----_res : ${_res} ----');
|
||||
print('----_res : $_res ----');
|
||||
}
|
||||
}
|
||||
return _res;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> makeCheckpoint(int user_id, String token, String checkin_time, String teamname, int cp, String eventcode, String imageurl) async {
|
||||
Future<Map<String, dynamic>> makeCheckpoint(int userId, String token, String checkinTime, String teamname, int cp, String eventcode, String imageurl) async {
|
||||
//print("--cpcp-- ${cp}");
|
||||
Map<String, dynamic> _res = {};
|
||||
String url = 'https://rogaining.sumasen.net/gifuroge/checkin_from_rogapp';
|
||||
print('++++++++${url}');
|
||||
print('++++++++$url');
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
if(imageurl != null){
|
||||
@ -94,7 +92,7 @@ class ExternalService {
|
||||
id:1,
|
||||
team_name: teamname,
|
||||
event_code : eventcode,
|
||||
user_id: user_id,
|
||||
user_id: userId,
|
||||
cp_number: cp,
|
||||
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
|
||||
image: imageurl,
|
||||
@ -103,31 +101,31 @@ class ExternalService {
|
||||
db.insertRogaining(_rog);
|
||||
}
|
||||
else {
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url1 = "${server_url}/api/checkinimage/";
|
||||
final im1Bytes = File(imageurl!).readAsBytesSync();
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url1 = "$serverUrl/api/checkinimage/";
|
||||
final im1Bytes = File(imageurl).readAsBytesSync();
|
||||
String im1_64 = base64Encode(im1Bytes);
|
||||
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url1),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token ${token}'
|
||||
'Authorization': 'Token $token'
|
||||
},
|
||||
// 'id', 'user', 'goalimage', 'goaltime', 'team_name', 'event_code','cp_number'
|
||||
body: jsonEncode(<String, String>{
|
||||
'user' : user_id.toString(),
|
||||
'user' : userId.toString(),
|
||||
'team_name': teamname,
|
||||
'event_code': eventcode,
|
||||
'checkinimage' : im1_64,
|
||||
'checkintime' : checkin_time,
|
||||
'checkintime' : checkinTime,
|
||||
'cp_number' : cp.toString()
|
||||
}),
|
||||
);
|
||||
|
||||
_res = json.decode(utf8.decode(response.bodyBytes));
|
||||
|
||||
print("-----@@@@@ ${_res} -----");
|
||||
print("-----@@@@@ $_res -----");
|
||||
|
||||
if(response.statusCode == 201){
|
||||
//print('---- toekn is ${token} -----');
|
||||
@ -149,11 +147,11 @@ class ExternalService {
|
||||
'event_code': eventcode,
|
||||
'image': _res["checkinimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
});
|
||||
print("--json-- ${vv}");
|
||||
print("--json-- $vv");
|
||||
print("--- checnin response ${response2.statusCode}----");
|
||||
if (response2.statusCode == 200) {
|
||||
_res = json.decode(utf8.decode(response2.bodyBytes));
|
||||
print('----checkin res _res : ${_res} ----');
|
||||
print('----checkin res _res : $_res ----');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -165,7 +163,7 @@ class ExternalService {
|
||||
id:1,
|
||||
team_name: teamname,
|
||||
event_code : eventcode,
|
||||
user_id: user_id,
|
||||
user_id: userId,
|
||||
cp_number: cp,
|
||||
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
|
||||
image: null,
|
||||
@ -192,11 +190,11 @@ class ExternalService {
|
||||
'event_code': eventcode,
|
||||
'image': _res["checkinimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
});
|
||||
print("--json-- ${vvv}");
|
||||
print("--json-- $vvv");
|
||||
print("--- checnin response ${response3.statusCode}----");
|
||||
if (response3.statusCode == 200) {
|
||||
_res = json.decode(utf8.decode(response3.bodyBytes));
|
||||
print('----checkin res _res : ${_res} ----');
|
||||
print('----checkin res _res : $_res ----');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -204,7 +202,7 @@ class ExternalService {
|
||||
}
|
||||
|
||||
|
||||
Future<Map<String, dynamic>> makeGoal(int user_id, String token, String teamname, String image, String goal_time, String eventcode) async {
|
||||
Future<Map<String, dynamic>> makeGoal(int userId, String token, String teamname, String image, String goalTime, String eventcode) async {
|
||||
Map<String, dynamic> _res2 = {};
|
||||
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
@ -216,7 +214,7 @@ class ExternalService {
|
||||
id:1,
|
||||
team_name: teamname,
|
||||
event_code : eventcode,
|
||||
user_id: user_id,
|
||||
user_id: userId,
|
||||
cp_number: -1,
|
||||
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
|
||||
image: image,
|
||||
@ -225,33 +223,33 @@ class ExternalService {
|
||||
db.insertRogaining(_rog);
|
||||
// }
|
||||
// else{
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url1 = "${server_url}/api/goalimage/";
|
||||
final im1Bytes = File(image!).readAsBytesSync();
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url1 = "$serverUrl/api/goalimage/";
|
||||
final im1Bytes = File(image).readAsBytesSync();
|
||||
String im1_64 = base64Encode(im1Bytes);
|
||||
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url1),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token ${token}'
|
||||
'Authorization': 'Token $token'
|
||||
},
|
||||
// 'id', 'user', 'goalimage', 'goaltime', 'team_name', 'event_code','cp_number'
|
||||
body: jsonEncode(<String, String>{
|
||||
'user' : user_id.toString(),
|
||||
'user' : userId.toString(),
|
||||
'team_name': teamname,
|
||||
'event_code': eventcode,
|
||||
'goaltime' : goal_time,
|
||||
'goaltime' : goalTime,
|
||||
'goalimage' : im1_64,
|
||||
'cp_number' : "-1"
|
||||
}),
|
||||
);
|
||||
|
||||
String url = 'https://rogaining.sumasen.net/gifuroge/goal_from_rogapp';
|
||||
print('++++++++${url}');
|
||||
print('++++++++$url');
|
||||
if (response.statusCode == 201) {
|
||||
Map<String, dynamic> _res = json.decode(utf8.decode(response.bodyBytes));
|
||||
print('----_res : ${_res} ----');
|
||||
print('----_res : $_res ----');
|
||||
print('---- image url ${_res["goalimage"]} ----');
|
||||
final http.Response response2 = await http.post(
|
||||
Uri.parse(url),
|
||||
@ -261,7 +259,7 @@ class ExternalService {
|
||||
body: jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'event_code': eventcode,
|
||||
'goal_time' : goal_time,
|
||||
'goal_time' : goalTime,
|
||||
'image' : _res["goalimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
}
|
||||
),
|
||||
@ -269,12 +267,12 @@ class ExternalService {
|
||||
String rec = jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'event_code': eventcode,
|
||||
'goal_time' : goal_time,
|
||||
'goal_time' : goalTime,
|
||||
'image' : _res["goalimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
}
|
||||
);
|
||||
print("-- json -- ${rec}");
|
||||
print('----- response2 is ${response2} --------');
|
||||
print("-- json -- $rec");
|
||||
print('----- response2 is $response2 --------');
|
||||
if (response2.statusCode == 200) {
|
||||
_res2 = json.decode(utf8.decode(response2.bodyBytes));
|
||||
}
|
||||
@ -287,8 +285,8 @@ class ExternalService {
|
||||
|
||||
static Future<Map<String, dynamic>> usersEventCode(String teamcode, String password) async {
|
||||
Map<String, dynamic> _res = {};
|
||||
String url = "https://rogaining.sumasen.net/gifuroge/check_event_code?zekken_number=${teamcode}&password=${password}";
|
||||
print('++++++++${url}');
|
||||
String url = "https://rogaining.sumasen.net/gifuroge/check_event_code?zekken_number=$teamcode&password=$password";
|
||||
print('++++++++$url');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
|
||||
Reference in New Issue
Block a user