huyuguo 4 anni fa
parent
commit
8fae6e118f

+ 0 - 164
app/src/main/java/com/electric/chargingpile/activity/LoginActivity.java

@ -57,140 +57,6 @@ public class LoginActivity extends Activity implements View.OnClickListener {
57 57
    String encode_token;
58 58
    Context mContext;
59 59
    public static final int RESULT_SUCCESS = 0;
60
//    private Bitmap download_bmp;
61
//
62
//    private Handler handler = new Handler() {
63
//        // 主线程通过这个方法处理消息
64
//        @Override
65
//        public void handleMessage(Message msg) {
66
//            switch (msg.what) {
67
//                case 1:
68
//                    try {
69
//                        JSONObject jsonObj = new JSONObject(msg.obj.toString());
70
//                        String status = jsonObj.getString("status");
71
//                        String info = jsonObj.getString("info");
72
//                        Log.e("成长模块测试", info);
73
//                    } catch (JSONException e) {
74
//                        e.printStackTrace();
75
//                    }
76
//                    break;
77
//                case 2:
78
//
79
//                    try {
80
//                        JSONObject jsonObj = new JSONObject(msg.obj.toString());
81
//                        String rtnCode = jsonObj.getString("rtnCode");
82
//
83
//
84
////                        String jifen = jsonObj.getString("jifen");
85
//                        if (rtnCode.equals("01")) {
86
//                            dismissDialog();
87
////                            ProfileManager.getInstance().setPassword(this,password.getText().toString());
88
////                            MainApplication.password = ProfileManager.getInstance().getPassword(mContext);
89
//                            String data = jsonObj.getString("data");
90
//                            try {
91
//                                Gson g = new Gson();
92
//                                User u = g.fromJson(data, User.class);
93
//                                Log.d("Nickname-----", u.getNickname());
94
//                                userid = u.getUserid().toString();
95
//                                if (!u.getUserpic().toString().equals("")) {
96
//                                    usericon = "http://123.57.6.131/zhannew//uploadfile/" + u.getUserpic().toString();
97
//                                } else {
98
//                                    usericon = "";
99
//                                }
100
//                                nickname = u.getNickname();
101
//                                username = u.getUsername();
102
//                                usersex = u.getSex();
103
//                                hascar = u.getChexing();
104
//                                nocar = u.getYichexing();
105
//                                if (nickname == null) {
106
//                                    nickname = "";
107
//                                }
108
//                                Log.e("usericon", usericon);
109
//                            } catch (Exception e) {
110
//                                e.printStackTrace();
111
//                            }
112
//
113
//                            SharedPreferences mySharedPreferences = getSharedPreferences("loginUserName",
114
//                                    Activity.MODE_PRIVATE);
115
//                            SharedPreferences.Editor editor1 = mySharedPreferences.edit();
116
//                            editor1.putString("username", phone.getText().toString());
117
//                            editor1.commit();
118
//
119
//
120
//                            SharedPreferences mSharedPreferences = getSharedPreferences("userInfo",
121
//                                    Activity.MODE_PRIVATE);
122
//                            SharedPreferences.Editor editor = mSharedPreferences.edit();
123
//                            editor.putString("nickname", nickname);
124
//                            editor.putString("username", username);
125
//                            editor.putString("sex", usersex);
126
//                            editor.putString("chexing", hascar);
127
//                            editor.putString("yichexing", nocar);
128
//                            editor.putString("password", password.getText().toString());
129
//                            editor.putString("yonghuming", phone.getText().toString());
130
////                            editor.putString("usericon",usericon);
131
//
132
//
133
//                            editor.commit();
134
//                            CreditActivity.canFresh = true;
135
//                            MainApplication.ok = "1";
136
//
137
//                            MainApplication.userPhone = phone.getText().toString().trim();
138
//                            MainApplication.userPassword = password.getText().toString();
139
//
140
//                            ProfileManager.getInstance().setUsername(LoginActivity.this,
141
//                                    phone.getText().toString().trim());
142
//                            ProfileManager.getInstance().setId(LoginActivity.this, phone.getText().toString().trim());
143
//                            ProfileManager.getInstance().setKeyUserpassword(LoginActivity.this, password.getText().toString().trim());
144
//
145
////                            Toast.makeText(LoginActivity.this,MainApplication.userId,Toast.LENGTH_SHORT).show();
146
//                            ProfileManager.getInstance().setUserid(LoginActivity.this, userid);
147
//                            ProfileManager.getInstance().setUsericon(LoginActivity.this, usericon);
148
//                            ProfileManager.getInstance().setNickname(LoginActivity.this, nickname);
149
//                            ProfileManager.getInstance().setUsercar(LoginActivity.this, hascar);
150
//                            MobclickAgent.onProfileSignIn(MainApplication.userId);
151
////                            startActivity(new Intent(LoginActivity.this, MainActicity.class));
152
////                            Toast.makeText(LoginActivity.this, "登录成功", Toast.LENGTH_SHORT).show();
153
//                            showTextToast("登录成功");
154
////                            MainFragment.showLogin();
155
////                            startActivity(new Intent(LoginActivity.this,UserCenterActivity.class));
156
//                            setResult(RESULT_SUCCESS);
157
//                            ProfileManager.getInstance().setCount(getApplicationContext(), 0);
158
//                            MainApplication.count = 0;
159
//                            finish();
160
//                        } else if (rtnCode.equals("03")) {
161
//                            dismissDialog();
162
//                            String rtnMsg = jsonObj.getString("rtnMsg");
163
////                            Toast.makeText(LoginActivity.this, "登录超时,请重新登录", Toast.LENGTH_SHORT).show();
164
//                            showTextToast("登录超时,请重新登录");
165
//                        } else if (rtnCode.equals("02")) {
166
//                            dismissDialog();
167
//                            String rtnMsg = jsonObj.getString("rtnMsg");
168
////                            Toast.makeText(LoginActivity.this, "用户不存在", Toast.LENGTH_SHORT).show();
169
//                            showTextToast("用户不存在,请核对后重新填写");
170
//                        } else if (rtnCode.equals("04")) {
171
//                            dismissDialog();
172
//                            String rtnMsg = jsonObj.getString("rtnMsg");
173
////                            Toast.makeText(LoginActivity.this, "密码错误", Toast.LENGTH_SHORT).show();
174
//                            showTextToast("密码错误,请重新输入");
175
//                        }
176
//                        return;
177
//                    } catch (Exception e) {
178
//                        e.printStackTrace();
179
//                    }
180
//                    break;
181
//                case 3:
182
////                    Toast.makeText(getApplication(), "服务器处理错误", Toast.LENGTH_SHORT).show();
183
//                    showTextToast("服务器处理错误");
184
//                    break;
185
//                case 5:
186
//
187
//                    break;
188
//                default:
189
//
190
//                    break;
191
//            }
192
//        }
193
//    };
194 60
195 61
    public void createDialog() {
196 62
        if (pd_info == null) {
@ -286,13 +152,6 @@ public class LoginActivity extends Activity implements View.OnClickListener {
286 152
287 153
            @Override
288 154
            public void afterTextChanged(Editable s) {
289
//                if (phone.hasFocus()){
290
//                    if (!password.getText().toString().equals("") && password.getText().toString() != null ){
291
//                        btn_clear.setVisibility(View.GONE);
292
//                    }else {
293
//                        btn_clear.setVisibility(View.GONE);
294
//                    }
295
//                }else{
296 155
                if (!password.getText().toString().equals("") && password.getText().toString() != null) {
297 156
                    btn_clear.setVisibility(View.VISIBLE);
298 157
                } else {
@ -309,8 +168,6 @@ public class LoginActivity extends Activity implements View.OnClickListener {
309 168
                    login.setTextColor(getResources().getColor(R.color.white));
310 169
                }
311 170
            }
312
313
//            }
314 171
        });
315 172
316 173
        //登陆按钮
@ -345,15 +202,8 @@ public class LoginActivity extends Activity implements View.OnClickListener {
345 202
346 203
    @Override
347 204
    public void onClick(View view) {
348
//        if (imm.isActive()) {
349
//            View v = getWindow().peekDecorView();
350
//            if (view != null) {
351
//                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
352
//            }
353
//        }
354 205
        switch (view.getId()) {
355 206
            case R.id.iv_back:
356
//                startActivity(new Intent(LoginActivity.this,MainActicity.class));
357 207
                finish();
358 208
                break;
359 209
            case R.id.tv_userLogin:
@ -363,31 +213,21 @@ public class LoginActivity extends Activity implements View.OnClickListener {
363 213
                        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
364 214
                    }
365 215
                }
366
367
368 216
                userLogin();
369
370
//                userGrowUp();
371 217
                break;
372 218
373 219
            case R.id.tv_newUser:
374 220
                startActivity(new Intent(this, RegisterActivity.class));
375 221
                ActivityManagerApplication.addDestoryActivity(this, "login");
376
//                startActivity(new Intent(this, UserInfoActivity.class));
377
378
//                finish();
379 222
                break;
380 223
381 224
            case R.id.tv_forgetPassword:
382 225
                ActivityManagerApplication.addDestoryActivity(LoginActivity.this, "LoginActivity");
383 226
                startActivity(new Intent(this, ForgetPasswordActivity.class));
384
//                finish();
385 227
                break;
386
387 228
            case R.id.btn_clear:
388 229
                password.setText("");
389 230
                break;
390
391 231
            case R.id.username_clear:
392 232
                phone.setText("");
393 233
                break;
@ -427,9 +267,6 @@ public class LoginActivity extends Activity implements View.OnClickListener {
427 267
428 268
                @Override
429 269
                public void onResponse(String response) {
430
                    LogUtils.e(response);
431
432
//                    Log.e(TAG, "onResponse: "+response );
433 270
                    dismissDialog();
434 271
                    String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
435 272
                    if ("01".equals(rtnCode)) {
@ -457,7 +294,6 @@ public class LoginActivity extends Activity implements View.OnClickListener {
457 294
    }
458 295
459 296
    private void saveUserInfo(String info) {
460
//        Log.e(TAG, "saveUserInfo: "+info );
461 297
        String userid = JsonUtils.getKeyResult(info, "userid");
462 298
        String nickname = JsonUtils.getKeyResult(info, "nickname");
463 299
        String tel = JsonUtils.getKeyResult(info, "tel");

+ 5 - 89
app/src/main/java/com/electric/chargingpile/activity/MainActicity.java

@ -12,8 +12,10 @@ import android.content.res.Configuration;
12 12
import android.os.Bundle;
13 13
import android.os.Handler;
14 14
import android.os.Message;
15

15 16
import androidx.fragment.app.FragmentActivity;
16 17
import androidx.fragment.app.FragmentTransaction;
18

17 19
import android.util.DisplayMetrics;
18 20
import android.util.Log;
19 21
import android.view.KeyEvent;
@ -83,57 +85,14 @@ public class MainActicity extends FragmentActivity {
83 85

84 86
    }
85 87

86

87
//    @TargetApi(19)
88
//    protected void setTranslucentStatus(boolean on) {
89
//        Window win = getWindow();
90
//        WindowManager.LayoutParams winParams = win.getAttributes();
91
//        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
92
//        if (on) {
93
//            winParams.flags |= bits;
94
//        } else {
95
//            winParams.flags &= ~bits;
96
//        }
97
//        win.setAttributes(winParams);
98
//    }
99
//
100
//    public void setStatusBarDarkMode(boolean darkmode, Activity activity) {
101
//        Class<? extends Window> clazz = activity.getWindow().getClass();
102
//        try {
103
//            int darkModeFlag = 0;
104
//            Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
105
//            Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
106
//            darkModeFlag = field.getInt(layoutParams);
107
//            Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
108
//            extraFlagField.invoke(activity.getWindow(), darkmode ? darkModeFlag : 0, darkModeFlag);
109
//        } catch (Exception e) {
110
//            e.printStackTrace();
111
//        }
112
//    }
113
//    @TargetApi(19)
114
//    private void setTranslucentStatus(boolean on) {
115
//        Window win = getWindow();
116
//        WindowManager.LayoutParams winParams = win.getAttributes();
117
//        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
118
//        if (on) {
119
//            winParams.flags |= bits;
120
//        } else {
121
//            winParams.flags &= ~bits;
122
//        }
123
//        win.setAttributes(winParams);
124
//    }
125

126

127 88
    protected void dialog() {
128 89
        AlertDialog.Builder builder = new AlertDialog.Builder(MainActicity.this);
129
//        builder.setMessage("请选择要显示的电桩类型");
130 90
        builder.setTitle("请选择要显示的电桩类型");
131 91
        builder.setPositiveButton("国标", new DialogInterface.OnClickListener() {
132 92
            @Override
133 93
            public void onClick(DialogInterface dialog, int which) {
134 94
                MainApplication.userTpye = "1";
135 95
                ProfileManager.getInstance().setType(MainActicity.this, "1");
136
//                MainFragment.firstSelect();
137 96
                dialog.dismiss();
138 97
            }
139 98
        });
@ -142,37 +101,14 @@ public class MainActicity extends FragmentActivity {
142 101
            public void onClick(DialogInterface dialog, int which) {
143 102
                MainApplication.userTpye = "2";
144 103
                ProfileManager.getInstance().setType(MainActicity.this, "2");
145
//                MainFragment.firstSelect();
146 104
                dialog.dismiss();
147 105
            }
148 106
        });
149 107
        builder.create().show();
150
//        Dialog.showSelectDialog(MainActicity.this, "选择对话框", new Dialog.DialogClickListener() {
151
//            @Override
152
//            public void confirm() {
153
//
154
//                MainApplication.userTpye="1";
155
//                ProfileManager.getInstance().setType(MainActicity.this, "1");
156
//                MainFragment.firstSelect();
157
//                Toast.makeText(MainActicity.this, "国标", Toast.LENGTH_SHORT).show();
158
//            }
159
//
160
//            @Override
161
//            public void cancel() {
162
//                MainApplication.userTpye="2";
163
//                ProfileManager.getInstance().setType(MainActicity.this, "2");
164
//                MainFragment.firstSelect();
165
//                Toast.makeText(MainActicity.this, "特斯拉", Toast.LENGTH_SHORT).show();
166
//            }
167
//        });
168

169 108
    }
170 109

171 110
    private void init() {
172 111
        if (!ProfileManager.getInstance().getGuide(this)) {
173
//            dialog();
174

175

176 112
            MainApplication.messageToken = "0";
177 113
            MainApplication.userTpye = "1";
178 114
            ProfileManager.getInstance().setGuide(this, true);
@ -189,22 +125,12 @@ public class MainActicity extends FragmentActivity {
189 125

190 126
            Log.i("MainApplication.costWay", MainApplication.costWay);
191 127
            MainApplication.messageToken = ProfileManager.getInstance().getKeyMessageToken(this);
192
//            MainApplication.userTpye=ProfileManager.getInstance().get(this);
193

194 128
        }
195 129
        mSlidingMenu = (SlidingMenu) findViewById(R.id.slidingMenu);
196
        mSlidingMenu.setLeftView(getLayoutInflater().inflate(
197
                R.layout.right_frame, null));
198
        mSlidingMenu.setCenterView(getLayoutInflater().inflate(
199
                R.layout.center_frame, null));
200

201
        FragmentTransaction t = this.getSupportFragmentManager()
202
                .beginTransaction();
130
        mSlidingMenu.setLeftView(getLayoutInflater().inflate(R.layout.right_frame, null));
131
        mSlidingMenu.setCenterView(getLayoutInflater().inflate(R.layout.center_frame, null));
203 132

204

205
//        mainFragment = new MainFragment();
206
//        t.replace(R.id.center_frame, mainFragment);
207
//        t.commit();
133
        FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
208 134
        mSlidingMenu.setCanSliding(false, false);
209 135
    }
210 136

@ -322,17 +248,7 @@ public class MainActicity extends FragmentActivity {
322 248
                if (!ExampleUtil.isEmpty(extras)) {
323 249
                    showMsg.append(KEY_EXTRAS + " : " + extras + "\n");
324 250
                }
325
                setCostomMsg(showMsg.toString());
326 251
            }
327 252
        }
328 253
    }
329

330
    private void setCostomMsg(String msg) {
331
//        if (null != msgText) {
332
//            msgText.setText(msg);
333
//            msgText.setVisibility(android.view.View.VISIBLE);
334
//        }
335
    }
336

337

338 254
}

+ 28 - 117
app/src/main/java/com/electric/chargingpile/activity/MainMapActivity.java

@ -2,7 +2,6 @@ package com.electric.chargingpile.activity;
2 2
3 3
import android.Manifest;
4 4
import android.app.Activity;
5
import android.app.Application;
6 5
import android.content.BroadcastReceiver;
7 6
import android.content.ContentValues;
8 7
import android.content.Context;
@ -378,8 +377,8 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
378 377
    public static boolean isStatusBack = false;
379 378
380 379
    private static final int RC_CAMERA_PERM = 123;
381
    private static final int RC_Location_FIRST_PERM = 124;
382 380
    private static final int RC_Location_PERM = 125;
381
    private static final int RC_Location_FIRST_PERM = 126;
383 382
384 383
    private String adfloatUrl = "";
385 384
@ -681,14 +680,6 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
681 680
                                    aMap.addMarker(oo);
682 681
                                }
683 682
                            }
684
//                            listt = list;
685
//                            if (list.size() > 0) {
686
//                                dialog.show();
687
//                                list = Util.getSortList(listt);
688
//                                list1 = list;
689
//                                dialog.cancel();
690
//                            }
691
//                            adapter.notifyDataSetChanged();
692 683
                        } catch (Exception e) {
693 684
                            BitmapDescriptor point = BitmapDescriptorFactory
694 685
                                    .fromResource(R.drawable.point_icon);
@ -696,7 +687,6 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
696 687
                                    anchor(0.5f, 0.5f).zIndex(7)
697 688
                                    .draggable(true).icon(point);
698 689
                            aMap.addMarker(oo);
699
//                            Toast.makeText(getActivity(),"该范围内没有充电桩",Toast.LENGTH_SHORT).show();
700 690
                        }
701 691
702 692
                    } catch (Exception e) {
@ -733,18 +723,6 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
733 723
        BarColorUtil.initStatusBarColor(MainMapActivity.this);
734 724
        m = this;
735 725
736
//        mquery = new WeatherSearchQuery("北京", WeatherSearchQuery.WEATHER_TYPE_FORECAST);
737
//        mweathersearch=new WeatherSearch(this);
738
//        mweathersearch.setOnWeatherSearchListener(this);
739
//        mweathersearch.setQuery(mquery);
740
//        mweathersearch.searchWeatherAsyn(); //异步搜索
741
//
742
//        mquery1 = new WeatherSearchQuery("北京", WeatherSearchQuery.WEATHER_TYPE_LIVE);
743
//        mweathersearch1=new WeatherSearch(this);
744
//        mweathersearch1.setOnWeatherSearchListener(this);
745
//        mweathersearch1.setQuery(mquery1);
746
//        mweathersearch1.searchWeatherAsyn(); //异步搜索
747
748 726
        mainMapActivity = MainMapActivity.this;
749 727
750 728
        intentFilter = new IntentFilter();
@ -757,12 +735,9 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
757 735
        if (MainApplication.ad_link.equals("1")) {
758 736
            againPoint = "1";
759 737
            is_dui = getIntent().getStringExtra("is_dui");
760
//            Log.e("is_dui===", is_dui);
761 738
            String url1 = getIntent().getStringExtra("shareUrl"); // web address
762
//            Log.e("z222", url1);
763 739
            if (is_dui.equals("0")) {
764 740
                Intent intent2 = new Intent(getApplication(), HomeWebActivity.class);
765
//        intent2.putExtra("shareUrl",url1);
766 741
                intent2.putExtra("shareUrl", url1);
767 742
                intent2.putExtra("shareTitle", getIntent().getStringExtra("shareTitle"));
768 743
                intent2.putExtra("shareIcon", getIntent().getStringExtra("shareIcon"));
@ -774,11 +749,7 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
774 749
                overridePendingTransition(0, 0);
775 750
            } else {
776 751
                long appTime11 = System.currentTimeMillis() / 1000;
777
//                Log.e("sfv_url===", getIntent().getStringExtra("shareUrl"));
778
//                Log.i("appTime(long)---", appTime11 + "");
779 752
                long updatetime1 = appTime11 - MainMapActivity.cha - 5;
780
//                Log.i("updatetime(long)---", updatetime1 + "");
781
//                Log.i("cha---", MainMapActivity.cha + "");
782 753
                String token1 = String.valueOf(updatetime1);
783 754
                String encode_token = null;
784 755
                try {
@ -787,14 +758,12 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
787 758
                    e.printStackTrace();
788 759
                }
789 760
                String replace = URLEncoder.encode(encode_token);
790
//                    startActivity(new Intent(getApplication(), ShopActivity.class));
791 761
                Intent intent11 = new Intent();
792 762
                intent11.setClass(getApplicationContext(), CreditActivity.class);
793 763
                intent11.putExtra("navColor", "#fcfcfc");    //配置导航条的背景颜色,请用#ffffff长格式。
794 764
                intent11.putExtra("titleColor", "#222222");    //配置导航条标题的颜色,请用#ffffff长格式。
795 765
                MainApplication.goods_type = "details";
796 766
                MainApplication.current_url = getIntent().getStringExtra("shareUrl");
797
//                MainApplication.current_url = "http://www.duiba.com.cn/mobile/appItemDetail?appItemId=453087";
798 767
                if (!MainApplication.isLogin()) {
799 768
                    intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?token=" + replace + "&url=" + MainApplication.current_url);    //配置自动登陆地址,每次需服务端动态生成。
800 769
                } else {
@ -880,13 +849,6 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
880 849
        }
881 850
        context = this;
882 851
        gestureguide = ProfileManager.getInstance().getGestureguide(getApplicationContext());
883
//        //开启logcat输出,方便debug,发布时请关闭
884
//        XGPushConfig.enableDebug(this, false);
885
//        XGPushManager.registerPush(context);
886
//
887
//        Context context = getApplicationContext();
888
//        Intent service = new Intent(context, XGPushService.class);
889
//        context.startService(service);
890 852
        dialog = new LoadingDialog(this);
891 853
        dialog.setCanceledOnTouchOutside(false);
892 854
@ -975,7 +937,6 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
975 937
                }
976 938
            }
977 939
        }, 2000);
978
979 940
    }
