Browse Source

优化代码

hy 1 year ago
parent
commit
028e3c7453

+ 13 - 0
app/src/main/AndroidManifest.xml

908
        <!-- since 3.5.6 新增华硕通道  -->
908
        <!-- since 3.5.6 新增华硕通道  -->
909
        <receiver android:name="cn.jpush.android.asus.AsusPushMessageReceiver"></receiver>
909
        <receiver android:name="cn.jpush.android.asus.AsusPushMessageReceiver"></receiver>
910
910
911
        <receiver
912
            android:name="cn.jpush.android.service.PushReceiver"
913
            android:enabled="true"
914
            android:exported="false"
915
            tools:node="replace">
916
            <intent-filter android:priority="1000">
917
                <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />
918
                <category android:name="${applicationId}" />
919
            </intent-filter>
920
        </receiver>
921
922
        <receiver android:name="cn.jpush.android.service.AlarmReceiver" tools:node="remove"/>
923
911
    </application>
924
    </application>
912
925
913
</manifest>
926
</manifest>

+ 2 - 1
app/src/main/java/com/electric/chargingpile/activity/ChargingStatusActivity.java

92
    SimpleDateFormat formatter;
92
    SimpleDateFormat formatter;
93
    private int count;
93
    private int count;
94
    private int try_count = 0;
94
    private int try_count = 0;
95
    private static final int MAX_RETRY = 10;
95
    private int status_count = 0;
96
    private int status_count = 0;
96
    private int stop_tag = 0;
97
    private int stop_tag = 0;
97
    private Activity activity;
98
    private Activity activity;
614
                                    finish();
615
                                    finish();
