Browse Source

代码修改

huyuguo 4 years ago
parent
commit
8fae6e118f

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

57
    String encode_token;
57
    String encode_token;
58
    Context mContext;
58
    Context mContext;
59
    public static final int RESULT_SUCCESS = 0;
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
    public void createDialog() {
61
    public void createDialog() {
196
        if (pd_info == null) {
62
        if (pd_info == null) {
286
152
287
            @Override
153
            @Override
288
            public void afterTextChanged(Editable s) {
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
                if (!password.getText().toString().equals("") && password.getText().toString() != null) {
155
                if (!password.getText().toString().equals("") && password.getText().toString() != null) {
297
                    btn_clear.setVisibility(View.VISIBLE);
156
                    btn_clear.setVisibility(View.VISIBLE);
298
                } else {
157
                } else {
309
                    login.setTextColor(getResources().getColor(R.color.white));
168
                    login.setTextColor(getResources().getColor(R.color.white));
310
                }
169
                }
311
            }
170
            }
312
313
//            }
314
        });
171
        });
315
172
316
        //登陆按钮
173
        //登陆按钮
345
202
346
    @Override
203
    @Override
347
    public void onClick(View view) {
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
        switch (view.getId()) {
205
        switch (view.getId()) {
355
            case R.id.iv_back:
206
            case R.id.iv_back:
356
//                startActivity(new Intent(LoginActivity.this,MainActicity.class));
357
                finish();
207
                finish();
358
                break;
208
                break;
359
            case R.id.tv_userLogin:
209
            case R.id.tv_userLogin:
363
                        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
213
                        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
364
                    }
214
                    }
365
                }
215
                }
366
367
368
                userLogin();
216
                userLogin();
369
370
//                userGrowUp();
371
                break;
217
                break;
372
218
373
            case R.id.tv_newUser:
219
            case R.id.tv_newUser:
374
                startActivity(new Intent(this, RegisterActivity.class));
220
                startActivity(new Intent(this, RegisterActivity.class));
375
                ActivityManagerApplication.addDestoryActivity(this, "login");
221
                ActivityManagerApplication.addDestoryActivity(this, "login");
376
//                startActivity(new Intent(this, UserInfoActivity.class));
377
378
//                finish();
379
                break;
222
                break;
380
223
381
            case R.id.tv_forgetPassword:
224
            case R.id.tv_forgetPassword:
382
                ActivityManagerApplication.addDestoryActivity(LoginActivity.this, "LoginActivity");
225
                ActivityManagerApplication.addDestoryActivity(LoginActivity.this, "LoginActivity");
383
                startActivity(new Intent(this, ForgetPasswordActivity.class));
226
                startActivity(new Intent(this, ForgetPasswordActivity.class));
384
//                finish();
385
                break;
227
                break;
386
387
            case R.id.btn_clear:
228
            case R.id.btn_clear:
388
                password.setText("");
229
                password.setText("");
389
                break;
230
                break;
390
391
            case R.id.username_clear:
231
            case R.id.username_clear:
392
                phone.setText("");
232
                phone.setText("");
393
                break;
233
                break;
427
267
428
                @Override
268
                @Override