980 941
981 942
@ -1515,18 +1476,24 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
1515 1476
            //设置是否强制刷新WIFI,默认为强制刷新
1516 1477
            //mLocationOption.setWifiActiveScan(false);
1517 1478
            mLocationOption.setWifiScan(true);
1518
            if (ProfileManager.getInstance().getRequestLocationPermission(MainMapActivity.this)) {
1479
1480
            if (ProfileManager.getInstance().getStartedRequestLocationPermission(MainMapActivity.this)) {
1519 1481
                if (hasLocationPermission()) {
1520 1482
                    requestLocationPermission();
1521 1483
                }
1522 1484
            } else { // 首次启动
1523
                ProfileManager.getInstance().setRequestLocationPermission(MainMapActivity.this, true);
1485
                ProfileManager.getInstance().setStartedRequestLocationPermission(MainMapActivity.this, true);
1524 1486
                EasyPermissions.requestPermissions(
1525 1487
                        this,
1526 1488
                        "为了定位您的位置,推荐充电桩,充电桩位置路线导航需要开启位置权限,是否前往开启?",
1527 1489
                        RC_Location_FIRST_PERM,
1528 1490
                        Manifest.permission.ACCESS_FINE_LOCATION);
1529 1491
            }
1492
1493
            if (hasLocationPermission()) {
1494
                requestLocationPermission();
1495
            }
1496
1530 1497
        }