615
616
616
                                } else {
617
                                } else {
617
                                    if (try_count < 6) {
618
                                    if (try_count < MAX_RETRY) {
618
                                        new Handler().postDelayed(new Runnable() {
619
                                        new Handler().postDelayed(new Runnable() {
619
                                            @Override
620
                                            @Override
620
                                            public void run() {
621
                                            public void run() {

+ 4 - 2
app/src/main/java/com/electric/chargingpile/activity/ConfirmOrderActivity.java

62
    private RelativeLayout rl_number_plate;
62
    private RelativeLayout rl_number_plate;
63
    private TextView tv_num_plate;
63
    private TextView tv_num_plate;
64
64
65
    private static final int MAX_RETRY = 10;
66
65
    @Override
67
    @Override
66
    protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
68
    protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
67
        super.onCreate(savedInstanceState);
69
        super.onCreate(savedInstanceState);
126
                                    dismissDialog();
128
                                    dismissDialog();
127
                                    upDateView();
129
                                    upDateView();
128
                                } else {
130
                                } else {
129
                                    if (delayedSettlementCount < 6) {
131
                                    if (delayedSettlementCount < MAX_RETRY) {
130
                                        new Handler().postDelayed(new Runnable() {
132
                                        new Handler().postDelayed(new Runnable() {
131
                                            @Override
133
                                            @Override
132
                                            public void run() {
134
                                            public void run() {
320
                                    finish();
322
                                    finish();
321
323
322
                                } else {
324
                                } else {
323
                                    if (try_count < 6) {
325
                                    if (try_count <= MAX_RETRY) {
324
                                        new Handler().postDelayed(new Runnable() {
326
                                        new Handler().postDelayed(new Runnable() {
325
                                            @Override
327
                                            @Override
326
                                            public void run() {
328
                                            public void run() {

+ 26 - 2
app/src/main/java/com/electric/chargingpile/activity/MyWebViewActivity.java

25
import android.view.KeyEvent;
25
import android.view.KeyEvent;
26
import android.view.View;
26
import android.view.View;
27
import android.view.animation.AnimationUtils;
27
import android.view.animation.AnimationUtils;
28
import android.webkit.DownloadListener;
28
import android.webkit.GeolocationPermissions;
29
import android.webkit.GeolocationPermissions;
29
import android.webkit.JavascriptInterface;
30
import android.webkit.JavascriptInterface;
30
import android.webkit.SslErrorHandler;
31
import android.webkit.SslErrorHandler;
128
    private final static int FILE_CAMERA_RESULT_CODE = 129; // 拍照
129
    private final static int FILE_CAMERA_RESULT_CODE = 129; // 拍照
129
    private String cameraFilePath;  // 拍照图片路径
130
    private String cameraFilePath;  // 拍照图片路径
130
    private boolean loginToShare;
131
    private boolean loginToShare;
131
132
    private boolean mIsDownload;
132
    @Override
133
    @Override
133
    protected void onCreate(Bundle savedInstanceState) {
134
    protected void onCreate(Bundle savedInstanceState) {
134
        super.onCreate(savedInstanceState);
135
        super.onCreate(savedInstanceState);
200
            webView.loadUrl(mUrl);
201
            webView.loadUrl(mUrl);
201
        }
202
        }
202
203
204
        webView.setDownloadListener((url, userAgent, contentDisposition, mimetype, contentLength) -> {
205
            if (mIsDownload) {
206
                Intent intent = new Intent(Intent.ACTION_VIEW);
207
                Uri uri = Uri.parse(url);
208
                intent.addCategory(Intent.CATEGORY_BROWSABLE);
209
                intent.setData(uri);
210
                startActivity(intent);
211
            }
212
            mIsDownload = true;//重置为初始状态
213
        });
214
203
        webView.setLongClickable(true);
215
        webView.setLongClickable(true);
204
        webView.setOnLongClickListener(new View.OnLongClickListener() {
216
        webView.setOnLongClickListener(new View.OnLongClickListener() {
205
            @Override
217
            @Override
1531
                        Uri.parse(url));
1543
                        Uri.parse(url));
1532
                startActivity(intent);
1544
                startActivity(intent);
1533
                return true;
1545
                return true;
1534
            } else {
1546
            }else if (url.contains("app://com.d1ev.app.ev01")){
1547
                try {
1548
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
1549
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
1550
                    startActivity(intent);
1551
                    mIsDownload = false;
1552
                } catch (Exception e) {
1553
                    //通过直接处理抛出的ActivityNotFound异常来确保程序不会崩溃
1554
                    e.printStackTrace();
1555
                }
1556
                return true;
1557
1558
            }else {
1535
                Log.e(TAG, "shouldOverrideUrlLoading: 1");
1559
                Log.e(TAG, "shouldOverrideUrlLoading: 1");
1536
                view.loadUrl(url);
1560
                view.loadUrl(url);
1537
            }
1561
            }

+ 29 - 14
app/src/main/java/com/electric/chargingpile/activity/RecommendChargingStationActivity.java

356
                }
356
                }
357
            }
357
            }
358
358
359
            if (recommendZhan.getFast_able_num() == null && recommendZhan.getSlow_able_num() == null) {
360
                holder.window_tv_fast_free_label.setVisibility(View.GONE);
361
                holder.window_tv_fast_total_num.setVisibility(View.GONE);
362
363
                holder.window_tv_slow_free_label.setVisibility(View.GONE);
364
                holder.window_tv_slow_total_num.setVisibility(View.GONE);
365
366
                holder.window_tv_fast_free_num.setText("".equals(recommendZhan.getFast_num()) ? "0" : recommendZhan.getFast_num());
367
                holder.window_tv_slow_free_num.setText("".equals(recommendZhan.getSlow_num()) ? "0" : recommendZhan.getSlow_num());
368
            } else {
359
            if (recommendZhan.getAcableNum() !=null ){
369
                holder.window_tv_fast_free_label.setVisibility(View.VISIBLE);
360
                holder.window_tv_fast_free_label.setVisibility(View.VISIBLE);
370
                holder.window_tv_fast_total_num.setVisibility(View.VISIBLE);
361
                holder.window_tv_fast_total_num.setVisibility(View.VISIBLE);
371
362
372
                holder.window_tv_slow_free_label.setVisibility(View.VISIBLE);
363
                holder.window_tv_slow_free_label.setVisibility(View.VISIBLE);
373
                holder.window_tv_slow_total_num.setVisibility(View.VISIBLE);
364
                holder.window_tv_slow_total_num.setVisibility(View.VISIBLE);
374
365
375
                holder.window_tv_fast_free_num.setText(recommendZhan.getFast_able_num());
376
                holder.window_tv_slow_free_num.setText(recommendZhan.getSlow_able_num());
377
                holder.window_tv_fast_total_num.setText("".equals(recommendZhan.getFast_num()) ? "0" : "/" + recommendZhan.getFast_num());
378
                holder.window_tv_slow_total_num.setText("".equals(recommendZhan.getSlow_num()) ? "0" : "/" + recommendZhan.getSlow_num());
366
                holder.window_tv_fast_free_num.setText(recommendZhan.getDcableNum());
367
                holder.window_tv_slow_free_num.setText(recommendZhan.getAcableNum());
368
                holder.window_tv_fast_total_num.setText("".equals(recommendZhan.getDcNum()) ? "0" : "/" + recommendZhan.getDcNum());
369
                holder.window_tv_slow_total_num.setText("".equals(recommendZhan.getAcNum()) ? "0" : "/" + recommendZhan.getAcNum());
370
            }else{
371
                if (recommendZhan.getFast_able_num() == null && recommendZhan.getSlow_able_num() == null) {
372
                    holder.window_tv_fast_free_label.setVisibility(View.GONE);
373
                    holder.window_tv_fast_total_num.setVisibility(View.GONE);
374
375
                    holder.window_tv_slow_free_label.setVisibility(View.GONE);
376
                    holder.window_tv_slow_total_num.setVisibility(View.GONE);
377
378
                    holder.window_tv_fast_free_num.setText("".equals(recommendZhan.getFast_num()) ? "0" : recommendZhan.getFast_num());
379
                    holder.window_tv_slow_free_num.setText("".equals(recommendZhan.getSlow_num()) ? "0" : recommendZhan.getSlow_num());
380
                } else {
381
                    holder.window_tv_fast_free_label.setVisibility(View.VISIBLE);
382
                    holder.window_tv_fast_total_num.setVisibility(View.VISIBLE);
383
384
                    holder.window_tv_slow_free_label.setVisibility(View.VISIBLE);
385
                    holder.window_tv_slow_total_num.setVisibility(View.VISIBLE);
386
387
                    holder.window_tv_fast_free_num.setText(recommendZhan.getFast_able_num());
388
                    holder.window_tv_slow_free_num.setText(recommendZhan.getSlow_able_num());
389
                    holder.window_tv_fast_total_num.setText("".equals(recommendZhan.getFast_num()) ? "0" : "/" + recommendZhan.getFast_num());
390
                    holder.window_tv_slow_total_num.setText("".equals(recommendZhan.getSlow_num()) ? "0" : "/" + recommendZhan.getSlow_num());
391
392
                }
393
379
            }
394
            }
380
            holder.fenshi_info_textview.setText("");
395
            holder.fenshi_info_textview.setText("");
381
396

+ 36 - 0
app/src/main/java/com/electric/chargingpile/data/RecommendZhan.java

56
    private String park_location;
56
    private String park_location;
57
    private String stop_cost;
57
    private String stop_cost;
58
    private String fenshi_is;
58
    private String fenshi_is;
59
    private String acNum;
60
    private String acableNum;
61
    private String dcNum;
62
    private String dcableNum;
63
64
    public String getAcNum() {
65
        return acNum;
66
    }
67
68
    public void setAcNum(String acNum) {
69
        this.acNum = acNum;
70
    }
71
72
    public String getAcableNum() {
73
        return acableNum;
74
    }
75
76
    public void setAcableNum(String acableNum) {
77
        this.acableNum = acableNum;
78
    }
79
80
    public String getDcNum() {
81
        return dcNum;
82
    }
83
84
    public void setDcNum(String dcNum) {
85
        this.dcNum = dcNum;
86
    }
87
88
    public String getDcableNum() {
89
        return dcableNum;
90
    }
91
92
    public void setDcableNum(String dcableNum) {
93
        this.dcableNum = dcableNum;
94
    }
59
95
60
    public double getDistanceDouble() {
96
    public double getDistanceDouble() {
61
        return distanceDouble;
97
        return distanceDouble;

+ 1 - 1
app/src/main/res/layout/activity_privacy_agreement.xml

41
                android:layout_width="match_parent"
41
                android:layout_width="match_parent"
42
                android:layout_height="wrap_content"
42
                android:layout_height="wrap_content"
43
                android:layout_marginTop="15dp"
43
                android:layout_marginTop="15dp"
44
                android:text="感谢您下载充电桩应用,当您开始使用本软件时,我们可能会对您的部分个人信息进行收集、使用和共享。请您仔细阅读《充电桩隐私政策》并确定了解我们对您个人信息的处理规则,包括:"
44
                android:text="感谢您下载充电桩应用,当您开始使用本软件时,我们可能会对您的部分个人信息进行收集、使用和共享。同时为了提升消息送达率,更好的为您提供服务,我们会默认开启自启动和关联启动功能。请您仔细阅读《充电桩隐私政策》并确定了解我们对您个人信息的处理规则,包括:"
45
                android:textColor="@color/color_222222"
45
                android:textColor="@color/color_222222"
46
                android:textSize="16sp" />
46
                android:textSize="16sp" />
47
47