502
                                    permissionTask();
501
                                } else {
502
                                    dialogup();
503
//                                    permissionTask();
504 503
                                }
504
//                                if (key.length - 1 > 2) {
505
//                                permissionTask();
506
//                                } else {
507
//                                    dialogup();
508
//                                    permissionTask();
509
//                                }
505 510
                            }
506 511
507 512
                        }
@ -719,6 +724,8 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
719 724
    private TextView tvNotification;
720 725
    private RelativeLayout layoutNotification;
721 726
    private boolean isShowNotification= false;
727
    private RequestCall downloadCall;
728
722 729
    @Override
723 730
    protected void onCreate(Bundle savedInstanceState) {
724 731
        super.onCreate(savedInstanceState);
@ -3427,7 +3434,13 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
3427 3434
3428 3435
    private void showProgressWindow() {
3429 3436
        updateDialog = new UpdateDialog(MainMapActivity.this);
3430
        updateDialog.builder().setMsg("").setCancelable(false).show();
3437
        updateDialog.builder().setMsg("")
3438
                .setBtnCancel(v->{
3439
                    if (downloadCall!=null){
3440
                        downloadCall.cancel();
3441
                    }
3442
                })
3443
                .setCancelable(false).show();
3431 3444
    }
3432 3445
3433 3446
    private void dialogup_other() {
@ -3439,32 +3452,25 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
3439 3452
            alterDialog.builder()
3440 3453
                    .setTitle("更新提示 " + now_versionName)
3441 3454
                    .setMsg(title.trim())
3442
                    .setPositiveButton("更新", new View.OnClickListener() {
3443
                        @Override
3444
                        public void onClick(View v) {
3445
                            showProgressWindow();
3446
                            ToastUtil.showToast(getApplicationContext(), "正在下载中", Toast.LENGTH_SHORT);
3447
                            downLoadFile();
3448
                        }
3449
                    }).setNegativeButton("退出", new View.OnClickListener() {
3450
                @Override
3451
                public void onClick(View v) {
3452
                    SharedPreferences mySharedPreferences = getSharedPreferences("showdialog",
3453
                            Activity.MODE_PRIVATE);
3454
                    SharedPreferences.Editor editor1 = mySharedPreferences.edit();
3455
                    editor1.clear();
3456
                    finish();
3457
                    ProfileManager.getInstance().setSearchAddress(getApplicationContext(), "");
3458
                    Process.killProcess(Process.myPid());
3459
                }
3460
            }).setCancelable(false).show();
3455
                    .setPositiveButton("更新", v -> {
3456
                        ToastUtil.showToast(getApplicationContext(), "正在下载中", Toast.LENGTH_SHORT);
3457
                        downLoadFile();
3458
                    }).setNegativeButton("退出", v -> {
3459
    //                    SharedPreferences mySharedPreferences = getSharedPreferences("showdialog",
3460
    //                            Activity.MODE_PRIVATE);
3461
    //                    SharedPreferences.Editor editor1 = mySharedPreferences.edit();
3462
    //                    editor1.clear();
3463
    //                    finish();
3464
    //                    ProfileManager.getInstance().setSearchAddress(getApplicationContext(), "");
3465
    //                    Process.killProcess(Process.myPid());
3466
                    }).setCancelable(false).show();
3461 3467
        }
3462 3468
    }