1531 1498
    }
1532 1499
@ -2504,24 +2471,8 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
2504 2471
                break;
2505 2472
2506 2473
            case R.id.tv_switch_city:
2507
                if (isListShow == false) {
2508
                    windowLayout.setVisibility(View.GONE);
2509
                    rl_control.setVisibility(View.VISIBLE);
2510
                }
2511
                if (null != current_chargePoint) {
2512
                    resetMarker();
2513
                }
2514
                MobclickAgent.onEvent(getApplicationContext(), "0107");
2515
                startActivity(new Intent(getApplicationContext(), NewSelectCityActivity.class));
2516
                if (ll_tuijian.getVisibility() == View.VISIBLE) {
2517
                    ll_tuijian.setVisibility(View.GONE);
2518
                    rl_tuijian_tip.setVisibility(View.VISIBLE);
2519
                    ll_top_right.setVisibility(View.VISIBLE);
2520
                    ll_map_control.setVisibility(View.VISIBLE);
2521
                }
2522
2474
                startNewSelectCityActivity();
2523 2475
                break;
2524
2525 2476
            case R.id.tab_screening:
2526 2477
                if (socket != null) {
2527 2478
                    try {
@ -2619,6 +2570,24 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
2619 2570
        }
2620 2571
    }
2621 2572
2573
    private void startNewSelectCityActivity() {
2574
        if (isListShow == false) {
2575
            windowLayout.setVisibility(View.GONE);
2576
            rl_control.setVisibility(View.VISIBLE);
2577
        }
2578
        if (null != current_chargePoint) {
2579
            resetMarker();
2580
        }
2581
        MobclickAgent.onEvent(getApplicationContext(), "0107");
2582
        startActivity(new Intent(getApplicationContext(), NewSelectCityActivity.class));
2583
        if (ll_tuijian.getVisibility() == View.VISIBLE) {
2584
            ll_tuijian.setVisibility(View.GONE);
2585
            rl_tuijian_tip.setVisibility(View.VISIBLE);
2586
            ll_top_right.setVisibility(View.VISIBLE);
2587
            ll_map_control.setVisibility(View.VISIBLE);
2588
        }
2589
    }
