|
@ -5,7 +5,10 @@ import android.content.ContentValues;
|
5
|
5
|
import android.content.Context;
|
6
|
6
|
import android.content.DialogInterface;
|
7
|
7
|
import android.content.Intent;
|
|
8
|
import android.content.pm.PackageInfo;
|
|
9
|
import android.content.pm.PackageManager;
|
8
|
10
|
import android.database.Cursor;
|
|
11
|
import android.graphics.drawable.BitmapDrawable;
|
9
|
12
|
import android.os.Bundle;
|
10
|
13
|
import android.os.Handler;
|
11
|
14
|
|
|
@ -15,6 +18,7 @@ import android.text.Editable;
|
15
|
18
|
import android.text.Html;
|
16
|
19
|
import android.text.TextUtils;
|
17
|
20
|
import android.text.TextWatcher;
|
|
21
|
import android.view.Gravity;
|
18
|
22
|
import android.view.KeyEvent;
|
19
|
23
|
import android.view.LayoutInflater;
|
20
|
24
|
import android.view.View;
|
|
@ -26,14 +30,18 @@ import android.widget.AbsListView;
|
26
|
30
|
import android.widget.AdapterView;
|
27
|
31
|
import android.widget.AdapterView.OnItemClickListener;
|
28
|
32
|
import android.widget.BaseAdapter;
|
|
33
|
import android.widget.Button;
|
29
|
34
|
import android.widget.EditText;
|
30
|
35
|
import android.widget.ImageView;
|
31
|
36
|
import android.widget.LinearLayout;
|
32
|
37
|
import android.widget.ListView;
|
|
38
|
import android.widget.PopupWindow;
|
33
|
39
|
import android.widget.SimpleCursorAdapter;
|
34
|
40
|
import android.widget.TextView;
|
35
|
41
|
import android.widget.Toast;
|
36
|
42
|
|
|
43
|
import com.amap.api.maps.AMapUtils;
|
|
44
|
import com.amap.api.maps.model.LatLng;
|
37
|
45
|
import com.amap.api.services.core.PoiItem;
|
38
|
46
|
import com.amap.api.services.core.SuggestionCity;
|
39
|
47
|
import com.amap.api.services.help.Inputtips;
|
|
@ -41,21 +49,24 @@ import com.amap.api.services.help.Tip;
|
41
|
49
|
import com.amap.api.services.poisearch.PoiResult;
|
42
|
50
|
import com.amap.api.services.poisearch.PoiSearch;
|
43
|
51
|
import com.amap.api.services.poisearch.PoiSearch.OnPoiSearchListener;
|
44
|
|
import com.electric.chargingpile.BuildConfig;
|
45
|
52
|
import com.electric.chargingpile.R;
|
46
|
53
|
import com.electric.chargingpile.application.MainApplication;
|
47
|
54
|
import com.electric.chargingpile.data.HistoryInfo;
|
|
55
|
import com.electric.chargingpile.data.PileData;
|
48
|
56
|
import com.electric.chargingpile.data.RecommendZhan;
|
49
|
57
|
import com.electric.chargingpile.manager.ProfileManager;
|
50
|
58
|
import com.electric.chargingpile.util.BarColorUtil;
|
51
|
59
|
import com.electric.chargingpile.util.DBOpenHandler;
|
52
|
60
|
import com.electric.chargingpile.util.DES3S;
|
53
|
61
|
import com.electric.chargingpile.util.JsonUtils;
|
|
62
|
import com.electric.chargingpile.util.Util;
|
54
|
63
|
import com.umeng.analytics.MobclickAgent;
|
55
|
64
|
import com.zhy.http.okhttp.OkHttpUtils;
|
56
|
65
|
import com.zhy.http.okhttp.callback.StringCallback;
|
57
|
66
|
|
|
67
|
import java.net.URISyntaxException;
|
58
|
68
|
import java.util.ArrayList;
|
|
69
|
import java.util.Calendar;
|
59
|
70
|
import java.util.HashMap;
|
60
|
71
|
import java.util.List;
|
61
|
72
|
import java.util.Map;
|
|
@ -91,6 +102,12 @@ public class SearchActivity extends Activity implements OnClickListener, Inputti
|
91
|
102
|
private String keyWord = "";// 要输入的poi搜索关键字
|
92
|
103
|
private static final String TAG = "SearchActivity";
|
93
|
104
|
|
|
105
|
private String gd_jing, gd_wei;
|
|
106
|
private View popupWindowView;
|
|
107
|
private PopupWindow popupWindow;
|
|
108
|
private Button cancleButton;
|
|
109
|
private TextView tvOne, tvTwo, tvThree;
|
|
110
|
private Double bd_lon, bd_lat, bd_jing, bd_wei;
|
94
|
111
|
|
95
|
112
|
@Override
|
96
|
113
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@ -102,6 +119,7 @@ public class SearchActivity extends Activity implements OnClickListener, Inputti
|
102
|
119
|
|
103
|
120
|
private void initView() {
|
104
|
121
|
lvContent = (ListView) findViewById(R.id.lv_search_list);
|
|
122
|
lvContent.setDividerHeight(0);
|
105
|
123
|
historyList = (ListView) findViewById(R.id.lv_history_list);
|
106
|
124
|
tvSearch = (TextView) findViewById(R.id.tv_search);
|
107
|
125
|
tvSearch.setOnClickListener(this);
|
|
@ -236,7 +254,7 @@ public class SearchActivity extends Activity implements OnClickListener, Inputti
|
236
|
254
|
|
237
|
255
|
}
|
238
|
256
|
});
|
239
|
|
adapter = new SearchAdapter(this, addressList);
|
|
257
|
adapter = new SearchAdapter(this, addressList, pointList);
|
240
|
258
|
lvContent.setAdapter(adapter);
|
241
|
259
|
|
242
|
260
|
// 点击历史记录
|
|
@ -469,20 +487,26 @@ public class SearchActivity extends Activity implements OnClickListener, Inputti
|
469
|
487
|
public class SearchAdapter extends BaseAdapter {
|
470
|
488
|
private Context context;
|
471
|
489
|
private List<Map<String, String>> list;
|
|
490
|
private List<RecommendZhan> pList;
|
472
|
491
|
|
473
|
|
public SearchAdapter(Context context, List<Map<String, String>> list) {
|
|
492
|
public SearchAdapter(Context context, List<Map<String, String>> list, List<RecommendZhan> pointList) {
|
474
|
493
|
this.context = context;
|
475
|
494
|
this.list = list;
|
|
495
|
this.pList = pointList;
|
476
|
496
|
}
|
477
|
497
|
|
478
|
498
|
@Override
|
479
|
499
|
public int getCount() {
|
480
|
|
return list.size();
|
|
500
|
return list.size() + pointList.size();
|
481
|
501
|
}
|
482
|
502
|
|
483
|
503
|
@Override
|
484
|
504
|
public Object getItem(int position) {
|
485
|
|
return list.get(position);
|
|
505
|
if (position < list.size()) {
|
|
506
|
return list.get(position);
|
|
507
|
} else {
|
|
508
|
return pointList.get(position - list.size());
|
|
509
|
}
|
486
|
510
|
}
|
487
|
511
|
|
488
|
512
|
@Override
|
|
@ -492,55 +516,306 @@ public class SearchActivity extends Activity implements OnClickListener, Inputti
|
492
|
516
|
|
493
|
517
|
@Override
|
494
|
518
|
public View getView(int position, View convertView, ViewGroup parent) {
|
495
|
|
if (addressList.size() > 0 && position < addressList.size()) {
|
496
|
|
ViewHolder viewHolder = null;
|
497
|
|
if (convertView == null) {
|
498
|
|
convertView = LayoutInflater.from(context).inflate(R.layout.item_search, null);
|
499
|
|
viewHolder = new ViewHolder();
|
500
|
|
viewHolder.name = convertView.findViewById(R.id.search_name);
|
501
|
|
viewHolder.address = convertView.findViewById(R.id.search_address);
|
502
|
|
viewHolder.header_title = convertView.findViewById(R.id.header_title);
|
503
|
|
viewHolder.query_all_addresses = convertView.findViewById(R.id.query_all_addresses);
|
504
|
|
convertView.setTag(viewHolder);
|
505
|
|
} else {
|
506
|
|
viewHolder = (ViewHolder) convertView.getTag();
|
|
519
|
|
|
520
|
ViewHolder viewHolder = null;
|
|
521
|
if (convertView == null) {
|
|
522
|
convertView = LayoutInflater.from(context).inflate(R.layout.item_search, null);
|
|
523
|
viewHolder = new ViewHolder();
|
|
524
|
|
|
525
|
viewHolder.address_item = convertView.findViewById(R.id.address_item);
|
|
526
|
viewHolder.point_item = convertView.findViewById(R.id.point_item);
|
|
527
|
|
|
528
|
viewHolder.name = convertView.findViewById(R.id.search_name);
|
|
529
|
viewHolder.address = convertView.findViewById(R.id.search_address);
|
|
530
|
viewHolder.address_header_title = convertView.findViewById(R.id.address_header_title);
|
|
531
|
viewHolder.query_all_addresses = convertView.findViewById(R.id.query_all_addresses);
|
|
532
|
|
|
533
|
viewHolder.point_header_title = convertView.findViewById(R.id.point_header_title);
|
|
534
|
viewHolder.query_all_points = convertView.findViewById(R.id.query_all_points);
|
|
535
|
viewHolder.zhan_name = convertView.findViewById(R.id.zhan_name);
|
|
536
|
viewHolder.red_paper_bag = convertView.findViewById(R.id.red_paper_bag);
|
|
537
|
viewHolder.score_img = convertView.findViewById(R.id.score_img);
|
|
538
|
viewHolder.score_text = convertView.findViewById(R.id.score_text);
|
|
539
|
viewHolder.distance = convertView.findViewById(R.id.distance);
|
|
540
|
viewHolder.zongjia_container = convertView.findViewById(R.id.zongjia_container);
|
|
541
|
viewHolder.zongjia = convertView.findViewById(R.id.zongjia);
|
|
542
|
viewHolder.charge_record_cnt = convertView.findViewById(R.id.charge_record_cnt);
|
|
543
|
viewHolder.comment_cnt = convertView.findViewById(R.id.comment_cnt);
|
|
544
|
viewHolder.times_line = convertView.findViewById(R.id.times_line);
|
|
545
|
viewHolder.fenshi_info_textview = convertView.findViewById(R.id.fenshi_info_textview);
|
|
546
|
viewHolder.iv_label_public = convertView.findViewById(R.id.iv_label_public);
|
|
547
|
viewHolder.iv_label_ground = convertView.findViewById(R.id.iv_label_ground);
|
|
548
|
viewHolder.iv_label_free_park = convertView.findViewById(R.id.iv_label_free_park);
|
|
549
|
viewHolder.payment_method = convertView.findViewById(R.id.payment_method);
|
|
550
|
viewHolder.recommend_nav = convertView.findViewById(R.id.recommend_nav);
|
|
551
|
viewHolder.window_tv_fast_free_label = convertView.findViewById(R.id.window_tv_fast_free_label);
|
|
552
|
viewHolder.window_tv_fast_free_num = convertView.findViewById(R.id.window_tv_fast_free_num);
|
|
553
|
viewHolder.window_tv_fast_total_num = convertView.findViewById(R.id.window_tv_fast_total_num);
|
|
554
|
viewHolder.window_tv_slow_free_label = convertView.findViewById(R.id.window_tv_slow_free_label);
|
|
555
|
viewHolder.window_tv_slow_free_num = convertView.findViewById(R.id.window_tv_slow_free_num);
|
|
556
|
viewHolder.window_tv_slow_total_num = convertView.findViewById(R.id.window_tv_slow_total_num);
|
|
557
|
|
|
558
|
convertView.setTag(viewHolder);
|
|
559
|
} else {
|
|
560
|
viewHolder = (ViewHolder) convertView.getTag();
|
|
561
|
}
|
|
562
|
|
|
563
|
if (position < list.size()) {
|
|
564
|
showAddressView(viewHolder, list.get(position), position);
|
|
565
|
} else {
|
|
566
|
RecommendZhan point = pList.get(position - list.size());
|
|
567
|
showPointView(viewHolder, point, position);
|
|
568
|
}
|
|
569
|
|
|
570
|
return convertView;
|
|
571
|
}
|
|
572
|
|
|
573
|
class ViewHolder {
|
|
574
|
LinearLayout address_item, point_item, zongjia_container;
|
|
575
|
|
|
576
|
TextView name, address, address_header_title, query_all_addresses;
|
|
577
|
|
|
578
|
TextView point_header_title, query_all_points, zhan_name, score_text, distance, zongjia,
|
|
579
|
charge_record_cnt, comment_cnt, fenshi_info_textview, iv_label_public, iv_label_ground,
|
|
580
|
iv_label_free_park, payment_method, window_tv_fast_free_label, window_tv_fast_free_num, window_tv_fast_total_num,
|
|
581
|
window_tv_slow_free_label, window_tv_slow_free_num, window_tv_slow_total_num;
|
|
582
|
ImageView red_paper_bag, score_img;
|
|
583
|
View times_line;
|
|
584
|
Button recommend_nav;
|
|
585
|
|
|
586
|
}
|
|
587
|
|
|
588
|
private void showAddressView(ViewHolder viewHolder, Map<String, String> item, int position) {
|
|
589
|
viewHolder.address_item.setVisibility(View.VISIBLE);
|
|
590
|
viewHolder.point_item.setVisibility(View.GONE);
|
|
591
|
|
|
592
|
String name = item.get("name");
|
|
593
|
String address = item.get("address");
|
|
594
|
name = name.replace(keyWord, "<font color=\"#1BB637\">" + keyWord + "</font>");
|
|
595
|
address = address.replace(keyWord, "<font color=\"#1BB637\">" + keyWord + "</font>");
|
|
596
|
viewHolder.name.setText(Html.fromHtml(name, Html.FROM_HTML_MODE_LEGACY));
|
|
597
|
viewHolder.address.setText(Html.fromHtml(address, Html.FROM_HTML_MODE_LEGACY));
|
|
598
|
|
|
599
|
if (position == 0) {
|
|
600
|
viewHolder.address_header_title.setVisibility(View.VISIBLE);
|
|
601
|
viewHolder.address_header_title.setText(keyWord + "相关目的地");
|
|
602
|
} else {
|
|
603
|
viewHolder.address_header_title.setVisibility(View.GONE);
|
|
604
|
}
|
|
605
|
|
|
606
|
if (position == list.size() - 1 && addressAllList.size() > 5) {
|
|
607
|
viewHolder.query_all_addresses.setVisibility(View.VISIBLE);
|
|
608
|
} else {
|
|
609
|
viewHolder.query_all_addresses.setVisibility(View.GONE);
|
|
610
|
}
|
|
611
|
viewHolder.query_all_addresses.setOnClickListener(new View.OnClickListener() {
|
|
612
|
|
|
613
|
@Override
|
|
614
|
public void onClick(View v) { // 查看所有
|
|
615
|
// TODO by hyg add
|
|
616
|
}
|
|
617
|
});
|
|
618
|
}
|
|
619
|
|
|
620
|
private void showPointView(ViewHolder viewHolder, RecommendZhan point, int position) {
|
|
621
|
|
|
622
|
viewHolder.point_item.setOnClickListener(new View.OnClickListener() {
|
|
623
|
@Override
|
|
624
|
public void onClick(View v) {
|
|
625
|
Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class);
|
|
626
|
intent.putExtra("zhan_id", point.getZhan_id());
|
|
627
|
startActivity(intent);
|
|
628
|
}
|
|
629
|
});
|
|
630
|
viewHolder.address_item.setVisibility(View.GONE);
|
|
631
|
viewHolder.point_item.setVisibility(View.VISIBLE);
|
|
632
|
if (position == list.size()) {
|
|
633
|
viewHolder.point_header_title.setVisibility(View.VISIBLE);
|
|
634
|
viewHolder.point_header_title.setText(keyWord + "相关充电桩");
|
|
635
|
} else {
|
|
636
|
viewHolder.point_header_title.setVisibility(View.GONE);
|
|
637
|
}
|
|
638
|
|
|
639
|
if (position == list.size() + pList.size() - 1 && pointFullList.size() > 3) {
|
|
640
|
viewHolder.query_all_points.setVisibility(View.VISIBLE);
|
|
641
|
} else {
|
|
642
|
viewHolder.query_all_points.setVisibility(View.GONE);
|
|
643
|
}
|
|
644
|
|
|
645
|
viewHolder.query_all_points.setOnClickListener(new View.OnClickListener() {
|
|
646
|
@Override
|
|
647
|
public void onClick(View v) { // 查看全部站点
|
|
648
|
}
|
|
649
|
});
|
|
650
|
|
|
651
|
|
|
652
|
viewHolder.zhan_name.setText(point.getZhan_name());
|
|
653
|
|
|
654
|
if ("1".equals(point.getOwn_pay())) {
|
|
655
|
viewHolder.red_paper_bag.setVisibility(View.VISIBLE);
|
|
656
|
} else {
|
|
657
|
viewHolder.red_paper_bag.setVisibility(View.GONE);
|
|
658
|
}
|
|
659
|
|
|
660
|
viewHolder.red_paper_bag.setOnClickListener(new View.OnClickListener() {
|
|
661
|
@Override
|
|
662
|
public void onClick(View v) {
|
|
663
|
Intent intent_example = new Intent(getApplicationContext(), ExampleActivity.class);
|
|
664
|
intent_example.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
|
665
|
startActivity(intent_example);
|
|
666
|
overridePendingTransition(0, 0);
|
507
|
667
|
}
|
|
668
|
});
|
508
|
669
|
|
509
|
|
String name = list.get(position).get("name");
|
510
|
|
String address = list.get(position).get("address");
|
511
|
|
name = name.replace(keyWord, "<font color=\"#1BB637\">" + keyWord + "</font>");
|
512
|
|
address = address.replace(keyWord, "<font color=\"#1BB637\">" + keyWord + "</font>");
|
513
|
|
viewHolder.name.setText(Html.fromHtml(name, Html.FROM_HTML_MODE_LEGACY));
|
514
|
|
viewHolder.address.setText(Html.fromHtml(address, Html.FROM_HTML_MODE_LEGACY));
|
|
670
|
showStarInfoView(viewHolder, point);
|
515
|
671
|
|
516
|
|
if (position == 0) {
|
517
|
|
viewHolder.header_title.setVisibility(View.VISIBLE);
|
518
|
|
viewHolder.header_title.setText(keyWord + "相关目的地");
|
|
672
|
if ("0m".equals(point.getDistance())) {
|
|
673
|
viewHolder.distance.setText("未知");
|
|
674
|
} else {
|
|
675
|
viewHolder.distance.setText(point.getDistance());
|
|
676
|
}
|
|
677
|
|
|
678
|
if (point.getZongjia() == 0) {
|
|
679
|
viewHolder.zongjia_container.setVisibility(View.GONE);
|
|
680
|
} else {
|
|
681
|
viewHolder.zongjia_container.setVisibility(View.VISIBLE);
|
|
682
|
viewHolder.zongjia.setText(String.format("%.2f", point.getZongjia()));
|
|
683
|
}
|
|
684
|
|
|
685
|
if (point.getComment_cnt() == 0) {
|
|
686
|
viewHolder.comment_cnt.setVisibility(View.GONE);
|
|
687
|
} else {
|
|
688
|
viewHolder.comment_cnt.setVisibility(View.VISIBLE);
|
|
689
|
if (point.getComment_cnt() < 1000) {
|
|
690
|
viewHolder.comment_cnt.setText(point.getComment_cnt() + "次评论");
|
|
691
|
} else if (point.getComment_cnt() < 10000) {
|
|
692
|
viewHolder.comment_cnt.setText(point.getComment_cnt() / 1000 + "k+次评论");
|
519
|
693
|
} else {
|
520
|
|
viewHolder.header_title.setVisibility(View.GONE);
|
|
694
|
viewHolder.comment_cnt.setText(point.getComment_cnt() / 10000 + "w+次评论");
|
521
|
695
|
}
|
522
|
696
|
|
523
|
|
if (position == addressList.size() - 1 && addressAllList.size() > 5) {
|
524
|
|
viewHolder.query_all_addresses.setVisibility(View.VISIBLE);
|
|
697
|
}
|
|
698
|
|
|
699
|
if (point.getComment_cnt() == 0 || point.getCharge_record_cnt() == 0 && point.getComment_cnt() == 0) {
|
|
700
|
viewHolder.times_line.setVisibility(View.GONE);
|
|
701
|
} else {
|
|
702
|
viewHolder.times_line.setVisibility(View.VISIBLE);
|
|
703
|
}
|
|
704
|
|
|
705
|
if (point.getComment_cnt() == 0) {
|
|
706
|
viewHolder.comment_cnt.setVisibility(View.GONE);
|
|
707
|
} else {
|
|
708
|
viewHolder.comment_cnt.setVisibility(View.VISIBLE);
|
|
709
|
if (point.getComment_cnt() < 1000) {
|
|
710
|
viewHolder.comment_cnt.setText(point.getComment_cnt() + "次评论");
|
|
711
|
} else if (point.getComment_cnt() < 10000) {
|
|
712
|
viewHolder.comment_cnt.setText(point.getComment_cnt() / 1000 + "k+次评论");
|
525
|
713
|
} else {
|
526
|
|
viewHolder.query_all_addresses.setVisibility(View.GONE);
|
|
714
|
viewHolder.comment_cnt.setText(point.getComment_cnt() / 10000 + "w+次评论");
|
527
|
715
|
}
|
528
|
|
viewHolder.query_all_addresses.setOnClickListener(new View.OnClickListener() {
|
|
716
|
}
|
529
|
717
|
|
530
|
|
@Override
|
531
|
|
public void onClick(View v) { // 查看所有
|
532
|
|
// TODO by hyg add
|
|
718
|
if ("1".equals(point.getFenshi_is())) {
|
|
719
|
viewHolder.fenshi_info_textview.setText("");
|
|
720
|
ArrayList<PileData.FenshiInfoBean> fenshiList = (ArrayList<PileData.FenshiInfoBean>) JsonUtils.parseToObjectList(point.getFenshi_info(), PileData.FenshiInfoBean.class);
|
|
721
|
Calendar calendar = Calendar.getInstance();
|
|
722
|
int hours = calendar.get(Calendar.HOUR_OF_DAY);
|
|
723
|
int minutes = calendar.get(Calendar.MINUTE);
|
|
724
|
int totalMinutes = hours * 60 + minutes;
|
|
725
|
|
|
726
|
for (PileData.FenshiInfoBean bean : fenshiList) {
|
|
727
|
if (bean.getStartTotalMinutes() > totalMinutes) {
|
|
728
|
Double service_free = Double.valueOf(bean.getService_free());
|
|
729
|
Double charge_free = Double.valueOf(bean.getCharge_free());
|
|
730
|
viewHolder.fenshi_info_textview.setText(String.format("%s开始 %.2f元/度", bean.getStart(), service_free + charge_free));
|
|
731
|
break;
|
533
|
732
|
}
|
534
|
|
});
|
|
733
|
}
|
|
734
|
} else {
|
|
735
|
viewHolder.fenshi_info_textview.setText("");
|
|
736
|
}
|
|
737
|
|
|
738
|
viewHolder.iv_label_public.setText(point.getBelong_attribute());
|
|
739
|
viewHolder.iv_label_ground.setText("0".equals(point.getPark_location()) ? "地下" : "地上");
|
|
740
|
viewHolder.iv_label_free_park.setVisibility(point.getStop_cost().contains("免费") ? View.VISIBLE : View.GONE);
|
|
741
|
|
|
742
|
if ("1".equals(point.getOwn_pay())) {
|
|
743
|
viewHolder.payment_method.setText("可使用本APP扫码支付");
|
|
744
|
} else {
|
|
745
|
if ("".equals(point.getCharge_cost_way2())) {
|
|
746
|
viewHolder.payment_method.setText("暂无");
|
|
747
|
} else {
|
|
748
|
viewHolder.payment_method.setText(point.getCharge_cost_way2());
|
|
749
|
}
|
|
750
|
}
|
|
751
|
|
|
752
|
viewHolder.recommend_nav.setOnClickListener(new View.OnClickListener() {
|
|
753
|
@Override
|
|
754
|
public void onClick(View v) {
|
|
755
|
recommendNav(point);
|
|
756
|
}
|
|
757
|
});
|
|
758
|
|
|
759
|
if (point.getFast_able_num() == null && point.getSlow_able_num() == null) {
|
|
760
|
viewHolder.window_tv_fast_free_label.setVisibility(View.GONE);
|
|
761
|
viewHolder.window_tv_fast_total_num.setVisibility(View.GONE);
|
|
762
|
|
|
763
|
viewHolder.window_tv_slow_free_label.setVisibility(View.GONE);
|
|
764
|
viewHolder.window_tv_slow_total_num.setVisibility(View.GONE);
|
|
765
|
|
|
766
|
viewHolder.window_tv_fast_free_num.setText("".equals(point.getFast_num()) ? "0" : point.getFast_num());
|
|
767
|
viewHolder.window_tv_slow_free_num.setText("".equals(point.getSlow_num()) ? "0" : point.getSlow_num());
|
|
768
|
} else {
|
|
769
|
viewHolder.window_tv_fast_free_label.setVisibility(View.VISIBLE);
|
|
770
|
viewHolder.window_tv_fast_total_num.setVisibility(View.VISIBLE);
|
|
771
|
|
|
772
|
viewHolder.window_tv_slow_free_label.setVisibility(View.VISIBLE);
|
|
773
|
viewHolder.window_tv_slow_total_num.setVisibility(View.VISIBLE);
|
|
774
|
|
|
775
|
viewHolder.window_tv_fast_free_num.setText(point.getFast_able_num());
|
|
776
|
viewHolder.window_tv_slow_free_num.setText(point.getSlow_able_num());
|
|
777
|
viewHolder.window_tv_fast_total_num.setText("".equals(point.getFast_num()) ? "0" : "/" + point.getFast_num());
|
|
778
|
viewHolder.window_tv_slow_total_num.setText("".equals(point.getSlow_num()) ? "0" : "/" + point.getSlow_num());
|
535
|
779
|
}
|
536
|
780
|
|
537
|
|
return convertView;
|
538
|
|
}
|
539
|
781
|
|
540
|
|
class ViewHolder {
|
541
|
|
TextView name, address, header_title, query_all_addresses;
|
542
|
782
|
}
|
543
|
783
|
|
|
784
|
private void showStarInfoView(ViewHolder viewHolder, RecommendZhan point) {
|
|
785
|
String starStr = point.getStar();
|
|
786
|
double star = 0.0;
|
|
787
|
try {
|
|
788
|
star = Double.parseDouble(starStr);
|
|
789
|
} catch (NumberFormatException e) {
|
|
790
|
e.printStackTrace();
|
|
791
|
}
|
|
792
|
|
|
793
|
viewHolder.score_text.setText(String.format("%.1f分", star));
|
|
794
|
if (star == 0) {
|
|
795
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_0xing));
|
|
796
|
viewHolder.score_text.setText("暂无评分");
|
|
797
|
} else if (star > 0 && star < 1) {
|
|
798
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_05xing));
|
|
799
|
} else if (star >= 1 && star < 1.5) {
|
|
800
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_1xing));
|
|
801
|
} else if (star >= 1.5 && star < 2) {
|
|
802
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_15xing));
|
|
803
|
} else if (star >= 2 && star < 2.5) {
|
|
804
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_2xing));
|
|
805
|
} else if (star >= 2.5 && star < 3) {
|
|
806
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_25xing));
|
|
807
|
} else if (star >= 3 && star < 3.5) {
|
|
808
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_3xing));
|
|
809
|
} else if (star >= 3.5 && star < 4) {
|
|
810
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_35xing));
|
|
811
|
} else if (star >= 4 && star < 4.5) {
|
|
812
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_4xing));
|
|
813
|
} else if (star >= 4.5 && star < 5) {
|
|
814
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_45xing));
|
|
815
|
} else {
|
|
816
|
viewHolder.score_img.setImageDrawable(getDrawable(R.drawable.icon_5xing));
|
|
817
|
}
|
|
818
|
}
|
544
|
819
|
}
|
545
|
820
|
|
546
|
821
|
@Override
|
|
@ -588,7 +863,10 @@ public class SearchActivity extends Activity implements OnClickListener, Inputti
|
588
|
863
|
longitude = MainApplication.center.longitude;
|
589
|
864
|
latitude = MainApplication.center.latitude;
|
590
|
865
|
}
|
591
|
|
String url = MainApplication.url + "/zhannew/basic/web/index.php/name_search?city=" + MainApplication.atCity + "&poi_jing=" + longitude + "&poi_wei=" + latitude + "&version=" + MainApplication.current_code + "&zhan_name=" + keyWord + "&version_code=" + BuildConfig.VERSION_CODE;
|
|
866
|
|
|
867
|
LatLng center = new LatLng(latitude, longitude);
|
|
868
|
|
|
869
|
String url = MainApplication.url + "/zhannew/basic/web/index.php/name_search?city=" + MainApplication.atCity + "&poi_jing=" + longitude + "&poi_wei=" + latitude + "&version=" + MainApplication.current_code + "&zhan_name=" + keyWord;
|
592
|
870
|
OkHttpUtils.get().url(url).build().readTimeOut(30000).connTimeOut(30000).execute(new StringCallback() {
|
593
|
871
|
@Override
|
594
|
872
|
public void onError(Call call, Exception e) {
|
|
@ -612,19 +890,213 @@ public class SearchActivity extends Activity implements OnClickListener, Inputti
|
612
|
890
|
pointList.clear();
|
613
|
891
|
|
614
|
892
|
List<RecommendZhan> list = JsonUtils.parseToObjectList(info_decode, RecommendZhan.class);
|
615
|
|
pointFullList.addAll(list);
|
|
893
|
if (list != null) {
|
|
894
|
for (RecommendZhan point : list) {
|
|
895
|
String wei = point.getPoi_wei().trim();
|
|
896
|
String jing = point.getPoi_jing().trim();
|
|
897
|
|
|
898
|
int position_jing = jing.length() - jing.indexOf(".") - 1;
|
|
899
|
int position_wei = wei.length() - wei.indexOf(".") - 1;
|
|
900
|
|
|
901
|
LatLng ll;
|
|
902
|
|
|
903
|
if (position_jing > 13 || position_wei > 13) {
|
|
904
|
ll = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing));
|
|
905
|
} else {
|
|
906
|
double dwei = Double.parseDouble(wei);
|
|
907
|
double djing = Double.parseDouble(jing);
|
|
908
|
getGaode(djing, dwei);
|
|
909
|
ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
|
|
910
|
}
|
616
|
911
|
|
617
|
|
for (RecommendZhan point : pointFullList) {
|
618
|
|
pointList.add(point);
|
619
|
|
if (pointList.size() >= 3) {
|
620
|
|
break;
|
|
912
|
double d = AMapUtils.calculateLineDistance(center, ll);
|
|
913
|
point.setDistance(Util.getDistance(d));
|
|
914
|
pointFullList.add(point);
|
|
915
|
}
|
|
916
|
|
|
917
|
for (RecommendZhan point : pointFullList) {
|
|
918
|
pointList.add(point);
|
|
919
|
if (pointList.size() >= 3) {
|
|
920
|
break;
|
|
921
|
}
|
|
922
|
}
|
|
923
|
|
|
924
|
if (pointList.size() > 0) {
|
|
925
|
adapter.notifyDataSetChanged();
|
621
|
926
|
}
|
622
|
927
|
}
|
623
|
|
System.out.println(info_decode);
|
624
|
928
|
}
|
625
|
929
|
}
|
626
|
930
|
}
|
627
|
931
|
});
|
628
|
932
|
|
629
|
933
|
}
|
|
934
|
|
|
935
|
private void getGaode(Double jing, Double wei) {
|
|
936
|
double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
|
937
|
double gg_lon;
|
|
938
|
double gg_lat;
|
|
939
|
double x = jing - 0.0065, y = wei - 0.006;
|
|
940
|
double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
|
|
941
|
double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
|
|
942
|
gg_lon = z * Math.cos(theta);
|
|
943
|
gd_jing = String.valueOf(gg_lon);
|
|
944
|
gg_lat = z * Math.sin(theta);
|
|
945
|
gd_wei = String.valueOf(gg_lat);
|
|
946
|
}
|
|
947
|
|
|
948
|
private void recommendNav(RecommendZhan rz) {
|
|
949
|
|
|
950
|
String wei = rz.getPoi_wei().trim();
|
|
951
|
String jing = rz.getPoi_jing().trim();
|
|
952
|
int position_jing = jing.length() - jing.indexOf(".") - 1;
|
|
953
|
int position_wei = wei.length() - wei.indexOf(".") - 1;
|
|
954
|
final LatLng ll;
|
|
955
|
if (position_jing > 13 || position_wei > 13) {
|
|
956
|
ll = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing));
|
|
957
|
} else {
|
|
958
|
double dwei = Double.parseDouble(wei);
|
|
959
|
double djing = Double.parseDouble(jing);
|
|
960
|
getGaode(djing, dwei);
|
|
961
|
ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
|
|
962
|
}
|
|
963
|
|
|
964
|
if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") &&
|
|
965
|
!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
|
|
966
|
Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
|
|
967
|
intent.putExtra("start_jing", MainApplication.center.longitude + "");
|
|
968
|
intent.putExtra("start_wei", MainApplication.center.latitude + "");
|
|
969
|
intent.putExtra("stop_jing", ll.longitude + "");
|
|
970
|
intent.putExtra("stop_wei", ll.latitude + "");
|
|
971
|
startActivity(intent);
|
|
972
|
} else {
|
|
973
|
if (MainApplication.center != null) {
|
|
974
|
LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
975
|
popupWindowView = inflater1.inflate(R.layout.item_selectmap, null);
|
|
976
|
popupWindow = new PopupWindow(popupWindowView,
|
|
977
|
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT,
|
|
978
|
true);
|
|
979
|
popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
980
|
// 设置PopupWindow的弹出和消失效果
|
|
981
|
popupWindow.setAnimationStyle(R.style.popupAnimation);
|
|
982
|
LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo);
|
|
983
|
if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
|
|
984
|
ll_tvTwo.setVisibility(View.GONE);
|
|
985
|
}
|
|
986
|
LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne);
|
|
987
|
if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) {
|
|
988
|
ll_tvOne.setVisibility(View.GONE);
|
|
989
|
}
|
|
990
|
cancleButton = (Button) popupWindowView.findViewById(R.id.cancleButton);
|
|
991
|
cancleButton.setOnClickListener(new View.OnClickListener() {
|
|
992
|
@Override
|
|
993
|
public void onClick(View view) {
|
|
994
|
popupWindow.dismiss();
|
|
995
|
}
|
|
996
|
});
|
|
997
|
tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree);
|
|
998
|
tvThree.setOnClickListener(new View.OnClickListener() {
|
|
999
|
@Override
|
|
1000
|
public void onClick(View v) {
|
|
1001
|
Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
|
|
1002
|
intent.putExtra("start_jing", MainApplication.center.longitude + "");
|
|
1003
|
intent.putExtra("start_wei", MainApplication.center.latitude + "");
|
|
1004
|
intent.putExtra("stop_jing", ll.longitude + "");
|
|
1005
|
intent.putExtra("stop_wei", ll.latitude + "");
|
|
1006
|
startActivity(intent);
|
|
1007
|
popupWindow.dismiss();
|
|
1008
|
}
|
|
1009
|
});
|
|
1010
|
tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne);
|
|
1011
|
tvOne.setOnClickListener(new View.OnClickListener() {
|
|
1012
|
@Override
|
|
1013
|
public void onClick(View view) {
|
|
1014
|
Intent intent = null;
|
|
1015
|
int position_jing = rz.getPoi_jing().length() - rz.getPoi_jing().indexOf(".") - 1;
|
|
1016
|
int position_wei = rz.getPoi_wei().length() - rz.getPoi_wei().indexOf(".") - 1;
|
|
1017
|
if (position_jing > 13 || position_wei > 13) {
|
|
1018
|
getBaidu1(Double.parseDouble(rz.getPoi_jing()), Double.parseDouble(rz.getPoi_wei()));
|
|
1019
|
} else {
|
|
1020
|
bd_jing = Double.parseDouble(rz.getPoi_jing());
|
|
1021
|
bd_wei = Double.parseDouble(rz.getPoi_wei());
|
|
1022
|
}
|
|
1023
|
getBaidu(MainApplication.center.longitude, MainApplication.center.latitude);
|
|
1024
|
try {
|
|
1025
|
String s = "intent://map/direction?" +
|
|
1026
|
"origin=" + bd_lat + "," + bd_lon + "&" +
|
|
1027
|
"destination=" + bd_wei + "," + bd_jing +
|
|
1028
|
"&mode=driving&" +
|
|
1029
|
"src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end";
|
|
1030
|
intent = Intent.getIntent(s);
|
|
1031
|
} catch (URISyntaxException e) {
|
|
1032
|
e.printStackTrace();
|
|
1033
|
}
|
|
1034
|
startActivity(intent);
|
|
1035
|
popupWindow.dismiss();
|
|
1036
|
}
|
|
1037
|
});
|
|
1038
|
tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
|
|
1039
|
tvTwo.setOnClickListener(new View.OnClickListener() {
|
|
1040
|
@Override
|
|
1041
|
public void onClick(View view) {
|
|
1042
|
try {
|
|
1043
|
Intent intent4 = new Intent("android.intent.action.VIEW",
|
|
1044
|
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"));
|
|
1045
|
intent4.setPackage("com.autonavi.minimap");
|
|
1046
|
startActivity(intent4);
|
|
1047
|
popupWindow.dismiss();
|
|
1048
|
} catch (Exception e) {
|
|
1049
|
e.printStackTrace();
|
|
1050
|
Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show();
|
|
1051
|
}
|
|
1052
|
|
|
1053
|
}
|
|
1054
|
});
|
|
1055
|
popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
|
|
1056
|
} else {
|
|
1057
|
Toast.makeText(getApplication(),
|
|
1058
|
"没有定位到您的当前位置", Toast.LENGTH_SHORT)
|
|
1059
|
.show();
|
|
1060
|
}
|
|
1061
|
}
|
|
1062
|
|
|
1063
|
}
|
|
1064
|
|
|
1065
|
private boolean isAvilible(Context context, String packageName) {
|
|
1066
|
//获取packagemanager
|
|
1067
|
final PackageManager packageManager = context.getPackageManager();
|
|
1068
|
//获取所有已安装程序的包信息
|
|
1069
|
List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
|
|
1070
|
//用于存储所有已安装程序的包名
|
|
1071
|
List<String> packageNames = new ArrayList<String>();
|
|
1072
|
//从pinfo中将包名字逐一取出,压入pName list中
|
|
1073
|
if (packageInfos != null) {
|
|
1074
|
for (int i = 0; i < packageInfos.size(); i++) {
|
|
1075
|
String packName = packageInfos.get(i).packageName;
|
|
1076
|
packageNames.add(packName);
|
|
1077
|
}
|
|
1078
|
}
|
|
1079
|
//判断packageNames中是否有目标程序的包名,有TRUE,没有FALSE
|
|
1080
|
return packageNames.contains(packageName);
|
|
1081
|
}
|
|
1082
|
|
|
1083
|
private void getBaidu(Double jing, Double wei) {
|
|
1084
|
double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
|
1085
|
double x = jing;
|
|
1086
|
double y = wei;
|
|
1087
|
double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
|
1088
|
double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
|
1089
|
bd_lon = z * Math.cos(theta) + 0.0065;
|
|
1090
|
bd_lat = z * Math.sin(theta) + 0.006;
|
|
1091
|
}
|
|
1092
|
|
|
1093
|
private void getBaidu1(Double jing, Double wei) {
|
|
1094
|
double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
|
1095
|
double x = jing;
|
|
1096
|
double y = wei;
|
|
1097
|
double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
|
1098
|
double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
|
1099
|
bd_jing = z * Math.cos(theta) + 0.0065;
|
|
1100
|
bd_wei = z * Math.sin(theta) + 0.006;
|
|
1101
|
}
|
630
|
1102
|
}
|