429
                public void onResponse(String response) {
269
                public void onResponse(String response) {
430
                    LogUtils.e(response);
431
432
//                    Log.e(TAG, "onResponse: "+response );
433
                    dismissDialog();
270
                    dismissDialog();
434
                    String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
271
                    String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
435
                    if ("01".equals(rtnCode)) {
272
                    if ("01".equals(rtnCode)) {
457
    }
294
    }
458
295
459
    private void saveUserInfo(String info) {
296
    private void saveUserInfo(String info) {
460
//        Log.e(TAG, "saveUserInfo: "+info );
461
        String userid = JsonUtils.getKeyResult(info, "userid");
297
        String userid = JsonUtils.getKeyResult(info, "userid");
462
        String nickname = JsonUtils.getKeyResult(info, "nickname");
298
        String nickname = JsonUtils.getKeyResult(info, "nickname");
463
        String tel = JsonUtils.getKeyResult(info, "tel");
299
        String tel = JsonUtils.getKeyResult(info, "tel");

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

12
import android.os.Bundle;
12
import android.os.Bundle;
13
import android.os.Handler;
13
import android.os.Handler;
14
import android.os.Message;
14
import android.os.Message;
15

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

17
import android.util.DisplayMetrics;
19
import android.util.DisplayMetrics;
18
import android.util.Log;
20
import android.util.Log;
19
import android.view.KeyEvent;
21
import android.view.KeyEvent;
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
    protected void dialog() {
88
    protected void dialog() {
128
        AlertDialog.Builder builder = new AlertDialog.Builder(MainActicity.this);
89
        AlertDialog.Builder builder = new AlertDialog.Builder(MainActicity.this);
129
//        builder.setMessage("请选择要显示的电桩类型");
130
        builder.setTitle("请选择要显示的电桩类型");
90
        builder.setTitle("请选择要显示的电桩类型");
131
        builder.setPositiveButton("国标", new DialogInterface.OnClickListener() {
91
        builder.setPositiveButton("国标", new DialogInterface.OnClickListener() {
132
            @Override
92
            @Override
133
            public void onClick(DialogInterface dialog, int which) {
93
            public void onClick(DialogInterface dialog, int which) {
134
                MainApplication.userTpye = "1";
94
                MainApplication.userTpye = "1";
135
                ProfileManager.getInstance().setType(MainActicity.this, "1");
95
                ProfileManager.getInstance().setType(MainActicity.this, "1");
136
//                MainFragment.firstSelect();
137
                dialog.dismiss();
96
                dialog.dismiss();
138
            }
97
            }
139
        });
98
        });
142
            public void onClick(DialogInterface dialog, int which) {
101
            public void onClick(DialogInterface dialog, int which) {
143
                MainApplication.userTpye = "2";
102
                MainApplication.userTpye = "2";
144
                ProfileManager.getInstance().setType(MainActicity.this, "2");
103
                ProfileManager.getInstance().setType(MainActicity.this, "2");
145
//                MainFragment.firstSelect();
146
                dialog.dismiss();
104
                dialog.dismiss();
147
            }
105
            }
148
        });
106
        });
149
        builder.create().show();
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
    private void init() {
110
    private void init() {
172
        if (!ProfileManager.getInstance().getGuide(this)) {
111
        if (!ProfileManager.getInstance().getGuide(this)) {
173
//            dialog();
174

175

176
            MainApplication.messageToken = "0";
112
            MainApplication.messageToken = "0";
177
            MainApplication.userTpye = "1";
113
            MainApplication.userTpye = "1";
178
            ProfileManager.getInstance().setGuide(this, true);
114
            ProfileManager.getInstance().setGuide(this, true);
189

125

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

194
        }
128
        }
195
        mSlidingMenu = (SlidingMenu) findViewById(R.id.slidingMenu);
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
        mSlidingMenu.setCanSliding(false, false);
134
        mSlidingMenu.setCanSliding(false, false);
209
    }
135
    }
210

136

322
                if (!ExampleUtil.isEmpty(extras)) {
248
                if (!ExampleUtil.isEmpty(extras)) {
323
                    showMsg.append(KEY_EXTRAS + " : " + extras + "\n");
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
2
3
import android.Manifest;
3
import android.Manifest;
4
import android.app.Activity;
4
import android.app.Activity;
5
import android.app.Application;
6
import android.content.BroadcastReceiver;
5
import android.content.BroadcastReceiver;
7
import android.content.ContentValues;
6
import android.content.ContentValues;
8
import android.content.Context;
7
import android.content.Context;
378
    public static boolean isStatusBack = false;
377
    public static boolean isStatusBack = false;
379
378
380
    private static final int RC_CAMERA_PERM = 123;
379
    private static final int RC_CAMERA_PERM = 123;
381
    private static final int RC_Location_FIRST_PERM = 124;
382
    private static final int RC_Location_PERM = 125;
380
    private static final int RC_Location_PERM = 125;
381
    private static final int RC_Location_FIRST_PERM = 126;
383
382
384
    private String adfloatUrl = "";
383
    private String adfloatUrl = "";
385
384
681
                                    aMap.addMarker(oo);
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
                        } catch (Exception e) {
683
                        } catch (Exception e) {
693
                            BitmapDescriptor point = BitmapDescriptorFactory
684
                            BitmapDescriptor point = BitmapDescriptorFactory
694
                                    .fromResource(R.drawable.point_icon);
685
                                    .fromResource(R.drawable.point_icon);
696
                                    anchor(0.5f, 0.5f).zIndex(7)
687
                                    anchor(0.5f, 0.5f).zIndex(7)
697
                                    .draggable(true).icon(point);
688
                                    .draggable(true).icon(point);
698
                            aMap.addMarker(oo);
689
                            aMap.addMarker(oo);
699
//                            Toast.makeText(getActivity(),"该范围内没有充电桩",Toast.LENGTH_SHORT).show();
700
                        }
690
                        }
701
691
702
                    } catch (Exception e) {
692
                    } catch (Exception e) {
733
        BarColorUtil.initStatusBarColor(MainMapActivity.this);
723
        BarColorUtil.initStatusBarColor(MainMapActivity.this);
734
        m = this;
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
        mainMapActivity = MainMapActivity.this;
726
        mainMapActivity = MainMapActivity.this;
749
727
750
        intentFilter = new IntentFilter();
728
        intentFilter = new IntentFilter();
757
        if (MainApplication.ad_link.equals("1")) {
735
        if (MainApplication.ad_link.equals("1")) {
758
            againPoint = "1";
736
            againPoint = "1";
759
            is_dui = getIntent().getStringExtra("is_dui");
737
            is_dui = getIntent().getStringExtra("is_dui");
760
//            Log.e("is_dui===", is_dui);
761
            String url1 = getIntent().getStringExtra("shareUrl"); // web address
738
            String url1 = getIntent().getStringExtra("shareUrl"); // web address
762
//            Log.e("z222", url1);
763
            if (is_dui.equals("0")) {
739
            if (is_dui.equals("0")) {
764
                Intent intent2 = new Intent(getApplication(), HomeWebActivity.class);
740
                Intent intent2 = new Intent(getApplication(), HomeWebActivity.class);
765
//        intent2.putExtra("shareUrl",url1);
766
                intent2.putExtra("shareUrl", url1);
741
                intent2.putExtra("shareUrl", url1);
767
                intent2.putExtra("shareTitle", getIntent().getStringExtra("shareTitle"));
742
                intent2.putExtra("shareTitle", getIntent().getStringExtra("shareTitle"));
768
                intent2.putExtra("shareIcon", getIntent().getStringExtra("shareIcon"));
743
                intent2.putExtra("shareIcon", getIntent().getStringExtra("shareIcon"));
774
                overridePendingTransition(0, 0);
749
                overridePendingTransition(0, 0);
775
            } else {
750
            } else {
776
                long appTime11 = System.currentTimeMillis() / 1000;
751
                long appTime11 = System.currentTimeMillis() / 1000;
777
//                Log.e("sfv_url===", getIntent().getStringExtra("shareUrl"));
778
//                Log.i("appTime(long)---", appTime11 + "");
779
                long updatetime1 = appTime11 - MainMapActivity.cha - 5;
752
                long updatetime1 = appTime11 - MainMapActivity.cha - 5;
780
//                Log.i("updatetime(long)---", updatetime1 + "");
781
//                Log.i("cha---", MainMapActivity.cha + "");
782
                String token1 = String.valueOf(updatetime1);
753
                String token1 = String.valueOf(updatetime1);
783
                String encode_token = null;
754
                String encode_token = null;
784
                try {
755
                try {
787
                    e.printStackTrace();
758
                    e.printStackTrace();
788
                }
759
                }
789
                String replace = URLEncoder.encode(encode_token);
760
                String replace = URLEncoder.encode(encode_token);
790
//                    startActivity(new Intent(getApplication(), ShopActivity.class));
791
                Intent intent11 = new Intent();
761
                Intent intent11 = new Intent();
792
                intent11.setClass(getApplicationContext(), CreditActivity.class);
762
                intent11.setClass(getApplicationContext(), CreditActivity.class);
793
                intent11.putExtra("navColor", "#fcfcfc");    //配置导航条的背景颜色,请用#ffffff长格式。
763
                intent11.putExtra("navColor", "#fcfcfc");    //配置导航条的背景颜色,请用#ffffff长格式。
794
                intent11.putExtra("titleColor", "#222222");    //配置导航条标题的颜色,请用#ffffff长格式。
764
                intent11.putExtra("titleColor", "#222222");    //配置导航条标题的颜色,请用#ffffff长格式。
795
                MainApplication.goods_type = "details";
765
                MainApplication.goods_type = "details";
796
                MainApplication.current_url = getIntent().getStringExtra("shareUrl");
766
                MainApplication.current_url = getIntent().getStringExtra("shareUrl");
797
//                MainApplication.current_url = "http://www.duiba.com.cn/mobile/appItemDetail?appItemId=453087";
798
                if (!MainApplication.isLogin()) {
767
                if (!MainApplication.isLogin()) {
799
                    intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?token=" + replace + "&url=" + MainApplication.current_url);    //配置自动登陆地址,每次需服务端动态生成。
768
                    intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?token=" + replace + "&url=" + MainApplication.current_url);    //配置自动登陆地址,每次需服务端动态生成。
800
                } else {
769
                } else {
880
        }
849
        }
881
        context = this;
850
        context = this;
882
        gestureguide = ProfileManager.getInstance().getGestureguide(getApplicationContext());
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
        dialog = new LoadingDialog(this);
852
        dialog = new LoadingDialog(this);
891
        dialog.setCanceledOnTouchOutside(false);
853
        dialog.setCanceledOnTouchOutside(false);
892
854
975
                }
937
                }
976
            }
938
            }
977
        }, 2000);