2590
2622 2591
    public void showMap() {
2623 2592
        if (MainApplication.isMap) {
2624 2593
            if (list.size() == 0) {
@ -3814,7 +3783,6 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
3814 3783
            MainApplication.sudu = ProfileManager.getInstance().getSudu(this);
3815 3784
        } else {
3816 3785
            MainApplication.userTpye = ProfileManager.getInstance().getTpey(this);
3817
//            Log.e("type!", MainApplication.userTpye);
3818 3786
            MainApplication.mapStatus = ProfileManager.getInstance().getMapstatus(this);
3819 3787
            MainApplication.costWay = ProfileManager.getInstance().getCostway(this);
3820 3788
            MainApplication.map = ProfileManager.getInstance().getMap(this);
@ -3882,57 +3850,6 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
3882 3850
        });
3883 3851
    }
3884 3852
3885
//    private void chargingStatus() {
3886
//        long appTime1 = System.currentTimeMillis() / 1000;
3887
//        long updatetime = appTime1 - MainMapActivity.cha - 3;
3888
//        String token = String.valueOf(updatetime);
3889
//        String url = MainApplication.url + "/zhannew/basic/web/index.php/xxapi/status_v2" +
3890
//                "?supplier=星星充电&timer=" + token + "&user_id=" + MainApplication.userId + "&password="+MainApplication.userPassword+"&ver=1.0&sign="
3891
//                + Md5Util.md5("password="+MainApplication.userPassword+"supplier=星星充电&timer=" + token + "&user_id=" + MainApplication.userId + "&key=661f9efdcb4f46fe7ab5f2e78a705a2a");
3892
////        Log.e("urlstatus", url);
3893
//        OkHttpUtils.get()
3894
//                .url(url)
3895
//                .build()
3896
//                .connTimeOut(10000)
3897
//                .readTimeOut(10000)
3898
//                .execute(new StringCallback() {
3899
//                    @Override
3900
//                    public void onError(Call call, Exception e) {
3901
//                        Toast.makeText(getApplicationContext(), "网络不给力", Toast.LENGTH_SHORT).show();
3902
//                    }
3903
//
3904
//                    @Override
3905
//                    public void onResponse(final String response) {
3906
//                        new Handler().postDelayed(new Runnable() {
3907
//                            @Override
3908
//                            public void run() {
3909
//                                String code = JsonUtils.getKeyResult(response, "code");
3910
//                                if (code.equals("200")) {
3911
//                                    rl_charging_notice.setVisibility(View.VISIBLE);
3912
//                                    if (firstCheck) {
3913
//                                        Intent intent3 = new Intent(getApplication(), MainScanActivity.class);
3914
//                                        intent3.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
3915
//                                        startActivity(intent3);
3916
//                                        overridePendingTransition(0, 0);
3917
//                                        ActivityManagerApplication.addDestoryActivity(MainMapActivity.this, "MainMapActivity");
3918
//                                        MainScanActivity.tag = "1";
3919
//                                        firstCheck = false;
3920
//                                    }
3921
//                                    Log.e("首页查询订单=", "有");
3922
//                                } else {
3923
//                                    rl_charging_notice.setVisibility(View.GONE);
3924
//                                    MainScanActivity.tag = "";
3925
//                                    Log.e("首页查询订单=", "没有");
3926
//                                    MainApplication.isAppStart = false;
3927
//                                    ProfileManager.getInstance().setAppStart(getApplicationContext(),MainApplication.isAppStart);
3928
//                                }
3929
//                            }
3930
//                        }, 2000);
3931
//
3932
//                    }
3933
//                });
3934
//    }
3935
3936 3853
3937 3854
    private void getZhanListData(int level) {
3938 3855
        aMap.clear();
@ -3974,12 +3891,6 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
3974 3891
                for (int i = 0; i < list_del.size(); i++) {
3975 3892
                    String[] args = {String.valueOf(list_del.get(i).getId())};
3976 3893
                    int mub = db.delete("zhan_list", "id=?", args);
3977
                    if (mub > 0) {
3978
//                        Log.e(TAG, "删除成功");
3979
                    } else {
3980
//                        Log.e(TAG, "删除失败---" + list_del.get(i).getId());
3981
                    }
3982
3983 3894
                }
3984 3895
                db.setTransactionSuccessful();//调用此方法会在执行到endTransaction() 时提交当前事务,如果不调用此方法会回滚事务
3985 3896
            } finally {

+ 91 - 98
app/src/main/java/com/electric/chargingpile/activity/NewSelectCityActivity.java

@ -1,13 +1,17 @@
1 1
package com.electric.chargingpile.activity;
2 2
3
import android.Manifest;
3 4
import android.content.Context;
4 5
import android.os.Bundle;
5 6
import android.os.Handler;
6 7
import android.os.Message;
8
9
import androidx.annotation.NonNull;
7 10
import androidx.appcompat.app.AppCompatActivity;
8 11
import androidx.recyclerview.widget.GridLayoutManager;
9 12
import androidx.recyclerview.widget.LinearLayoutManager;
10 13
import androidx.recyclerview.widget.RecyclerView;
14
11 15
import android.text.Editable;
12 16
import android.text.TextUtils;
13 17
import android.text.TextWatcher;
@ -43,13 +47,16 @@ import com.electric.chargingpile.data.CityTopHeaderBean;
43 47
import com.electric.chargingpile.gen.CityRecordDao;
44 48
import com.electric.chargingpile.helper.SuspensionDecoration;
45 49
import com.electric.chargingpile.iview.ISelectCityView;
50
import com.electric.chargingpile.manager.ProfileManager;
46 51
import com.electric.chargingpile.table.CityRecord;
47 52
import com.electric.chargingpile.util.BarColorUtil;
48 53
import com.electric.chargingpile.util.EventBusUtil;
49 54
import com.electric.chargingpile.util.JsonUtils;
50 55
import com.electric.chargingpile.util.LifeCycleEvent;
51 56
import com.electric.chargingpile.util.LoadingDialog;
57
import com.electric.chargingpile.util.SystemTypeUtil;
52 58
import com.electric.chargingpile.util.ToastUtil;
59
import com.electric.chargingpile.view.AlertDialogCommon;
53 60
import com.electric.chargingpile.view.IndexBar;
54 61
import com.electric.chargingpile.view.MyItemDecoration;
55 62
import com.google.gson.Gson;
@ -66,9 +73,11 @@ import java.util.ArrayList;
66 73
import java.util.List;
67 74
68 75
import io.reactivex.subjects.PublishSubject;
76
import pub.devrel.easypermissions.AfterPermissionGranted;
77
import pub.devrel.easypermissions.EasyPermissions;
69 78
70 79
71
public class NewSelectCityActivity extends AppCompatActivity implements ISelectCityView, AMapLocationListener {
80
public class NewSelectCityActivity extends AppCompatActivity implements ISelectCityView, AMapLocationListener, EasyPermissions.PermissionCallbacks {
72 81
    private RecyclerView evsdkRvSearch;
73 82
    private Context mContext;
74 83
    private RecyclerView mRv;
@ -103,6 +112,9 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
103 112
    private ImageView ivBack, ivSearchClear;
104 113
    private EditText etSearch;
105 114
    private LinearLayout llLayout;
115
116
    private static final int RC_Location_PERM = 125;
117
106 118
    Handler hand = new Handler() {
107 119
        public void handleMessage(android.os.Message msg) {
108 120
            switch (msg.what) {
@ -117,18 +129,13 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
117 129
                        } catch (Exception e) {
118 130
                            e.printStackTrace();
119 131
                        }
120
121 132
                    } catch (Exception e) {
122 133
                        e.printStackTrace();
123 134
                    }
124
125 135
                    break;
126
127
128 136
                default:
129 137
                    break;
130 138
            }
131
132 139
        }
133 140
134 141
        ;
@ -139,7 +146,6 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
139 146
        super.onCreate(savedInstanceState);
140 147
        setContentView(R.layout.activity_new_select_city);
141 148
        BarColorUtil.initStatusBarColor(NewSelectCityActivity.this);
142
143 149
        initViews();
144 150
    }
145 151
@ -153,19 +159,13 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
153 159
        llLayout.setFocusable(true);
154 160
        llLayout.setFocusableInTouchMode(true);
155 161
        mContext = this;
156
//        selectCityPresenter = new SelectCityPresenter(this, SelectCityActivity.this);
157 162
        mRv = (RecyclerView) findViewById(R.id.evsdk_rv);
158 163
        mRv.setLayoutManager(mManager = new LinearLayoutManager(this));
159 164
160 165
        mSourceDatas = new ArrayList<>();
161 166
        mHeaderDatas = new ArrayList<>();
162
//        List<AllCityBean> locationCity = new ArrayList<>();
163
//        locationCity.add("定位中");
164
//        mHeaderDatas.add(new CityHeaderBean(locationCity, "定位城市", "定"));
165 167
        List<AllCityBean> recentCitys = new ArrayList<>();
166 168
        mHeaderDatas.add(new CityHeaderBean(recentCitys, "最近访问", "近"));
167
//        List<String> hotCitys = new ArrayList<>();
168
//        mHeaderDatas.add(new CityHeaderBean(recentCitys, "热门城市", "热"));
169 169
        mSourceDatas.addAll(mHeaderDatas);
170 170
171 171
        mAdapter = new SelectCityAdapter(this, R.layout.evsdk_item_select_city, mBodyDatas, NewSelectCityActivity.this);
@ -208,8 +208,6 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
208 208
                    mTvCity = holder.getView(R.id.evsdk_tv_current_city);
209 209
                    holder.setText(R.id.evsdk_tv_current_city, cityTopHeaderBean.getTxt() + currentLocationCity);
210 210
                    mTvLocation = holder.getView(R.id.evsdk_tv_location);
211
//                        holder.setText(R.id.evsdk_tv_location, cityTopHeaderBean.getTxt());
212
213 211
                    holder.setOnClickListener(R.id.evsdk_tv_location, new View.OnClickListener() {
214 212
                        @Override
215 213
                        public void onClick(View view) {
@ -217,7 +215,7 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
217 215
                            if (null == mlocationClient) {
218 216
                                initLocation();
219 217
                            } else {
220
                                mlocationClient.startLocation();
218
                                requestLocationPermission();
221 219
                            }
222 220
                            mTvLocation.setEnabled(false);
223 221
                        }
@ -244,9 +242,6 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
244 242
        };
245 243
        mHeaderAdapter.setHeaderView(0, R.layout.evsdk_item_header_top, new CityTopHeaderBean("定位城市:" + currentLocationCity));
246 244
        mHeaderAdapter.setHeaderView(1, R.layout.evsdk_item_header, mHeaderDatas.get(0));
247
//        mHeaderAdapter.setHeaderView(2, R.layout.evsdk_item_header, mHeaderDatas.get(1));
248
//        mHeaderAdapter.setHeaderView(3, R.layout.meituan_item_header, mHeaderDatas.get(2));
249
250 245
        mRv.setAdapter(mHeaderAdapter);
251 246
        mRv.addItemDecoration(mDecoration = new SuspensionDecoration(this, mSourceDatas)
252 247
                .setmTitleHeight((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 28, getResources().getDisplayMetrics()))
@ -254,7 +249,6 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
254 249
                .setTitleFontSize((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14, getResources().getDisplayMetrics()))
255 250
                .setColorTitleFont(mContext.getResources().getColor(R.color.ui_68))
256 251
                .setHeaderViewCount(mHeaderAdapter.getHeaderViewCount() - mHeaderDatas.size()));
257
//        mRv.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
258 252
        mRv.addItemDecoration(new MyItemDecoration());
259 253
260 254
        //使用indexBar
@ -384,10 +378,6 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
384 378
                .invalidate();
385 379
        mDecoration.setmDatas(mSourceDatas);
386 380
387
//        CityHeaderBean header1 = mHeaderDatas.get(0);
388
//        header1.getCityList().clear();
389
//        header1.getCityList().add("北京");
390
391 381
        //初始化选择过的城市信息
392 382
        List<CityRecord> localRecordList = getLocalCityRecordData();
393 383
        List<AllCityBean> showCityList = new ArrayList<>();
@ -404,44 +394,38 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
404 394
        initLocation();
405 395
        CityHeaderBean header2 = mHeaderDatas.get(0);
406 396
        header2.setCityList(showCityList);
407
//
408
////        添加热门城市
409
//                CityHeaderBean header3 = mHeaderDatas.get(1);
410
//                List<String> hotCitys = new ArrayList<>();
411
//                hotCitys.add("上海");
412
//                hotCitys.add("北京");
413
//                hotCitys.add("杭州");
414
//                hotCitys.add("广州");
415
//                header3.setCityList(showCityList);
416
//
417
//        mHeaderAdapter.notifyItemRangeChanged(1, 3);
418
//        initLocation();
419 397
    }
420 398
421 399
    private void initLocation() {
422
//        AMapLocationClientOption mLocationOption = null;
423 400
        mlocationClient = new AMapLocationClient(this);
424
//初始化定位参数
401
        //初始化定位参数
425 402
        mLocationOption = new AMapLocationClientOption();
426
//设置定位监听
403
        //设置定位监听
427 404
        mlocationClient.setLocationListener(this);
428
//设置定位模式为高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式
405
        //设置定位模式为高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式
429 406
        mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
430 407
        mLocationOption.setOnceLocation(true);
431 408
        //设置是否强制刷新WIFI,默认为强制刷新
432 409
        mLocationOption.setWifiActiveScan(false);
433
//设置定位间隔,单位毫秒,默认为2000ms
434
//        mLocationOption.setInterval(2000);
435
//设置定位参数
410
        //设置定位间隔,单位毫秒,默认为2000ms
411
        // mLocationOption.setInterval(2000);
412
        // 设置定位参数
436 413
        mlocationClient.setLocationOption(mLocationOption);
437
// 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
438
// 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求
439
// 在定位结束后,在合适的生命周期调用onDestroy()方法
440
// 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除
441
442
//启动定位
443
        mlocationClient.startLocation();
444
414
        // 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
415
        // 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求
416
        // 在定位结束后,在合适的生命周期调用onDestroy()方法
417
        // 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除
418
        //启动定位
419
420
        if (hasLocationPermission()) {
421
            requestLocationPermission();
422
        } else {
423
            mTvLocation.setText("定位失败");
424
            if (!ProfileManager.getInstance().getFirstRequestLocationPermission(NewSelectCityActivity.this)) {
425
                ProfileManager.getInstance().setFirstRequestLocationPermission(NewSelectCityActivity.this, true);
426
                requestLocationPermission();
427
            }
428
        }
445 429
    }
446 430
447 431
    private void insertData(CityRecord cityRecord) {
@ -476,17 +460,11 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
476 460
                try {
477 461
                    socket = new Socket("cdz.evcharge.cc", 9503); // IP:10.14.114.127,端口54321
478 462
                    // 向服务器发送消息
479
                    PrintWriter out = new PrintWriter(new BufferedWriter(
480
                            new OutputStreamWriter(socket.getOutputStream())), true);
463
                    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true);
481 464
                    out.println(params);
482
                    // out.println("{\"fun\":\"getcity\"}");
483 465
                    // 接收来自服务器的消息
484
                    BufferedReader br = new BufferedReader(new InputStreamReader(
485
                            socket.getInputStream()));
486
466
                    BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
487 467
                    String msg = br.readLine();
488
//                        Log.d("dddddmsg",msg);
489
490 468
                    if (msg != null) {
491 469
                        Message mes = new Message();
492 470
                        mes.obj = msg;
@ -498,7 +476,6 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
498 476
                    br.close();
499 477
                    // 关闭Socket
500 478
                    socket.close();
501
//                    }
502 479
                } catch (Exception e) {
503 480
                }
504 481
            }
@ -506,39 +483,23 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
506 483
    }
