lines-code">
//                .addParams("Lat","30.2787510000000000")
227
//                .addParams("Lng","120.0488070000000000")
228
                .addParams("version", BuildConfig.VERSION_NAME)
229
                .build().connTimeOut(5000).readTimeOut(5000).execute(new StringCallback() {
230
            @Override
231
            public void onError(Call call, Exception e) {
232
                Toast.makeText(requireContext(), "网络不给力,请检查网络状态", Toast.LENGTH_SHORT).show();
233
                dismissAllowingStateLoss();
234
            }
235
236
            @Override
237
            public void onResponse(String response) {
238
                if (null != response) {
239
                    String data = JsonUtils.getKeyResult(response, "Data");
240
                    if (data == null || !data.equals("true")) {
241
                        String msg = JsonUtils.getKeyResult(response, "Msg");
242
                        ToastUtil.showToast(requireContext(), msg, Toast.LENGTH_SHORT);
243
                    }
244
                }
245
                dismissAllowingStateLoss();
246
            }
113 247
        });
114 248
115 249
    }
116 250
117
    @AfterPermissionGranted(RC_TELL_PERM)
118
    public void tellTask() {
119
        if (hasTellPermission()) {
120
            Intent intent = new Intent();
121
            intent.setAction("android.intent.action.CALL");
122
            intent.addCategory("android.intent.category.DEFAULT");
123
            intent.setData(Uri.parse("tel:" + telNum));
124
            startActivity(intent);
125
        } else {
126
            // Ask for one permission
127
            EasyPermissions.requestPermissions(
128
                    this,
129
                    "该功能需要开启拨号权限,是否前往开启?",
130
                    RC_TELL_PERM,
131
                    Manifest.permission.CALL_PHONE);
251
252
253
    private void setUpMap() {
254
//        //声明mLocationOption对象
255
//        AMapLocationClientOption mLocationOption = null;
256
        try {
257
            mlocationClient = new AMapLocationClient(requireContext());
258
            //初始化定位参数
259
            mLocationOption = new AMapLocationClientOption();
260
            //设置定位监听
261
            mlocationClient.setLocationListener(this);
262
            //设置定位模式为高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式
263
            mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
264
            mLocationOption.setOnceLocation(true);
265
            //设置是否强制刷新WIFI,默认为强制刷新
266
            mLocationOption.setWifiActiveScan(false);
267
            //设置定位间隔,单位毫秒,默认为2000ms
268
            //        mLocationOption.setInterval(2000);
269
            //设置定位参数
270
            mlocationClient.setLocationOption(mLocationOption);
271
            // 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
272
            // 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求
273
            // 在定位结束后,在合适的生命周期调用onDestroy()方法
274
            // 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除
275
276
            //启动定位
277
            mlocationClient.startLocation();
278
        } catch (Exception e) {
279
            e.printStackTrace();
132 280
        }
133
    }
134
    private boolean hasTellPermission() {
135
        return EasyPermissions.hasPermissions(requireContext(), Manifest.permission.CALL_PHONE);
281
136 282
    }
137 283
284
138 285
    @Override
139
    public void onRequestPermissionsResult(int requestCode, @NonNull @NotNull String[] permissions, @NonNull @NotNull int[] grantResults) {
140
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
141
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
286
    public void onLocationChanged(AMapLocation aMapLocation) {
287
        if (aMapLocation != null) {
288
            if (aMapLocation != null
289
                    && aMapLocation.getErrorCode() == 0) {
290
                mAMapLocation = aMapLocation;
291
            } else {
292
                mAMapLocation = null;
293
                String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
294
                Toast.makeText(requireContext(), errText, Toast.LENGTH_SHORT).show();
295
            }
296
        }
297
142 298
    }
143 299
300
    @Override
301
    public void onDestroy() {
302
        if (mlocationClient!=null){
303
            mlocationClient .onDestroy();
304
        }
305
        super.onDestroy();
306
    }
144 307
145 308
    public void show(FragmentManager fragmentManager){
146 309
        FragmentTransaction ft = fragmentManager.beginTransaction();

+ 121 - 0
app/src/main/java/com/electric/chargingpile/view/PhoneDialog.java

@ -0,0 +1,121 @@
1
package com.electric.chargingpile.view;
2
3
import android.Manifest;
4
import android.content.Intent;
5
import android.net.Uri;
6
import android.os.Bundle;
7
import android.util.Log;
8
import android.view.LayoutInflater;
9
import android.view.View;
10
import android.view.ViewGroup;
11
import android.widget.TextView;
12
import android.widget.Toast;
13
14
import androidx.activity.result.contract.ActivityResultContracts;
15
import androidx.annotation.NonNull;
16
import androidx.annotation.Nullable;
17
import androidx.fragment.app.DialogFragment;
18
import androidx.fragment.app.Fragment;
19
import androidx.fragment.app.FragmentManager;
20
import androidx.fragment.app.FragmentTransaction;
21
22
import com.electric.chargingpile.R;
23
import com.electric.chargingpile.util.ToastUtil;
24
import com.hjq.permissions.OnPermissionCallback;
25
import com.hjq.permissions.Permission;
26
import com.hjq.permissions.XXPermissions;
27
28
import org.jetbrains.annotations.NotNull;
29
30
import java.util.List;
31
32
33
public class PhoneDialog extends DialogFragment {
34
35
    private static final String PHONE_KEY = "phone";
36
    private static final int RC_TELL_PERM = 124;
37
    private String telNum = "";
38
39
    public static PhoneDialog newInstart(String phone){
40
        PhoneDialog phoneDialog = new PhoneDialog();
41
        final Bundle args = new Bundle();
42
        args.putString(PHONE_KEY, phone);
43
        phoneDialog.setArguments(args);
44
        return phoneDialog;
45
    }
46
47
    @Override
48
    public void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
49
        super.onCreate(savedInstanceState);
50
        setStyle(DialogFragment.STYLE_NORMAL, R.style.TransparentVideoDialogFragmentTheme);
51
52
    }
53
    @Nullable
54
    @org.jetbrains.annotations.Nullable
55
    @Override
56
    public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
57
        return LayoutInflater.from(requireContext()).inflate(R.layout.dialog_phone, container, false);
58
    }
59
60
61
    @Override
62
    public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
63
        super.onViewCreated(view, savedInstanceState);
64
        telNum = getArguments() == null ? "" : getArguments().getString(PHONE_KEY);
65
        TextView tvPhone = view.findViewById(R.id.tvPhone);
66
        tvPhone.setText(telNum);
67
        view.findViewById(R.id.tvCancel).setOnClickListener(v->{
68
            dismissAllowingStateLoss();
69
        });
70
        view.findViewById(R.id.tvCall).setOnClickListener(v->{
71
            tellTask();
72
        });
73
    }
74
75
    public void tellTask() {
76
        boolean granted = XXPermissions.isGranted(requireContext(), Permission.CALL_PHONE);
77
        if (granted) {
78
            callPhone();
79
        } else {
80
            XXPermissions.with(this)
81
                    // 申请单个权限
82
                    .permission(Permission.CALL_PHONE)
83
                    .request(new OnPermissionCallback() {
84
                        @Override
85
                        public void onGranted(List<String> permissions, boolean all) {
86
                            callPhone();
87
                        }
88
                        @Override
89
                        public void onDenied(List<String> permissions, boolean never) {
90
                            if (never) {
91
                                ToastUtil.showToast(requireContext(),"被永久拒绝授权,请手动授予拨打电话权限", Toast.LENGTH_SHORT);
92
                                // 如果是被永久拒绝就跳转到应用权限系统设置页面
93
                                XXPermissions.startPermissionActivity(requireContext(), permissions);
94
                            } else {
95
                                ToastUtil.showToast(requireContext(),"获取拨打电话权限失败", Toast.LENGTH_SHORT);
96
                            }
97
                            dismissAllowingStateLoss();
98
                        }
99
                    });
100
        }
101
    }
102
103
    private void callPhone() {
104
        Intent intent = new Intent();
105
        intent.setAction("android.intent.action.CALL");
106
        intent.addCategory("android.intent.category.DEFAULT");
107
        intent.setData(Uri.parse("tel:" + telNum));
108
        startActivity(intent);
109
        dismissAllowingStateLoss();
110
    }
111
112
    public void show(FragmentManager fragmentManager){
113
        FragmentTransaction ft = fragmentManager.beginTransaction();
114
        Fragment prev = fragmentManager.findFragmentByTag(PhoneDialog.class.getName());
115
        if (prev != null) {
116
            ft.remove(prev);
117
        }
118
        show(fragmentManager,PhoneDialog.class.getName());
119
        fragmentManager.executePendingTransactions();
120
    }
121
}

+ 9 - 0
app/src/main/res/drawable/bg_3ec34c_hollow_radius20.xml

@ -0,0 +1,9 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3
    <item >
4
        <shape android:shape="rectangle">
5
            <stroke android:width="1dp" android:color="#ff3ec34c" />
6
            <corners android:radius="20dp" />
7
        </shape>
8
    </item>
9
</selector>

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

@ -936,7 +936,7 @@
936 936
        android:layout_alignParentBottom="true"
937 937
        android:background="@color/white"
938 938
        android:visibility="gone"
939
        tools:visibility="visible">
939
        >
940 940
941 941
        <LinearLayout
942 942
            android:layout_width="match_parent"

+ 18 - 5
app/src/main/res/layout/dialog_lock_status.xml

@ -62,14 +62,27 @@
62 62
            android:textColor="@color/color_3ec34c"
63 63
            android:textSize="12sp"
64 64
            />
65
        <androidx.recyclerview.widget.RecyclerView
65
66
        <RelativeLayout
67
            android:layout_marginBottom="13dp"
66 68
            android:layout_marginTop="13dp"
67
            android:layout_width="match_parent"
68
            android:id="@+id/recyclerView"
69
            android:layout_height="0dp"
69 70
            android:layout_weight="1"
70
            android:layout_marginBottom="13dp"
71
            android:layout_height="0dp"/>
71
            android:layout_width="match_parent"
72
           >
73
            <androidx.recyclerview.widget.RecyclerView
74
                android:layout_width="match_parent"
75
                android:id="@+id/recyclerView"
76
                android:layout_height="match_parent"/>
72 77
78
            <ProgressBar
79
                android:id="@+id/progressBar"
80
                tools:visibility="visible"
81
                android:visibility="gone"
82
                android:layout_centerInParent="true"
83
                android:layout_width="wrap_content"
84
                android:layout_height="wrap_content"/>
85
        </RelativeLayout>
73 86
        <LinearLayout
74 87
            android:layout_width="match_parent"
75 88
            android:layout_height="wrap_content">

+ 61 - 0
app/src/main/res/layout/dialog_phone.xml

@ -0,0 +1,61 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="match_parent"
4
    xmlns:tools="http://schemas.android.com/tools"
5
    xmlns:app="http://schemas.android.com/apk/res-auto"
6
    tools:background="#f1f1"
7
    android:layout_height="match_parent">
8
    <androidx.constraintlayout.widget.ConstraintLayout
9
        android:layout_centerInParent="true"
10
        android:background="@drawable/bg_white_radius6"
11
        android:paddingBottom="20dp"
12
        android:paddingEnd="10dp"
13
        android:paddingStart="10dp"
14
        android:paddingTop="30dp"
15
        android:layout_width="256dp"
16
        android:layout_height="wrap_content">
17
18
        <TextView
19
            android:id="@+id/tvPhone"
20
            app:layout_constraintEnd_toEndOf="parent"
21
            app:layout_constraintStart_toStartOf="parent"
22
            app:layout_constraintTop_toTopOf="parent"
23
            android:gravity="center"
24
            android:layout_width="match_parent"
25
            android:layout_height="wrap_content"
26
            tools:text="400-061-0999"
27
            android:textColor="@color/editcolor"
28
            android:textSize="20sp"
29
            />
30
31
        <TextView
32
            android:background="@drawable/bg_3ec34c_hollow_radius20"
33
            android:id="@+id/tvCancel"
34
            android:gravity="center"
35
            android:layout_marginTop="20dp"
36
            app:layout_constraintTop_toBottomOf="@+id/tvPhone"
37
            app:layout_constraintStart_toStartOf="parent"
38
            android:layout_width="0dp"
39
            android:layout_height="30dp"
40
            android:text="取消"
41
            android:textColor="@color/color_3ec34c"
42
            android:textSize="14sp"
43
            app:layout_constraintEnd_toStartOf="@+id/tvCall"
44
            />
45
46
        <TextView
47
            android:background="@drawable/bg_3ec34c_radius20"
48
            android:layout_marginStart="8dp"
49
            android:id="@+id/tvCall"
50
            android:layout_width="0dp"
51
            android:layout_height="30dp"
52
            android:layout_marginTop="20dp"
53
            android:gravity="center"
54
            android:text="呼叫"
55
            android:textColor="@color/white"
56
            android:textSize="14sp"
57
            app:layout_constraintEnd_toEndOf="parent"
58
            app:layout_constraintStart_toEndOf="@+id/tvCancel"
59
            app:layout_constraintTop_toBottomOf="@+id/tvPhone" />
60
    </androidx.constraintlayout.widget.ConstraintLayout>
61
</RelativeLayout>

+ 19 - 1
app/src/main/res/layout/fragment_zhan_status.xml

@ -41,11 +41,29 @@
41 41
    </LinearLayout>
42 42
43 43
    <ListView
44
        android:layout_above="@+id/tvLock"
44 45
        android:id="@+id/lv_status"
45 46
        android:layout_width="match_parent"
46
        android:layout_height="match_parent"
47
        android:layout_height="wrap_content"
47 48
        android:divider="@color/ui_6d"
48 49
        android:dividerHeight="0.5dp"
49 50
        android:background="@color/white"/>
50 51
52
    <TextView
53
        tools:visibility="visible"
54
        android:visibility="gone"
55
        android:gravity="center"
56
        android:background="@drawable/bg_lock_contact"
57
        android:layout_marginTop="12dp"
58
        android:layout_marginEnd="12dp"
59
        android:layout_marginStart="12dp"
60
        android:layout_marginBottom="30dp"
61
        android:layout_alignParentBottom="true"
62
        android:id="@+id/tvLock"
63
        android:layout_width="match_parent"
64
        android:layout_height="42dp"
65
        android:text="降地锁"
66
        android:textColor="@color/white"
67
        android:textSize="16sp"
68
        />
51 69
</RelativeLayout>

+ 2 - 2
app/src/main/res/layout/item_lock.xml

@ -25,8 +25,8 @@
25 25
        app:layout_constraintStart_toStartOf="parent"
26 26
        app:layout_constraintBottom_toBottomOf="parent"
27 27
        app:layout_constraintTop_toTopOf="parent"
28
        android:layout_width="8dp"
29
        android:layout_height="22dp"
28
        android:layout_width="wrap_content"
29
        android:layout_height="wrap_content"
30 30
        android:text="1"
31 31
        android:textColor="@color/editcolor"
32 32
        android:textSize="16sp"

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

@ -235,7 +235,7 @@
235 235
236 236
        <TextView
237 237
            tools:visibility="visible"
238
            android:visibility="visible"
238
            android:visibility="gone"
239 239
            android:id="@+id/tvLock"
240 240
            android:layout_gravity="end|bottom"
241 241
            android:gravity="center"

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

@ -1,8 +1,8 @@
1 1
package com.google.zxing.client.android.constant;
2 2
3 3
public interface UrlConstants {
4
    String HOST_URL = "http://cdz.evcharge.cc/zhannew/basic/web/index.php/";
5
//    String HOST_URL = "http://59.110.68.162/zhannew/basic/web/index.php/"; //测试链接
4
//    String HOST_URL = "http://cdz.evcharge.cc/zhannew/basic/web/index.php/";
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 8
//    String START_CHARGING_URL = HOST_URL + "api/charge/start";

Inloggen - Gogs: Go Git Service

Inloggen