-3497c5682454e2d1e6749e1163981d835ff9c88aL139">139
|
- }
|
|
140
|
|
- initBanner();
|
|
141
|
|
- return;
|
|
142
|
|
- }
|
|
143
|
124
|
HashMap<String,String> params = new HashMap<String,String>();
|
|
144
|
125
|
String userId = Preferences.getInstance(getActivity()).getUserId();
|
|
145
|
126
|
if(userId.length()==0){
|
|
|
|
@@ -156,8 +137,23 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh
|
|
156
|
137
|
JSONObject json = new JSONObject(response);
|
|
157
|
138
|
int status = json.getInt("status");
|
|
158
|
139
|
if(status == 200){
|
|
159
|
|
- JSONObject info = json.getJSONObject("data");
|
|
160
|
|
-
|
|
|
140
|
+ JSONObject data = json.getJSONObject("data");
|
|
|
141
|
+ String groupId = data.getString("group_id");
|
|
|
142
|
+ if(!TextUtils.isEmpty(groupId)){
|
|
|
143
|
+ Preferences.getInstance(context).setTourMode(true);
|
|
|
144
|
+ JSONObject group = data.getJSONObject("group");
|
|
|
145
|
+ String phone = group.getString("phone");
|
|
|
146
|
+ Preferences.getInstance(context).setTourGuidePhone(phone);
|
|
|
147
|
+ String gatherTimeStr = group.getString("gather_at");
|
|
|
148
|
+ Preferences.getInstance(context).setGatherTime(TimeUtils.getStandardTimeInMiliSec(gatherTimeStr));
|
|
|
149
|
+ JSONObject banners = group.getJSONObject("banners");
|
|
|
150
|
+ images[0] = banners.getString("attentions");
|
|
|
151
|
+ images[1] = banners.getString("schedules");
|
|
|
152
|
+ }else{
|
|
|
153
|
+ Preferences.getInstance(context).setTourMode(false);
|
|
|
154
|
+ Preferences.getInstance(context).setTourGuidePhone("");
|
|
|
155
|
+ Preferences.getInstance(context).setGatherTime(0);
|
|
|
156
|
+ }
|
|
161
|
157
|
return true;
|
|
162
|
158
|
}
|
|
163
|
159
|
}catch (Exception e){
|
|
|
|
@@ -174,6 +170,16 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh
|
|
174
|
170
|
@Override
|
|
175
|
171
|
protected void onPostSuccess(Context context) {
|
|
176
|
172
|
super.onPostSuccess(context);
|
|
|
173
|
+ initBanner();
|
|
|
174
|
+ if(Preferences.getInstance(context).isTourMode()){
|
|
|
175
|
+ Intent intent = new Intent(context, MyLocationService.class);
|
|
|
176
|
+ intent.putExtra("command",MyLocationService.COMMAND_START_LOCATION);
|
|
|
177
|
+ context.startService(intent);
|
|
|
178
|
+ }else{
|
|
|
179
|
+ Intent intent = new Intent(context, MyLocationService.class);
|
|
|
180
|
+ intent.putExtra("command",MyLocationService.COMMAND_DESTROY_LOCATION);
|
|
|
181
|
+ context.startService(intent);
|
|
|
182
|
+ }
|
|
177
|
183
|
}
|
|
178
|
184
|
};
|
|
179
|
185
|
fetchTourInfoTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), UrlContainer.TOUR_INFO_URL);
|
|
|
|
@@ -181,7 +187,12 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh
|
|
181
|
187
|
}
|
|
182
|
188
|
|
|
183
|
189
|
private void initBanner(){
|
|
|
190
|
+ if(TextUtils.isEmpty(images[0]) && TextUtils.isEmpty(images[1])){
|
|
|
191
|
+ banner.setVisibility(View.GONE);
|
|
|
192
|
+ return;
|
|
|
193
|
+ }
|
|
184
|
194
|
banner.setVisibility(View.VISIBLE);
|
|
|
195
|
+
|
|
185
|
196
|
banner.setPages(new CBViewHolderCreator<NetworkImageHolderView>() {
|
|
186
|
197
|
@Override
|
|
187
|
198
|
public NetworkImageHolderView createHolder() {
|
|
|
|
@@ -219,7 +230,6 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh
|
|
219
|
230
|
protected void onPreExecute() {
|
|
220
|
231
|
super.onPreExecute();
|
|
221
|
232
|
scrollListener.setLoading(true);
|
|
222
|
|
-// swipeRefreshLayout.setRefreshing(true);
|
|
223
|
233
|
}
|
|
224
|
234
|
|
|
225
|
235
|
@Override
|
|
|
|
@@ -293,14 +303,13 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh
|
|
293
|
303
|
|
|
294
|
304
|
@Override
|
|
295
|
305
|
public void onItemClick(int position) {
|
|
296
|
|
- new FullScreenImgPopup(getActivity(),bannerBeanList.get(position).url).showPopupWindow();
|
|
|
306
|
+ new FullScreenImgPopup(getActivity(),images[position]).showPopupWindow();
|
|
297
|
307
|
}
|
|
298
|
308
|
|
|
299
|
309
|
public class NetworkImageHolderView implements Holder<String> {
|
|
300
|
310
|
private ImageView imageView;
|
|
301
|
311
|
@Override
|
|
302
|
312
|
public View createView(Context context) {
|
|
303
|
|
- //你可以通过layout文件来创建,也可以像我一样用代码创建,不一定是Image,任何控件都可以进行翻页
|
|
304
|
313
|
imageView = new ImageView(context);
|
|
305
|
314
|
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
|
306
|
315
|
return imageView;
|
|
|
|
@@ -71,13 +71,7 @@ public class MyLocationService extends Service {
|
|
71
|
71
|
destroyLocation();
|
|
72
|
72
|
}
|
|
73
|
73
|
|
|
74
|
|
- /**
|
|
75
|
|
- * 初始化定位
|
|
76
|
|
- *
|
|
77
|
|
- * @since 2.8.0
|
|
78
|
|
- * @author hongming.wang
|
|
79
|
|
- *
|
|
80
|
|
- */
|
|
|
74
|
+
|
|
81
|
75
|
private void initLocation(){
|
|
82
|
76
|
if(locationClient!=null){
|
|
83
|
77
|
return;
|
|
|
|
@@ -91,12 +85,7 @@ public class MyLocationService extends Service {
|
|
91
|
85
|
status = 0;
|
|
92
|
86
|
}
|
|
93
|
87
|
|
|
94
|
|
- /**
|
|
95
|
|
- * 默认的定位参数
|
|
96
|
|
- * @since 2.8.0
|
|
97
|
|
- * @author hongming.wang
|
|
98
|
|
- *
|
|
99
|
|
- */
|
|
|
88
|
+
|
|
100
|
89
|
private AMapLocationClientOption getDefaultOption(){
|
|
101
|
90
|
AMapLocationClientOption mOption = new AMapLocationClientOption();
|
|
102
|
91
|
mOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);//可选,设置定位模式,可选的模式有高精度、仅设备、仅网络。默认为高精度模式
|
|
|
|
@@ -112,9 +101,6 @@ public class MyLocationService extends Service {
|
|
112
|
101
|
return mOption;
|
|
113
|
102
|
}
|
|
114
|
103
|
|
|
115
|
|
- /**
|
|
116
|
|
- * 定位监听
|
|
117
|
|
- */
|
|
118
|
104
|
AMapLocationListener locationListener = new AMapLocationListener() {
|
|
119
|
105
|
@Override
|
|
120
|
106
|
public void onLocationChanged(AMapLocation loc) {
|
|
|
|
@@ -125,13 +111,6 @@ public class MyLocationService extends Service {
|
|
125
|
111
|
};
|
|
126
|
112
|
|
|
127
|
113
|
|
|
128
|
|
- /**
|
|
129
|
|
- * 开始定位
|
|
130
|
|
- *
|
|
131
|
|
- * @since 2.8.0
|
|
132
|
|
- * @author hongming.wang
|
|
133
|
|
- *
|
|
134
|
|
- */
|
|
135
|
114
|
private void startLocation(){
|
|
136
|
115
|
if(status==1){
|
|
137
|
116
|
return;
|
|
|
|
@@ -144,13 +123,6 @@ public class MyLocationService extends Service {
|
|
144
|
123
|
status = 1;
|
|
145
|
124
|
}
|
|
146
|
125
|
|
|
147
|
|
- /**
|
|
148
|
|
- * 停止定位
|
|
149
|
|
- *
|
|
150
|
|
- * @since 2.8.0
|
|
151
|
|
- * @author hongming.wang
|
|
152
|
|
- *
|
|
153
|
|
- */
|
|
154
|
126
|
private void stopLocation(){
|
|
155
|
127
|
if(status == 2){
|
|
156
|
128
|
return;
|
|
|
|
@@ -160,13 +132,6 @@ public class MyLocationService extends Service {
|
|
160
|
132
|
status = 2;
|
|
161
|
133
|
}
|
|
162
|
134
|
|
|
163
|
|
- /**
|
|
164
|
|
- * 销毁定位
|
|
165
|
|
- *
|
|
166
|
|
- * @since 2.8.0
|
|
167
|
|
- * @author hongming.wang
|
|
168
|
|
- *
|
|
169
|
|
- */
|
|
170
|
135
|
private void destroyLocation(){
|
|
171
|
136
|
if (null != locationClient) {
|
|
172
|
137
|
locationClient.onDestroy();
|
|
|
|
@@ -184,7 +149,7 @@ private void reportLocationWhenTourMode(double lat, double lon){
|
|
184
|
149
|
repeatTime = 0;
|
|
185
|
150
|
lastLat = lat;
|
|
186
|
151
|
lastLon = lon;
|
|
187
|
|
- if(Preferences.getInstance(this).isTourMode()|| BuildConfig.DEBUG){
|
|
|
152
|
+ if(Preferences.getInstance(this).isTourMode()){
|
|
188
|
153
|
HashMap<String,String> params = new HashMap<String,String>();
|
|
189
|
154
|
String userId = Preferences.getInstance(this).getUserId();
|
|
190
|
155
|
if(userId.length()==0){
|
|
|
|
@@ -194,7 +159,7 @@ private void reportLocationWhenTourMode(double lat, double lon){
|
|
194
|
159
|
params.put("lon",String.valueOf(lon));
|
|
195
|
160
|
params.put("lat",String.valueOf(lat));
|
|
196
|
161
|
new HttpPostTask(this,params).executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), UrlContainer.GEO_LOCATION_URL);
|
|
197
|
|
- LogHelper.d("czy","reportLocationWhenTourMode lat = "+lat+"lon="+lon);
|
|
|
162
|
+ LogHelper.dfile("czy","上报经纬度位置 lat = "+lat+"lon="+lon);
|
|
198
|
163
|
}
|
|
199
|
164
|
}
|
|
200
|
165
|
|
|
|
|
@@ -84,5 +84,5 @@ public class UrlContainer {
|
|
84
|
84
|
|
|
85
|
85
|
public static final String GEO_LOCATION_URL = HOST_URL+"geo/submit";
|
|
86
|
86
|
//TODO
|
|
87
|
|
- public static final String TOUR_INFO_URL = HOST_URL +"tg/info";
|
|
|
87
|
+ public static final String TOUR_INFO_URL = HOST_URL +"pai2/tginfo";
|
|
88
|
88
|
}
|
|
|
|
@@ -137,7 +137,7 @@ class FileLog {
|
|
137
|
137
|
|
|
138
|
138
|
public FileLog() throws RuntimeException, IOException {
|
|
139
|
139
|
File sdcard = new File(SD_CARD);
|
|
140
|
|
- String fileName = "上传测试"+new SimpleDateFormat("MM-dd-HH-mm").format(new Date()) + ".log";
|
|
|
140
|
+ String fileName = "paiai-"+new SimpleDateFormat("MM-dd-HH-mm").format(new Date()) + ".log";
|
|
141
|
141
|
File logFile = new File(LOG_PATH+fileName);
|
|
142
|
142
|
|
|
143
|
143
|
if (!sdcard.exists()) {
|
|
|
|
@@ -1,6 +1,7 @@
|
|
1
|
1
|
package com.android.common.utils;
|
|
2
|
2
|
|
|
3
|
3
|
import java.text.DateFormat;
|
|
|
4
|
+import java.text.ParseException;
|
|
4
|
5
|
import java.text.SimpleDateFormat;
|
|
5
|
6
|
import java.util.Date;
|
|
6
|
7
|
import java.util.TimeZone;
|
|
|
|
@@ -53,6 +54,17 @@ public class TimeUtils {
|
|
53
|
54
|
return utc2Local(utcTime, "yyyy-MM-dd'T'HH:mm:ss'Z'", "yyyy-MM-dd HH:mm");
|
|
54
|
55
|
}
|
|
55
|
56
|
|
|
|
57
|
+ public static long getStandardTimeInMiliSec(String utcTime){
|
|
|
58
|
+ long time = 0;
|
|
|
59
|
+ String standardTimeStr = getStandardTime(utcTime);
|
|
|
60
|
+ try {
|
|
|
61
|
+ Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(standardTimeStr);
|
|
|
62
|
+ time = date.getTime();
|
|
|
63
|
+ } catch (ParseException e) {
|
|
|
64
|
+ e.printStackTrace();
|
|
|
65
|
+ }
|
|
|
66
|
+ return time;
|
|
|
67
|
+ }
|
|
56
|
68
|
|
|
57
|
69
|
public static String getFormattedTime(String utcTime) {
|
|
58
|
70
|
String formattedTime = utc2Local(utcTime, "yyyy-MM-dd'T'HH:mm:ss'Z'", "yyyy-MM-dd HH:mm");
|