="wrap language-java">
public static LockStatusDialog newInstart(String zhan_id){
LockStatusDialog lockStatusDialog = new LockStatusDialog();
Bundle bundle = new Bundle();
bundle.putString("zhan_id",zhan_id);
lockStatusDialog.setArguments(bundle);
return lockStatusDialog;
}
}
@Override
@Override
@Override
@Override
public void onStart() {
public void onStart() {
super.onStart();
super.onStart();
if (mlocationClient != null && mlocationClient.isStarted()){
mlocationClient.startLocation();
}
Dialog dialog = getDialog();
Dialog dialog = getDialog();
if (dialog!=null){
if (dialog!=null){
View bottomSheet = dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
View bottomSheet = dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
}
}
}
}
@Override
public void onStop() {
if (mlocationClient != null && !mlocationClient.isStarted()){
mlocationClient.stopLocation();
}
super.onStop();
}
@Nullable
@Nullable
@org.jetbrains.annotations.Nullable
@org.jetbrains.annotations.Nullable
@Override
@Override
@Override
@Override
public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
super.onViewCreated(view, savedInstanceState);
RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
zhan_id = getArguments() != null ? getArguments().getString("zhan_id") : "";
initView(view);
setUpMap();
}
private void initView(@NotNull View view) {
recyclerView = view.findViewById(R.id.recyclerView);
TextView tvRefresh = view.findViewById(R.id.tvRefresh);
TextView tvRefresh = view.findViewById(R.id.tvRefresh);
TextView tvContact = view.findViewById(R.id.tvContact);
TextView tvContact = view.findViewById(R.id.tvContact);
TextView tvNum = view.findViewById(R.id.tvNum);
progressBar = view.findViewById(R.id.progressBar);
tvNum = view.findViewById(R.id.tvNum);
recyclerView.setLayoutManager( new GridLayoutManager(requireContext(),5));
recyclerView.setLayoutManager( new GridLayoutManager(requireContext(),5));
recyclerView.setAdapter(new LockAdapter(requireContext()));
mAdapter = new LockAdapter(requireContext());
mAdapter.setLockItemOnClickListner(item->{
request(item.getLockNum());
});
recyclerView.setAdapter(mAdapter);
tvNum.setText(Html.fromHtml("空 <font color='#333333'>"+6+"/</font> <font color='#A5A5A5'>"+2+"</font>",FROM_HTML_MODE_LEGACY));
tvNum.setText(Html.fromHtml("空 <font color='#333333'>"+6+"/</font> <font color='#A5A5A5'>"+2+"</font>",FROM_HTML_MODE_LEGACY));
tvContact.setOnClickListener(v->{
tvContact.setOnClickListener(v->{
//拨打电话
//拨打电话
tellTask();
PhoneDialog.newInstart("10086").show(getChildFragmentManager());
});
});
tvRefresh.setOnClickListener(v->{
tvRefresh.setOnClickListener(v->{
//刷新接口
//刷新接口
requestUpData();
});
requestUpData();
}
private void requestUpData(){
progressBar.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.GONE);
String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanlist/zhan-info2?zhan_id=" + zhan_id + "&version=" + MainApplication.current_code;
OkHttpUtils.get().url(url)
.build()
.connTimeOut(5000)
.readTimeOut(5000)
.execute(new StringCallback(){
@Override
public void onError(Call call, Exception e) {
progressBar.setVisibility(View.GONE);
recyclerView.setVisibility(View.VISIBLE);
}
@Override
public void onResponse(String response) {
progressBar.setVisibility(View.GONE);
recyclerView.setVisibility(View.VISIBLE);
try {
String info = JsonUtils.getKeyResult(response, "info");
info_decode = DES3S.decode(info);
String locks = JsonUtils.getKeyResult(info_decode, "locks");
ArrayList<LocksBean> locksBeans = (ArrayList<LocksBean>) JsonUtils.parseToObjectList(locks, LocksBean.class);
mAdapter.setData(locksBeans);
int available = 0;
for (LocksBean bean: locksBeans) {
if (bean.getLockStatus() == 1){
++available;
}
}
tvNum.setText(Html.fromHtml("空 <font color='#333333'>"+available+"/</font> <font color='#A5A5A5'>"+mAdapter.getItemCount()+"</font>",FROM_HTML_MODE_LEGACY));
}catch (Exception e) {
e.printStackTrace();
}
}
});
}
private void request(String lockNum){
double lat = mAMapLocation == null ? 0.0: mAMapLocation.getLongitude();//经度
double lng = mAMapLocation== null ? 0.0: mAMapLocation.getLatitude();//纬度
OkHttpUtils.get().url(MainApplication.url +"/zhannew/basic/web/index.php/zhanlist/drop-lock")
.addParams("stationId",JsonUtils.getKeyResult(info_decode, "zhan_id"))
.addParams("LockNum",lockNum)
.addParams("Lat",lat+"")
.addParams("Lng",lng+"")
// .addParams("stationId","101437000_269")
// .addParams("LockNum","30353")
// .addParams("Lat","30.2787510000000000")
// .addParams("Lng","120.0488070000000000")
.addParams("version", BuildConfig.VERSION_NAME)
.build().connTimeOut(5000).readTimeOut(5000).execute(new StringCallback() {
@Override
public void onError(Call call, Exception e) {
Toast.makeText(requireContext(), "网络不给力,请检查网络状态", Toast.LENGTH_SHORT).show();
dismissAllowingStateLoss();
}
@Override
public void onResponse(String response) {
if (null != response) {
String data = JsonUtils.getKeyResult(response, "Data");
if (data == null || !data.equals("true")) {
String msg = JsonUtils.getKeyResult(response, "Msg");
ToastUtil.showToast(requireContext(), msg, Toast.LENGTH_SHORT);
}
}
dismissAllowingStateLoss();
}
});
});
}
}
@AfterPermissionGranted(RC_TELL_PERM)
public void tellTask() {
if (hasTellPermission()) {
Intent intent = new Intent();
intent.setAction("android.intent.action.CALL");
intent.addCategory("android.intent.category.DEFAULT");
intent.setData(Uri.parse("tel:" + telNum));
startActivity(intent);
} else {
// Ask for one permission
EasyPermissions.requestPermissions(
this,
"该功能需要开启拨号权限,是否前往开启?",
RC_TELL_PERM,
Manifest.permission.CALL_PHONE);
private void setUpMap() {
// //声明mLocationOption对象
// AMapLocationClientOption mLocationOption = null;
try {
mlocationClient = new AMapLocationClient(requireContext());
//初始化定位参数
mLocationOption = new AMapLocationClientOption();
//设置定位监听
mlocationClient.setLocationListener(this);
//设置定位模式为高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
mLocationOption.setOnceLocation(true);
//设置是否强制刷新WIFI,默认为强制刷新
mLocationOption.setWifiActiveScan(false);
//设置定位间隔,单位毫秒,默认为2000ms
// mLocationOption.setInterval(2000);
//设置定位参数
mlocationClient.setLocationOption(mLocationOption);
// 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
// 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求
// 在定位结束后,在合适的生命周期调用onDestroy()方法
// 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除
//启动定位
mlocationClient.startLocation();
} catch (Exception e) {
e.printStackTrace();
}
}
}
private boolean hasTellPermission() {
return EasyPermissions.hasPermissions(requireContext(), Manifest.permission.CALL_PHONE);
}
}
@Override
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull @NotNull String[] permissions, @NonNull @NotNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
if (aMapLocation != null
&& aMapLocation.getErrorCode() == 0) {
mAMapLocation = aMapLocation;
} else {
mAMapLocation = null;
String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
Toast.makeText(requireContext(), errText, Toast.LENGTH_SHORT).show();
}
}
}
}
@Override
public void onDestroy() {
if (mlocationClient!=null){
mlocationClient .onDestroy();
}
super.onDestroy();
}
public void show(FragmentManager fragmentManager){
public void show(FragmentManager fragmentManager){
FragmentTransaction ft = fragmentManager.beginTransaction();
FragmentTransaction ft = fragmentManager.beginTransaction();
|
|
||
|
1 |
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
||
|
1 |
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
||
| 936 |
|
936 |
|
| 937 |
|
937 |
|
| 938 |
|
938 |
|
| 939 |
|
|
|
|
939 |
|
|
| 940 |
|
940 |
|
| 941 |
|
941 |
|
| 942 |
|
942 |
|
|
|
||
| 62 |
|
62 |
|
| 63 |
|
63 |
|
| 64 |
|
64 |
|
| 65 |
|
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
| 66 |
|
68 |
|
| 67 |
|
|
|
| 68 |
|
|
|
|
69 |
|
|
| 69 |
|
70 |
|
| 70 |
|
|
|
| 71 |
|
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
| 72 |
|
77 |
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
| 73 |
|
86 |
|
| 74 |
|
87 |
|
| 75 |
|
88 |
|
|
|
||
|
1 |
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
||
| 41 |
|
41 |
|
| 42 |
|
42 |
|
| 43 |
|
43 |
|
|
44 |
|
|
| 44 |
|
45 |
|
| 45 |
|
46 |
|
| 46 |
|
|
|
|
47 |
|
|
| 47 |
|
48 |
|
| 48 |
|
49 |
|
| 49 |
|
50 |
|
| 50 |
|
51 |
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
| 51 |
|
69 |
|
|
|
||
| 25 |
|
25 |
|
| 26 |
|
26 |
|
| 27 |
|
27 |
|
| 28 |
|
|
|
| 29 |
|
|
|
|
28 |
|
|
|
29 |
|
|
| 30 |
|
30 |
|
| 31 |
|
31 |
|
| 32 |
|
32 |
|
|
|
||
| 235 |
|
235 |
|
| 236 |
|
236 |
|
| 237 |
|
237 |
|
| 238 |
|
|
|
|
238 |
|
|
| 239 |
|
239 |
|
| 240 |
|
240 |
|
| 241 |
|
241 |
|
|
|
||
| 1 |
|
1 |
|
| 2 |
|
2 |
|
| 3 |
|
3 |
|
| 4 |
|
|
|
| 5 |
|
|
|
|
4 |
|
|
|
5 |
|
|
| 6 |
|
6 |
|
| 7 |
|
7 |
|
| 8 |
|
8 |
|