|
@ -32,13 +32,11 @@ import com.electric.chargingpile.util.JsonUtils;
|
32
|
32
|
import com.electric.chargingpile.util.LoadingDialog;
|
33
|
33
|
import com.electric.chargingpile.util.ToastUtil;
|
34
|
34
|
import com.electric.chargingpile.util.Util;
|
35
|
|
import com.umeng.analytics.MobclickAgent;
|
36
|
35
|
import com.zhy.http.okhttp.OkHttpUtils;
|
37
|
36
|
import com.zhy.http.okhttp.callback.StringCallback;
|
38
|
37
|
|
39
|
38
|
import java.net.URISyntaxException;
|
40
|
39
|
import java.util.ArrayList;
|
41
|
|
import java.util.HashMap;
|
42
|
40
|
import java.util.List;
|
43
|
41
|
|
44
|
42
|
import okhttp3.Call;
|
|
@ -80,6 +78,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
80
|
78
|
|
81
|
79
|
private RecyclerView recyclerView;
|
82
|
80
|
private RecommendChargingStationAdapter recommendChargingStationAdapter;
|
|
81
|
private TextView no_result;
|
83
|
82
|
|
84
|
83
|
|
85
|
84
|
@Override
|
|
@ -96,6 +95,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
96
|
95
|
activity = this;
|
97
|
96
|
loadingDialog = new LoadingDialog(this);
|
98
|
97
|
loadingDialog.setCanceledOnTouchOutside(false);
|
|
98
|
no_result = findViewById(R.id.no_result);
|
99
|
99
|
|
100
|
100
|
center_jing = getIntent().getStringExtra("center_jing");
|
101
|
101
|
center_wei = getIntent().getStringExtra("center_wei");
|
|
@ -154,27 +154,30 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
154
|
154
|
} else {
|
155
|
155
|
unfoldSecondCondition();
|
156
|
156
|
}
|
157
|
|
|
158
|
157
|
break;
|
159
|
158
|
case R.id.first_can_charging:
|
160
|
159
|
firstCanCharging = !firstCanCharging;
|
161
|
160
|
first_can_charging.setTextColor(firstCanCharging ? Color.parseColor("#2FC45B") : Color.parseColor("#222222"));
|
162
|
161
|
foldSecondCondition();
|
|
162
|
filterChargingStation(recommendZhanList);
|
163
|
163
|
break;
|
164
|
164
|
case R.id.first_free_parking:
|
165
|
165
|
firstFreeParking = !firstFreeParking;
|
166
|
166
|
first_free_parking.setTextColor(firstFreeParking ? Color.parseColor("#2FC45B") : Color.parseColor("#222222"));
|
167
|
167
|
foldSecondCondition();
|
|
168
|
filterChargingStation(recommendZhanList);
|
168
|
169
|
break;
|
169
|
170
|
case R.id.first_quick_charging:
|
170
|
171
|
firstQuickCharging = !firstQuickCharging;
|
171
|
172
|
first_quick_charging.setTextColor(firstQuickCharging ? Color.parseColor("#2FC45B") : Color.parseColor("#222222"));
|
172
|
173
|
foldSecondCondition();
|
|
174
|
filterChargingStation(recommendZhanList);
|
173
|
175
|
break;
|
174
|
176
|
case R.id.first_slow_charging:
|
175
|
177
|
firstSlowCharging = !firstSlowCharging;
|
176
|
178
|
first_slow_charging.setTextColor(firstSlowCharging ? Color.parseColor("#2FC45B") : Color.parseColor("#222222"));
|
177
|
179
|
foldSecondCondition();
|
|
180
|
filterChargingStation(recommendZhanList);
|
178
|
181
|
break;
|
179
|
182
|
case R.id.second_1:
|
180
|
183
|
case R.id.second_2:
|
|
@ -219,6 +222,9 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
219
|
222
|
second_1.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
220
|
223
|
second_1.setTextColor(Color.parseColor("#FFFFFF"));
|
221
|
224
|
first_condition_text.setText("智能推荐");
|
|
225
|
if (recommendZhanList.size() == 0) {
|
|
226
|
recommendChargingStationFunc();
|
|
227
|
}
|
222
|
228
|
break;
|
223
|
229
|
case R.id.second_2:
|
224
|
230
|
firstCondition = 2;
|
|
@ -266,6 +272,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
266
|
272
|
|
267
|
273
|
private void recommendChargingStationFunc() {
|
268
|
274
|
loadingDialog.show();
|
|
275
|
no_result.setVisibility(View.GONE);
|
269
|
276
|
|
270
|
277
|
String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanlist/recommend?longitude=" + center_jing + "&latitude=" + center_wei;
|
271
|
278
|
|
|
@ -292,7 +299,6 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
292
|
299
|
String data = JsonUtils.getKeyResult(response, "data");
|
293
|
300
|
List<RecommendZhan> list = JsonUtils.parseToObjectList(data, RecommendZhan.class);
|
294
|
301
|
if (list != null) {
|
295
|
|
|
296
|
302
|
for (int i = 0; i < list.size(); i++) {
|
297
|
303
|
String wei = list.get(i).getPoi_wei().trim();
|
298
|
304
|
String jing = list.get(i).getPoi_jing().trim();
|
|
@ -316,6 +322,11 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
316
|
322
|
}
|
317
|
323
|
recommendZhanList = list;
|
318
|
324
|
recommendChargingStationAdapter.setData(list);
|
|
325
|
if (list.size() == 0) {
|
|
326
|
no_result.setVisibility(View.VISIBLE);
|
|
327
|
} else {
|
|
328
|
no_result.setVisibility(View.GONE);
|
|
329
|
}
|
319
|
330
|
}
|
320
|
331
|
}
|
321
|
332
|
}
|
|
@ -710,6 +721,83 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
710
|
721
|
}
|
711
|
722
|
}
|
712
|
723
|
|
|
724
|
private void filterChargingStation(List<RecommendZhan> zhanList) {
|
|
725
|
no_result.setVisibility(View.GONE);
|
|
726
|
|
|
727
|
List<RecommendZhan> list1 = new ArrayList<>();
|
|
728
|
if (firstCanCharging) {
|
|
729
|
for (RecommendZhan item : zhanList) {
|
|
730
|
if ("1".equals(item.getOwn_pay())) {
|
|
731
|
list1.add(item);
|
|
732
|
}
|
|
733
|
}
|
|
734
|
} else {
|
|
735
|
for (RecommendZhan item : zhanList) {
|
|
736
|
list1.add(item);
|
|
737
|
}
|
|
738
|
}
|
|
739
|
|
|
740
|
List<RecommendZhan> list2 = new ArrayList<>();
|
|
741
|
if (firstFreeParking) {
|
|
742
|
for (RecommendZhan item : list1) {
|
|
743
|
if (item.getStop_cost().contains("免费")) {
|
|
744
|
list2.add(item);
|
|
745
|
}
|
|
746
|
}
|
|
747
|
} else {
|
|
748
|
for (RecommendZhan item : list1) {
|
|
749
|
list2.add(item);
|
|
750
|
}
|
|
751
|
}
|
|
752
|
|
|
753
|
List<RecommendZhan> list3 = new ArrayList<>();
|
|
754
|
if (firstQuickCharging) {
|
|
755
|
for (RecommendZhan item : list2) {
|
|
756
|
int fastNum;
|
|
757
|
if ("".equals(item.getFast_num())) {
|
|
758
|
fastNum = 0;
|
|
759
|
} else {
|
|
760
|
fastNum = Integer.parseInt(item.getFast_num());
|
|
761
|
}
|
|
762
|
|
|
763
|
if (fastNum > 0) {
|
|
764
|
list3.add(item);
|
|
765
|
}
|
|
766
|
}
|
|
767
|
} else {
|
|
768
|
for (RecommendZhan item : list2) {
|
|
769
|
list3.add(item);
|
|
770
|
}
|
|
771
|
}
|
|
772
|
|
|
773
|
List<RecommendZhan> list4 = new ArrayList<>();
|
|
774
|
if (firstSlowCharging) {
|
|
775
|
for (RecommendZhan item : list3) {
|
|
776
|
int slowNum;
|
|
777
|
if ("".equals(item.getSlow_num())) {
|
|
778
|
slowNum = 0;
|
|
779
|
} else {
|
|
780
|
slowNum = Integer.parseInt(item.getSlow_num());
|
|
781
|
}
|
|
782
|
if (slowNum > 0) {
|
|
783
|
list4.add(item);
|
|
784
|
}
|
|
785
|
}
|
|
786
|
} else {
|
|
787
|
for (RecommendZhan item : list3) {
|
|
788
|
list4.add(item);
|
|
789
|
}
|
|
790
|
}
|
|
791
|
|
|
792
|
recommendChargingStationAdapter.setData(list4);
|
|
793
|
|
|
794
|
if (list4.size() == 0) {
|
|
795
|
no_result.setVisibility(View.VISIBLE);
|
|
796
|
} else {
|
|
797
|
no_result.setVisibility(View.GONE);
|
|
798
|
}
|
|
799
|
}
|
|
800
|
|
713
|
801
|
private void getGaode(Double jing, Double wei) {
|
714
|
802
|
double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
715
|
803
|
double gg_lon;
|