3463 3469
    private void downLoadFile() {
3464 3470
        showProgressWindow();
3465 3471
        ToastUtil.showToast(getApplicationContext(), "正在下载中", Toast.LENGTH_SHORT);
3466
        OkHttpUtils.get().url("http://cdz.evcharge.cc/app/app.apk").build()
3467
                .execute(new FileCallBack(PhotoUtils.DOWNLOADS, "cdz_install") {
3472
        downloadCall = OkHttpUtils.get().url("http://cdz.evcharge.cc/app/app.apk").build();
3473
        downloadCall.execute(new FileCallBack(PhotoUtils.DOWNLOADS, "cdz_install") {
3468 3474
                    @Override
3469 3475
                    public void inProgress(final float progress, long total) {
3470 3476

+ 158 - 10
app/src/main/java/com/electric/chargingpile/activity/UserCenterMoreActivity.java

@ -11,10 +11,17 @@ import android.content.pm.PackageInfo;
11 11
import android.content.pm.PackageManager;
12 12
import android.graphics.drawable.ColorDrawable;
13 13
import android.net.Uri;
14
import android.os.Build;
14 15
import android.os.Bundle;
15 16
import android.os.Handler;
17
import android.os.Looper;
16 18
import android.os.Message;
19
20
import androidx.annotation.NonNull;
17 21
import androidx.appcompat.app.AlertDialog;
22
import androidx.core.content.FileProvider;
23
24
import android.os.Process;
18 25
import android.text.TextUtils;
19 26
import android.util.Log;
20 27
import android.view.Display;
@ -32,6 +39,8 @@ import android.widget.TextView;
32 39
import android.widget.Toast;
33 40
34 41
import com.alibaba.fastjson.JSON;
42
import com.blankj.utilcode.util.AppUtils;
43
import com.blankj.utilcode.util.LogUtils;
35 44
import com.electric.chargingpile.R;
36 45
import com.electric.chargingpile.application.MainApplication;
37 46
import com.electric.chargingpile.manager.ProfileManager;
@ -42,43 +51,59 @@ import com.electric.chargingpile.util.ImageTools;
42 51
import com.electric.chargingpile.util.JsonUtils;
43 52
import com.electric.chargingpile.util.LoadingDialog;
44 53
import com.electric.chargingpile.util.OkHttpUtil;
54
import com.electric.chargingpile.util.PhotoUtils;
55
import com.electric.chargingpile.util.ToastUtil;
56
import com.electric.chargingpile.view.AlertDialogUpdate;
57
import com.electric.chargingpile.view.UpdateDialog;
45 58
import com.squareup.okhttp.Request;
46 59
import com.squareup.okhttp.Response;
47 60
import com.umeng.analytics.MobclickAgent;
48 61
import com.zhy.http.okhttp.OkHttpUtils;
62
import com.zhy.http.okhttp.callback.FileCallBack;
49 63
import com.zhy.http.okhttp.callback.StringCallback;
64
import com.zhy.http.okhttp.request.RequestCall;
50 65
51 66
import org.json.JSONException;
52 67
import org.json.JSONObject;
53 68
54 69
import java.io.BufferedReader;
55 70
import java.io.BufferedWriter;
71
import java.io.File;
56 72
import java.io.InputStreamReader;
57 73
import java.io.OutputStreamWriter;
58 74
import java.io.PrintWriter;
59 75
import java.net.Socket;
60 76
import java.net.URLEncoder;
61 77
import java.security.MessageDigest;
78
import java.text.NumberFormat;
62 79
63 80
import okhttp3.Call;
81
import pub.devrel.easypermissions.AfterPermissionGranted;
64 82
import pub.devrel.easypermissions.EasyPermissions;
65 83
66 84
public class UserCenterMoreActivity extends Activity implements View.OnClickListener {
67 85
    private static final String TAG = "UserCenterMoreActivity";
86
    private static final int RC_READ_EXTERNAL_PERM = 127;
68 87
    private RelativeLayout rl_recommend, rl_feedback, rl_about, rl_message, rl_update, rl_alter_password;
69 88
    private ImageView iv_back, iv_message, iv_fen;
70 89
    private String now_version, app_version;
71 90
    private TextView tv_exit;
72
    private String now_versionCode, now_versionName;
91
    private String now_versionCode, now_versionName,title;
73 92
    private android.view.animation.Animation animation;
74 93
    private ImageView point, iv_message_f;
94
    private LinearLayout logOutLayout;
95
75 96
    private Socket socket;
76 97
    private String Token = "";
77 98
    static String token = "";
78 99
    public static long cha;
79 100
    LoadingDialog dialog;
101
    Context context;
102
    private AlertDialogUpdate alterDialog;
103
    private UpdateDialog updateDialog;
80 104
    Dialog et_dialog;
81
    private Handler handler = new Handler() {
105
    private RequestCall downloadCall;
106
    private Handler handler = new Handler(Looper.getMainLooper()) {
82 107
        // 主线程通过这个方法处理消息
83 108
        @Override
84 109
        public void handleMessage(Message msg) {
@ -117,6 +142,8 @@ public class UserCenterMoreActivity extends Activity implements View.OnClickList
117 142
118 143
                            now_versionCode = JsonUtils.getKeyResult(android, "versionCode");
119 144
                            now_versionName = JsonUtils.getKeyResult(android, "versionName");
145
                            title = JsonUtils.getKeyResult(jsonArray.toJSONString(), "title");
146
                            title = title.replace("\\n", "\n");
120 147
                        } catch (Exception e) {
121 148
                            e.printStackTrace();
122 149
                        }
@ -131,7 +158,7 @@ public class UserCenterMoreActivity extends Activity implements View.OnClickList
131 158
                        }
132 159
//
133 160
                        if (new_versionCode - getVersionCode(getApplication()) > 0) {
134
                            dialogup();
161
                            permissionTask();
135 162
                        } else {
136 163
                            Toast.makeText(UserCenterMoreActivity.this, "当前为最新版本" + now_versionName, Toast.LENGTH_SHORT).show();
137 164
                        }
@ -160,7 +187,33 @@ public class UserCenterMoreActivity extends Activity implements View.OnClickList
160 187
            }
161 188
        }
162 189
    };
163
    private LinearLayout logOutLayout;
190
    private Handler myHandler = new Handler(Looper.getMainLooper()) {
191
192
        @Override
193
        public void handleMessage(Message msg) {
194
            super.handleMessage(msg);
195
196
            switch (msg.what) {
197
198
                case 0x01:
199
200
                    Bundle data = msg.getData();
201
                    String format = data.getString("format");
202
                    String f = data.getString("progress");
203
                    String s = f.substring(0, f.indexOf("."));
204
//                    LogUtils.e(s);
205
206
                    updateDialog.updateMsg("当前已下载:" + format);
207
                    updateDialog.updateProgress(Integer.parseInt(s));
208
209
                    break;
210
211
            }
212
213
        }
214
    };
215
216
164 217
165 218
    @Override
166 219
    protected void onCreate(Bundle savedInstanceState) {
@ -169,6 +222,7 @@ public class UserCenterMoreActivity extends Activity implements View.OnClickList
169 222
        BarColorUtil.initStatusBarColor(UserCenterMoreActivity.this);
170 223
        dialog = new LoadingDialog(this);
171 224
        dialog.setCanceledOnTouchOutside(false);
225
        context = this;
172 226
        initView();
173 227
    }
174 228
@ -718,12 +772,8 @@ public class UserCenterMoreActivity extends Activity implements View.OnClickList
718 772
                .setPositiveButton("要,马上要", new View.OnClickListener() {
719 773
                    @Override
720 774
                    public void onClick(View v) {
721
                        Intent intent = new Intent();
722
                        intent.setAction("android.intent.action.VIEW");
723
                        intent.addCategory(Intent.CATEGORY_BROWSABLE);
724
                        Uri content_url = Uri.parse("http://cdz.evcharge.cc/app/app.apk");
725
                        intent.setData(content_url);
726
                        startActivity(Intent.createChooser(intent, "请选择浏览器"));
775
                        ToastUtil.showToast(getApplicationContext(), "正在下载中", Toast.LENGTH_SHORT);
776
                        downLoadFile();
727 777
                    }
728 778
                }).setNegativeButton("先退下", new View.OnClickListener() {
729 779
            @Override
@ -850,8 +900,106 @@ public class UserCenterMoreActivity extends Activity implements View.OnClickList
850 900
            }
851 901
        });
852 902
    }
903
    private void showProgressWindow() {
904
        updateDialog = new UpdateDialog(UserCenterMoreActivity.this);
905
        updateDialog.builder().setMsg("")
906
                .setBtnCancel(v->{
907
                    if (downloadCall!=null){
908
                        downloadCall.cancel();
909
                    }
910
                })
911
                .setCancelable(false).show();
912
    }
913
914
    private void downLoadFile() {
915
        showProgressWindow();
916
        ToastUtil.showToast(getApplicationContext(), "正在下载中", Toast.LENGTH_SHORT);
917
        downloadCall = OkHttpUtils.get().url("http://cdz.evcharge.cc/app/app.apk").build();
918
        downloadCall.execute(new FileCallBack(PhotoUtils.DOWNLOADS, "cdz_install") {
919
            @Override
920
            public void inProgress(final float progress, long total) {
921
922
                NumberFormat numberFormat = NumberFormat.getInstance();
923
924
                // 设置精确到小数点后2位
853 925
926
                numberFormat.setMaximumFractionDigits(2);
927
                String format = numberFormat.format(progress * 100);
854 928
929
                Message message = new Message();
930
                message.what = 0x01;
931
932
                Bundle bundle = new Bundle();
933
                bundle.putString("format", format + "%");
934
//                        LogUtils.e("当前:" + format);
935
                if (!format.contains(".")) {
936
                    bundle.putString("progress", format + ".");
937
                } else {
938
                    bundle.putString("progress", format);
939
                }
940
941
942
                message.setData(bundle);
943
                myHandler.sendMessage(message);
944
945
946
            }
947
948
            @Override
949
            public void onError(Call call, Exception e) {
950
                LogUtils.e(e.getMessage());
951
            }
952
953
            @Override
954
            public void onResponse(File response) {
955
                String path = getDatabasePath("zhan_list").getPath();
956
                com.blankj.utilcode.util.LogUtils.e(path);
957
                AppUtils.cleanAppData(path);
958
                Log.e("hyc","**------**"+response.getAbsolutePath());
959
                Log.e("hyc","**------**"+!response.exists());
960
                if (!response.exists()){
961
                    Toast.makeText(context, "文件不存在", Toast.LENGTH_SHORT).show();
962
                    return  ;
963
                }
964
965
                Intent intent = new Intent();
966
                intent.setAction(android.content.Intent.ACTION_VIEW);
967
                Uri uri;
968
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
969
                    Uri contentUri = FileProvider.getUriForFile(context,
970
                            context.getApplicationContext().getPackageName() + ".provider",
971
                            response);
972
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
973
                    intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
974
                    intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
975
                } else {
976
                    uri = Uri.fromFile(response);
977
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
978
                    intent.setDataAndType(uri, "application/vnd.android.package-archive");
979
                }
980
                context.startActivity(intent);
981
                android.os.Process.killProcess(android.os.Process.myPid());
982
            }
983
        });
984
    }
985
986
    @AfterPermissionGranted(RC_READ_EXTERNAL_PERM)
987
    public void permissionTask() {
988
        if (isPermissionOK()) {
989
            dialogup();
990
        } else {
991
            EasyPermissions.requestPermissions(
992
                    this, "充电桩想要获取您的图片读取权限,是否允许?",
993
                    RC_READ_EXTERNAL_PERM,
994
                    Manifest.permission.WRITE_EXTERNAL_STORAGE,
995
                    Manifest.permission.READ_EXTERNAL_STORAGE);
996
        }
997
    }
998
    @Override
999
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
1000
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
1001
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
1002
    }
855 1003
    @Override
856 1004
    protected void onPause() {
857 1005
        super.onPause();

+ 20 - 4
app/src/main/java/com/electric/chargingpile/view/UpdateDialog.java

@ -8,7 +8,9 @@ import android.view.LayoutInflater;
8 8
import android.view.View;
9 9
import android.view.WindowManager;
10 10
import android.widget.FrameLayout;
11
import android.widget.ImageView;
11 12
import android.widget.LinearLayout;
13
import android.widget.ProgressBar;
12 14
import android.widget.TextView;
13 15
14 16
import com.electric.chargingpile.R;
@ -20,12 +22,13 @@ public class UpdateDialog {
20 22
    private android.app.Dialog dialog;
21 23
    private LinearLayout layout_bg;
22 24
    private TextView txt_msg;
25
    private ImageView imgCancel;
23 26
    private Display display;
24 27
    private boolean showTitle = false;
25 28
    private boolean showMsg = false;
26 29
    private boolean showPosBtn = false;
27 30
    private boolean showNegBtn = false;
28
    private QMUIProgressBar qmuiProgressBar;
31
    private ProgressBar qmuiProgressBar;
29 32
30 33
    public UpdateDialog(Context context) {
31 34
        this.context = context;
@ -41,12 +44,13 @@ public class UpdateDialog {
41 44
42 45
        // 获取自定义Dialog布局中的控件
43 46
        layout_bg = view.findViewById(R.id.layout_bg);
47
        imgCancel = view.findViewById(R.id.imgCancel);
44 48
45 49
        txt_msg = (TextView) view.findViewById(R.id.txt_msg);
46 50
        txt_msg.setVisibility(View.GONE);
47 51
48 52
        qmuiProgressBar = view.findViewById(R.id.qMUIProgressBar);
49
        qmuiProgressBar.setMaxValue(100);
53
        qmuiProgressBar.setMax(100);
50 54
51 55
        // 定义Dialog布局和参数
52 56
        dialog = new Dialog(context, R.style.AlertDialogStyle);
@ -54,7 +58,7 @@ public class UpdateDialog {
54 58
55 59
        // 调整dialog背景大小
56 60
        layout_bg.setLayoutParams(new FrameLayout.LayoutParams((int) (display
57
                .getWidth() * 0.85), LinearLayout.LayoutParams.WRAP_CONTENT));
61
                .getWidth() * 0.65), LinearLayout.LayoutParams.WRAP_CONTENT));
58 62
59 63
        return this;
60 64
    }
@ -73,6 +77,15 @@ public class UpdateDialog {
73 77
        dialog.setCancelable(cancel);
74 78
        return this;
75 79
    }
80
    public UpdateDialog setBtnCancel(View.OnClickListener listener) {
81
        if (imgCancel!=null){
82
            imgCancel.setOnClickListener(v -> {
83
                listener.onClick(v);
84
                dialog.dismiss();
85
            });
86
        }
87
        return this;
88
    }
76 89
77 90
78 91
    private void setLayout() {
@ -87,10 +100,13 @@ public class UpdateDialog {
87 100
    }
88 101
89 102
    public void updateMsg(String msg) {
90
        txt_msg.setText(msg);
103
91 104
    }
92 105
93 106
    public void updateProgress(int i) {
94 107
        qmuiProgressBar.setProgress(i);
108
        if (txt_msg!=null){
109
            txt_msg.setText(i+"%");
110
        }
95 111
    }
96 112
}

BIN
app/src/main/res/drawable-xxhdpi/ic_cancel_updata.png


BIN
app/src/main/res/drawable-xxhdpi/ic_no_check_square.png


BIN
app/src/main/res/drawable-xxhdpi/ic_select_check_square.png


+ 8 - 0
app/src/main/res/drawable/bg_car_owner_check.xml

@ -0,0 +1,8 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3
4
    <item android:drawable="@drawable/ic_select_check_square" android:state_checked="true"/>
5
    <item android:drawable="@drawable/ic_no_check_square"  android:state_checked="false"/>
6
    <item android:drawable="@drawable/ic_no_check_square"/>
7
8
</selector>

+ 39 - 0
app/src/main/res/drawable/progressbar_color.xml

@ -0,0 +1,39 @@
1
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
2
    android:layout_width="match_parent"
3
    android:layout_height="wrap_content">
4
5
    <!-- 背景  gradient是渐变,corners定义的是圆角 -->
6
    <item android:id="@android:id/background"
7
        android:layout_width="wrap_content">
8
        <shape>
9
            <corners android:radius="10dp" />
10
11
            <solid android:color="#ECECEC" />
12
        </shape>
13
    </item>
14
    <!-- 第二条进度条颜色 -->
15
    <item android:id="@android:id/secondaryProgress">
16
        <clip>
17
            <shape>
18
                <corners android:radius="10dp" />
19
20
                <gradient
21
                    android:angle="90.0"
22
                    android:centerColor="#aadfdf"
23
                    android:centerY="0.45"
24
                    android:endColor="#aadfdf"
25
                    android:startColor="#aadfdf" />
26
            </shape>
27
        </clip>
28
    </item>
29
    <!-- 进度条 -->
30
    <item android:id="@android:id/progress">
31
        <clip>
32
            <shape>
33
                <corners android:radius="10dp" />
34
                <solid android:color="#3EC34C" />
35
            </shape>
36
        </clip>
37
    </item>
38
39
</layer-list>

+ 30 - 3
app/src/main/res/layout/activity_car_owner_certificate.xml

@ -47,7 +47,7 @@
47 47
        android:layout_height="0dp"
48 48
        android:orientation="vertical"
49 49
        android:scrollbars="none"
50
        app:layout_constraintBottom_toTopOf="@+id/submit_btn"
50
        app:layout_constraintBottom_toTopOf="@+id/layoutAuthorize"
51 51
        app:layout_constraintTop_toBottomOf="@+id/nav_bar">
52 52
53 53
        <androidx.constraintlayout.widget.ConstraintLayout
@ -353,7 +353,7 @@
353 353
                android:layout_width="match_parent"
354 354
                android:layout_height="wrap_content"
355 355
                android:layout_marginTop="10dp"
356
                android:layout_marginBottom="30dp"
356
                android:layout_marginBottom="60dp"
357 357
                android:text="认证说明\n\n1.车型信息和行驶证主页为必填项;\n2.最多可认证三款车型;\n3.默认首款认证车型为主车型;\n4.上传行驶证详细页面,并保证所有信息清晰;\n5.首次车主认证审核通过有充电满减和折扣红包\n6.红包自发放日起有效期为一个月"
358 358
                android:textColor="#0D1120"
359 359
                android:textSize="14sp"
@ -361,7 +361,34 @@
361 361
                app:layout_constraintTop_toBottomOf="@+id/driving_license_type" />
362 362
        </androidx.constraintlayout.widget.ConstraintLayout>
363 363
    </ScrollView>
364
364
    <LinearLayout
365
        android:orientation="horizontal"
366
        android:gravity="center"
367
        android:layout_marginBottom="10dp"
368
        app:layout_constraintEnd_toEndOf="parent"
369
        app:layout_constraintStart_toStartOf="parent"
370
        android:id="@+id/layoutAuthorize"
371
        app:layout_constraintBottom_toTopOf="@+id/submit_btn"
372
        android:layout_width="0dp"
373
        android:layout_height="wrap_content">
374
        <CheckBox
375
            android:padding="5dp"
376
            android:layout_gravity="center"
377
            android:gravity="center"
378
            style="@style/SquareCheckboxTheme"
379
            android:id="@+id/checkBox"
380
            android:layout_width="wrap_content"
381
            android:layout_height="wrap_content"/>
382
        <TextView
383
            android:gravity="center"
384
            android:id="@+id/tvAuthorize"
385
            android:layout_width="wrap_content"
386
            android:layout_height="match_parent"
387
            android:text="勾选后,即您同意《个人信息处理授权书》并确认授权"
388
            android:textColor="#ff9b9b9b"
389
            android:textSize="12sp"
390
            />
391
    </LinearLayout>
365 392
    <Button
366 393
        android:id="@+id/submit_btn"
367 394
        android:layout_width="match_parent"

+ 32 - 15
app/src/main/res/layout/layout_update_dialog.xml

@ -1,34 +1,51 @@
1 1
<?xml version="1.0" encoding="utf-8"?>
2 2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4
    xmlns:tools="http://schemas.android.com/tools"
4 5
    android:id="@+id/layout_bg"
5 6
    android:layout_width="match_parent"
6
    android:layout_height="200dp"
7
    android:layout_height="wrap_content"
7 8
    android:background="@drawable/offlinearrow_but_normal"
8 9
    android:orientation="vertical">
9
10 10
    <TextView
11
        android:id="@+id/txt_msg"
11
        android:gravity="center"
12
        android:text="下载中"
13
12 14
        android:layout_width="match_parent"
13 15
        android:layout_height="wrap_content"
14 16
        android:layout_gravity="center|left"
15
        android:textColor="@color/ui_62"
16
        android:layout_marginLeft="16dp"
17
        android:layout_marginTop="16dp"
18
        android:layout_marginBottom="16dp"
17
        android:textColor="@color/color_0e0e0e"
18
        android:layout_marginTop="30dp"
19
        android:layout_marginBottom="20dp"
19 20
        android:textSize="16sp" />
20 21
21
    <com.qmuiteam.qmui.widget.QMUIProgressBar
22
    <ProgressBar
23
        style="?android:attr/progressBarStyleHorizontal"
24
        tools:progress="45"
22 25
        android:id="@+id/qMUIProgressBar"
23 26
        android:layout_width="match_parent"
24
        android:layout_height="12dp"
25
        android:textColor="@color/lvse"
27
        android:layout_height="10dp"
28
        android:progressDrawable="@drawable/progressbar_color"
26 29
        android:textSize="12sp"
27
        android:layout_marginBottom="20dp"
30
        android:layout_marginBottom="6dp"
28 31
        android:layout_marginLeft="16dp"
29 32
        android:layout_marginRight="16dp"
30
        app:qmui_background_color="@color/ui_68"
31
        app:qmui_progress_color="@color/lvse"
32
        app:qmui_type="type_rect"/>
33
33
       />
34
    <TextView
35
        android:id="@+id/txt_msg"
36
        tools:text="12"
37
        android:textColor="#3EC34C"
38
        android:textSize="14sp"
39
        android:layout_marginEnd="18dp"
40
        android:layout_gravity="end"
41
        android:layout_marginBottom="30dp"
42
        android:layout_width="wrap_content"
43
        android:layout_height="wrap_content"/>
44
    <ImageView
45
        android:id="@+id/imgCancel"
46
        android:layout_marginBottom="30dp"
47
        android:layout_gravity="center"
48
        android:src="@drawable/ic_cancel_updata"
49
        android:layout_width="wrap_content"
50
        android:layout_height="wrap_content"/>
34 51
</LinearLayout>

+ 3 - 0
app/src/main/res/values/styles.xml

@ -377,4 +377,7 @@
377 377
    <style name="CustomCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">
378 378
        <item name="android:button">@drawable/checkbox_style</item>
379 379
    </style>
380
    <style name="SquareCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">
381
        <item name="android:button">@drawable/bg_car_owner_check</item>
382
    </style>
380 383
</resources>

+ 1 - 1
autolayout/src/main/AndroidManifest.xml

@ -1,7 +1,7 @@
1 1
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2 2
          package="com.zhy.autolayout">
3 3
4
    <application android:allowBackup="true"
4
    <application android:allowBackup="false"
5 5
                 android:label="@string/app_name"
6 6
        >
7 7

+ 1 - 0
zxing/src/main/AndroidManifest.xml

@ -28,6 +28,7 @@
28 28
    <supports-screens android:xlargeScreens="true"
29 29
        android:largeScreens="true"
30 30
        android:normalScreens="true"
31
        android:allowBackup="false"
31 32
        android:smallScreens="true"
32 33
        android:anyDensity="true"/>
33 34

+ 2 - 1
zxing/src/main/java/com/google/zxing/client/android/constant/UrlConstants.java

@ -5,7 +5,8 @@ public interface UrlConstants {
5 5
//    String HOST_URL = "http://59.110.68.162/zhannew/basic/web/index.php/"; //测试链接
6 6
7 7
    String USER_CHARGING_CHECK_URL = HOST_URL + "api/charge/check-user";
8
    String START_CHARGING_URL = HOST_URL + "api/charge/start";
8
//    String START_CHARGING_URL = HOST_URL + "api/charge/start";
9
    String START_CHARGING_URL = HOST_URL + "api/charge/start2";
9 10
    String CHARGING_STATUS_URL = HOST_URL + "api/charge/query";
10 11
    String STOP_CHARGING_URL = HOST_URL + "api/charge/close";//关闭充电
11 12

智能推荐开发完成 · c7840fa629 - Gogs: Go Git Service
ソースを参照

智能推荐开发完成

huyuguo 6 年 前
コミット
c7840fa629

+ 92 - 4
app/src/main/java/com/electric/chargingpile/activity/RecommendChargingStationActivity.java

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

+ 13 - 1
app/src/main/res/layout/activity_recommend_charging_station.xml

@ -160,7 +160,6 @@
160 160
        android:layout_height="0dp"
161 161
        app:layout_constraintBottom_toBottomOf="parent"
162 162
        app:layout_constraintTop_toBottomOf="@+id/condition_first_bar" />
163
164 163
    <android.support.constraint.ConstraintLayout
165 164
        android:id="@+id/condition_second_bar"
166 165
        android:layout_width="match_parent"
@ -293,4 +292,17 @@
293 292
294 293
    </android.support.constraint.ConstraintLayout>
295 294
295
    <TextView
296
        android:id="@+id/no_result"
297
        android:visibility="gone"
298
        tools:visibility="visible"
299
        android:gravity="center"
300
        android:textSize="14sp"
301
        android:textColor="#666666"
302
        android:text="周边没有符合筛选条件的站点,请检查您的筛选项"
303
        android:layout_width="match_parent"
304
        android:layout_height="0dp"
305
        app:layout_constraintBottom_toBottomOf="parent"
306
        app:layout_constraintTop_toBottomOf="@+id/condition_first_bar"/>
307
296 308
</android.support.constraint.ConstraintLayout>