939
        }, 2000);
978
979
    }
940
    }
980
941
981
942
1515
            //设置是否强制刷新WIFI,默认为强制刷新
1476
            //设置是否强制刷新WIFI,默认为强制刷新
1516
            //mLocationOption.setWifiActiveScan(false);
1477
            //mLocationOption.setWifiActiveScan(false);
1517
            mLocationOption.setWifiScan(true);
1478
            mLocationOption.setWifiScan(true);
1518
            if (ProfileManager.getInstance().getRequestLocationPermission(MainMapActivity.this)) {
1479
1480
            if (ProfileManager.getInstance().getStartedRequestLocationPermission(MainMapActivity.this)) {
1519
                if (hasLocationPermission()) {
1481
                if (hasLocationPermission()) {
1520
                    requestLocationPermission();
1482
                    requestLocationPermission();
1521
                }
1483
                }
1522
            } else { // 首次启动
1484
            } else { // 首次启动
1523
                ProfileManager.getInstance().setRequestLocationPermission(MainMapActivity.this, true);
1485
                ProfileManager.getInstance().setStartedRequestLocationPermission(MainMapActivity.this, true);
1524
                EasyPermissions.requestPermissions(
1486
                EasyPermissions.requestPermissions(
1525
                        this,
1487
                        this,
1526
                        "为了定位您的位置,推荐充电桩,充电桩位置路线导航需要开启位置权限,是否前往开启?",
1488
                        "为了定位您的位置,推荐充电桩,充电桩位置路线导航需要开启位置权限,是否前往开启?",
1527
                        RC_Location_FIRST_PERM,
1489
                        RC_Location_FIRST_PERM,
1528
                        Manifest.permission.ACCESS_FINE_LOCATION);
1490
                        Manifest.permission.ACCESS_FINE_LOCATION);
1529
            }
1491
            }
1492
1493
            if (hasLocationPermission()) {
1494
                requestLocationPermission();
1495
            }
1496
1530
        }
1497
        }
1531
    }
