|
|
@ -0,0 +1,567 @@
|
|
|
1
|
package com.electric.chargingpile.activity;
|
|
|
2
|
|
|
|
3
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
4
|
|
|
|
5
|
import android.content.Context;
|
|
|
6
|
import android.content.Intent;
|
|
|
7
|
import android.content.pm.PackageInfo;
|
|
|
8
|
import android.content.pm.PackageManager;
|
|
|
9
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
10
|
import android.os.Bundle;
|
|
|
11
|
import android.text.Html;
|
|
|
12
|
import android.view.Gravity;
|
|
|
13
|
import android.view.LayoutInflater;
|
|
|
14
|
import android.view.View;
|
|
|
15
|
import android.view.ViewGroup;
|
|
|
16
|
import android.widget.AdapterView;
|
|
|
17
|
import android.widget.BaseAdapter;
|
|
|
18
|
import android.widget.Button;
|
|
|
19
|
import android.widget.ImageView;
|
|
|
20
|
import android.widget.LinearLayout;
|
|
|
21
|
import android.widget.ListView;
|
|
|
22
|
import android.widget.PopupWindow;
|
|
|
23
|
import android.widget.TextView;
|
|
|
24
|
import android.widget.Toast;
|
|
|
25
|
|
|
|
26
|
import com.amap.api.maps.model.LatLng;
|
|
|
27
|
import com.electric.chargingpile.R;
|
|
|
28
|
import com.electric.chargingpile.application.MainApplication;
|
|
|
29
|
import com.electric.chargingpile.data.PileData;
|
|
|
30
|
import com.electric.chargingpile.data.RecommendZhan;
|
|
|
31
|
import com.electric.chargingpile.manager.ProfileManager;
|
|
|
32
|
import com.electric.chargingpile.util.JsonUtils;
|
|
|
33
|
|
|
|
34
|
import java.net.URISyntaxException;
|
|
|
35
|
import java.util.ArrayList;
|
|
|
36
|
import java.util.Calendar;
|
|
|
37
|
import java.util.HashMap;
|
|
|
38
|
import java.util.List;
|
|
|
39
|
import java.util.Map;
|
|
|
40
|
|
|
|
41
|
public class SearchAllActivity extends AppCompatActivity {
|
|
|
42
|
|
|
|
43
|
private View popupWindowView;
|
|
|
44
|
private PopupWindow popupWindow;
|
|
|
45
|
private Button cancleButton;
|
|
|
46
|
private TextView tvOne, tvTwo, tvThree;
|
|
|
47
|
private Double bd_lon, bd_lat, bd_jing, bd_wei;
|
|
|
48
|
private String gd_jing, gd_wei;
|
|
|
49
|
|
|
|
50
|
@Override
|
|
|
51
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
52
|
super.onCreate(savedInstanceState);
|
|
|
53
|
setContentView(R.layout.activity_search_all);
|
|
|
54
|
initView();
|
|
|
55
|
}
|
|
|
56
|
|
|
|
57
|
private void initView() {
|
|
|
58
|
String title = getIntent().getStringExtra("title");
|
|
|
59
|
TextView iv_title = findViewById(R.id.iv_title);
|
|
|
60
|
iv_title.setText(title);
|
|
|
61
|
|
|
|
62
|
List<Map<String, String>> addressAllList;
|
|
|
63
|
List<RecommendZhan> pointAllList;
|
|
|
64
|
if ("全部目的地".equals(title)) {
|
|
|
65
|
ArrayList arrayList = getIntent().getExtras().getParcelableArrayList("list");
|
|
|
66
|
addressAllList = (List<Map<String, String>>) arrayList.get(0);
|
|
|
67
|
pointAllList = new ArrayList<>();
|
|
|
68
|
} else {
|
|
|
69
|
addressAllList = new ArrayList<>();
|
|
|
70
|
String data = getIntent().getStringExtra("data");
|
|
|
71
|
pointAllList = JsonUtils.parseToObjectList(data, RecommendZhan.class);
|
|
|
72
|
}
|
|
|
73
|
|
|
|
74
|
|
|
|
75
|
ListView lv_search_list = findViewById(R.id.lv_search_list);
|
|
|
76
|
lv_search_list.setDividerHeight(0);
|
|
|
77
|
|
|
|
78
|
SearchAdapter searchAdapter = new SearchAdapter(this, addressAllList, pointAllList);
|
|
|
79
|
lv_search_list.setAdapter(searchAdapter);
|
|
|
80
|
|
|
|
81
|
lv_search_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
82
|
@Override
|
|
|
83
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
84
|
Intent intent = new Intent();
|
|
|
85
|
intent.setClass(getApplicationContext(), MainMapActivity.class);
|
|
|
86
|
intent.putExtra("from", "search_all_activity");
|
|
|
87
|
intent.putExtra("zhan_name", addressAllList.get(position).get("name"));
|
|
|
88
|
intent.putExtra("jing", addressAllList.get(position).get("jing"));
|
|
|
89
|
intent.putExtra("wei", addressAllList.get(position).get("wei"));
|
|
|
90
|
ProfileManager.getInstance().setSearchAddress(getApplicationContext(), addressAllList.get(position).get("name"));
|
|
|
91
|
startActivity(intent);
|
|
|
92
|
}
|
|
|
93
|
});
|
|
|
94
|
|
|
|
95
|
}
|
|
|
96
|
|
|
|
97
|
public class SearchAdapter extends BaseAdapter {
|
|
|
98
|
private Context context;
|
|
|
99
|
private List<Map<String, String>> aList;
|
|
|
100
|
private List<RecommendZhan> pList;
|
|
|
101
|
|
|
|
102
|
public SearchAdapter(Context context, List<Map<String, String>> list, List<RecommendZhan> pointList) {
|
|
|
103
|
this.context = context;
|
|
|
104
|
this.aList = list;
|
|
|
105
|
this.pList = pointList;
|
|
|
106
|
}
|
|
|
107
|
|
|
|
108
|
@Override
|
|
|
109
|
public int getCount() {
|
|
|
110
|
return aList.size() + pList.size();
|
|
|
111
|
}
|
|
|
112
|
|
|
|
113
|
@Override
|
|
|
114
|
public Object getItem(int position) {
|
|
|
115
|
|
|
|
116
|
if (aList.size() == 0) {
|
|
|
117
|
return pList.get(position);
|
|
|
118
|
} else {
|
|
|
119
|
return aList.get(position);
|
|
|
120
|
}
|
|
|
121
|
}
|
|
|
122
|
|
|
|
123
|
@Override
|
|
|
124
|
public long getItemId(int position) {
|
|
|
125
|
return position;
|
|
|
126
|
}
|
|
|
127
|
|
|
|
128
|
@Override
|
|
|
129
|
public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
130
|
|
|
|
131
|
ViewHolder viewHolder = null;
|
|
|
132
|
if (convertView == null) {
|
|
|
133
|
convertView = LayoutInflater.from(context).inflate(R.layout.item_search, null);
|
|
|
134
|
viewHolder = new ViewHolder();
|
|
|
135
|
|
|
|
136
|
viewHolder.address_item = convertView.findViewById(R.id.address_item);
|
|
|
137
|
viewHolder.point_item = convertView.findViewById(R.id.point_item);
|
|
|
138
|
|
|
|
139
|
viewHolder.name = convertView.findViewById(R.id.search_name);
|
|
|
140
|
viewHolder.address = convertView.findViewById(R.id.search_address);
|
|
|
141
|
viewHolder.address_header_title = convertView.findViewById(R.id.address_header_title);
|
|
|
142
|
viewHolder.query_all_addresses = convertView.findViewById(R.id.query_all_addresses);
|
|
|
143
|
|
|
|
144
|
viewHolder.point_header_title = convertView.findViewById(R.id.point_header_title);
|
|
|
145
|
viewHolder.query_all_points = convertView.findViewById(R.id.query_all_points);
|
|
|
146
|
viewHolder.zhan_name = convertView.findViewById(R.id.zhan_name);
|
|
|
147
|
viewHolder.red_paper_bag = convertView.findViewById(R.id.red_paper_bag);
|
|
|
148
|
viewHolder.score_img = convertView.findViewById(R.id.score_img);
|
|
|
149
|
viewHolder.score_text = convertView.findViewById(R.id.score_text);
|
|
|
150
|
viewHolder.distance = convertView.findViewById(R.id.distance);
|
|
|
151
|
viewHolder.zongjia_container = convertView.findViewById(R.id.zongjia_container);
|
|
|
152
|
viewHolder.zongjia = convertView.findViewById(R.id.zongjia);
|
|
|
153
|
viewHolder.charge_record_cnt = convertView.findViewById(R.id.charge_record_cnt);
|
|
|
154
|
viewHolder.comment_cnt = convertView.findViewById(R.id.comment_cnt);
|
|
|
155
|
viewHolder.times_line = convertView.findViewById(R.id.times_line);
|
|
|
156
|
viewHolder.fenshi_info_textview = convertView.findViewById(R.id.fenshi_info_textview);
|
|
|
157
|
viewHolder.iv_label_public = convertView.findViewById(R.id.iv_label_public);
|
|
|
158
|
viewHolder.iv_label_ground = convertView.findViewById(R.id.iv_label_ground);
|
|
|
159
|
viewHolder.iv_label_free_park = convertView.findViewById(R.id.iv_label_free_park);
|
|
|
160
|
viewHolder.payment_method = convertView.findViewById(R.id.payment_method);
|
|
|
161
|
viewHolder.recommend_nav = convertView.findViewById(R.id.recommend_nav);
|
|
|
162
|
viewHolder.window_tv_fast_free_label = convertView.findViewById(R.id.window_tv_fast_free_label);
|
|
|
163
|
viewHolder.window_tv_fast_free_num = convertView.findViewById(R.id.window_tv_fast_free_num);
|
|
|
164
|
viewHolder.window_tv_fast_total_num = convertView.findViewById(R.id.window_tv_fast_total_num);
|
|
|
165
|
viewHolder.window_tv_slow_free_label = convertView.findViewById(R.id.window_tv_slow_free_label);
|
|
|
166
|
viewHolder.window_tv_slow_free_num = convertView.findViewById(R.id.window_tv_slow_free_num);
|
|
|
167
|
viewHolder.window_tv_slow_total_num = convertView.findViewById(R.id.window_tv_slow_total_num);
|
|
|
168
|
|
|
|
169
|
convertView.setTag(viewHolder);
|
|
|
170
|
} else {
|
|
|
171
|
viewHolder = (ViewHolder) convertView.getTag();
|
|
|
172
|
}
|
|
|
173
|
|
|
|
174
|
if (aList.size() != 0) {
|
|
|
175
|
showAddressView(viewHolder, aList.get(position), position);
|
|
|
176
|
} else {
|
|
|
177
|
RecommendZhan point = pList.get(position - aList.size());
|
|
|
178
|
showPointView(viewHolder, point, position);
|
|
|
179
|
}
|
|
|
180
|
|
|
|
181
|
return convertView;
|
|
|
182
|
}
|
|
|
183
|
|
|
|
184
|
class ViewHolder {
|
|
|
185
|
LinearLayout address_item, point_item, zongjia_container;
|
|
|
186
|
|
|
|
187
|
TextView name, address, address_header_title, query_all_addresses;
|
|
|
188
|
|
|
|
189
|
TextView point_header_title, query_all_points, zhan_name, score_text, distance, zongjia,
|
|
|
190
|
charge_record_cnt, comment_cnt, fenshi_info_textview, iv_label_public, iv_label_ground,
|
|
|
191
|
iv_label_free_park, payment_method, window_tv_fast_free_label, window_tv_fast_free_num, window_tv_fast_total_num,
|
|
|
192
|
window_tv_slow_free_label, window_tv_slow_free_num, window_tv_slow_total_num;
|
|
|
193
|
ImageView red_paper_bag, score_img;
|
|
|
194
|
View times_line;
|
|
|
195
|
Button recommend_nav;
|
|
|
196
|
|
|
|
197
|
}
|
|
|
198
|
|
|
|
199
|
private void showAddressView(ViewHolder viewHolder, Map<String, String> item, int position) {
|
|
|
200
|
viewHolder.address_item.setVisibility(View.VISIBLE);
|
|
|
201
|
viewHolder.point_item.setVisibility(View.GONE);
|
|
|
202
|
viewHolder.address_header_title.setVisibility(View.GONE);
|
|
|
203
|
|
|
|
204
|
viewHolder.name.setText(item.get("name"));
|
|
|
205
|
viewHolder.address.setText(item.get("address"));
|
|
|
206
|
viewHolder.query_all_addresses.setVisibility(View.GONE);
|
|
|
207
|
}
|
|
|
208
|
|
|
|
209
|
private void showPointView(ViewHolder viewHolder, RecommendZhan point, int position) {
|
|
|
210
|
|
|
|
211
|
viewHolder.point_item.setOnClickListener(new View.OnClickListener() {
|
|
|
212
|
@Override
|
|
|
213
|
public void onClick(View v) {
|
|
|
214
|
Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class);
|
|
|
215
|
intent.putExtra("zhan_id", point.getId());
|
|
|
216
|
startActivity(intent);
|
|
|
217
|
}
|
|
|
218
|
});
|
|
|
219
|
viewHolder.address_item.setVisibility(View.GONE);
|
|
|
220
|
viewHolder.point_item.setVisibility(View.VISIBLE);
|
|
|
221
|
viewHolder.point_header_title.setVisibility(View.GONE);
|
|
|
222
|
viewHolder.query_all_points.setVisibility(View.GONE);
|
|
|
223
|
viewHolder.zhan_name.setText(point.getZhan_name());
|
|
|
224
|
|
|
|
225
|
if ("1".equals(point.getOwn_pay())) {
|
|
|
226
|
viewHolder.red_paper_bag.setVisibility(View.VISIBLE);
|
|
|
227
|
} else {
|
|
|
228
|
viewHolder.red_paper_bag.setVisibility(View.GONE);
|
|
|
229
|
}
|
|
|
230
|
|
|
|
231
|
viewHolder.red_paper_bag.setOnClickListener(new View.OnClickListener() {
|
|
|
232
|
@Override
|
|
|
233
|
public void onClick(View v) {
|
|
|
234
|
Intent intent_example = new Intent(getApplicationContext(), ExampleActivity.class);
|
|
|
235
|
intent_example.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
|
|
236
|
startActivity(intent_example);
|
|
|
237
|
overridePendingTransition(0, 0);
|
|
|
238
|
}
|
|
|
239
|
});
|
|
|
240
|
|
|
|
241
|
showStarInfoView(viewHolder, point);
|
|
|
242
|
|
|
|
243
|
if ("0m".equals(point.getDistance())) {
|
|
|
244
|
viewHolder.distance.setText("未知");
|
|
|
245
|
} else {
|
|
|
246
|
viewHolder.distance.setText(point.getDistance());
|
|
|
247
|
}
|
|
|
248
|
|
|
|
249
|
if (point.getZongjia() == 0) {
|
|
|
250
|
viewHolder.zongjia_container.setVisibility(View.GONE);
|
|
|
251
|
} else {
|
|
|
252
|
viewHolder.zongjia_container.setVisibility(View.VISIBLE);
|
|
|
253
|
viewHolder.zongjia.setText(String.format("%.2f", point.getZongjia()));
|
|
|
254
|
}
|
|
|
255
|
|
|
|
256
|
if (point.getComment_cnt() == 0 || point.getCharge_record_cnt() == 0 && point.getComment_cnt() == 0) {
|
|
|
257
|
viewHolder.times_line.setVisibility(View.GONE);
|
|
|
258
|
} else {
|
|
|
259
|
viewHolder.times_line.setVisibility(View.VISIBLE);
|
|
|
260
|
}
|
|
|
261
|
|
|
|
262
|
if (point.getCharge_record_cnt() == 0) {
|
|
|
263
|
viewHolder.charge_record_cnt.setVisibility(View.GONE);
|
|
|
264
|
} else {
|
|
|
265
|
viewHolder.charge_record_cnt.setVisibility(View.VISIBLE);
|
|
|
266
|
|
|
|
267
|
if (point.getCharge_record_cnt() < 1000) {
|
|
|
268
|
viewHolder.charge_record_cnt.setText(point.getCharge_record_cnt() + "次充电成功");
|
|
|
269
|
} else if (point.getCharge_record_cnt() < 10000) {
|
|
|
270
|
viewHolder.charge_record_cnt.setText(point.getCharge_record_cnt() / 1000 + "k+次充电成功");
|
|
|
271
|
} else {
|
|
|
272
|
viewHolder.charge_record_cnt.setText(point.getCharge_record_cnt() / 10000 + "w+次充电成功");
|
|
|
273
|
}
|
|
|
274
|
|
|
|
275
|
}
|
|
|
276
|
|
|
|
277
|
if (point.getComment_cnt() == 0) {
|
|
|
278
|
viewHolder.comment_cnt.setVisibility(View.GONE);
|
|
|
279
|
} else {
|
|
|
280
|
viewHolder.comment_cnt.setVisibility(View.VISIBLE);
|
|
|
281
|
if (point.getComment_cnt() < 1000) {
|
|
|
282
|
viewHolder.comment_cnt.setText(point.getComment_cnt() + "次评论");
|
|
|
283
|
} else if (point.getComment_cnt() < 10000) {
|
|
|
284
|
viewHolder.comment_cnt.setText(point.getComment_cnt() / 1000 + "k+次评论");
|
|
|
285
|
} else {
|
|
|
286
|
viewHolder.comment_cnt.setText(point.getComment_cnt() / 10000 + "w+次评论");
|
|
|
287
|
}
|
|
|
288
|
}
|
|
|
289
|
|
|
|
290
|
if ("1".equals(point.getFenshi_is())) {
|
|
|
291
|
viewHolder.fenshi_info_textview.setText("");
|
|
|
292
|
ArrayList<PileData.FenshiInfoBean> fenshiList = (ArrayList<PileData.FenshiInfoBean>) JsonUtils.parseToObjectList(point.getFenshi_info(), PileData.FenshiInfoBean.class);
|
|
|
293
|
Calendar calendar = Calendar.getInstance();
|
|
|
294
|
int hours = calendar.get(Calendar.HOUR_OF_DAY);
|
|
|
295
|
int minutes = calendar.get(Calendar.MINUTE);
|
|
|
296
|
int totalMinutes = hours * 60 + minutes;
|
|
|
297
|
|
|
|
298
|
for (PileData.FenshiInfoBean bean : fenshiList) {
|
|
|
299
|
if (bean.getStartTotalMinutes() > totalMinutes) {
|
|
|
300
|
double service_free = 0;
|
|
|
301
|
double charge_free = 0;
|
|
|
302
|
try {
|
|
|
303
|
service_free = Double.valueOf(bean.getService_free());
|
|
|
304
|
charge_free = Double.valueOf(bean.getCharge_free());
|
|
|
305
|
} catch (Exception e) {
|
|
|
306
|
e.printStackTrace();
|
|
|
307
|
}
|
|
|
308
|
viewHolder.fenshi_info_textview.setText(String.format("%s开始 %.2f元/度", bean.getStart(), service_free + charge_free));
|
|
|
309
|
break;
|
|
|
310
|
}
|
|
|
311
|
}
|
|
|
312
|
} else {
|
|
|
313
|
viewHolder.fenshi_info_textview.setText("");
|
|
|
314
|
}
|
|
|
315
|
|
|
|
316
|
viewHolder.iv_label_public.setText(point.getBelong_attribute());
|
|
|
317
|
viewHolder.iv_label_ground.setText("0".equals(point.getPark_location()) ? "地下" : "地上");
|
|
|
318
|
viewHolder.iv_label_free_park.setVisibility(point.getStop_cost().contains("免费") ? View.VISIBLE : View.GONE);
|
|
|
319
|
|
|
|
320
|
if ("1".equals(point.getOwn_pay())) {
|
|
|
321
|
viewHolder.payment_method.setText("可使用本APP扫码支付");
|
|
|
322
|
} else {
|
|
|
323
|
if ("".equals(point.getCharge_cost_way2())) {
|
|
|
324
|
viewHolder.payment_method.setText("暂无");
|
|
|
325
|
} else {
|
|
|
326
|
viewHolder.payment_method.setText(point.getCharge_cost_way2());
|
|
|
327
|
}
|
|
|
328
|
}
|
|
|
329
|
|
|
|
330
|
viewHolder.recommend_nav.setOnClickListener(new View.OnClickListener() {
|
|
|
331
|
@Override
|
|
|
332
|
public void onClick(View v) {
|
|
|
333
|
recommendNav(point);
|
|
|
334
|
}
|
|
|
335
|
});
|
|
|
336
|
|
|
|
337
|
if (point.getFast_able_num() == null && point.getSlow_able_num() == null) {
|
|
|
338
|
viewHolder.window_tv_fast_free_label.setVisibility(View.GONE);
|
|
|
339
|
viewHolder.window_tv_fast_total_num.setVisibility(View.GONE);
|
|
|
340
|
|
|
|
341
|
viewHolder.window_tv_slow_free_label.setVisibility(View.GONE);
|
|
|
342
|
viewHolder.window_tv_slow_total_num.setVisibility(View.GONE);
|
|
|
343
|
|
|
|
344
|
viewHolder.window_tv_fast_free_num.setText("".equals(point.getFast_num()) ? "0" : point.getFast_num());
|
|
|
345
|
viewHolder.window_tv_slow_free_num.setText("".equals(point.getSlow_num()) ? "0" : point.getSlow_num());
|
|
|
346
|
} else {
|
|
|
347
|
viewHolder.window_tv_fast_free_label.setVisibility(View.VISIBLE);
|
|
|
348
|
viewHolder.window_tv_fast_total_num.setVisibility(View.VISIBLE);
|
|
|
349
|
|
|
|
350
|
viewHolder.window_tv_slow_free_label.setVisibility(View.VISIBLE);
|
|
|
351
|
viewHolder.window_tv_slow_total_num.setVisibility(View.VISIBLE);
|
|
|
352
|
|
|
|
353
|
viewHolder.window_tv_fast_free_num.setText(point.getFast_able_num());
|
|
|
354
|
viewHolder.window_tv_slow_free_num.setText(point.getSlow_able_num());
|
|
|
355
|
viewHolder.window_tv_fast_total_num.setText("".equals(point.getFast_num()) ? "0" : "/" + point.getFast_num());
|
|
|
356
|
viewHolder.window_tv_slow_total_num.setText("".equals(point.getSlow_num()) ? "0" : "/" + point.getSlow_num());
|
|
|
357
|
}
|
|
|
358
|
|
|
|
359
|
|
|
|
360
|
}
|
|
|
361
|
|
|
|
362
|
private void showStarInfoView(ViewHolder viewHolder, RecommendZhan point) {
|
|
|
363
|
String starStr = point.getStar();
|
|
|
364
|
double star = 0.0;
|
|
|
365
|
try {
|
|
|
366
|
star = Double.parseDouble(starStr);
|
|
|
367
|
} catch (NumberFormatException e) {
|
|
|
368
|
e.printStackTrace();
|
|
|
369
|
}
|
|
|
370
|
|
|
|
371
|
viewHolder.score_text.setText(String.format("%.1f分", star));
|
|
|
372
|
if (star == 0) {
|
|
|
373
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_0xing));
|
|
|
374
|
viewHolder.score_text.setText("暂无评分");
|
|
|
375
|
} else if (star > 0 && star < 1) {
|
|
|
376
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_05xing));
|
|
|
377
|
} else if (star >= 1 && star < 1.5) {
|
|
|
378
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_1xing));
|
|
|
379
|
} else if (star >= 1.5 && star < 2) {
|
|
|
380
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_15xing));
|
|
|
381
|
} else if (star >= 2 && star < 2.5) {
|
|
|
382
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_2xing));
|
|
|
383
|
} else if (star >= 2.5 && star < 3) {
|
|
|
384
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_25xing));
|
|
|
385
|
} else if (star >= 3 && star < 3.5) {
|
|
|
386
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_3xing));
|
|
|
387
|
} else if (star >= 3.5 && star < 4) {
|
|
|
388
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_35xing));
|
|
|
389
|
} else if (star >= 4 && star < 4.5) {
|
|
|
390
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_4xing));
|
|
|
391
|
} else if (star >= 4.5 && star < 5) {
|
|
|
392
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_45xing));
|
|
|
393
|
} else {
|
|
|
394
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_5xing));
|
|
|
395
|
}
|
|
|
396
|
}
|
|
|
397
|
}
|
|
|
398
|
|
|
|
399
|
private void getGaode(Double jing, Double wei) {
|
|
|
400
|
double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
|
|
401
|
double gg_lon;
|
|
|
402
|
double gg_lat;
|
|
|
403
|
double x = jing - 0.0065, y = wei - 0.006;
|
|
|
404
|
double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
|
|
|
405
|
double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
|
|
|
406
|
gg_lon = z * Math.cos(theta);
|
|
|
407
|
gd_jing = String.valueOf(gg_lon);
|
|
|
408
|
gg_lat = z * Math.sin(theta);
|
|
|
409
|
gd_wei = String.valueOf(gg_lat);
|
|
|
410
|
}
|
|
|
411
|
|
|
|
412
|
private void recommendNav(RecommendZhan rz) {
|
|
|
413
|
|
|
|
414
|
String wei = rz.getPoi_wei().trim();
|
|
|
415
|
String jing = rz.getPoi_jing().trim();
|
|
|
416
|
int position_jing = jing.length() - jing.indexOf(".") - 1;
|
|
|
417
|
int position_wei = wei.length() - wei.indexOf(".") - 1;
|
|
|
418
|
final LatLng ll;
|
|
|
419
|
if (position_jing > 13 || position_wei > 13) {
|
|
|
420
|
ll = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing));
|
|
|
421
|
} else {
|
|
|
422
|
double dwei = Double.parseDouble(wei);
|
|
|
423
|
double djing = Double.parseDouble(jing);
|
|
|
424
|
getGaode(djing, dwei);
|
|
|
425
|
ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
|
|
|
426
|
}
|
|
|
427
|
|
|
|
428
|
if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") &&
|
|
|
429
|
!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
|
|
|
430
|
Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
|
|
|
431
|
intent.putExtra("start_jing", MainApplication.center.longitude + "");
|
|
|
432
|
intent.putExtra("start_wei", MainApplication.center.latitude + "");
|
|
|
433
|
intent.putExtra("stop_jing", ll.longitude + "");
|
|
|
434
|
intent.putExtra("stop_wei", ll.latitude + "");
|
|
|
435
|
startActivity(intent);
|
|
|
436
|
} else {
|
|
|
437
|
if (MainApplication.center != null) {
|
|
|
438
|
LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
439
|
popupWindowView = inflater1.inflate(R.layout.item_selectmap, null);
|
|
|
440
|
popupWindow = new PopupWindow(popupWindowView,
|
|
|
441
|
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT,
|
|
|
442
|
true);
|
|
|
443
|
popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
444
|
// 设置PopupWindow的弹出和消失效果
|
|
|
445
|
popupWindow.setAnimationStyle(R.style.popupAnimation);
|
|
|
446
|
LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo);
|
|
|
447
|
if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
|
|
|
448
|
ll_tvTwo.setVisibility(View.GONE);
|
|
|
449
|
}
|
|
|
450
|
LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne);
|
|
|
451
|
if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) {
|
|
|
452
|
ll_tvOne.setVisibility(View.GONE);
|
|
|
453
|
}
|
|
|
454
|
cancleButton = (Button) popupWindowView.findViewById(R.id.cancleButton);
|
|
|
455
|
cancleButton.setOnClickListener(new View.OnClickListener() {
|
|
|
456
|
@Override
|
|
|
457
|
public void onClick(View view) {
|
|
|
458
|
popupWindow.dismiss();
|
|
|
459
|
}
|
|
|
460
|
});
|
|
|
461
|
tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree);
|
|
|
462
|
tvThree.setOnClickListener(new View.OnClickListener() {
|
|
|
463
|
@Override
|
|
|
464
|
public void onClick(View v) {
|
|
|
465
|
Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
|
|
|
466
|
intent.putExtra("start_jing", MainApplication.center.longitude + "");
|
|
|
467
|
intent.putExtra("start_wei", MainApplication.center.latitude + "");
|
|
|
468
|
intent.putExtra("stop_jing", ll.longitude + "");
|
|
|
469
|
intent.putExtra("stop_wei", ll.latitude + "");
|
|
|
470
|
startActivity(intent);
|
|
|
471
|
popupWindow.dismiss();
|
|
|
472
|
}
|
|
|
473
|
});
|
|
|
474
|
tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne);
|
|
|
475
|
tvOne.setOnClickListener(new View.OnClickListener() {
|
|
|
476
|
@Override
|
|
|
477
|
public void onClick(View view) {
|
|
|
478
|
Intent intent = null;
|
|
|
479
|
int position_jing = rz.getPoi_jing().length() - rz.getPoi_jing().indexOf(".") - 1;
|
|
|
480
|
int position_wei = rz.getPoi_wei().length() - rz.getPoi_wei().indexOf(".") - 1;
|
|
|
481
|
if (position_jing > 13 || position_wei > 13) {
|
|
|
482
|
getBaidu1(Double.parseDouble(rz.getPoi_jing()), Double.parseDouble(rz.getPoi_wei()));
|
|
|
483
|
} else {
|
|
|
484
|
bd_jing = Double.parseDouble(rz.getPoi_jing());
|
|
|
485
|
bd_wei = Double.parseDouble(rz.getPoi_wei());
|
|
|
486
|
}
|
|
|
487
|
getBaidu(MainApplication.center.longitude, MainApplication.center.latitude);
|
|
|
488
|
try {
|
|
|
489
|
String s = "intent://map/direction?" +
|
|
|
490
|
"origin=" + bd_lat + "," + bd_lon + "&" +
|
|
|
491
|
"destination=" + bd_wei + "," + bd_jing +
|
|
|
492
|
"&mode=driving&" +
|
|
|
493
|
"src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end";
|
|
|
494
|
intent = Intent.getIntent(s);
|
|
|
495
|
} catch (URISyntaxException e) {
|
|
|
496
|
e.printStackTrace();
|
|
|
497
|
}
|
|
|
498
|
startActivity(intent);
|
|
|
499
|
popupWindow.dismiss();
|
|
|
500
|
}
|
|
|
501
|
});
|
|
|
502
|
tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
|
|
|
503
|
tvTwo.setOnClickListener(new View.OnClickListener() {
|
|
|
504
|
@Override
|
|
|
505
|
public void onClick(View view) {
|
|
|
506
|
try {
|
|
|
507
|
Intent intent4 = new Intent("android.intent.action.VIEW",
|
|
|
508
|
android.net.Uri.parse("androidamap://route?sourceApplication=amap&slat=" + MainApplication.center.latitude + "&slon=" + MainApplication.center.longitude + "&sname=我的位置&dlat=" + ll.latitude + "&dlon=" + ll.longitude + "&dname=" + rz.getZhan_name() + "&dev=0&m=0&t=2"));
|
|
|
509
|
intent4.setPackage("com.autonavi.minimap");
|
|
|
510
|
startActivity(intent4);
|
|
|
511
|
popupWindow.dismiss();
|
|
|
512
|
} catch (Exception e) {
|
|
|
513
|
e.printStackTrace();
|
|
|
514
|
Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show();
|
|
|
515
|
}
|
|
|
516
|
|
|
|
517
|
}
|
|
|
518
|
});
|
|
|
519
|
popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
|
|
|
520
|
} else {
|
|
|
521
|
Toast.makeText(getApplication(),
|
|
|
522
|
"没有定位到您的当前位置", Toast.LENGTH_SHORT)
|
|
|
523
|
.show();
|
|
|
524
|
}
|
|
|
525
|
}
|
|
|
526
|
|
|
|
527
|
}
|
|
|
528
|
|
|
|
529
|
private boolean isAvilible(Context context, String packageName) {
|
|
|
530
|
//获取packagemanager
|
|
|
531
|
final PackageManager packageManager = context.getPackageManager();
|
|
|
532
|
//获取所有已安装程序的包信息
|
|
|
533
|
List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
|
|
|
534
|
//用于存储所有已安装程序的包名
|
|
|
535
|
List<String> packageNames = new ArrayList<String>();
|
|
|
536
|
//从pinfo中将包名字逐一取出,压入pName list中
|
|
|
537
|
if (packageInfos != null) {
|
|
|
538
|
for (int i = 0; i < packageInfos.size(); i++) {
|
|
|
539
|
String packName = packageInfos.get(i).packageName;
|
|
|
540
|
packageNames.add(packName);
|
|
|
541
|
}
|
|
|
542
|
}
|
|
|
543
|
//判断packageNames中是否有目标程序的包名,有TRUE,没有FALSE
|
|
|
544
|
return packageNames.contains(packageName);
|
|
|
545
|
}
|
|
|
546
|
|
|
|
547
|
private void getBaidu(Double jing, Double wei) {
|
|
|
548
|
double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
|
|
549
|
double x = jing;
|
|
|
550
|
double y = wei;
|
|
|
551
|
double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
|
|
552
|
double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
|
|
553
|
bd_lon = z * Math.cos(theta) + 0.0065;
|
|
|
554
|
bd_lat = z * Math.sin(theta) + 0.006;
|
|
|
555
|
}
|
|
|
556
|
|
|
|
557
|
private void getBaidu1(Double jing, Double wei) {
|
|
|
558
|
double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
|
|
559
|
double x = jing;
|
|
|
560
|
double y = wei;
|
|
|
561
|
double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
|
|
562
|
double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
|
|
563
|
bd_jing = z * Math.cos(theta) + 0.0065;
|
|
|
564
|
bd_wei = z * Math.sin(theta) + 0.006;
|
|
|
565
|
}
|
|
|
566
|
|
|
|
567
|
}
|