1.优化我的界面的更新本地数据功能添加loding
2.优化巡检详情页面增大放大级别
3.优化我的界面的更新本地数据功能所有接口都结束后显示数据更新成功
|  |  |  | 
|---|
|  |  |  | { icon: createIcon(CONFIG.IMAGES.MARKER_START, 35) } | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | map.addOverLay(marker); | 
|---|
|  |  |  | map.setZoom(15); | 
|---|
|  |  |  | } else if (end === "true" || end === true) { | 
|---|
|  |  |  | let marker = new T.Marker( | 
|---|
|  |  |  | newPoint, | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dayu.pipirrapp.R; | 
|---|
|  |  |  | import com.dayu.pipirrapp.bean.db.InspectionLocationBean; | 
|---|
|  |  |  | import com.dayu.pipirrapp.bean.net.InspectListResult; | 
|---|
|  |  |  | import com.dayu.pipirrapp.bean.net.InspectPointResult; | 
|---|
|  |  |  | import com.dayu.pipirrapp.dao.DaoSingleton; | 
|---|
|  |  |  | import com.dayu.pipirrapp.net.ApiManager; | 
|---|
|  |  |  | import com.dayu.pipirrapp.net.BaseResponse; | 
|---|
|  |  |  | import com.dayu.pipirrapp.net.Constants; | 
|---|
|  |  |  | import com.dayu.pipirrapp.net.subscribers.SubscriberListener; | 
|---|
|  |  |  | import com.dayu.pipirrapp.utils.CommonData; | 
|---|
|  |  |  | import com.dayu.pipirrapp.utils.MapJpgUtils; | 
|---|
|  |  |  | import com.dayu.pipirrapp.view.TitleBar; | 
|---|
|  |  |  | 
|---|
|  |  |  | import java.io.File; | 
|---|
|  |  |  | import java.io.FileInputStream; | 
|---|
|  |  |  | import java.io.FileNotFoundException; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; | 
|---|
|  |  |  | import io.reactivex.rxjava3.schedulers.Schedulers; | 
|---|
|  |  |  | 
|---|
|  |  |  | // 查询当前未关闭的巡检记录下所有的坐标 | 
|---|
|  |  |  | DaoSingleton.getAsynchInstance(this).inspectionLocationDao().findByInspectId(inspectId).subscribeOn(Schedulers.io()) | 
|---|
|  |  |  | .observeOn(AndroidSchedulers.mainThread()).subscribe(inspectionLocationBeans -> { | 
|---|
|  |  |  | aginShowLocation(inspectionLocationBeans); | 
|---|
|  |  |  | if (inspectionLocationBeans != null && inspectionLocationBeans.size() > 0) { | 
|---|
|  |  |  | aginShowLocation(inspectionLocationBeans); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | getHttpLocation(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | isEnd = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Log.i("mWebView", "showHistoryLocation" + inspectionLocationBean.getLng() + "\",\"" + inspectionLocationBean.getLat()); | 
|---|
|  |  |  | mWebView.evaluateJavascript("javascript:showHistoryLocation(\"" + inspectionLocationBean.getLng() + "\",\"" + inspectionLocationBean.getLat() + "\",\"" + isStart + "\",\"" + isEnd + "\")", value -> { | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | putDataToWeb(inspectionLocationBean.getLng(), inspectionLocationBean.getLat(), isStart + "", isEnd + ""); | 
|---|
|  |  |  | index++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 向 WebView 注入数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 向 WebView 注入数据 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param lng | 
|---|
|  |  |  | * @param lat | 
|---|
|  |  |  | * @param isStart | 
|---|
|  |  |  | * @param isEnd | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void putDataToWeb(String lng, String lat, String isStart, String isEnd) { | 
|---|
|  |  |  | Log.i("mWebView", "showHistoryLocation" + lng + "\",\"" + lat); | 
|---|
|  |  |  | mWebView.evaluateJavascript("javascript:showHistoryLocation(\"" + lng + "\",\"" + lat + "\",\"" + isStart + "\",\"" + isEnd + "\")", value -> { | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void getHttpLocation() { | 
|---|
|  |  |  | Map<String, Object> params = new HashMap<>(); | 
|---|
|  |  |  | params.put("inspectId", inspectId); | 
|---|
|  |  |  | ApiManager.getInstance().requestGet(this, Constants.BASE_URL + "/app/inspect/getInspects", InspectListResult.class, params, new SubscriberListener<BaseResponse<InspectListResult>>() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onNext(BaseResponse<InspectListResult> t) { | 
|---|
|  |  |  | if (t.isSuccess()) { | 
|---|
|  |  |  | if (t.getContent() != null) { | 
|---|
|  |  |  | List<InspectionLocationBean> locationBeans = new ArrayList<>(); | 
|---|
|  |  |  | if (t.getContent().getObj()!=null&&t.getContent().getObj().size()>0){ | 
|---|
|  |  |  | for (InspectPointResult inspectPointResult : t.getContent().getObj().get(0).getTracks()) { | 
|---|
|  |  |  | InspectionLocationBean inspectionLocationBean = new InspectionLocationBean(); | 
|---|
|  |  |  | inspectionLocationBean.setLng(inspectPointResult.getLng()); | 
|---|
|  |  |  | inspectionLocationBean.setLat(inspectPointResult.getLat()); | 
|---|
|  |  |  | inspectionLocationBean.setInspectId(inspectId); | 
|---|
|  |  |  | inspectionLocationBean.setId(inspectPointResult.getId()); | 
|---|
|  |  |  | inspectionLocationBean.setLocateTime(inspectPointResult.getLocateTime()); | 
|---|
|  |  |  | locationBeans.add(inspectionLocationBean); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | aginShowLocation(locationBeans); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onCloose() { | 
|---|
|  |  |  | super.onCloose(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onError(Throwable e) { | 
|---|
|  |  |  | super.onError(e); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dayu.pipirrapp.bean.net; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * InspectPointResult - 巡检点结果 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author zuoxiao | 
|---|
|  |  |  | * @version 1.0 | 
|---|
|  |  |  | * @since 2025-02-21 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public class InspectPointResult { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 巡检位置记录的唯一标识符 | 
|---|
|  |  |  | private String id; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 巡检记录的ID,关联到巡检记录表 | 
|---|
|  |  |  | private String inspectId; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 经度信息,表示巡检位置的经度坐标 | 
|---|
|  |  |  | private String lng; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 纬度信息,表示巡检位置的纬度坐标 | 
|---|
|  |  |  | private String lat; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 打点时间,表示记录该巡检位置的时间 | 
|---|
|  |  |  | private String locateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取巡检位置记录的唯一标识符 | 
|---|
|  |  |  | public String getId() { | 
|---|
|  |  |  | return id; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 设置巡检位置记录的唯一标识符 | 
|---|
|  |  |  | public void setId(String id) { | 
|---|
|  |  |  | this.id = id; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取巡检记录的ID | 
|---|
|  |  |  | public String getInspectId() { | 
|---|
|  |  |  | return inspectId; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 设置巡检记录的ID | 
|---|
|  |  |  | public void setInspectId(String inspectId) { | 
|---|
|  |  |  | this.inspectId = inspectId; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取经度信息 | 
|---|
|  |  |  | public String getLng() { | 
|---|
|  |  |  | return lng; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 设置经度信息 | 
|---|
|  |  |  | public void setLng(String lng) { | 
|---|
|  |  |  | this.lng = lng; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取纬度信息 | 
|---|
|  |  |  | public String getLat() { | 
|---|
|  |  |  | return lat; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 设置纬度信息 | 
|---|
|  |  |  | public void setLat(String lat) { | 
|---|
|  |  |  | this.lat = lat; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取打点时间 | 
|---|
|  |  |  | public String getLocateTime() { | 
|---|
|  |  |  | return locateTime; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 设置打点时间 | 
|---|
|  |  |  | public void setLocateTime(String locateTime) { | 
|---|
|  |  |  | this.locateTime = locateTime; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 重写toString方法,便于打印对象信息 | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String toString() { | 
|---|
|  |  |  | return "InspectionLocationBean{" + | 
|---|
|  |  |  | "id='" + id + '\'' + | 
|---|
|  |  |  | ", inspectId='" + inspectId + '\'' + | 
|---|
|  |  |  | ", lng='" + lng + '\'' + | 
|---|
|  |  |  | ", lat='" + lat + '\'' + | 
|---|
|  |  |  | ", locateTime='" + locateTime + '\'' + | 
|---|
|  |  |  | '}'; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | private String startTime; // 开始时间 | 
|---|
|  |  |  | private String stopTime; // 结束时间 | 
|---|
|  |  |  | private Double inspectDistance; // 巡检距离 | 
|---|
|  |  |  | private List<String> tracks; // 巡检节点列表 | 
|---|
|  |  |  | private List<InspectPointResult> tracks; // 巡检节点列表 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 构造函数 | 
|---|
|  |  |  | public InspectResult(String inspectorId, String inspectorName, String inspectId, String startTime, String stopTime, Double inspectDistance, List<String> tracks) { | 
|---|
|  |  |  | public InspectResult(String inspectorId, String inspectorName, String inspectId, String startTime, String stopTime, Double inspectDistance, List<InspectPointResult> tracks) { | 
|---|
|  |  |  | this.inspectorId = inspectorId; | 
|---|
|  |  |  | this.inspectorName = inspectorName; | 
|---|
|  |  |  | this.inspectId = inspectId; | 
|---|
|  |  |  | 
|---|
|  |  |  | this.inspectDistance = inspectDistance; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<String> getTracks() { | 
|---|
|  |  |  | public List<InspectPointResult> getTracks() { | 
|---|
|  |  |  | return tracks; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setTracks(List<String> tracks) { | 
|---|
|  |  |  | public void setTracks(List<InspectPointResult> tracks) { | 
|---|
|  |  |  | this.tracks = tracks; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.jeremyliao.liveeventbus.LiveEventBus; | 
|---|
|  |  |  | import com.tencent.bugly.crashreport.CrashReport; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.File; | 
|---|
|  |  |  | import java.io.FileInputStream; | 
|---|
|  |  |  | import java.io.FileNotFoundException; | 
|---|
|  |  |  | 
|---|
|  |  |  | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; | 
|---|
|  |  |  | import io.reactivex.rxjava3.disposables.CompositeDisposable; | 
|---|
|  |  |  | import io.reactivex.rxjava3.schedulers.Schedulers; | 
|---|
|  |  |  | import io.reactivex.rxjava3.core.Single; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * author: zuo | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 添加刷新数据的监听 | 
|---|
|  |  |  | LiveEventBus.get(CommonKeyName.refreshData).observe(this, o -> { | 
|---|
|  |  |  | getCenterPoint(); | 
|---|
|  |  |  | getMarkerData(); | 
|---|
|  |  |  | getDivideList(); | 
|---|
|  |  |  | getPipeNetworkList(); | 
|---|
|  |  |  | // 显示加载动画 | 
|---|
|  |  |  | TipUtil.showLoading(MapFragment.this.getActivity(), "正在更新数据..."); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 创建多个Single对象来表示每个网络请求 | 
|---|
|  |  |  | Single<Boolean> centerPointSingle = Single.create(emitter -> { | 
|---|
|  |  |  | getCenterPoint(); | 
|---|
|  |  |  | emitter.onSuccess(true); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Single<Boolean> markerDataSingle = Single.create(emitter -> { | 
|---|
|  |  |  | getMarkerData(); | 
|---|
|  |  |  | emitter.onSuccess(true); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Single<Boolean> divideListSingle = Single.create(emitter -> { | 
|---|
|  |  |  | getDivideList(); | 
|---|
|  |  |  | emitter.onSuccess(true); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Single<Boolean> pipeNetworkListSingle = Single.create(emitter -> { | 
|---|
|  |  |  | getPipeNetworkList(); | 
|---|
|  |  |  | emitter.onSuccess(true); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 组合所有Single | 
|---|
|  |  |  | compositeDisposable.add( | 
|---|
|  |  |  | Single.zip( | 
|---|
|  |  |  | centerPointSingle, | 
|---|
|  |  |  | markerDataSingle, | 
|---|
|  |  |  | divideListSingle, | 
|---|
|  |  |  | pipeNetworkListSingle, | 
|---|
|  |  |  | (centerPoint, marker, divide, pipe) -> true | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .subscribeOn(Schedulers.io()) | 
|---|
|  |  |  | .observeOn(AndroidSchedulers.mainThread()) | 
|---|
|  |  |  | .doFinally(() -> { | 
|---|
|  |  |  | // 无论成功还是失败,都需要隐藏加载动画 | 
|---|
|  |  |  | TipUtil.dismissLoading(); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .subscribe( | 
|---|
|  |  |  | result -> { | 
|---|
|  |  |  | ToastUtil.showToast(MapFragment.this.getContext(), "数据更新完成"); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | throwable -> { | 
|---|
|  |  |  | Log.e(TAG, "数据更新失败: " + throwable.getMessage()); | 
|---|
|  |  |  | ToastUtil.showToast(MapFragment.this.getContext(), "数据更新失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | //巡检按钮 | 
|---|
|  |  |  | binding.inspectButton.setOnClickListener(v -> { | 
|---|
|  |  |  | if (XXPermissions.isGranted(MapFragment.this.getContext(), Permission.ACCESS_BACKGROUND_LOCATION)) { | 
|---|
|  |  |  | new ConfirmDialog(MapFragment.this.getActivity(), "确认开始巡检吗?",(confirmDialog, v1) -> { | 
|---|
|  |  |  | new ConfirmDialog(MapFragment.this.getActivity(), "确认开始巡检吗?", (confirmDialog, v1) -> { | 
|---|
|  |  |  | chageInspecState(InspectionUtils.STAT_INSPECTION_ONCLICK); | 
|---|
|  |  |  | confirmDialog.dismiss(); | 
|---|
|  |  |  | }).show(); | 
|---|
|  |  |  | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | // 跳转到选择的位置 | 
|---|
|  |  |  | mWebView.evaluateJavascript( | 
|---|
|  |  |  | String.format("javascript:setCenterAndZoom(\"%s\",\"%s\",\"17\")", | 
|---|
|  |  |  | item.getLng(), | 
|---|
|  |  |  | item.getLat()), | 
|---|
|  |  |  | null | 
|---|
|  |  |  | String.format("javascript:setCenterAndZoom(\"%s\",\"%s\",\"17\")", | 
|---|
|  |  |  | item.getLng(), | 
|---|
|  |  |  | item.getLat()), | 
|---|
|  |  |  | null | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 执行搜索 | 
|---|
|  |  |  | compositeDisposable.add( | 
|---|
|  |  |  | DaoSingleton.getAsynchInstance(requireContext()) | 
|---|
|  |  |  | .divideDao() | 
|---|
|  |  |  | .searchAllByKeyword(s) | 
|---|
|  |  |  | .subscribeOn(Schedulers.io()) | 
|---|
|  |  |  | .observeOn(AndroidSchedulers.mainThread()) | 
|---|
|  |  |  | .subscribe( | 
|---|
|  |  |  | results -> { | 
|---|
|  |  |  | if (results != null && !results.isEmpty()) { | 
|---|
|  |  |  | searchDialog.setData(results); | 
|---|
|  |  |  | searchDialog.show(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | ToastUtil.showToast(requireContext(), "未找到相关结果"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | throwable -> { | 
|---|
|  |  |  | ToastUtil.showToast(requireContext(), "搜索失败:" + throwable.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | DaoSingleton.getAsynchInstance(requireContext()) | 
|---|
|  |  |  | .divideDao() | 
|---|
|  |  |  | .searchAllByKeyword(s) | 
|---|
|  |  |  | .subscribeOn(Schedulers.io()) | 
|---|
|  |  |  | .observeOn(AndroidSchedulers.mainThread()) | 
|---|
|  |  |  | .subscribe( | 
|---|
|  |  |  | results -> { | 
|---|
|  |  |  | if (results != null && !results.isEmpty()) { | 
|---|
|  |  |  | searchDialog.setData(results); | 
|---|
|  |  |  | searchDialog.show(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | ToastUtil.showToast(requireContext(), "未找到相关结果"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | throwable -> { | 
|---|
|  |  |  | ToastUtil.showToast(requireContext(), "搜索失败:" + throwable.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | 
|---|
|  |  |  | boolean isfrist = true; | 
|---|
|  |  |  | for (PipeNetworkDataCoordinateBean data : pipeNetworkBean.getData().getCoordinates()) { | 
|---|
|  |  |  | if (!TextUtils.isEmpty(data.getLat()) && !TextUtils.isEmpty(data.getLng())) { | 
|---|
|  |  |  | mWebView.evaluateJavascript("javascript:addPipeNetwork(\"" + data.getLng() + "\",\"" + data.getLat() + "\",\"" + isfrist +  "\",\"" + isShowPipeNetwork +"\")", new ValueCallback<String>() { | 
|---|
|  |  |  | mWebView.evaluateJavascript("javascript:addPipeNetwork(\"" + data.getLng() + "\",\"" + data.getLat() + "\",\"" + isfrist + "\",\"" + isShowPipeNetwork + "\")", new ValueCallback<String>() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onReceiveValue(String value) { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.dayu.pipirrapp.view; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import android.app.Activity; | 
|---|
|  |  |  | import android.app.Dialog; | 
|---|
|  |  |  | import android.os.Build; | 
|---|
|  |  |  | import android.view.LayoutInflater; | 
|---|
|  |  |  | import android.view.View; | 
|---|
|  |  |  | import android.widget.TextView; | 
|---|
|  |  |  | import android.widget.Toast; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dayu.pipirrapp.MyApplication; | 
|---|
|  |  |  | import com.dayu.pipirrapp.R; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class TipUtil { | 
|---|
|  |  |  | private static Dialog loadingDialog; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public interface TipListener { | 
|---|
|  |  |  | void onCancle(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 显示加载动画 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param activity Activity | 
|---|
|  |  |  | * @param loadingText 加载提示文字 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static void showLoading(Activity activity, String loadingText) { | 
|---|
|  |  |  | if (isDestroy(activity)) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | dismissLoading(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | View view = LayoutInflater.from(activity).inflate(R.layout.dialog_loading, null); | 
|---|
|  |  |  | TextView tvLoading = view.findViewById(R.id.tv_loading_text); | 
|---|
|  |  |  | tvLoading.setText(loadingText); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | loadingDialog = new Dialog(activity, R.style.LoadingDialog); | 
|---|
|  |  |  | loadingDialog.setCancelable(false); | 
|---|
|  |  |  | loadingDialog.setContentView(view); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!activity.isFinishing()) { | 
|---|
|  |  |  | loadingDialog.show(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 隐藏加载动画 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static void dismissLoading() { | 
|---|
|  |  |  | if (loadingDialog != null && loadingDialog.isShowing()) { | 
|---|
|  |  |  | loadingDialog.dismiss(); | 
|---|
|  |  |  | loadingDialog = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void show(Activity mActivity, String data) { | 
|---|
|  |  |  | //        Toast.makeText(context, data, Toast.LENGTH_LONG).show(); | 
|---|
|  |  |  | try { | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | <?xml version="1.0" encoding="utf-8"?> | 
|---|
|  |  |  | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 
|---|
|  |  |  | android:layout_width="wrap_content" | 
|---|
|  |  |  | android:layout_height="wrap_content" | 
|---|
|  |  |  | android:background="@drawable/bg_loading_dialog" | 
|---|
|  |  |  | android:gravity="center" | 
|---|
|  |  |  | android:minWidth="120dp" | 
|---|
|  |  |  | android:minHeight="120dp" | 
|---|
|  |  |  | android:orientation="vertical" | 
|---|
|  |  |  | android:padding="16dp"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <ProgressBar | 
|---|
|  |  |  | android:layout_width="36dp" | 
|---|
|  |  |  | android:layout_height="36dp" | 
|---|
|  |  |  | android:indeterminateTint="@color/white" /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <TextView | 
|---|
|  |  |  | android:id="@+id/tv_loading_text" | 
|---|
|  |  |  | android:layout_width="wrap_content" | 
|---|
|  |  |  | android:layout_height="wrap_content" | 
|---|
|  |  |  | android:layout_marginTop="8dp" | 
|---|
|  |  |  | android:textColor="@color/white" | 
|---|
|  |  |  | android:textSize="14sp" /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </LinearLayout> | 
|---|
|  |  |  | 
|---|
|  |  |  | <item name="android:backgroundDimEnabled">true</item> | 
|---|
|  |  |  | </style> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!-- 加载对话框样式 --> | 
|---|
|  |  |  | <style name="LoadingDialog" parent="Theme.AppCompat.Dialog"> | 
|---|
|  |  |  | <item name="android:windowBackground">@android:color/transparent</item> | 
|---|
|  |  |  | <item name="android:windowFrame">@null</item> | 
|---|
|  |  |  | <item name="android:windowNoTitle">true</item> | 
|---|
|  |  |  | <item name="android:windowIsFloating">true</item> | 
|---|
|  |  |  | <item name="android:windowIsTranslucent">false</item> | 
|---|
|  |  |  | <item name="android:windowContentOverlay">@null</item> | 
|---|
|  |  |  | <item name="android:backgroundDimEnabled">false</item> | 
|---|
|  |  |  | </style> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|