1498
    }
1532
1499
2504
                break;
2471
                break;
2505
2472
2506
            case R.id.tv_switch_city:
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
                break;
2475
                break;
2524
2525
            case R.id.tab_screening:
2476
            case R.id.tab_screening:
2526
                if (socket != null) {
2477
                if (socket != null) {
2527
                    try {
2478
                    try {
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
    public void showMap() {
2591
    public void showMap() {
2623
        if (MainApplication.isMap) {
2592
        if (MainApplication.isMap) {
2624
            if (list.size() == 0) {
2593
            if (list.size() == 0) {
3814
            MainApplication.sudu = ProfileManager.getInstance().getSudu(this);
3783
            MainApplication.sudu = ProfileManager.getInstance().getSudu(this);
3815
        } else {
3784
        } else {
3816
            MainApplication.userTpye = ProfileManager.getInstance().getTpey(this);
3785
            MainApplication.userTpye = ProfileManager.getInstance().getTpey(this);
3817
//            Log.e("type!", MainApplication.userTpye);
3818
            MainApplication.mapStatus = ProfileManager.getInstance().getMapstatus(this);
3786
            MainApplication.mapStatus = ProfileManager.getInstance().getMapstatus(this);
3819
            MainApplication.costWay = ProfileManager.getInstance().getCostway(this);
3787
            MainApplication.costWay = ProfileManager.getInstance().getCostway(this);
3820
            MainApplication.map = ProfileManager.getInstance().getMap(this);
3788
            MainApplication.map = ProfileManager.getInstance().getMap(this);
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
    private void getZhanListData(int level) {
3854
    private void getZhanListData(int level) {
3938
        aMap.clear();
3855
        aMap.clear();
3974
                for (int i = 0; i < list_del.size(); i++) {
3891
                for (int i = 0; i < list_del.size(); i++) {
3975
                    String[] args = {String.valueOf(list_del.get(i).getId())};
3892
                    String[] args = {String.valueOf(list_del.get(i).getId())};
3976
                    int mub = db.delete("zhan_list", "id=?", args);
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
                db.setTransactionSuccessful();//调用此方法会在执行到endTransaction() 时提交当前事务,如果不调用此方法会回滚事务
3895
                db.setTransactionSuccessful();//调用此方法会在执行到endTransaction() 时提交当前事务,如果不调用此方法会回滚事务
3985
            } finally {
3896
            } finally {

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

1
package com.electric.chargingpile.activity;
1
package com.electric.chargingpile.activity;
2
2
3
import android.Manifest;
3
import android.content.Context;
4
import android.content.Context;
4
import android.os.Bundle;
5
import android.os.Bundle;
5
import android.os.Handler;
6
import android.os.Handler;
6
import android.os.Message;
7
import android.os.Message;
8
9
import androidx.annotation.NonNull;
7
import androidx.appcompat.app.AppCompatActivity;
10
import androidx.appcompat.app.AppCompatActivity;
8
import androidx.recyclerview.widget.GridLayoutManager;
11
import androidx.recyclerview.widget.GridLayoutManager;
9
import androidx.recyclerview.widget.LinearLayoutManager;
12
import androidx.recyclerview.widget.LinearLayoutManager;
10
import androidx.recyclerview.widget.RecyclerView;
13
import androidx.recyclerview.widget.RecyclerView;
14
11
import android.text.Editable;
15
import android.text.Editable;
12
import android.text.TextUtils;
16
import android.text.TextUtils;
13
import android.text.TextWatcher;
17
import android.text.TextWatcher;
43
import com.electric.chargingpile.gen.CityRecordDao;
47
import com.electric.chargingpile.gen.CityRecordDao;
44
import com.electric.chargingpile.helper.SuspensionDecoration;
48
import com.electric.chargingpile.helper.SuspensionDecoration;
45
import com.electric.chargingpile.iview.ISelectCityView;
49
import com.electric.chargingpile.iview.ISelectCityView;
50
import com.electric.chargingpile.manager.ProfileManager;
46
import com.electric.chargingpile.table.CityRecord;
51
import com.electric.chargingpile.table.CityRecord;
47
import com.electric.chargingpile.util.BarColorUtil;
52
import com.electric.chargingpile.util.BarColorUtil;
48
import com.electric.chargingpile.util.EventBusUtil;
53
import com.electric.chargingpile.util.EventBusUtil;
49
import com.electric.chargingpile.util.JsonUtils;
54
import com.electric.chargingpile.util.JsonUtils;
50
import com.electric.chargingpile.util.LifeCycleEvent;
55
import com.electric.chargingpile.util.LifeCycleEvent;
51
import com.electric.chargingpile.util.LoadingDialog;
56
import com.electric.chargingpile.util.LoadingDialog;
57
import com.electric.chargingpile.util.SystemTypeUtil;
52
import com.electric.chargingpile.util.ToastUtil;
58
import com.electric.chargingpile.util.ToastUtil;
59
import com.electric.chargingpile.view.AlertDialogCommon;
53
import com.electric.chargingpile.view.IndexBar;
60
import com.electric.chargingpile.view.IndexBar;
54
import com.electric.chargingpile.view.MyItemDecoration;
61
import com.electric.chargingpile.view.MyItemDecoration;
55
import com.google.gson.Gson;
62
import com.google.gson.Gson;
66
import java.util.List;
73
import java.util.List;
67
74
68
import io.reactivex.subjects.PublishSubject;
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
    private RecyclerView evsdkRvSearch;
81
    private RecyclerView evsdkRvSearch;
73
    private Context mContext;
82
    private Context mContext;
74
    private RecyclerView mRv;
83
    private RecyclerView mRv;
103
    private ImageView ivBack, ivSearchClear;
112
    private ImageView ivBack, ivSearchClear;
104
    private EditText etSearch;
113
    private EditText etSearch;
105
    private LinearLayout llLayout;
114
    private LinearLayout llLayout;
115
116
    private static final int RC_Location_PERM = 125;
117
106
    Handler hand = new Handler() {
118
    Handler hand = new Handler() {
107
        public void handleMessage(android.os.Message msg) {
119
        public void handleMessage(android.os.Message msg) {
108
            switch (msg.what) {
120
            switch (msg.what) {
117
                        } catch (Exception e) {
129
                        } catch (Exception e) {
118
                            e.printStackTrace();
130
                            e.printStackTrace();
119
                        }
131
                        }
120
121
                    } catch (Exception e) {
132
                    } catch (Exception e) {
122
                        e.printStackTrace();
133
                        e.printStackTrace();
123
                    }
134
                    }
124
125
                    break;
135
                    break;
126
127
128
                default:
136
                default:
129
                    break;
137
                    break;
130
            }
138
            }
131
132
        }
139
        }
133
140
134
        ;
141
        ;
139
        super.onCreate(savedInstanceState);
146
        super.onCreate(savedInstanceState);
140
        setContentView(R.layout.activity_new_select_city);
147
        setContentView(R.layout.activity_new_select_city);
141
        BarColorUtil.initStatusBarColor(NewSelectCityActivity.this);
148
        BarColorUtil.initStatusBarColor(NewSelectCityActivity.this);
142
143
        initViews();
149
        initViews();
144
    }
150
    }
145
151
153
        llLayout.setFocusable(true);
159
        llLayout.setFocusable(true);
154
        llLayout.setFocusableInTouchMode(true);
160
        llLayout.setFocusableInTouchMode(true);
155
        mContext = this;
161
        mContext = this;
156
//        selectCityPresenter = new SelectCityPresenter(this, SelectCityActivity.this);
157
        mRv = (RecyclerView) findViewById(R.id.evsdk_rv);
162
        mRv = (RecyclerView) findViewById(R.id.evsdk_rv);
158
        mRv.setLayoutManager(mManager = new LinearLayoutManager(this));
163
        mRv.setLayoutManager(mManager = new LinearLayoutManager(this));
159
164
160
        mSourceDatas = new ArrayList<>();
165
        mSourceDatas = new ArrayList<>();
161
        mHeaderDatas = new ArrayList<>();
166
        mHeaderDatas = new ArrayList<>();
162
//        List<AllCityBean> locationCity = new ArrayList<>();
163
//        locationCity.add("定位中");
164
//        mHeaderDatas.add(new CityHeaderBean(locationCity, "定位城市", "定"));
165
        List<AllCityBean> recentCitys = new ArrayList<>();
167
        List<AllCityBean> recentCitys = new ArrayList<>();
166
        mHeaderDatas.add(new CityHeaderBean(recentCitys, "最近访问", "近"));
168
        mHeaderDatas.add(new CityHeaderBean(recentCitys, "最近访问", "近"));
167
//        List<String> hotCitys = new ArrayList<>();
168
//        mHeaderDatas.add(new CityHeaderBean(recentCitys, "热门城市", "热"));
169
        mSourceDatas.addAll(mHeaderDatas);
169
        mSourceDatas.addAll(mHeaderDatas);
170
170
171
        mAdapter = new SelectCityAdapter(this, R.layout.evsdk_item_select_city, mBodyDatas, NewSelectCityActivity.this);
171
        mAdapter = new SelectCityAdapter(this, R.layout.evsdk_item_select_city, mBodyDatas, NewSelectCityActivity.this);
208
                    mTvCity = holder.getView(R.id.evsdk_tv_current_city);
208
                    mTvCity = holder.getView(R.id.evsdk_tv_current_city);
209
                    holder.setText(R.id.evsdk_tv_current_city, cityTopHeaderBean.getTxt() + currentLocationCity);
209
                    holder.setText(R.id.evsdk_tv_current_city, cityTopHeaderBean.getTxt() + currentLocationCity);
210
                    mTvLocation = holder.getView(R.id.evsdk_tv_location);
210
                    mTvLocation = holder.getView(R.id.evsdk_tv_location);
211
//                        holder.setText(R.id.evsdk_tv_location, cityTopHeaderBean.getTxt());
212
213
                    holder.setOnClickListener(R.id.evsdk_tv_location, new View.OnClickListener() {
211
                    holder.setOnClickListener(R.id.evsdk_tv_location, new View.OnClickListener() {
214
                        @Override
212
                        @Override
215
                        public void onClick(View view) {
213
                        public void onClick(View view) {
217
                            if (null == mlocationClient) {
215
                            if (null == mlocationClient) {
218
                                initLocation();
216
                                initLocation();
219
                            } else {
217
                            } else {
220
                                mlocationClient.startLocation();
218
                                requestLocationPermission();
221
                            }
219
                            }
222
                            mTvLocation.setEnabled(false);
220
                            mTvLocation.setEnabled(false);
223
                        }
221
                        }
244
        };
242
        };
245
        mHeaderAdapter.setHeaderView(0, R.layout.evsdk_item_header_top, new CityTopHeaderBean("定位城市:" + currentLocationCity));
243
        mHeaderAdapter.setHeaderView(0, R.layout.evsdk_item_header_top, new CityTopHeaderBean("定位城市:" + currentLocationCity));
246
        mHeaderAdapter.setHeaderView(1, R.layout.evsdk_item_header, mHeaderDatas.get(0));
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
        mRv.setAdapter(mHeaderAdapter);
245
        mRv.setAdapter(mHeaderAdapter);
251
        mRv.addItemDecoration(mDecoration = new SuspensionDecoration(this, mSourceDatas)
246
        mRv.addItemDecoration(mDecoration = new SuspensionDecoration(this, mSourceDatas)
252
                .setmTitleHeight((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 28, getResources().getDisplayMetrics()))
247
                .setmTitleHeight((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 28, getResources().getDisplayMetrics()))
254
                .setTitleFontSize((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14, getResources().getDisplayMetrics()))
249
                .setTitleFontSize((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14, getResources().getDisplayMetrics()))
255
                .setColorTitleFont(mContext.getResources().getColor(R.color.ui_68))
250
                .setColorTitleFont(mContext.getResources().getColor(R.color.ui_68))
256
                .setHeaderViewCount(mHeaderAdapter.getHeaderViewCount() - mHeaderDatas.size()));
251
                .setHeaderViewCount(mHeaderAdapter.getHeaderViewCount() - mHeaderDatas.size()));
257
//        mRv.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
258
        mRv.addItemDecoration(new MyItemDecoration());
252
        mRv.addItemDecoration(new MyItemDecoration());
259
253
260
        //使用indexBar
254
        //使用indexBar
384
                .invalidate();
378
                .invalidate();
385
        mDecoration.setmDatas(mSourceDatas);
379
        mDecoration.setmDatas(mSourceDatas);
386
380
387
//        CityHeaderBean header1 = mHeaderDatas.get(0);
388
//        header1.getCityList().clear();
389
//        header1.getCityList().add("北京");
390
391
        //初始化选择过的城市信息
381
        //初始化选择过的城市信息
392
        List<CityRecord> localRecordList = getLocalCityRecordData();
382
        List<CityRecord> localRecordList = getLocalCityRecordData();
393
        List<AllCityBean> showCityList = new ArrayList<>();
383
        List<AllCityBean> showCityList = new ArrayList<>();
404
        initLocation();
394
        initLocation();
405
        CityHeaderBean header2 = mHeaderDatas.get(0);
395
        CityHeaderBean header2 = mHeaderDatas.get(0);
406
        header2.setCityList(showCityList);
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
    private void initLocation() {
399
    private void initLocation() {
422
//        AMapLocationClientOption mLocationOption = null;
423
        mlocationClient = new AMapLocationClient(this);
400
        mlocationClient = new AMapLocationClient(this);
424
//初始化定位参数
401
        //初始化定位参数
425
        mLocationOption = new AMapLocationClientOption();
402
        mLocationOption = new AMapLocationClientOption();
426
//设置定位监听
403
        //设置定位监听
427
        mlocationClient.setLocationListener(this);
404
        mlocationClient.setLocationListener(this);
428
//设置定位模式为高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式
405
        //设置定位模式为高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式
429
        mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
406
        mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
430
        mLocationOption.setOnceLocation(true);
407
        mLocationOption.setOnceLocation(true);
431
        //设置是否强制刷新WIFI,默认为强制刷新
408
        //设置是否强制刷新WIFI,默认为强制刷新
432
        mLocationOption.setWifiActiveScan(false);
409
        mLocationOption.setWifiActiveScan(false);
433
//设置定位间隔,单位毫秒,默认为2000ms
434
//        mLocationOption.setInterval(2000);
435
//设置定位参数
410
        //设置定位间隔,单位毫秒,默认为2000ms
411
        // mLocationOption.setInterval(2000);
412
        // 设置定位参数
436
        mlocationClient.setLocationOption(mLocationOption);
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
    private void insertData(CityRecord cityRecord) {
431
    private void insertData(CityRecord cityRecord) {
476
                try {
460
                try {
477
                    socket = new Socket("cdz.evcharge.cc", 9503); // IP:10.14.114.127,端口54321
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
                    out.println(params);
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
                    String msg = br.readLine();
467
                    String msg = br.readLine();
488
//                        Log.d("dddddmsg",msg);
489
490
                    if (msg != null) {
468
                    if (msg != null) {
491
                        Message mes = new Message();
469
                        Message mes = new Message();
492
                        mes.obj = msg;
470
                        mes.obj = msg;
498
                    br.close();
476
                    br.close();
499
                    // 关闭Socket
477
                    // 关闭Socket
500
                    socket.close();
478
                    socket.close();
501
//                    }
502
                } catch (Exception e) {
479
                } catch (Exception e) {
503
                }
480
                }
504
            }
481
            }
506
    }
483
    }
507
484
508
    public static String getMD5(String content) {
485
    public static String getMD5(String content) {
509
510
        try {
486
        try {
511
512
            MessageDigest digest = MessageDigest.getInstance("MD5");
487
            MessageDigest digest = MessageDigest.getInstance("MD5");
513
514
            digest.update(content.getBytes());
488
            digest.update(content.getBytes());
515
516
            return getHashString(digest);
489
            return getHashString(digest);
517
518
519
        } catch (Exception e) {
490
        } catch (Exception e) {
520
491
            e.printStackTrace();
521
        }
492
        }
522
523
        return null;
493
        return null;
524
525
    }
494
    }
526
495
527
    private static String getHashString(MessageDigest digest) {
496
    private static String getHashString(MessageDigest digest) {
528
529
        StringBuilder builder = new StringBuilder();
497
        StringBuilder builder = new StringBuilder();
530
531
        for (byte b : digest.digest()) {
498
        for (byte b : digest.digest()) {
532
533
            builder.append(Integer.toHexString((b >> 4) & 0xf));
499
            builder.append(Integer.toHexString((b >> 4) & 0xf));
534
535
            builder.append(Integer.toHexString(b & 0xf));
500
            builder.append(Integer.toHexString(b & 0xf));
536
537
        }
501
        }
538
539
540
        return builder.toString().toLowerCase();
502
        return builder.toString().toLowerCase();
541
542
    }
503
    }
543
504
544
    @Override
505
    @Override
560
                String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
521
                String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
561
                LogUtils.e(errText);
522
                LogUtils.e(errText);
562
                mTvLocation.setText("定位失败");
523
                mTvLocation.setText("定位失败");
563
564
            }
524
            }
565
        }
525
        }
566
    }
526
    }
575
        mLoadingDialog.show();
535
        mLoadingDialog.show();
576
    }
536
    }
577
537
578
579
    /**
538
    /**
580
     * 关闭进度对话框
539
     * 关闭进度对话框
581
     */
540
     */
606
        } else {
565
        } else {
607
            ToastUtil.showToast(getApplicationContext(), "抱歉,暂时没有找到相关城市", Toast.LENGTH_SHORT);
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
    @Override
570
    @Override
631
    public PublishSubject<LifeCycleEvent> getLifeSubject() {
571
    public PublishSubject<LifeCycleEvent> getLifeSubject() {
632
        return null;
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
                Log.e("info", "city = " + amapLocation.getCity());
525
                Log.e("info", "city = " + amapLocation.getCity());
526
                locateProcess = 2; // 定位成功
526
                locateProcess = 2; // 定位成功
527
                Log.e(TAG, "onLocationChanged: " + locateProcess);
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
                currentCity = amapLocation.getCity().substring(0,
528
                currentCity = amapLocation.getCity().substring(0,
539
                        amapLocation.getCity().length() - 1);
529
                        amapLocation.getCity().length() - 1);
540
                MainMapActivity.tv_atCity.setText(currentCity);
530
                MainMapActivity.tv_atCity.setText(currentCity);
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
    private class ResultListAdapter extends BaseAdapter {
547
    private class ResultListAdapter extends BaseAdapter {
591
        private LayoutInflater inflater;
548
        private LayoutInflater inflater;
592
        private ArrayList<SwitchCity> results = new ArrayList<SwitchCity>();
549
        private ArrayList<SwitchCity> results = new ArrayList<SwitchCity>();

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

85
import pub.devrel.easypermissions.AfterPermissionGranted;
85
import pub.devrel.easypermissions.AfterPermissionGranted;
86
import pub.devrel.easypermissions.EasyPermissions;
86
import pub.devrel.easypermissions.EasyPermissions;
87

87

88
public class WelcomeActivity extends Activity implements OnClickListener {
88
public class WelcomeActivity extends Activity {
89
    private static final String TAG = "WelcomeActivity";
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
    private TextView androidd;
90
    private TextView androidd;
96
    Bitmap bitmap;
97
    private ImageView enter;
98
    private String imgUrl = "", app_version = "";
91
    private String imgUrl = "", app_version = "";
99
    String img = "";
92
    String img = "";
100
    String url = "";
93
    String url = "";
102
    private Timer mTimer;
95
    private Timer mTimer;
103
    private int count = 0;
96
    private int count = 0;
104
    private LinearLayout ll_1;
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
    public static List<OperatorData> ll = new ArrayList<OperatorData>();
99
    public static List<OperatorData> ll = new ArrayList<OperatorData>();
107
    public static String canCost = "";
100
    public static String canCost = "";
108
    private static final int RC_CAMERA_PERM = 123;
101
    private static final int RC_CAMERA_PERM = 123;
287
        getVersion();
280
        getVersion();
288
        MapsInitializer.sdcardDir = MAP_FILE_PATH;
281
        MapsInitializer.sdcardDir = MAP_FILE_PATH;
289
        mTimer = new Timer();
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
    private void openNotification() {
299
    private void openNotification() {
326
        AlertDialog.Builder builder = new AlertDialog.Builder(WelcomeActivity.this);
300
        AlertDialog.Builder builder = new AlertDialog.Builder(WelcomeActivity.this);
327
        builder.setTitle("\"充电桩\"想给您发送通知");
301
        builder.setTitle("\"充电桩\"想给您发送通知");
535
                    long appTime1 = System.currentTimeMillis() / 1000;
509
                    long appTime1 = System.currentTimeMillis() / 1000;
536
                    long updatetime = appTime1 - 7200;
510
                    long updatetime = appTime1 - 7200;
537
                    String token = String.valueOf(updatetime);
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
                    url = MainApplication.url + "/zhannew/basic/web/index.php/ad/get?timer=" + replace;
513
                    url = MainApplication.url + "/zhannew/basic/web/index.php/ad/get?timer=" + replace;
540
                } catch (Exception e) {
514
                } catch (Exception e) {
541
                    e.printStackTrace();
515
                    e.printStackTrace();
594
        JPushInterface.onPause(this);
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
    private void dealOperatorData() {
571
    private void dealOperatorData() {
616
        String operator = ProfileManager.getInstance().getKeyOperator(getApplicationContext());
572
        String operator = ProfileManager.getInstance().getKeyOperator(getApplicationContext());
617
        String localOperators = "";
573
        String localOperators = "";
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
            if (amapLocation != null
259
            if (amapLocation != null
260
                    && amapLocation.getErrorCode() == 0) {
260
                    && amapLocation.getErrorCode() == 0) {
261
                Log.e("info", "city = " + amapLocation.getCity());
261
                Log.e("info", "city = " + amapLocation.getCity());
262
//					if (!isNeedFresh) {
263
//						return;
264
//					}
265
                isNeedRefresh = false;
266
                if (amapLocation.getCity() == null) {
262
                if (amapLocation.getCity() == null) {
267
//						locateProcess = 3; // 定位失败
268
//						personList.setAdapter(adapter);
269
//						adapter.notifyDataSetChanged();
270
271
                    return;
263
                    return;
272
                }
264
                }
273
                currentCity = amapLocation.getCity().substring(0,
265
                currentCity = amapLocation.getCity().substring(0,
280
                mlocationClient.stopLocation();
272
                mlocationClient.stopLocation();
281
                pbLocate.setVisibility(View.GONE);
273
                pbLocate.setVisibility(View.GONE);
282
                SelectCityActivity.locateProcess = 2;
274
                SelectCityActivity.locateProcess = 2;
283
284
//					locateProcess = 2; // 定位成功
285
//					personList.setAdapter(adapter);
286
//					adapter.notifyDataSetChanged();
287
            } else {
275
            } else {
288
                String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
276
                String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
289
                Log.e("AmapErr", errText);
277
                Log.e("AmapErr", errText);
298
        LinearLayout llMain;
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
    private void setUpMap() {
289
    private void setUpMap() {
358
//        //声明mLocationOption对象
290
//        //声明mLocationOption对象
359
//        AMapLocationClientOption mLocationOption = null;
291
//        AMapLocationClientOption mLocationOption = null;

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

15
    private static final String KEY_GUIDE = "key_guide";
15
    private static final String KEY_GUIDE = "key_guide";
16
    private static final String KEY_PRIVACY_AGREEMENT = "key_privacy_agreement";
16
    private static final String KEY_PRIVACY_AGREEMENT = "key_privacy_agreement";
17
    private static final String KEY_PRIVACY_PERMISSION = "key_privacy_permission";
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
    private static final String KEY_TYPE = "key_type";
20
    private static final String KEY_TYPE = "key_type";
20
    private static final String KEY_USERID = "key_userid";
21
    private static final String KEY_USERID = "key_userid";
21
    private static final String KEY_USERICON = "key_usericon";
22
    private static final String KEY_USERICON = "key_usericon";
593
                false);
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
import android.net.Uri;
7
import android.net.Uri;
8
import android.os.Build;
8
import android.os.Build;
9
import android.os.Environment;
9
import android.os.Environment;
10
import android.provider.Settings;
10
import android.text.TextUtils;
11
import android.text.TextUtils;
11
import android.util.Log;
12
import android.util.Log;
12
import android.view.View;
13
import android.view.View;
50
51
51
    private static String sName;
52
    private static String sName;
52
    private static String sVersion;
53
    private static String sVersion;
54
53
    // 华为
55
    // 华为
54
    public static boolean isEmui() {
56
    public static boolean isEmui() {
55
        return check(ROM_EMUI);
57
        return check(ROM_EMUI);
172
            }
174
            }
173
        } else if (isMiui()) {
175
        } else if (isMiui()) {
174
//            ToastUtil.show("我是小米");
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
            try {
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
            } catch (Exception e) {
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
        } else if (isEmui()) {
198
        } else if (isEmui()) {
186
//            ToastUtil.show("我是华为");
199
//            ToastUtil.show("我是华为");
314
    /*
327
    /*
315
     * 将时间戳转换为时间
328
     * 将时间戳转换为时间
316
     */
329
     */
317
    public static String stampToDate(String s){
330
    public static String stampToDate(String s) {
318
        String res;
331
        String res;
319
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");
332
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");
320
        long lt = new Long(s);
333
        long lt = new Long(s);

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

22
            android:layout_marginTop="240dp"
22
            android:layout_marginTop="240dp"
23
            android:contentDescription="@null"
23
            android:contentDescription="@null"
24
            android:src="@drawable/bg_welcome_text"
24
            android:src="@drawable/bg_welcome_text"
25
            android:visibility="visible"
26
            tools:visibility="gone" />
25
            android:visibility="visible" />
27
    </LinearLayout>
26
    </LinearLayout>
28
    <!-- logo end    -->
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
    <!-- 版本信息 start    -->
29
    <!-- 版本信息 start    -->
49
    <TextView
30
    <TextView
50
        android:id="@+id/android"
31
        android:id="@+id/android"