507 484
508 485
    public static String getMD5(String content) {
509
510 486
        try {
511
512 487
            MessageDigest digest = MessageDigest.getInstance("MD5");
513
514 488
            digest.update(content.getBytes());
515
516 489
            return getHashString(digest);
517
518
519 490
        } catch (Exception e) {
520
491
            e.printStackTrace();
521 492
        }
522
523 493
        return null;
524
525 494
    }
526 495
527 496
    private static String getHashString(MessageDigest digest) {
528
529 497
        StringBuilder builder = new StringBuilder();
530
531 498
        for (byte b : digest.digest()) {
532
533 499
            builder.append(Integer.toHexString((b >> 4) & 0xf));
534
535 500
            builder.append(Integer.toHexString(b & 0xf));
536
537 501
        }
538
539
540 502
        return builder.toString().toLowerCase();
541
542 503
    }
543 504
544 505
    @Override
@ -560,7 +521,6 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
560 521
                String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
561 522
                LogUtils.e(errText);
562 523
                mTvLocation.setText("定位失败");
563
564 524
            }
565 525
        }
566 526
    }
@ -575,7 +535,6 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
575 535
        mLoadingDialog.show();
576 536
    }
577 537
578
579 538
    /**
580 539
     * 关闭进度对话框
581 540
     */
