|
|
- long gatherTime = Preferences.getInstance(this).getGatherTime();
|
|
108
|
|
- if(gatherTime<System.currentTimeMillis()){
|
|
109
|
|
- mHandler.sendEmptyMessageDelayed(MSG_FETCH_TOUR_INFO,60000);
|
|
110
|
|
- }
|
|
111
|
|
- }
|
|
112
|
106
|
|
|
113
|
107
|
private void fetchTourInfo(){
|
|
|
108
|
+ mHandler.removeMessages(MSG_FETCH_TOUR_INFO);
|
|
114
|
109
|
mHandler.sendEmptyMessageDelayed(MSG_FETCH_TOUR_INFO,FETCH_GATHER_INFO_PERIOD);
|
|
115
|
|
- if(!Preferences.getInstance(this).isTourMode()&&Preferences.getInstance(this).getTourEndTime()<System.currentTimeMillis()){
|
|
|
110
|
+ if(!Preferences.getInstance(this).isTourMode()){
|
|
|
111
|
+ LogHelper.d(TAG,"已经知道不是旅行模式,跳过此次集合信息请求");
|
|
116
|
112
|
return;
|
|
117
|
113
|
}
|
|
118
|
114
|
long gatherTime = Preferences.getInstance(this).getGatherTime();
|
|
119
|
|
- if(gatherTime>System.currentTimeMillis()){
|
|
|
115
|
+ if(Preferences.getInstance(this).isTourMode() && gatherTime>System.currentTimeMillis()){
|
|
|
116
|
+ LogHelper.d(TAG,"已经知道是旅行模式,且集合时间已得到,跳过此次集合信息请求");
|
|
120
|
117
|
return;
|
|
121
|
118
|
}
|
|
122
|
119
|
if(fetchTourInfoTask!=null && fetchTourInfoTask.getStatus()== AsyncTask.Status.RUNNING){
|
|
123
|
120
|
return;
|
|
124
|
121
|
}
|
|
125
|
|
- HashMap<String,String> params = new HashMap<String,String>();
|
|
|
122
|
+ LogHelper.d(TAG,"发起获取集合信息的网络请求");
|
|
|
123
|
+ HashMap<String,String> params = new HashMap<>();
|
|
126
|
124
|
String userId = Preferences.getInstance(this).getUserId();
|
|
127
|
125
|
if(userId.length()==0){
|
|
128
|
126
|
return;
|
|
|
|
@@ -131,7 +129,6 @@ public class MyLocationService extends Service implements Handler.Callback{
|
|
131
|
129
|
|
|
132
|
130
|
fetchTourInfoTask = new HttpPostTask(this,params) {
|
|
133
|
131
|
|
|
134
|
|
-
|
|
135
|
132
|
@Override
|
|
136
|
133
|
protected boolean parseResponse(Context context, String response) {
|
|
137
|
134
|
try{
|
|
|
|
@@ -146,7 +143,7 @@ public class MyLocationService extends Service implements Handler.Callback{
|
|
146
|
143
|
String phone = group.getString("phone");
|
|
147
|
144
|
Preferences.getInstance(context).setTourGuidePhone(phone);
|
|
148
|
145
|
String gatherTimeStr = group.getString("gather_at");
|
|
149
|
|
- Preferences.getInstance(context).setGatherTime(TimeUtils.getStandardTimeInMiliSec(gatherTimeStr));
|
|
|
146
|
+ Preferences.getInstance(context).setGatherTime(TimeUtils.getStandardTimeInMiliSec(gatherTimeStr)+30*60*1000);
|
|
150
|
147
|
String endTimeStr = group.getString("ended_at");
|
|
151
|
148
|
Preferences.getInstance(context).setTourEndTime(TimeUtils.getStandardTimeInMiliSec(endTimeStr));
|
|
152
|
149
|
if(group.has("gather_location")){
|
|
|
|
@@ -202,7 +199,7 @@ public class MyLocationService extends Service implements Handler.Callback{
|
|
202
|
199
|
}
|
|
203
|
200
|
double lat = loc.getLatitude();
|
|
204
|
201
|
double lon = loc.getLongitude();
|
|
205
|
|
- LogHelper.dfile("czy","经纬度 lat = "+lat+"lon="+lon+" 位置 ="+loc.getAddress());
|
|
|
202
|
+ LogHelper.d(TAG,"上报经纬度 lat = "+lat+"lon="+lon+" 位置 ="+loc.getAddress());
|
|
206
|
203
|
reportLocationWhenTourMode(lat,lon);
|
|
207
|
204
|
}
|
|
208
|
205
|
};
|
|
|
|
@@ -211,9 +208,11 @@ public class MyLocationService extends Service implements Handler.Callback{
|
|
211
|
208
|
private void startLocation(){
|
|
212
|
209
|
initLocation();
|
|
213
|
210
|
if(Preferences.getInstance(this).isTourMode()){
|
|
|
211
|
+ LogHelper.d(TAG,"当前是旅行模式,开始定位");
|
|
214
|
212
|
locationClient.setLocationOption(locationOption);
|
|
215
|
213
|
locationClient.startLocation();
|
|
216
|
214
|
if(Preferences.getInstance(this).getGatherTime()> System.currentTimeMillis()){
|
|
|
215
|
+ LogHelper.d(TAG,"当前是旅行模式,且存在集合时间,预约下一次定位");
|
|
217
|
216
|
mHandler.sendEmptyMessageDelayed(MSG_START_LOCATION,Preferences.getInstance(this)
|
|
218
|
217
|
.getGatherTime()-System.currentTimeMillis()>LOCATION_PERIOD_CHANGE_DEADLINE ? LOCATION_MAX_PERIOD:LOCATION_MIN_PERIOD);
|
|
219
|
218
|
}
|
|
|
|
@@ -235,7 +234,7 @@ private void reportLocationWhenTourMode(double lat, double lon){
|
|
235
|
234
|
if(locationClient!=null){
|
|
236
|
235
|
locationClient.stopLocation();
|
|
237
|
236
|
}
|
|
238
|
|
- if(lat == lastLat && lon ==lastLon && repeatTime<5){
|
|
|
237
|
+ if(lat == lastLat && lon ==lastLon && repeatTime<2){
|
|
239
|
238
|
repeatTime++;
|
|
240
|
239
|
return;
|
|
241
|
240
|
}
|
|
|
|
@@ -4,7 +4,7 @@ buildscript {
|
|
4
|
4
|
jcenter()
|
|
5
|
5
|
}
|
|
6
|
6
|
dependencies {
|
|
7
|
|
- classpath 'com.android.tools.build:gradle:2.3.0'
|
|
|
7
|
+ classpath 'com.android.tools.build:gradle:2.3.1'
|
|
8
|
8
|
|
|
9
|
9
|
// NOTE: Do not place your application dependencies here; they belong
|
|
10
|
10
|
// in the individual module build.gradle files
|