s-code">
resetFirstCondition();
foldSecondCondition();
second_1.setBackground(getResources().getDrawable(R.drawable.recommend_btn_normal));
second_2.setBackground(getResources().getDrawable(R.drawable.recommend_btn_normal));
second_3.setBackground(getResources().getDrawable(R.drawable.recommend_btn_normal));
second_4.setBackground(getResources().getDrawable(R.drawable.recommend_btn_normal));
second_5.setBackground(getResources().getDrawable(R.drawable.recommend_btn_normal));
second_1.setTextColor(Color.parseColor("#2FC45B"));
second_2.setTextColor(Color.parseColor("#2FC45B"));
second_3.setTextColor(Color.parseColor("#2FC45B"));
second_4.setTextColor(Color.parseColor("#2FC45B"));
second_5.setTextColor(Color.parseColor("#2FC45B"));
first_condition.setTextColor(Color.parseColor("#222222"));
second_condition.setTextColor(Color.parseColor("#222222"));
third_condition.setTextColor(Color.parseColor("#222222"));
forth_condition.setTextColor(Color.parseColor("#222222"));
switch (id) {
case R.id.second_1:
firstCondition = 1;
second_1.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
second_1.setTextColor(Color.parseColor("#FFFFFF"));
first_condition_text.setText("智能推荐");
if (recommendZhanList.size() == 0) {
recommendChargingStationFunc();
} else {
filterChargingStation();
}
MobclickAgent.onEvent(getApplicationContext(), "1136");
case R.id.first_condition:
condition = 1;
first_condition.setTextColor(Color.parseColor("#1BB637"));
MobclickAgent.onEvent(getApplicationContext(), "1139");
break;
case R.id.second_2:
firstCondition = 2;
second_2.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
second_2.setTextColor(Color.parseColor("#FFFFFF"));
first_condition_text.setText("价格最低");
if (zhanList.size() == 0 && socket != null && socket.isClosed()) {
loadingDialog.show();
ete("{\"fun\":\"timer\"}");
} else {
filterChargingStation();
}
case R.id.second_condition:
condition = 2;
second_condition.setTextColor(Color.parseColor("#1BB637"));
MobclickAgent.onEvent(getApplicationContext(), "1138");
break;
case R.id.second_3:
firstCondition = 3;
second_3.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
second_3.setTextColor(Color.parseColor("#FFFFFF"));
first_condition_text.setText("距离最近");
if (zhanList.size() == 0 && socket != null && socket.isClosed()) {
loadingDialog.show();
ete("{\"fun\":\"timer\"}");
} else {
filterChargingStation();
}
MobclickAgent.onEvent(getApplicationContext(), "1139");
break;
case R.id.second_4:
firstCondition = 4;
second_4.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
second_4.setTextColor(Color.parseColor("#FFFFFF"));
first_condition_text.setText("空闲最多");
if (zhanList.size() == 0 && socket != null && socket.isClosed()) {
loadingDialog.show();
ete("{\"fun\":\"timer\"}");
} else {
filterChargingStation();
}
case R.id.third_condition:
condition = 3;
third_condition.setTextColor(Color.parseColor("#1BB637"));
MobclickAgent.onEvent(getApplicationContext(), "1140");
break;
case R.id.second_5:
firstCondition = 5;
second_5.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
second_5.setTextColor(Color.parseColor("#FFFFFF"));
first_condition_text.setText("评分最高");
if (zhanList.size() == 0 && socket != null && socket.isClosed()) {
loadingDialog.show();
ete("{\"fun\":\"timer\"}");
} else {
filterChargingStation();
}
case R.id.forth_condition:
condition = 4;
forth_condition.setTextColor(Color.parseColor("#1BB637"));
MobclickAgent.onEvent(getApplicationContext(), "1137");
break;
}
}
private void resetFirstCondition() {
firstCanCharging = false;
first_can_charging.setTextColor(Color.parseColor("#222222"));
firstFreeParking = false;
first_free_parking.setTextColor(Color.parseColor("#222222"));
firstQuickCharging = false;
first_quick_charging.setTextColor(Color.parseColor("#222222"));
firstSlowCharging = false;
first_slow_charging.setTextColor(Color.parseColor("#222222"));
}
private void recommendChargingStationFunc() {
loadingDialog.show();
no_result.setVisibility(View.GONE);
String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanlist/recommend?longitude=" + center_jing + "&latitude=" + center_wei + "&version_name=" + BuildConfig.VERSION_NAME + "&version_code=" + BuildConfig.VERSION_CODE + "&pg=30";
OkHttpUtils.get().url(url).build().readTimeOut(10000).connTimeOut(10000).execute(new StringCallback() {
@Override
public void onError(Call call, Exception e) {
if (activity != null && !activity.isFinishing()) {
loadingDialog.dismiss();
}
ToastUtil.showToast(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT);
}
@Override
public void onResponse(String response) {
if (activity != null && !activity.isFinishing()) {
loadingDialog.dismiss();
} else {
return;
}
String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
if (rtnCode.equals("01")) {
String data = JsonUtils.getKeyResult(response, "data");
List<RecommendZhan> list = JsonUtils.parseToObjectList(data, RecommendZhan.class);
if (list != null) {
for (int i = 0; i < list.size(); i++) {
String wei = list.get(i).getPoi_wei().trim();
String jing = list.get(i).getPoi_jing().trim();
int position_jing = jing.length() - jing.indexOf(".") - 1;
int position_wei = wei.length() - wei.indexOf(".") - 1;
LatLng ll;
if (position_jing > 13 || position_wei > 13) {
ll = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing));
} else {
double dwei = Double.parseDouble(wei);
double djing = Double.parseDouble(jing);
getGaode(djing, dwei);
ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
}
double d = AMapUtils.calculateLineDistance(center, ll);
list.get(i).setDistanceNum(d);
list.get(i).setDistance(Util.getDistance(d));
if (zhanList.size() == 0 && socket != null && socket.isClosed()) {
loadingDialog.show();
ete("{\"fun\":\"timer\"}");
} else {
filterChargingStation();
}
list.get(i).setZhan_id(list.get(i).getId()); // 呵呵...
}
recommendZhanList = list;
filterChargingStation();
}
}
ete("{\"fun\":\"timer\"}");
}
});
}
public class RecommendChargingStationAdapter extends RecyclerView.Adapter<RecommendChargingStationAdapter.ViewHolder> {
private List<RecommendZhan> mList;
@ -835,28 +604,21 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
private void filterChargingStation() {
no_result.setVisibility(View.GONE);
List<RecommendZhan> list = new ArrayList<RecommendZhan>();
List<RecommendZhan> list;
if (firstCondition == 1) {
list = recommendZhanList;
} else {
list = zhanList;
}
if (firstCondition == 2) { // 价格最低
if (condition == 2) { // 价格最低
List<RecommendZhan> priceList1 = new ArrayList<>();
List<RecommendZhan> priceList2 = new ArrayList<>();
for (RecommendZhan zhan : list) {
if (zhan.getZongjia() > 0) {
priceList1.add(zhan);
for (RecommendZhan point : zhanList) {
if (point.getZongjia() > 0) {
priceList1.add(point);
} else {
priceList2.add(zhan);
priceList2.add(point);
}
}
list = priceList1;
list.addAll(priceList1);
Collections.sort(list, new Comparator<RecommendZhan>() {
@Override
public int compare(RecommendZhan o1, RecommendZhan o2) {
@ -876,7 +638,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
list.addAll(priceList2);
}
if (firstCondition == 3) { // 距离最近
if (condition == 1) { // 距离最近
list.addAll(zhanList);
Collections.sort(list, new Comparator<RecommendZhan>() {
@Override
public int compare(RecommendZhan o1, RecommendZhan o2) {
@ -891,7 +654,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
});
}
if (firstCondition == 4) { // 空闲最多
if (condition == 3) { // 空闲最多
list.addAll(zhanList);
Collections.sort(list, new Comparator<RecommendZhan>() {
@Override
public int compare(RecommendZhan o1, RecommendZhan o2) {
@ -942,7 +706,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
});
}
if (firstCondition == 5) { // 评分最高
if (condition == 4) { // 评分最高
list.addAll(zhanList);
Collections.sort(list, new Comparator<RecommendZhan>() {
@Override
public int compare(RecommendZhan o1, RecommendZhan o2) {
@ -975,75 +740,9 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
list = list.subList(0, 30);
}
recommendChargingStationAdapter.setData(list);
List<RecommendZhan> list1 = new ArrayList<>();
if (firstCanCharging) {
for (RecommendZhan item : list) {
if ("1".equals(item.getOwn_pay())) {
list1.add(item);
}
}
} else {
for (RecommendZhan item : list) {
list1.add(item);
}
}
List<RecommendZhan> list2 = new ArrayList<>();
if (firstFreeParking) {
for (RecommendZhan item : list1) {
if (item.getStop_cost().contains("免费")) {
list2.add(item);
}
}
} else {
for (RecommendZhan item : list1) {
list2.add(item);
}
}
List<RecommendZhan> list3 = new ArrayList<>();
if (firstQuickCharging) {
for (RecommendZhan item : list2) {
int fastNum;
if ("".equals(item.getFast_num())) {
fastNum = 0;
} else {
fastNum = Integer.parseInt(item.getFast_num());
}
if (fastNum > 0) {
list3.add(item);
}
}
} else {
for (RecommendZhan item : list2) {
list3.add(item);
}
}
List<RecommendZhan> list4 = new ArrayList<>();
if (firstSlowCharging) {
for (RecommendZhan item : list3) {
int slowNum;
if ("".equals(item.getSlow_num())) {
slowNum = 0;
} else {
slowNum = Integer.parseInt(item.getSlow_num());
}
if (slowNum > 0) {
list4.add(item);
}
}
} else {
for (RecommendZhan item : list3) {
list4.add(item);
}
}
recommendChargingStationAdapter.setData(list4);
if (list4.size() == 0) {
if (list.size() == 0) {
if (socket != null && !socket.isClosed()) {
no_result.setText("数据加载中,请稍后...");
} else {
@ -1137,8 +836,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
new OutputStreamWriter(socket.getOutputStream())), true);
out.println(params);
// 接收来自服务器的消息
BufferedReader br = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String msg = br.readLine();
int time = (int) (System.currentTimeMillis() / 1000);
int cha = time - Integer.parseInt(msg);
@ -1181,8 +879,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true);
out.println(params);
// 接收来自服务器的消息
BufferedReader br = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String msg = br.readLine();
if (msg != null) {
Message mes = new Message();
@ -1205,8 +902,6 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
}
}
}).start();
}
}
|
||
| 44 | 44 |
|
| 45 | 45 |
|
| 46 | 46 |
|
| 47 |
|
|
| 48 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 | 49 |
|
| 50 | 50 |
|
| 51 |
|
|
| 52 |
|
|
| 51 | 53 |
|
| 52 | 54 |
|
| 53 | 55 |
|
| 54 | 56 |
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 57 | 60 |
|
| 61 |
|
|
| 58 | 62 |
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 77 | 67 |
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 105 | 72 |
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 115 | 83 |
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 120 | 88 |
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 130 | 99 |
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 135 | 104 |
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 146 | 115 |
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 116 |
|
|
| 154 | 117 |
|
| 155 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 156 | 126 |
|
| 157 | 127 |
|
| 158 | 128 |
|
| 159 | 129 |
|
| 160 | 130 |
|
| 161 | 131 |
|
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
|
|
| 183 |
|
|
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
|
|
| 223 |
|
|
| 224 |
|
|
| 225 |
|
|
| 226 |
|
|
| 227 |
|
|
| 228 |
|
|
| 229 |
|
|
| 230 |
|
|
| 231 |
|
|
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| 238 |
|
|
| 239 |
|
|
| 240 |
|
|
| 241 |
|
|
| 242 |
|
|
| 243 |
|
|
| 244 |
|
|
| 245 |
|
|
| 246 |
|
|
| 247 |
|
|
| 248 |
|
|
| 249 |
|
|
| 250 |
|
|
| 251 |
|
|
| 252 |
|
|
| 253 |
|
|
| 254 |
|
|
| 255 |
|
|
| 256 |
|
|
| 257 |
|
|
| 258 |
|
|
| 259 |
|
|
| 260 |
|
|
| 261 |
|
|
| 262 |
|
|
| 263 |
|
|
| 264 |
|
|
| 265 |
|
|
| 266 |
|
|
| 267 |
|
|
| 268 |
|
|
| 269 |
|
|
| 270 |
|
|
| 271 |
|
|
| 272 |
|
|
| 273 |
|
|
| 274 |
|
|
| 275 |
|
|
| 276 |
|
|
| 277 |
|
|
| 278 |
|
|
| 279 |
|
|
| 280 |
|
|
| 281 |
|
|
| 282 |
|
|
| 283 |
|
|
| 284 |
|
|
| 285 |
|
|
| 286 |
|
|
| 287 |
|
|
| 288 |
|
|
| 289 |
|
|
| 290 |
|
|
| 291 |
|
|
| 292 |
|
|
| 293 |
|
|
| 132 |
|
|
| 294 | 133 |
|
| 295 | 134 |
|
| 296 | 135 |
|
| 297 |
|
|
| 298 |
|
|
| 299 |
|
|
| 300 |
|
|
| 301 |
|
|
| 302 |
|
|
| 303 | 136 |
|
| 304 | 137 |
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
|
|
| 305 | 143 |
|
| 306 |
|
|
| 144 |
|
|
| 145 |
|
|
| 307 | 146 |
|
| 308 | 147 |
|