@ -606,29 +565,63 @@ public class NewSelectCityActivity extends AppCompatActivity implements ISelectC
606 565
        } else {
607 566
            ToastUtil.showToast(getApplicationContext(), "抱歉,暂时没有找到相关城市", Toast.LENGTH_SHORT);
608 567
        }
609
//        return findCityList;
610
//        if (null != mIView) {
611
//            Observable.create(new ObservableOnSubscribe<List<AllCityBean>>() {
612
//                @Override
613
//                public void subscribe(@NonNull ObservableEmitter<List<AllCityBean>> e) throws Exception {
614
//                    e.onNext(cityModel.getSearchDataList(allCityBeanList, searchString));
615
//                }
616
//            }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<List<AllCityBean>>() {
617
//                @Override
618
//                public void accept(List<AllCityBean> list) throws Exception {
619
//                    LogUtils.e(list.size());
620
//                    if (list.size() > 0) {
621
//                        mIView.showSearchCityData(list);
622
//                    } else {
623
//                        mIView.showFailToast(activity.getResources().getString(R.string.evsdk_select_city_error));
624
//                    }
625
//                }
626
//            });
627
//        }
628 568
    }
629 569
630 570
    @Override
631 571
    public PublishSubject<LifeCycleEvent> getLifeSubject() {
632 572
        return null;
633 573
    }
574
575
576
    @Override
577
    public void onPermissionsGranted(int requestCode, List<String> perms) {
578
        dismissLoadingDialog();
579
        mTvLocation.setEnabled(true);
580
    }
581
582
    @Override
583
    public void onPermissionsDenied(int requestCode, List<String> perms) {
584
        dismissLoadingDialog();
585
        mTvLocation.setEnabled(true);
586
        if (SystemTypeUtil.isEmui()) {
587
            return;
588
        }
589
        if (requestCode == RC_Location_PERM) {
590
            new AlertDialogCommon(NewSelectCityActivity.this).builder()
591
                    .setMsg("为了定位您的位置,推荐充电桩,充电桩位置路线导航需要开启位置权限,是否前往开启?")
592
                    .setPositiveButton("去开启", new View.OnClickListener() {
593
                        @Override
594
                        public void onClick(View v) {
595
                            SystemTypeUtil.goToPermissionManager(NewSelectCityActivity.this);
596
                        }
597
                    }).setNegativeButton("取消", new View.OnClickListener() {
598
                @Override
599
                public void onClick(View v) {
600
                }
601
            }).show();
602
        }
603
    }
604
605
    @Override
606
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
607
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
608
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
609
    }
610
611
    private boolean hasLocationPermission() {
612
        return EasyPermissions.hasPermissions(this, Manifest.permission.ACCESS_FINE_LOCATION);
613
    }
614
615
    @AfterPermissionGranted(RC_Location_PERM)
616
    public void requestLocationPermission() {
617
        if (hasLocationPermission()) {
618
            mlocationClient.startLocation();
619
        } else {
620
            EasyPermissions.requestPermissions(
621
                    this,
622
                    "为了定位您的位置,推荐充电桩,充电桩位置路线导航需要开启位置权限,是否前往开启?",
623
                    RC_Location_PERM,
624
                    Manifest.permission.ACCESS_FINE_LOCATION);
625
        }
626
    }
634 627
}

+ 0 - 43
app/src/main/java/com/electric/chargingpile/activity/SwitchCityActivity.java

@ -525,16 +525,6 @@ public class SwitchCityActivity extends Activity implements OnScrollListener, AM
525 525
                Log.e("info", "city = " + amapLocation.getCity());
526 526
                locateProcess = 2; // 定位成功
527 527
                Log.e(TAG, "onLocationChanged: " + locateProcess);
528
//                if (!isNeedFresh) {
529
//                    return;
530
//                }
531
//                isNeedFresh = false;
532
//                if (amapLocation.getCity() == null) {
533
//                    locateProcess = 3; // 定位失败
534
//                    personList.setAdapter(adapter);
535
//                    adapter.notifyDataSetChanged();
536
//                    return;
537
//                }
538 528
                currentCity = amapLocation.getCity().substring(0,
539 529
                        amapLocation.getCity().length() - 1);
540 530
                MainMapActivity.tv_atCity.setText(currentCity);
@ -554,39 +544,6 @@ public class SwitchCityActivity extends Activity implements OnScrollListener, AM
554 544
        }
555 545
    }
556 546
557
//    /**
558
//     * 实现实位回调监听
559
//     */
560
//    public class MyLocationListener implements BDLocationListener {
561
//
562
//        @Override
563
//        public void onReceiveLocation(BDLocation arg0) {
564
//            MainFragment.tv_switch.setText(arg0.getCity());
565
//            Log.e("info", "city = " + arg0.getCity());
566
//            if (!isNeedFresh) {
567
//                return;
568
//            }
569
//            isNeedFresh = false;
570
//            if (arg0.getCity() == null) {
571
//                locateProcess = 3; // 定位失败
572
//                personList.setAdapter(adapter);
573
//                adapter.notifyDataSetChanged();
574
//                return;
575
//            }
576
//            currentCity = arg0.getCity().substring(0,
577
//                    arg0.getCity().length() - 1);
578
//
579
//            locateProcess = 2; // 定位成功
580
//            personList.setAdapter(adapter);
581
//            adapter.notifyDataSetChanged();
582
//        }
583
//
584
//        @Override
585
//        public void onReceivePoi(BDLocation arg0) {
586
//
587
//        }
588
//    }
589
590 547
    private class ResultListAdapter extends BaseAdapter {
591 548
        private LayoutInflater inflater;
592 549
        private ArrayList<SwitchCity> results = new ArrayList<SwitchCity>();

+ 16 - 82
app/src/main/java/com/electric/chargingpile/activity/WelcomeActivity.java

@ -85,16 +85,9 @@ import okhttp3.Call;
85 85
import pub.devrel.easypermissions.AfterPermissionGranted;
86 86
import pub.devrel.easypermissions.EasyPermissions;
87 87

88
public class WelcomeActivity extends Activity implements OnClickListener {
88
public class WelcomeActivity extends Activity {
89 89
    private static final String TAG = "WelcomeActivity";
90
    private ViewPager viewPager;
91
    private List<View> views;
92
    private ImageView img_welcome;
93
    private View one, two, three, four;
94
    private RelativeLayout rl_welcome;
95 90
    private TextView androidd;
96
    Bitmap bitmap;
97
    private ImageView enter;
98 91
    private String imgUrl = "", app_version = "";
99 92
    String img = "";
100 93
    String url = "";
@ -102,7 +95,7 @@ public class WelcomeActivity extends Activity implements OnClickListener {
102 95
    private Timer mTimer;
103 96
    private int count = 0;
104 97
    private LinearLayout ll_1;
105
    public static List<AdDetail> list_ad = new ArrayList<AdDetail>();
98
//    public static List<AdDetail> list_ad = new ArrayList<AdDetail>();
106 99
    public static List<OperatorData> ll = new ArrayList<OperatorData>();
107 100
    public static String canCost = "";
108 101
    private static final int RC_CAMERA_PERM = 123;
@ -287,41 +280,22 @@ public class WelcomeActivity extends Activity implements OnClickListener {
287 280
        getVersion();
288 281
        MapsInitializer.sdcardDir = MAP_FILE_PATH;
289 282
        mTimer = new Timer();
290
        if (ProfileManager.getInstance().getGuide(this)) {
291
            new Handler().postDelayed(new Runnable() {
292
                @Override
293
                public void run() {
294
                    eteinit("{\"fun\":\"timer\"}");
295
                }
296
            }, 1000);
297

298
        } else {
299
            androidd.setVisibility(View.GONE);
300
            ll_1.setVisibility(View.GONE);
301
            viewPager = (ViewPager) findViewById(R.id.viewpager);
302
            viewPager.setVisibility(View.VISIBLE);
303
            views = new ArrayList<View>();
304
            one = LayoutInflater.from(this).inflate(R.layout.viewpager_guide_one, null);
305
            two = LayoutInflater.from(this).inflate(R.layout.viewpager_guide_two, null);
306
            three = LayoutInflater.from(this).inflate(R.layout.viewpager_guide_three, null);
307
            four = LayoutInflater.from(this).inflate(R.layout.viewpager_guide_four, null);
308
            enter = (ImageView) four.findViewById(R.id.bt_enter);
309
            enter.setOnClickListener(this);
310

311
            views.add(one);
312
            views.add(two);
313
            views.add(three);
314
            views.add(four);
315

316
            viewPager.setAdapter(new ViewPagerAdapter(views));
317
            viewPager.setCurrentItem(0);
318

319
            if (!NotificationManagerCompat.from(WelcomeActivity.this).areNotificationsEnabled()) {
320
                openNotification();
283
        new Handler().postDelayed(new Runnable() {
284
            @Override
285
            public void run() {
286
                eteinit("{\"fun\":\"timer\"}");
321 287
            }
322
        }
288
        }, 1000);
289

290

291
//            if (!NotificationManagerCompat.from(WelcomeActivity.this).areNotificationsEnabled()) {
292
//                openNotification();
293
//            }
323 294
    }
324 295

296
    /**
297
     * 打开消息推送权限
298
     */
325 299
    private void openNotification() {
326 300
        AlertDialog.Builder builder = new AlertDialog.Builder(WelcomeActivity.this);
327 301
        builder.setTitle("\"充电桩\"想给您发送通知");
@ -535,7 +509,7 @@ public class WelcomeActivity extends Activity implements OnClickListener {
535 509
                    long appTime1 = System.currentTimeMillis() / 1000;
536 510
                    long updatetime = appTime1 - 7200;
537 511
                    String token = String.valueOf(updatetime);
538
                    String replace = URLEncoder.encode(DES3.encode(token));
512
                    String replace = URLEncoder.encode(DES3.encode(token), "UTF-8");
539 513
                    url = MainApplication.url + "/zhannew/basic/web/index.php/ad/get?timer=" + replace;
540 514
                } catch (Exception e) {
541 515
                    e.printStackTrace();
@ -594,24 +568,6 @@ public class WelcomeActivity extends Activity implements OnClickListener {
594 568
        JPushInterface.onPause(this);
595 569
    }
596 570

597
    @Override
598
    public void onClick(View v) {
599
        switch (v.getId()) {
600
            case R.id.guideone:
601
                viewPager.setCurrentItem(1);
602
                break;
603
            case R.id.guidetwo:
604
                viewPager.setCurrentItem(2);
605
                break;
606
            case R.id.guidethree:
607
                viewPager.setCurrentItem(3);
608
            case R.id.bt_enter:
609
                startActivity(new Intent(this, MainMapActivity.class));
610
                finish();
611
                break;
612
        }
613
    }
614

615 571
    private void dealOperatorData() {
616 572
        String operator = ProfileManager.getInstance().getKeyOperator(getApplicationContext());
617 573
        String localOperators = "";
@ -659,26 +615,4 @@ public class WelcomeActivity extends Activity implements OnClickListener {
659 615
            }
660 616
        });
661 617
    }
662

663
    public static void DeleteFile(File file) {
664
        if (file.exists() == false) {
665
            return;
666
        } else {
667
            if (file.isFile()) {
668
                file.delete();
669
                return;
670
            }
671
            if (file.isDirectory()) {
672
                File[] childFile = file.listFiles();
673
                if (childFile == null || childFile.length == 0) {
674
                    file.delete();
675
                    return;
676
                }
677
                for (File f : childFile) {
678
                    DeleteFile(f);
679
                }
680
                file.delete();
681
            }
682
        }
683
    }
684 618
}

+ 0 - 68
app/src/main/java/com/electric/chargingpile/adapter/CityListAdapter.java

@ -259,15 +259,7 @@ public class CityListAdapter extends BaseAdapter implements AMapLocationListener
259 259
            if (amapLocation != null
260 260
                    && amapLocation.getErrorCode() == 0) {
261 261
                Log.e("info", "city = " + amapLocation.getCity());
262
//					if (!isNeedFresh) {
263
//						return;
264
//					}
265
                isNeedRefresh = false;
266 262
                if (amapLocation.getCity() == null) {
267
//						locateProcess = 3; // 定位失败
268
//						personList.setAdapter(adapter);
269
//						adapter.notifyDataSetChanged();
270
271 263
                    return;
272 264
                }
273 265
                currentCity = amapLocation.getCity().substring(0,
@ -280,10 +272,6 @@ public class CityListAdapter extends BaseAdapter implements AMapLocationListener
280 272
                mlocationClient.stopLocation();
281 273
                pbLocate.setVisibility(View.GONE);
282 274
                SelectCityActivity.locateProcess = 2;
283
284
//					locateProcess = 2; // 定位成功
285
//					personList.setAdapter(adapter);
286
//					adapter.notifyDataSetChanged();
287 275
            } else {
288 276
                String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
289 277
                Log.e("AmapErr", errText);
@ -298,62 +286,6 @@ public class CityListAdapter extends BaseAdapter implements AMapLocationListener
298 286
        LinearLayout llMain;
299 287
    }
300 288
301
//	public void initLocation() {
302
//		myLocationClient = new LocationClient(mContext);
303
//		myLocationListener=new MyLocationListener();
304
//		myLocationClient.registerLocationListener(myLocationListener);
305
//		// 设置定位参数
306
//		LocationClientOption option = new LocationClientOption();
307
//		option.setCoorType("bd09ll"); // 设置坐标类型
308
//		option.setScanSpan(10000); // 10分钟扫描1次
309
//		// 需要地址信息,设置为其他任何值(string类型,且不能为null)时,都表示无地址信息。
310
//		option.setAddrType("all");
311
//		// 设置是否返回POI的电话和地址等详细信息。默认值为false,即不返回POI的电话和地址信息。
312
//		option.setPoiExtraInfo(true);
313
//		// 设置产品线名称。强烈建议您使用自定义的产品线名称,方便我们以后为您提供更高效准确的定位服务。
314
//		option.setProdName("通过GPS定位我当前的位置");
315
//		// 禁用启用缓存定位数据
316
//		option.disableCache(true);
317
//		// 设置最多可返回的POI个数,默认值为3。由于POI查询比较耗费流量,设置最多返回的POI个数,以便节省流量。
318
//		option.setPoiNumber(3);
319
//		// 设置定位方式的优先级。
320
//		// 当gps可用,而且获取了定位结果时,不再发起网络请求,直接返回给用户坐标。这个选项适合希望得到准确坐标位置的用户。如果gps不可用,再发起网络请求,进行定位。
321
//		option.setPriority(LocationClientOption.GpsFirst);
322
//		myLocationClient.setLocOption(option);
323
//		myLocationClient.start();
324
//	}
325
//
326
//	public class MyLocationListener implements BDLocationListener{
327
//
328
//		@Override
329
//		public void onReceiveLocation(BDLocation arg0) {
330
//
331
//			isNeedRefresh=false;
332
//			if(arg0.getCity()==null){
333
//				//定位失败
334
//				tvLocate.setText("未定位到城市,请选择");
335
//				tvCurrentLocateCity.setVisibility(View.VISIBLE);
336
//				tvCurrentLocateCity.setText("重新选择");
337
//				pbLocate.setVisibility(View.GONE);
338
//				return;
339
//			}else{
340
//				//定位成功
341
//				currentCity=arg0.getCity().substring(0,arg0.getCity().length()-1);
342
//				tvLocate.setText("当前定位城市");
343
//				tvCurrentLocateCity.setVisibility(View.VISIBLE);
344
//				tvCurrentLocateCity.setText(currentCity);
345
//				myLocationClient.stop();
346
//				pbLocate.setVisibility(View.GONE);
347
//			}
348
//		}
349
//
350
//		@Override
351
//		public void onReceivePoi(BDLocation arg0) {
352
//
353
//		}
354
//
355
//	}
356
357 289
    private void setUpMap() {
358 290
//        //声明mLocationOption对象
359 291
//        AMapLocationClientOption mLocationOption = null;

+ 14 - 6
app/src/main/java/com/electric/chargingpile/manager/ProfileManager.java

@ -15,7 +15,8 @@ public class ProfileManager {
15 15
    private static final String KEY_GUIDE = "key_guide";
16 16
    private static final String KEY_PRIVACY_AGREEMENT = "key_privacy_agreement";
17 17
    private static final String KEY_PRIVACY_PERMISSION = "key_privacy_permission";
18
    private static final String KEY_LOCATION_PERMISSION = "key_location_permission";
18
    private static final String KEY_FIRST_REQUEST_LOCATION_PERMISSION = "key_first_requrest_location_permission";
19
    private static final String KEY_STARTED_REQUEST_LOCATION_PERMISSION = "key_started_requrest_location_permission";
19 20
    private static final String KEY_TYPE = "key_type";
20 21
    private static final String KEY_USERID = "key_userid";
21 22
    private static final String KEY_USERICON = "key_usericon";
@ -593,13 +594,20 @@ public class ProfileManager {
593 594
                false);
594 595
    }
595 596

596
    public void setRequestLocationPermission(Context context, boolean permission) {
597
        PreferenceManager.getInstance(context).putBoolean(KEY_LOCATION_PERMISSION, permission);
597
    public void setFirstRequestLocationPermission(Context context, boolean permission) {
598
        PreferenceManager.getInstance(context).putBoolean(KEY_FIRST_REQUEST_LOCATION_PERMISSION, permission);
598 599
    }
599 600

600
    public boolean getRequestLocationPermission(Context context) {
601
        return PreferenceManager.getInstance(context).getBoolean(KEY_LOCATION_PERMISSION,
602
                false);
601
    public boolean getFirstRequestLocationPermission(Context context) {
602
        return PreferenceManager.getInstance(context).getBoolean(KEY_FIRST_REQUEST_LOCATION_PERMISSION, false);
603
    }
604

605
    public void setStartedRequestLocationPermission(Context context, boolean permission) {
606
        PreferenceManager.getInstance(context).putBoolean(KEY_STARTED_REQUEST_LOCATION_PERMISSION, permission);
607
    }
608

609
    public boolean getStartedRequestLocationPermission(Context context) {
610
        return PreferenceManager.getInstance(context).getBoolean(KEY_STARTED_REQUEST_LOCATION_PERMISSION, false);
603 611
    }
604 612

605 613


+ 21 - 8
app/src/main/java/com/electric/chargingpile/util/SystemTypeUtil.java

@ -7,6 +7,7 @@ import android.content.Intent;
7 7
import android.net.Uri;
8 8
import android.os.Build;
9 9
import android.os.Environment;
10
import android.provider.Settings;
10 11
import android.text.TextUtils;
11 12
import android.util.Log;
12 13
import android.view.View;
@ -50,6 +51,7 @@ public class SystemTypeUtil {
50 51
51 52
    private static String sName;
52 53
    private static String sVersion;
54
53 55
    // 华为
54 56
    public static boolean isEmui() {
55 57
        return check(ROM_EMUI);
@ -172,15 +174,26 @@ public class SystemTypeUtil {
172 174
            }
173 175
        } else if (isMiui()) {
174 176
//            ToastUtil.show("我是小米");
175
            Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
176
            ComponentName componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
177
            intent.setComponent(componentName);
178
            intent.putExtra("extra_pkgname", BuildConfig.APPLICATION_ID);
179 177
            try {
180
                context.startActivity(intent);
178
                // MIUI 7/8
179
                Intent localIntent = new Intent("miui.intent.action.APP_PERM_EDITOR");
180
                localIntent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.PermissionsEditorActivity");
181
                localIntent.putExtra("extra_pkgname", context.getPackageName());
182
                context.startActivity(localIntent);
181 183
            } catch (Exception e) {
182
                e.printStackTrace();
183
                context.startActivity(getAppDetailSettingIntent(context));
184
                try {
185
                    // MIUI 5/6
186
                    Intent localIntent = new Intent("miui.intent.action.APP_PERM_EDITOR");
187
                    localIntent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
188
                    localIntent.putExtra("extra_pkgname", context.getPackageName());
189
                    context.startActivity(localIntent);
190
                } catch (Exception e1) {
191
                    // 否则跳转到应用详情
192
                    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
193
                    Uri uri = Uri.fromParts("package", context.getPackageName(), null);
194
                    intent.setData(uri);
195
                    context.startActivity(intent);
196
                }
184 197
            }
185 198
        } else if (isEmui()) {
186 199
//            ToastUtil.show("我是华为");
@ -314,7 +327,7 @@ public class SystemTypeUtil {
314 327
    /*
315 328
     * 将时间戳转换为时间
316 329
     */
317
    public static String stampToDate(String s){
330
    public static String stampToDate(String s) {
318 331
        String res;
319 332
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");
320 333
        long lt = new Long(s);

+ 1 - 20
app/src/main/res/layout/activity_welcome.xml

@ -22,29 +22,10 @@
22 22
            android:layout_marginTop="240dp"
23 23
            android:contentDescription="@null"
24 24
            android:src="@drawable/bg_welcome_text"
25
            android:visibility="visible"
26
            tools:visibility="gone" />
25
            android:visibility="visible" />
27 26
    </LinearLayout>
28 27
    <!-- logo end    -->
29 28

30
    <!-- 360 首发标识 start -->
31
    <!--<ImageView-->
32
    <!--android:src="@drawable/logo_360"-->
33
    <!--android:layout_width="wrap_content"-->
34
    <!--android:layout_centerHorizontal="true"-->
35
    <!--android:layout_alignParentBottom="true"-->
36
    <!--android:layout_marginBottom="80dp"-->
37
    <!--android:layout_height="wrap_content" />-->
38
    <!-- 360 首发标识 end -->
39

40
    <!-- guide start    -->
41
    <androidx.viewpager.widget.ViewPager
42
        android:id="@+id/viewpager"
43
        android:layout_width="fill_parent"
44
        android:layout_height="fill_parent"
45
        android:visibility="gone" />
46
    <!-- guide end    -->
47

48 29
    <!-- 版本信息 start    -->
49 30
    <TextView
50 31
        android:id="@+id/android"