From 873e671de9e99ebb984e2aa144b9336711f3f84c Mon Sep 17 00:00:00 2001 From: wangdongsheng Date: Tue, 9 Nov 2021 17:10:37 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=82=E4=BF=AE=E6=94=B9=E4=BA=86=E8=B6=85?= =?UTF-8?q?=E6=97=B6=20=202.=E4=BF=AE=E6=94=B9=E6=8B=8D=E7=85=A7=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84bug=203.=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9retfit=5Ftoken=204.token=20=E7=99=BB=E5=BD=95=E5=B7=B2?= =?UTF-8?q?=E8=BF=87=E6=9C=9F=EF=BC=8C=E6=98=AF=E5=90=A6=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E7=99=BB=E5=BD=95=205.=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=B7=B2?= =?UTF-8?q?=E9=A2=86=E5=8F=96=EF=BC=88=E7=BD=91=E7=BB=9C=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=EF=BC=89=E5=88=97=E8=A1=A8=206.=E9=80=80=E5=87=BA=E6=8B=8D?= =?UTF-8?q?=E6=91=84=E7=95=8C=E9=9D=A2=EF=BC=88=E7=82=B9=E5=87=BB=E9=80=80?= =?UTF-8?q?=E5=87=BA=EF=BC=89=E5=BC=B9=E7=AA=97=E6=98=BE=E7=A4=BA=20?= =?UTF-8?q?=E7=85=A7=E7=89=87=E8=87=AA=E5=8A=A8=E4=BF=9D=E5=AD=98=207.?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8=E7=9A=84=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=20=E5=BC=B9=E7=AA=97=E6=98=BE=E7=A4=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../outdoor/activity/GuidanceActivity.java | 6 + .../outdoor/activity/LoginActivity.java | 6 +- .../outdoor/activity/MainActivity.java | 70 +- .../outdoor/activity/PictureActivity.java | 1 - .../outdoor/activity/PicturesActivity.java | 316 ++-- .../outdoor/activity/TestActivity.java | 1 + .../outdoor/activity/UserActivity.java | 4 +- .../navinfo/outdoor/activity/WebActivity.java | 1 + .../adapter/CapacityMeasureAdapter.java | 1 - .../outdoor/adapter/TaskExplainAdapter.java | 2 - .../com/navinfo/outdoor/api/Constant.java | 37 +- .../navinfo/outdoor/api/UserApplication.java | 12 +- .../outdoor/base/BaseDrawerFragment.java | 3 +- .../fragment/CapacityEvaluationFragment.java | 9 +- .../fragment/CapacityEvaluationFragment2.java | 4 + .../fragment/CapacityMeasurementFragment.java | 25 +- .../fragment/ChargingPileFragment.java | 12 + .../fragment/ChargingStationFragment.java | 169 +- .../fragment/EventPrefectureFragment.java | 4 + .../outdoor/fragment/FilterFragment.java | 46 +- .../outdoor/fragment/FindFragment.java | 6 +- .../outdoor/fragment/ForgetPawFragment.java | 2 + .../outdoor/fragment/GatherGetFragment.java | 30 +- .../outdoor/fragment/GatheringFragment.java | 48 +- .../outdoor/fragment/HasSubmitFragment.java | 43 +- .../outdoor/fragment/IssueFragment.java | 4 + .../outdoor/fragment/MessageFragment.java | 4 + .../outdoor/fragment/MineFragment.java | 21 +- .../outdoor/fragment/OtherFragment.java | 131 +- .../outdoor/fragment/PhotoFragment.java | 39 +- .../navinfo/outdoor/fragment/PoiFragment.java | 157 +- .../outdoor/fragment/PoiTaskFragment.java | 4 + .../outdoor/fragment/PoiVideoFragment.java | 174 +- .../outdoor/fragment/RegisterFragment.java | 2 + .../outdoor/fragment/RoadFragment.java | 210 ++- .../outdoor/fragment/StaySubmitFragment.java | 6 +- .../outdoor/fragment/TaskExplainFragment.java | 4 + .../fragment/TaskExplainFragment2.java | 4 + .../fragment/TaskPrefectureFragment.java | 4 + .../outdoor/fragment/TreasureFragment.java | 1459 ++++++++++------- .../fragment/UserAttestationFragment.java | 38 +- .../outdoor/fragment/VideoFragment.java | 2 - .../outdoor/fragment/WithdrawFragment.java | 69 +- .../fragment/WithdrawalRecordFragment.java | 6 +- .../navinfo/outdoor/http/HttpInterface.java | 63 +- .../com/navinfo/outdoor/http/OkGoBuilder.java | 116 +- .../com/navinfo/outdoor/room/PoiDatabase.java | 2 +- .../com/navinfo/outdoor/room/PoiEntity.java | 4 +- .../navinfo/outdoor/util/FlushTokenUtil.java | 167 ++ .../outdoor/util/PoiEntityDeleteUtil.java | 2 + .../navinfo/outdoor/util/PoiSaveUtils.java | 29 +- .../com/navinfo/outdoor/util/UploadUtils.java | 10 + app/src/main/res/layout/activity_pictures.xml | 12 +- app/src/main/res/layout/capacity_item.xml | 24 +- app/src/main/res/layout/contact_fragment.xml | 2 +- .../main/res/layout/event_prefecture_item.xml | 4 +- .../res/layout/fragment_capacity_eva_web.xml | 2 +- .../main/res/layout/fragment_gather_get.xml | 2 + .../main/res/layout/fragment_has_submit.xml | 30 +- app/src/main/res/layout/fragment_other.xml | 4 - app/src/main/res/layout/tas_explain_item.xml | 47 +- 61 files changed, 2297 insertions(+), 1419 deletions(-) create mode 100644 app/src/main/java/com/navinfo/outdoor/util/FlushTokenUtil.java diff --git a/app/src/main/java/com/navinfo/outdoor/activity/GuidanceActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/GuidanceActivity.java index dafe2f4..dccd17c 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/GuidanceActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/GuidanceActivity.java @@ -22,6 +22,7 @@ import com.navinfo.outdoor.bean.BaseBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; +import com.navinfo.outdoor.util.FlushTokenUtil; import java.io.File; import java.text.DateFormat; @@ -271,6 +272,7 @@ public class GuidanceActivity extends BaseActivity { long time = System.currentTimeMillis(); httpParams.put("datetime", time);*/ OkGoBuilder.getInstance() + .time(30) .Builder(this) .url(HttpInterface.INSERT_USER_GUIDE) .cls(BaseBean.class) @@ -283,6 +285,10 @@ public class GuidanceActivity extends BaseActivity { startActivity(new Intent(GuidanceActivity.this, HomeActivity.class)); GuidanceActivity.this.finish(); Toast.makeText(GuidanceActivity.this, "可以在发现版块的任务说明中,进行再次学习哦", Toast.LENGTH_LONG).show(); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(GuidanceActivity.this); + }else { + Toast.makeText(GuidanceActivity.this, response.getMessage(), Toast.LENGTH_SHORT).show(); } } @Override diff --git a/app/src/main/java/com/navinfo/outdoor/activity/LoginActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/LoginActivity.java index a41be08..9aa2354 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/LoginActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/LoginActivity.java @@ -197,6 +197,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener httpParams.put("datetime", time); showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(this) .url(HttpInterface.USER_LOGIN_OAUTH_TOKEN) .cls(LoginOauthTokenBean.class) @@ -242,6 +243,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener private void initGetUserInfo() { OkGoBuilder.getInstance() + .time(30) .Builder(this) .url(HttpInterface.USER_DETAIL_BY_USER_ID) .token(Constant.ACCESS_TOKEN) @@ -268,9 +270,9 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener Constant.LEVEL = body.getLevel(); UserDetailBean.BodyBean.UserBankcardBean userBankcard = body.getUserBankcard(); if (userBankcard != null) {//存储银行卡信息 - navInfoEditor.putString("bankAccount", userBankcard.getBankAccount());//银行卡编号 + navInfoEditor.putString("bankAccount", userBankcard.getBankAccount());//银行卡号 Constant.BACKGROUND = userBankcard.getBankAccount(); - navInfoEditor.putString("idNumber", userBankcard.getIdNumber());//银行卡账号 + navInfoEditor.putString("idNumber", userBankcard.getIdNumber());//身份证号 Constant.ID_NUMBER = userBankcard.getIdNumber(); navInfoEditor.putString("bankName", userBankcard.getBankName());//銀行姓名 Constant.BACKGROUND_NAME = userBankcard.getBankName(); diff --git a/app/src/main/java/com/navinfo/outdoor/activity/MainActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/MainActivity.java index c0f974b..f3a9691 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/MainActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/MainActivity.java @@ -99,7 +99,6 @@ public class MainActivity extends BaseActivity { } - private void initPermission() { XXPermissions.with(this) // 申请安装包权限 @@ -135,7 +134,7 @@ public class MainActivity extends BaseActivity { Constant.initRootFolder(Constant.USHERED); HttpInterface.initHttpInter(Constant.USHERED); initCheckVersion(); - }else { + } else { initTime(); } //initTime(); @@ -143,11 +142,12 @@ public class MainActivity extends BaseActivity { initPermission(); } } + @Override public void onDenied(List permissions, boolean never) { if (never) { DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; - DialogSettings.cancelable=false; + DialogSettings.cancelable = false; MessageDialog.show(MainActivity.this, "提示", permissions.toString() + " 被永久拒绝授权请手动授权,", "确定").setOkButton(new OnDialogButtonClickListener() { @Override public boolean onClick(BaseDialog baseDialog, View v) { @@ -168,6 +168,7 @@ public class MainActivity extends BaseActivity { httpParams.put("operationType", "android"); showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(this) .url(HttpInterface.APP_CHECK_VERSION) .params(httpParams) @@ -179,7 +180,7 @@ public class MainActivity extends BaseActivity { dismissLoadingDialog(); if (response.getCode() == 200) { int version = response.getBody().getVersion(); - if (versionCode sizeList = (List) options.getSupportedVideoSizes(); -// // Size size = null; // SizeSelector maxWidthSizeSelector = SizeSelectors.maxWidth(size.getWidth()); // SizeSelector maxHeightSizeSelector = SizeSelectors.maxHeight(size.getHeight()); diff --git a/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java index cf0263e..4e018aa 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java @@ -42,6 +42,7 @@ import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.GeometryTools; import com.navinfo.outdoor.util.MyTecentLocationSource; import com.navinfo.outdoor.util.SystemTTS; +import com.navinfo.outdoor.util.ToastUtil; import com.otaliastudios.cameraview.CameraListener; import com.otaliastudios.cameraview.CameraLogger; import com.otaliastudios.cameraview.CameraView; @@ -64,6 +65,7 @@ import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle; import com.tencent.tencentmap.mapsdk.maps.model.Polyline; import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; +import com.umeng.umcrash.UMCrash; import com.vividsolutions.jts.geom.Geometry; import com.wanghong.webpnative.WebPNative; @@ -88,28 +90,26 @@ import static com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle.LOCATION_ public class PicturesActivity extends BaseActivity implements View.OnClickListener { private static final CameraLogger LOG = CameraLogger.create("Picture"); private CameraView camera; - private Button btnSwitch; private TencentMap tencentMap; private TextureMapView ivMap; private List removables; - private PoiEntity poiEntity; private Polyline polyline; private String finalVideoPath; // 摄像后最终保存的文件名 private ViewGroup layerChange; // 切换地图和相机的父控件 private CheckBox capturePicture, cbMapType; //拍照 - private boolean isMapSlide=false; + private boolean isMapSlide = false; private boolean isOration = false; private SimpleDateFormat formatter; - private File paperFile,logFile; + private File paperFile, logFile; private int poi_video_type; - private ImageView ivZoomAdd, ivZoomDel, ivLocation,ivPicImage, ivPicVideoImage; + private ImageView ivZoomAdd, ivZoomDel, ivLocation, ivPicImage, ivPicVideoImage, imageView; private TencentLocation oldCurrentLocation = null; private Timer timer; private TimerTask timerTask; private int videoIndex = -1; private int oration = 0; private SystemTTS systemTTS; - private boolean isBack = false; + private boolean isBack = true; private StringBuilder picturesBuilder; private Handler handler = new Handler(new Handler.Callback() { @Override @@ -117,8 +117,8 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen if (msg.what == 0x101) { camera.takePicture(); } else if (msg.what == 0x102) { - if (btnSwitch != null) { - btnSwitch.setEnabled(true); + if (imageView != null) { + imageView.setEnabled(true); } } else if (msg.what == 0x103) { if (poi_video_type != 2) { @@ -130,6 +130,13 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen return false; } }); + private LatLng startLatLine; + private LatLng endLatLine; + private TextView tvTitle; + private String geoWkt; + private String detail; + private String type; + @Override protected int getLayout() { @@ -144,10 +151,12 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen removables = new ArrayList<>();//存储轨迹的marker layerChange = findViewById(R.id.layer_change); if (getIntent() != null) { - poiEntity = (PoiEntity) getIntent().getSerializableExtra("poiEntity"); poi_video_type = getIntent().getIntExtra(Constant.INTENT_POI_VIDEO_TYPE, -1); oration = getIntent().getIntExtra(Constant.INTENT_VIDEO_OBLATION, -1); finalVideoPath = getIntent().getStringExtra(Constant.INTENT_JPG_PATH); + type = getIntent().getStringExtra(Constant.INTENT_TYPE); + geoWkt = getIntent().getStringExtra(Constant.INTENT_GEO_WKT); + detail = getIntent().getStringExtra(Constant.INTENT_DETAIL); if (finalVideoPath != null) { File file = new File(finalVideoPath); paperFile = new File(Objects.requireNonNull(file.getParentFile()).getAbsoluteFile() + "/" + "paper.txt"); @@ -167,7 +176,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen ivPicImage.setVisibility(View.VISIBLE); ivPicVideoImage.setVisibility(View.GONE); } - btnSwitch = findViewById(R.id.btn_switch); + Button btnSwitch = findViewById(R.id.btn_switch); btnSwitch.setOnClickListener(this); //相机记录器 CameraLogger.setLogLevel(CameraLogger.LEVEL_VERBOSE); @@ -179,7 +188,8 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen ivLocation.setOnClickListener(this); camera = findViewById(R.id.camera); camera.setOnClickListener(this); - ImageView imageView = findViewById(R.id.image_view); + imageView = findViewById(R.id.image_view); + tvTitle = findViewById(R.id.tv_title); imageView.setOnClickListener(this); capturePicture = findViewById(R.id.capture_picture); if (poi_video_type == 2) { @@ -196,7 +206,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen isOration = true; capturePicture.setText("暂停采集"); picturesBuilder.append("capturePicture 点击了开始采集 ,"); - }else { + } else { picturesBuilder.append("capturePicture 点击了拍摄 ,"); } startTimer(); @@ -222,64 +232,53 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen uiSettings.setTiltGesturesEnabled(false);//禁止倾斜手势. setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE); initLine(); - if (poiEntity!=null){ - if (poiEntity.getId() != null) { - List fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId()); - if (fileListByUUID != null) { - List lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID); - for (int i = 0; i < lineStringByFileList.size(); i++) { - LatLng latLng = lineStringByFileList.get(i); - if (latLng != null) { - BitmapDescriptor pileDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.ic_baseline); - Marker marker = tencentMap.addMarker(new MarkerOptions(latLng).icon(pileDescriptor).alpha(0.9f) - .flat(true) - .clockwise(false)); - removables.add(marker); - } - } - } - } - } - camera.addCameraListener(new CameraListener() { @Override public void onPictureTaken(@NonNull PictureResult result) { - super.onPictureTaken(result); - if (oration == 0) { // oblation为0时,拍摄视频必须为横屏 - // 如果当前手机是竖向,则不 - if (isOration) { - if (Objects.requireNonNull(camera.getPictureSize()).getWidth() < camera.getPictureSize().getHeight()) { - Toast.makeText(PicturesActivity.this, "不允许竖向拍摄...", Toast.LENGTH_SHORT).show(); - picturesBuilder.append("camera 用户竖屏拍照 ,"); - stopTimer(); - capturePicture.setChecked(false); - if (poi_video_type != 2) { - capturePicture.setText("开始采集"); + if (result != null && result.getData() != null && result.getData().length > 0) { + super.onPictureTaken(result); + isBack = true; + if (oration == 0) { // oblation为0时,拍摄视频必须为横屏 + // 如果当前手机是竖向,则不 + if (isOration) { + if (Objects.requireNonNull(camera.getPictureSize()).getWidth() < camera.getPictureSize().getHeight()) { + Toast.makeText(PicturesActivity.this, "不允许竖向拍摄...", Toast.LENGTH_SHORT).show(); + picturesBuilder.append("camera 用户竖屏拍照 ,"); + stopTimer(); capturePicture.setChecked(false); + if (poi_video_type != 2) { + capturePicture.setText("开始采集"); + capturePicture.setChecked(false); + } + return; + } else { + isOration = false; } - return; - } else { - isOration = false; } } - - } - File file = new File(finalVideoPath); - initMarkerPaper(); - result.toFile(file, new FileCallback() { - @Override - public void onFileReady(@Nullable File file) { - if (file.exists()) { - initMarker(); - videoIndex = Integer.parseInt(file.getName().replace(".jpg", "")); - finalVideoPath = Objects.requireNonNull(file.getParentFile()).getAbsolutePath() + "/" + (videoIndex + 1) + ".jpg"; - Toast.makeText(PicturesActivity.this, "保存成功:" + (videoIndex + 1), Toast.LENGTH_SHORT).show(); - } - if (poi_video_type == 2) { - Message message = new Message(); - message.what = 0x103; - handler.sendMessage(message); - } + File file = new File(finalVideoPath); + initMarkerPaper(); + result.toFile(file, new FileCallback() { + @Override + public void onFileReady(@Nullable File file) { + if (file.exists()) { + initMarker(); + videoIndex = Integer.parseInt(file.getName().replace(".jpg", "")); + finalVideoPath = Objects.requireNonNull(file.getParentFile()).getAbsolutePath() + "/" + (videoIndex + 1) + ".jpg"; + runOnUiThread(new Runnable() { + @SuppressLint("SetTextI18n") + @Override + public void run() { + //Toast.makeText(PicturesActivity.this, "保存成功:" + (videoIndex + 1), Toast.LENGTH_SHORT).show(); + tvTitle.setText("保存成功:" + (videoIndex + 1)); + } + }); + } + if (poi_video_type == 2) { + Message message = new Message(); + message.what = 0x103; + handler.sendMessage(message); + } /* if (file.exists()) { WebPNative webPNative = new WebPNative(); new Thread(new Runnable() { @@ -316,8 +315,11 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen } else { Toast.makeText(PicturesActivity.this, "源文件不存在", Toast.LENGTH_SHORT).show(); }*/ - } - }); + } + }); + } else { + isBack = false; + } } }); DisplayMetrics dm = new DisplayMetrics(); @@ -334,33 +336,53 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen } private void initLine() { - if (poiEntity!=null){ - String geoWkt = poiEntity.getGeoWkt(); - if (geoWkt != null) { - String geo = Geohash.getInstance().decode(geoWkt); - Geometry geometry = GeometryTools.createGeometry(geo); - if (geometry.getGeometryType().equals("LineString")) {//线 - BitmapDescriptor bitmapLine = null; - if (poiEntity.getType() == 3) {//poi录像 + if (geoWkt != null) { + String geo = Geohash.getInstance().decode(geoWkt); + Geometry geometry = GeometryTools.createGeometry(geo); + if (geometry.getGeometryType().equals("LineString")) {//线 + BitmapDescriptor bitmapLine = null; + if (type != null) { + if (type.equals("3")) {//poi录像 bitmapLine = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_arrows); - } else if (poiEntity.getType() == 4) {//道路录像 + } else if (type.equals("4")) {//道路录像 bitmapLine = BitmapDescriptorFactory.fromResource(R.drawable.road_arrows); } - List latLineString = GeometryTools.getLatLags(geo); - // 构造 PolylineOnions - PolylineOptions polylineOptions = new PolylineOptions().addAll(latLineString) - // 折线设置圆形线头 - .lineCap(true) - // 折线的颜色为绿色 - .color(Color.parseColor("#0096FF")) - // 折线宽度为5像素 - .width(20) - .arrow(true) - .arrowSpacing(150) - .arrowTexture(bitmapLine); - // 绘制折线 - polyline = tencentMap.addPolyline(polylineOptions); - polyline.setZIndex(2); + } + List latLineString = GeometryTools.getLatLags(geo); + assert latLineString != null; + startLatLine = latLineString.get(0); + endLatLine = latLineString.get(latLineString.size() - 1); + // 构造 PolylineOnions + PolylineOptions polylineOptions = new PolylineOptions().addAll(latLineString) + // 折线设置圆形线头 + .lineCap(true) + // 折线的颜色为绿色 + .color(Color.parseColor("#0096FF")) + // 折线宽度为5像素 + .width(20) + .arrow(true) + .arrowSpacing(150) + .arrowTexture(bitmapLine); + // 绘制折线 + polyline = tencentMap.addPolyline(polylineOptions); + polyline.setZIndex(2); + } + } + if (detail != null) { + String geo = Geohash.getInstance().decode(detail); + Geometry geometry = GeometryTools.createGeometry(geo); + if (geometry.getGeometryType().equals("LineString")) {//线 + List latLineString = GeometryTools.getLatLags(geo); + assert latLineString != null; + for (int i = 0; i < latLineString.size(); i++) { + LatLng latLng = latLineString.get(i); + if (latLng != null) { + BitmapDescriptor pileDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.ic_baseline); + Marker marker = tencentMap.addMarker(new MarkerOptions(latLng).icon(pileDescriptor).alpha(0.9f) + .flat(true) + .clockwise(false)); + removables.add(marker); + } } } } @@ -375,20 +397,20 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen DateFormat formatter = new SimpleDateFormat("yyyyMMdd"); String newFormat = formatter.format(new Date(System.currentTimeMillis())); String pictures_time = sharedPreferences.getString("pictures_time", null); - if (pictures_time==null){ - sharedEdit.putString("pictures_time",newFormat); + if (pictures_time == null) { + sharedEdit.putString("pictures_time", newFormat); sharedEdit.apply(); logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt"); - }else { - if (pictures_time.equals(newFormat)){ + } else { + if (pictures_time.equals(newFormat)) { logFile = new File(Constant.LOG_FOLDER + "/" + pictures_time + ".txt"); - }else { + } else { logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt"); } } picturesBuilder = new StringBuilder(); picturesBuilder.append("PicturesActivity-onCreate-initData ,"); - if (Constant.USHERED!=null){ + if (Constant.USHERED != null) { picturesBuilder.append("userId:").append(Constant.USHERED).append(","); } camera.setMode(Mode.PICTURE); @@ -411,8 +433,10 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen break; case R.id.image_view: picturesBuilder.append("onClick 点击了切换的窗口 ,"); + v.setEnabled(false); benSwitch(); - break; + handler.sendEmptyMessageDelayed(0x102, 2000);// 利用handler延迟发送更改状态信息 + break; case R.id.btn_switch: picturesBuilder.append("onClick 点击了切换按钮 ,"); v.setEnabled(false); @@ -602,7 +626,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen TencentLocation tencentLocation = (TencentLocation) msg.obj; CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition( new LatLng(tencentLocation.getLatitude(), tencentLocation.getLongitude()), //中心点坐标,地图目标经纬度 - tencentMap.getCameraPosition().zoom, //目标缩放级别 + 20, //目标缩放级别 0, //目标倾斜角 tencentLocation.getBearing())); //目标旋转角 0~360° (正北方为0) tencentMap.animateCamera(cameraSigma); @@ -612,23 +636,35 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen @SuppressLint("SetTextI18n") public void initMarkerPaper() { - // 记录当前时间、视频时间、以及当前经纬度信息 - StringBuilder sb = new StringBuilder(); - sb.append(formatter.format(new Date())); // 记录当前时 - sb.append(","); - sb.append(videoIndex == -1 ? 0 : (videoIndex + 1));//個數 - sb.append(","); - sb.append(Constant.currentLocation.getLatitude()); - sb.append(","); - sb.append(Constant.currentLocation.getLongitude()); - sb.append(","); - if (Constant.currentLocation.getBearing() != 0) { - sb.append(Constant.currentLocation.getBearing()); - } else { - sb.append(Constant.currentLocation.getDirection()); + try { + // 记录当前时间、视频时间、以及当前经纬度信息 + StringBuilder sb = new StringBuilder(); + sb.append(formatter.format(new Date())); // 记录当前时 + sb.append(","); + sb.append(videoIndex == -1 ? 0 : (videoIndex + 1));//個數 + sb.append(","); + sb.append(Constant.currentLocation.getLatitude()); + sb.append(","); + sb.append(Constant.currentLocation.getLongitude()); + sb.append(","); + if (Constant.currentLocation.getBearing() != 0) { + sb.append(Constant.currentLocation.getBearing()); + } else { + sb.append(Constant.currentLocation.getDirection()); + } + sb.append("\r\n"); + if (isBack) { + FileUtils.writeFile(paperFile.getAbsolutePath(), sb.toString(), true); + } + } catch (Exception e) { + UMCrash.generateCustomLog(e, "自定义"); + handler.postDelayed(new Runnable() { + @Override + public void run() { + initMarkerPaper(); + } + }, 100); } - sb.append("\r\n"); - FileUtils.writeFile(paperFile.getAbsolutePath(), sb.toString(), true); /* float speed = Constant.currentLocation.getSpeed();//米/秒 if (speed != 0) { float a = (speed * 3600 / 1000);//km/h @@ -660,26 +696,50 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen } oldCurrentLocation = Constant.currentLocation; }*/ + //快到终点的语音播报 + /*if (Constant.currentLocation!=null){ + LatLng newLatLine = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); + if (endLatLine!=null&&startLatLine!=null){ + double startDistance = GeometryTools.distanceToDouble(newLatLine, startLatLine); + double endDistance = GeometryTools.distanceToDouble(newLatLine, endLatLine); + if (startDistance>endDistance){//endDistance: 起点 startDistance:终点 + if (startDistance==50){ + systemTTS.playText("即将到达任务终点"); + } + }else { + if (endDistance==50){ + systemTTS.playText("即将到达任务终点"); + } + } + } + }*/ } @Override public void onBackPressed() { - if (!isBack) { - if (isOration) { - stopTimer(); - } - DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; - MessageDialog.show(this, "提示", "当前路段已拍摄的自动保存,可以在选择继续拍摄", "确定").setOnOkButtonClickListener(new OnDialogButtonClickListener() { - @Override - public boolean onClick(BaseDialog baseDialog, View v) { - isBack = true; - finish(); - return false; - } - }); - } else { - this.finish(); + if (isOration) { + stopTimer(); } + String tvIndex = tvTitle.getText().toString(); + String message = null; + if (tvIndex.equals("")) { + message = "您还没有对当前路段进行拍摄作业,是否退出"; + } else { + message = "当前作业路段已拍摄的自动保存,是否退出"; + } + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + MessageDialog.show(this, "提示", message, "是", "否").setOnOkButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + picturesBuilder.append("onClick 点击了结束采集 ,"); + Intent intent = new Intent(); + finalVideoPath = Objects.requireNonNull(paperFile.getParentFile()).getAbsolutePath() + "/" + videoIndex + ".jpg"; + intent.putExtra(Constant.INTENT_PICTURES_PATH, finalVideoPath); + setResult(0x111, intent); + finish(); + return false; + } + }); } public void initMarker() { diff --git a/app/src/main/java/com/navinfo/outdoor/activity/TestActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/TestActivity.java index 006acae..0b9dd86 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/TestActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/TestActivity.java @@ -124,6 +124,7 @@ public class TestActivity extends BaseActivity { httpParams.put("type", task_type); httpParams.put("isExclusive", limit_type); OkGoBuilder.getInstance() + .time(30) .Builder(this) .url(HttpInterface.TASK_LIST) .cls(JobSearchBean.class) diff --git a/app/src/main/java/com/navinfo/outdoor/activity/UserActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/UserActivity.java index b2749b9..fdef638 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/UserActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/UserActivity.java @@ -241,6 +241,7 @@ public class UserActivity extends BaseActivity implements View.OnClickListener { } showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(this) .url(HttpInterface.USER_UPDATE) .cls(UserBean.class) @@ -304,9 +305,10 @@ public class UserActivity extends BaseActivity implements View.OnClickListener { && options3Items.get(options1).get(options2).size() > 0 ? options3Items.get(options1).get(options2).get(options3) : ""; region_id = cityItems.get(options1).get(options2).get(options3).getRegion_id(); - Toast.makeText(UserActivity.this, region_id, Toast.LENGTH_SHORT).show(); + Log.d("TAG", "onOptionsSelect: "+region_id); region_text = opt1tx + " " + opt2tx + " " + opt3tx; region.setText(region_text); + Log.d("TAG", "onOptionsSelect: "+region_text); } }).setSubmitText("确定")//确定按钮文字 .setCancelText("取消")//取消按钮文字 diff --git a/app/src/main/java/com/navinfo/outdoor/activity/WebActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/WebActivity.java index 6f324f7..57a69d5 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/WebActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/WebActivity.java @@ -63,6 +63,7 @@ public class WebActivity extends BaseActivity implements View.OnClickListener { } showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(this) .url(url) .cls(RichTextBean.class) diff --git a/app/src/main/java/com/navinfo/outdoor/adapter/CapacityMeasureAdapter.java b/app/src/main/java/com/navinfo/outdoor/adapter/CapacityMeasureAdapter.java index b72af80..10e7297 100644 --- a/app/src/main/java/com/navinfo/outdoor/adapter/CapacityMeasureAdapter.java +++ b/app/src/main/java/com/navinfo/outdoor/adapter/CapacityMeasureAdapter.java @@ -56,7 +56,6 @@ public class CapacityMeasureAdapter extends RecyclerView.Adapter0){ + capacityMeasureAdapter.setMeasureList(baleen); + }else { + btnSubmit.setVisibility(View.GONE); + tvCapacity.setVisibility(View.GONE); + } } + Log.d("TAG", "onSuccess: " + response.toString()); } @@ -213,6 +227,7 @@ public class CapacityMeasurementFragment extends BaseFragment implements View.On examBeans.clear(); showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.EXAM_SUBMIT) .cls(ExamSubmitBean.class) diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java index 9ab8966..bb9e4e9 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java @@ -169,6 +169,12 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC moveLatlng(latLng, null); } + @Override + public boolean onBackPressed() { + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); + return true; + } + @Override protected void initView() { super.initView(); @@ -234,6 +240,8 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC checkButton3.setChecked(false); checkButton4.setChecked(false); checkButton5.setChecked(false); + }else { + buffer1 = ""; } } }); @@ -678,6 +686,9 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC if (station != null) { PoiEntity showPoiEntity = new Gson().fromJson(station, PoiEntity.class); pid = showPoiEntity.getId(); + if (showPoiEntity.getTaskStatus()==3){ + disables(); + } } // 添加信息: chargingPileEntity = (ChargingPileEntity) getArguments().getSerializable("chargingPileEntity"); @@ -804,6 +815,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC setDList(dList); setEList(eList); } + } } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java index 9678104..6923d81 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java @@ -48,6 +48,7 @@ import com.navinfo.outdoor.activity.PhotographActivity; import com.navinfo.outdoor.adapter.ChargingPileAdapter; import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.base.BaseDrawerFragment; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.UploadUtils; import com.navinfo.outdoor.bean.ChargingPileSaveBean; import com.navinfo.outdoor.bean.ChargingStationBean; @@ -159,19 +160,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. header.findViewById(R.id.iv_charging_station_final).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Bundle arguments = getArguments(); - if (arguments != null) { - isSliding = arguments.getBoolean("isSliding", true); - Log.d("TAG", "onCaresses: " + isSliding); - } - if (isSliding) { - // 监听到返回按钮点击事件 - Message obtain = Message.obtain(); - obtain.what = Constant.TREASURE_FRAGMENT; - obtain.obj = isSliding; - EventBus.getDefault().post(obtain); - } - onBackPressed(); + initBack(); } }); header.findViewById(R.id.tv_charging_station_explain).setOnClickListener(new View.OnClickListener() { @@ -184,6 +173,89 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. }); } + @Override + public boolean onBackPressed() { + initBack(); + return true; + } + + private void initBack() { + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + if (showPoiEntity != null) { + if (showPoiEntity.getTaskStatus() == 5) { + initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity); + } else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) { + initList(); + new Thread(new Runnable() { + @Override + public void run() { + if (showPoiEntity != null) { + if (showPoiEntity.getId() != null) { + List chargingPileEntityList = PoiDatabase.getInstance(getActivity()).getChargingPileDao().getChargingPileByStationId(showPoiEntity.getId()); + if (chargingPileEntityList != null && !chargingPileEntityList.isEmpty()) { + for (ChargingPileEntity chargingPileEntity : chargingPileEntityList) { + List chargingPileFileList = new ArrayList<>(); + if (chargingPileEntity.getPhotos() != null && !chargingPileEntity.getPhotos().isEmpty()) { + for (String photoPath : chargingPileEntity.getPhotos()) { + chargingPileFileList.add(new File(photoPath)); + } + } + PoiDatabase.getInstance(getActivity()).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity); + for (int i = 0; i < chargingPileFileList.size(); i++) { + chargingPileFileList.get(i).delete(); + } + } + } + } + + } + } + }).start(); + Message obtain = Message.obtain(); + obtain.what = Constant.JOB_WORD_MONITOR; + obtain.obj = true; + EventBus.getDefault().post(obtain); + Bundle arguments = getArguments(); + if (arguments != null) { + isSliding = arguments.getBoolean("isSliding", true); + } + if (isSliding) { + Message obtain1 = Message.obtain(); + obtain1.what = Constant.TREASURE_FRAGMENT; + obtain1.obj = isSliding; + EventBus.getDefault().post(obtain1); + } + } else { + Message obtain = Message.obtain(); + obtain.what = Constant.JOB_WORD_MONITOR; + obtain.obj = true; + EventBus.getDefault().post(obtain); + Bundle arguments = getArguments(); + if (arguments != null) { + isSliding = arguments.getBoolean("isSliding", true); + } + if (isSliding) { + Message obtain1 = Message.obtain(); + obtain1.what = Constant.TREASURE_FRAGMENT; + obtain1.obj = isSliding; + EventBus.getDefault().post(obtain1); + } + } + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); + } + return false; + } + }).setOnCancelButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + return false; + } + }); + } + @Override public void onStart() { super.onStart(); @@ -680,6 +752,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. } showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.GET_PHONES) .params(new HttpParams("geo", encode)) @@ -703,6 +776,10 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. } }); } + }else if (getPhoneBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { + Toast.makeText(getActivity(), getPhoneBean.getMessage(), Toast.LENGTH_SHORT).show(); } } @@ -1018,7 +1095,9 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. try { HttpParams httpParams = new HttpParams(); httpParams.put("auditId", chargingPileEntity.getBodyId()); - Response execute = OkGoBuilder.getInstance().url(HttpInterface.CS_TASK_UP_LOAD_PIC) + Response execute = OkGoBuilder.getInstance() + .time(0) + .url(HttpInterface.CS_TASK_UP_LOAD_PIC) .params(httpParams) .token(Constant.ACCESS_TOKEN) .fileList(chargingPileFileList) @@ -1142,6 +1221,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. HttpParams httpParams = new HttpParams(); httpParams.put("auditId", poiEntity.getBodyId()); OkGoBuilder.getInstance() + .time(0) .Builder(getActivity()) .url(HttpInterface.C_TASK_UP_LOAD_PIC) .fileList(chargingStationList) @@ -1149,7 +1229,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. .params(httpParams) .cls(PoiUploadBean.class) .postFileAsynchronous(UploadUtils.getInstance().getChargingUploadCallback(getActivity(), showPoiEntity, chargingStationList)); - Objects.requireNonNull(getActivity()).onBackPressed();//回退 + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();//回退 WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候..."); WaitDialog.dismiss(3000); } @@ -1172,6 +1252,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. httpParams.put("geo", poiEntity.getGeoWkt()); showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.SUBMIT_CTASK) .cls(ChargingStationBean.class) @@ -1205,7 +1286,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. obtain.what = Constant.JOB_WORD_MONITOR; obtain.obj = true; EventBus.getDefault().post(obtain); - getActivity().onBackPressed(); + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); } } }); @@ -1216,6 +1297,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. } else { Toast.makeText(getActivity(), "" + chargingStationBean.getMessage(), Toast.LENGTH_SHORT).show(); } + }else if (chargingStationBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + chargingStationBean.getMessage(), Toast.LENGTH_SHORT).show(); } @@ -1244,9 +1327,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. .getRequest(new Callback() { @Override public void onSuccess(TaskNameBean taskNameBean, int id) { - if (getActivity() == null) { - return; - } dismissLoadingDialog(); if (taskNameBean.getCode() == 200) { editNameContent.setTextColor(Color.BLACK); @@ -1263,6 +1343,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. } else { Toast.makeText(getActivity(), "没有类似名称可以作业", Toast.LENGTH_SHORT).show(); } + }else if (taskNameBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { editNameContent.setTextColor(Color.RED); btnSaveLocal.setEnabled(false); @@ -1435,52 +1517,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. } } - @Override - public void onDestroyView() { - super.onDestroyView(); - if (showPoiEntity != null) { - if (showPoiEntity.getTaskStatus() == 5) { - initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity); - } else if (showPoiEntity.getTaskStatus() == 0 | showPoiEntity.getTaskStatus() == 1) { - initList(); - new Thread(new Runnable() { - @Override - public void run() { - if (showPoiEntity != null) { - if (showPoiEntity.getId() != null) { - List chargingPileEntityList = PoiDatabase.getInstance(getActivity()).getChargingPileDao().getChargingPileByStationId(showPoiEntity.getId()); - if (chargingPileEntityList != null && !chargingPileEntityList.isEmpty()) { - for (ChargingPileEntity chargingPileEntity : chargingPileEntityList) { - List chargingPileFileList = new ArrayList<>(); - if (chargingPileEntity.getPhotos() != null && !chargingPileEntity.getPhotos().isEmpty()) { - for (String photoPath : chargingPileEntity.getPhotos()) { - chargingPileFileList.add(new File(photoPath)); - } - } - PoiDatabase.getInstance(getActivity()).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity); - for (int i = 0; i < chargingPileFileList.size(); i++) { - chargingPileFileList.get(i).delete(); - } - } - } - } - - } - } - }).start(); - Message obtain = Message.obtain(); - obtain.what = Constant.JOB_WORD_MONITOR; - obtain.obj = true; - EventBus.getDefault().post(obtain); - } else { - Message obtain = Message.obtain(); - obtain.what = Constant.JOB_WORD_MONITOR; - obtain.obj = true; - EventBus.getDefault().post(obtain); - } - } - } - private void initList() { if (chargingStationList != null) { chargingStationList.clear(); @@ -1549,6 +1585,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. httpParams.put("taskIds", poiEntity.getTaskId()); httpParams.put("auditIds", ""); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(url) .params(httpParams) @@ -1587,6 +1624,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. obtain.what = Constant.JOB_WORD_MONITOR; obtain.obj = true; EventBus.getDefault().post(obtain); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + response.getMessage(), Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/EventPrefectureFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/EventPrefectureFragment.java index 7c72d2a..8291f48 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/EventPrefectureFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/EventPrefectureFragment.java @@ -28,6 +28,7 @@ import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; import com.jcodecraeer.xrecyclerview.ProgressStyle; import com.jcodecraeer.xrecyclerview.XRecyclerView; +import com.navinfo.outdoor.util.FlushTokenUtil; import org.json.JSONObject; @@ -99,6 +100,7 @@ public class EventPrefectureFragment extends BaseFragment implements View.OnClic httpParams.put("pageNum", eventPage); httpParams.put("pageSize", "20"); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.LIST_EVENT) .cls(TaskPrefectureBean.class) @@ -110,6 +112,8 @@ public class EventPrefectureFragment extends BaseFragment implements View.OnClic dismissLoadingDialog(); if (taskPrefectureBean.getCode() == 200){ initTaskPrefectureBean(taskPrefectureBean,aNet); + }else if (taskPrefectureBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); }else { Toast.makeText(getActivity(), taskPrefectureBean.getMessage()+"", Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/FilterFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/FilterFragment.java index 6fed827..b5d8ceb 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/FilterFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/FilterFragment.java @@ -45,6 +45,7 @@ import com.navinfo.outdoor.room.InsertAndUpdateUtils; import com.navinfo.outdoor.room.PoiDao; import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiEntity; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.GeometryTools; import com.tencent.tencentmap.mapsdk.maps.model.LatLng; @@ -116,6 +117,12 @@ public class FilterFragment extends BaseDrawerFragment implements View.OnClickLi }); } + @Override + public boolean onBackPressed() { + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); + return true; + } + @Override public void onStart() { super.onStart(); @@ -269,6 +276,8 @@ public class FilterFragment extends BaseDrawerFragment implements View.OnClickLi tvType.setText("未领取"); } else if (Constant.TASK_STARTUP == 1) { tvType.setText("已领取"); + }else if (Constant.TASK_STARTUP ==2){ + tvType.setText("已领取(网络)"); } /* else if (Constant.TASK_STATUS == 2) { tvType.setText("未保存"); @@ -499,7 +508,7 @@ public class FilterFragment extends BaseDrawerFragment implements View.OnClickLi break; case R.id.cl_type://任务状态 0.未领取 1.已领取,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集), filterBuilder.append("点击了任务状态的按钮 ,"); - BottomMenu.show((AppCompatActivity) Objects.requireNonNull(getContext()), new String[]{"全部", "未领取", "已领取"/*, "未保存", "已保存"*/}, new OnMenuItemClickListener() { + BottomMenu.show((AppCompatActivity) Objects.requireNonNull(getContext()), new String[]{"全部", "未领取", "已领取","已领取(网络)"/*, "未保存", "已保存"*/}, new OnMenuItemClickListener() { @Override public void onClick(String text, int index) { tvType.setText(text); @@ -513,6 +522,9 @@ public class FilterFragment extends BaseDrawerFragment implements View.OnClickLi case 2: Constant.TASK_STARTUP = 1; break; + case 3: + Constant.TASK_STARTUP = 2; + break; /* case 3: Constant.TASK_STATUS = 2; @@ -540,6 +552,7 @@ public class FilterFragment extends BaseDrawerFragment implements View.OnClickLi httpParams.put("taskIds", taskId); showLoadingDialog(); OkGoBuilder.getInstance() + .time(60) .Builder(getActivity()) .token(Constant.ACCESS_TOKEN) .params(httpParams) @@ -549,19 +562,26 @@ public class FilterFragment extends BaseDrawerFragment implements View.OnClickLi @Override public void onSuccess(FilterBatchBean response, int id) { dismissLoadingDialog(); - List success = response.getBody().getSuccess(); - for (int i = 0; i < success.size(); i++) { - initType(success.get(i)); + if (response.getCode()==200){ + List success = response.getBody().getSuccess(); + for (int i = 0; i < success.size(); i++) { + initType(success.get(i)); + } + filterAdapter.setAddFilter(false); + filterAdapter.notifyDataSetChanged(); + btnChock.clear(); + checkOk.setChecked(false); + Message obtain = Message.obtain(); + obtain.what = Constant.JOB_WORD_MONITOR; + obtain.obj = true; + EventBus.getDefault().post(obtain); + Toast.makeText(getContext(), "领取成功", Toast.LENGTH_SHORT).show(); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { + Toast.makeText(getContext(), response.getMessage(), Toast.LENGTH_SHORT).show(); } - filterAdapter.setAddFilter(false); - filterAdapter.notifyDataSetChanged(); - btnChock.clear(); - checkOk.setChecked(false); - Message obtain = Message.obtain(); - obtain.what = Constant.JOB_WORD_MONITOR; - obtain.obj = true; - EventBus.getDefault().post(obtain); - Toast.makeText(getContext(), "领取成功", Toast.LENGTH_SHORT).show(); + } @Override diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/FindFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/FindFragment.java index 5ee1abe..1499b77 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/FindFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/FindFragment.java @@ -27,7 +27,7 @@ import java.util.Objects; * 发现的Fragment * 2021-5-25 */ -public class FindFragment extends BaseFragment implements View.OnClickListener{ +public class FindFragment extends BaseFragment implements View.OnClickListener { private File logFile; private StringBuilder findBuilder; @@ -103,13 +103,13 @@ public class FindFragment extends BaseFragment implements View.OnClickListener{ case R.id.linear_event_prefecture: findBuilder.append("点击了最新公告:活动专区 跳转 ,"); Intent eventIntent = new Intent(getActivity(), FragmentManagement.class); - eventIntent.putExtra("tag",9); + eventIntent.putExtra("tag", 9); startActivity(eventIntent); break; case R.id.linear_end: findBuilder.append("点击了帮助中心:能力测评 ,"); Toast.makeText(getContext(), "该功能以后上新,敬请期待", Toast.LENGTH_SHORT).show(); - /* Intent endIntent = new Intent(getActivity(), FragmentManagement.class); + /*Intent endIntent = new Intent(getActivity(), FragmentManagement.class); endIntent.putExtra("tag", 11); startActivity(endIntent);*/ break; diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/ForgetPawFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/ForgetPawFragment.java index 8ac1264..1a311dc 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/ForgetPawFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/ForgetPawFragment.java @@ -169,6 +169,7 @@ public class ForgetPawFragment extends BaseFragment implements View.OnClickListe httpParams.put("datetime", time); showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.USER_FORGET_PASSWORD) .token(null) @@ -238,6 +239,7 @@ public class ForgetPawFragment extends BaseFragment implements View.OnClickListe httpParams.put("type", 2); showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.USER_MESSAGE) .cls(MessageCodeBean.class) diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/GatherGetFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/GatherGetFragment.java index 481091d..35c3680 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/GatherGetFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/GatherGetFragment.java @@ -37,6 +37,7 @@ import com.navinfo.outdoor.room.InsertAndUpdateUtils; import com.navinfo.outdoor.room.PoiDao; import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiEntity; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.GeometryTools; import com.tencent.tencentmap.mapsdk.maps.model.LatLng; @@ -110,7 +111,6 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe getView().setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { - if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { assert getArguments() != null; boolean aBoolean = getArguments().getBoolean("boolean", false); @@ -358,6 +358,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe private void chargingTaskByWork(String url, PoiEntity poiEntity, boolean isSaver, int statusId) { showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(url + "/" + poiEntity.getTaskId()) .cls(ReceivedBean.class) @@ -471,6 +472,8 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe } }).start(); } + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), response.getMessage(), Toast.LENGTH_SHORT).show(); } @@ -495,6 +498,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe } showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(url + "/" + poiEntity.getTaskId()) .cls(PolygonTaskBean.class) @@ -555,6 +559,8 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe } } }).start(); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + response.getMessage(), Toast.LENGTH_SHORT).show(); } @@ -583,6 +589,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe httpParams.put("taskIds", poiEntity.getTaskId()); httpParams.put("auditIds", ""); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(url) .params(httpParams) @@ -615,12 +622,12 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe } } }).start(); - + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + response.getMessage(), Toast.LENGTH_SHORT).show(); } } - @Override public void onError(Throwable e, int id) { dismissLoadingDialog(); @@ -629,7 +636,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe }); } - /** + /* * @param url 面妆任务立即采集 */ private void initCompleteTask(String url, PoiEntity poiEntity) { @@ -641,6 +648,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe HttpParams httpParams = new HttpParams(); httpParams.put("id", poiEntity.getTaskId()); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(url) .cls(UnPolygonTaskBean.class) @@ -674,11 +682,12 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe } } }).start(); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + response.getMessage(), Toast.LENGTH_SHORT).show(); } } - @Override public void onError(Throwable e, int id) { dismissLoadingDialog(); @@ -700,6 +709,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe httpParams.put("id",poiEntity.getTaskId()); showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(url) .params(httpParams) @@ -716,11 +726,12 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe poiDao.deletePoiEntity(poiEntity); } }).start(); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + response.getMessage(), Toast.LENGTH_SHORT).show(); } } - @Override public void onError(Throwable e, int id) { dismissLoadingDialog(); @@ -740,6 +751,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe } showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(url + "/" + poiEntity.getTaskId()) .cls(ReceivedPoiBean.class) @@ -837,11 +849,12 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe } }); } - } } }).start(); } + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + response.getMessage(), Toast.LENGTH_SHORT).show(); } @@ -871,6 +884,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe private void taskByNet(String url, PoiEntity poiEntity, boolean isSaver, int statusId) { showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(url + "/" + poiEntity.getTaskId()) .cls(TaskByNetBean.class) @@ -964,6 +978,8 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe } }).start(); } + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + response.getMessage(), Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/GatheringFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/GatheringFragment.java index a4f0876..d9fca77 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/GatheringFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/GatheringFragment.java @@ -44,6 +44,7 @@ import com.navinfo.outdoor.bean.BankPhoneBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.GetJsonDataUtil; import com.navinfo.outdoor.util.PhotoUtils; import org.json.JSONArray; @@ -62,7 +63,6 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe private EditText etBankNum; private ImageView gatheringCamera; private ArrayList jsonBean; - private String value; private SharedPreferences.Editor navInfoEditor; private File logFile; private StringBuilder gatheringBuilder; @@ -99,8 +99,8 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe if (Constant.NAME != null) { tvName.setText(Constant.NAME); } - if (Constant.ID_NUMBER != null && Constant.BACKGROUND != null) { - etBankNum.setText(Constant.ID_NUMBER); + if (Constant.BACKGROUND != null) { + etBankNum.setText(Constant.BACKGROUND); if (Constant.BACKGROUND_NAME==null){ String bank = navInfo.getString("bankName", null); if (bank!=null&&!bank.equals("")){ @@ -109,7 +109,7 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe }else { tvBank.setText(Constant.BACKGROUND_NAME); } - value = Constant.BACKGROUND; + btnBank.setText("重新绑定"); } } @@ -171,7 +171,6 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe @Override public void onClick(BankPathBean bankPathBean) { tvBank.setText(bankPathBean.getLabel()); - value = bankPathBean.getValue(); dialog.dismiss(); } }); @@ -239,6 +238,9 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe } private void gatheringNetWork() { + if (Constant.USHERED==null){ + return; + } ArrayList gatheringList = new ArrayList<>(); if (gatheringCamera.getTag() == null) { if (Constant.ID_NUMBER == null) { @@ -257,17 +259,14 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe return; } } - if (value == null) { - Toast.makeText(getActivity(), "请选择所属银行", Toast.LENGTH_SHORT).show(); - return; - } String bank = tvBank.getText().toString().trim(); showLoadingDialog(); HttpParams httpParams = new HttpParams(); httpParams.put("userid", Constant.USHERED); - httpParams.put("bankAccount", value);//银行id - httpParams.put("idNumber", etBankAccount);//银行卡号 + httpParams.put("bankAccount",etBankAccount);//银行卡号 + httpParams.put("bankName", bank);//银行id OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.USER_BANKCARD_UP_DATA) .cls(BankPhoneBean.class) @@ -285,17 +284,17 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe @Override public boolean onClick(BaseDialog baseDialog, View v) { gatheringBuilder.append("绑定成功 ,"); - Constant.BACKGROUND = value; Constant.BACKGROUND_NAME = bank; - Constant.ID_NUMBER = etBankAccount; - navInfoEditor.putString("bankAccount", value); - navInfoEditor.putString("idNumber", etBankAccount); + Constant.BACKGROUND = etBankAccount; + navInfoEditor.putString("bankAccount", etBankAccount); navInfoEditor.putString("bankName",bank); navInfoEditor.commit(); getActivity().finish(); return false; } }); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "绑定失败!", Toast.LENGTH_SHORT).show(); } @@ -327,16 +326,19 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe if (bankCardBean == null) { Toast.makeText(getContext(), "识别失败,可以重新识别或则进行手动输入", Toast.LENGTH_SHORT).show(); } else { - if (bankCardBean.getResult() != null && bankCardBean.getResult().getBank_card_number() != null) { - String bankCardNumber = bankCardBean.getResult().getBank_card_number().trim(); - String bank_card_number = bankCardNumber.replace(" ", ""); - if (StringUtils.isEmpty(bank_card_number)) { + if (bankCardBean.getResult()!=null){ + if (bankCardBean.getResult().getBank_card_number()!=null){ + String bankCardNumber = bankCardBean.getResult().getBank_card_number().trim(); + String bank_card_number = bankCardNumber.replace(" ", ""); + if (StringUtils.isEmpty(bank_card_number)) { + Toast.makeText(getActivity(), "识别失败,可以重新识别或则进行手动输入", Toast.LENGTH_SHORT).show(); + return; + } + etBankNum.setText(bank_card_number); + }else { Toast.makeText(getActivity(), "识别失败,可以重新识别或则进行手动输入", Toast.LENGTH_SHORT).show(); - return; } - etBankNum.setText(bank_card_number); - // String bankName = bankCardBean.getResult().getBank_name(); - } else { + }else { Toast.makeText(getActivity(), "识别失败,可以重新识别或则进行手动输入", Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/HasSubmitFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/HasSubmitFragment.java index 0bb4e7e..27e42bc 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/HasSubmitFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/HasSubmitFragment.java @@ -5,15 +5,23 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.View; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; import androidx.constraintlayout.widget.ConstraintLayout; import com.github.lazylibrary.util.FileUtils; +import com.kongzue.dialog.interfaces.OnDialogButtonClickListener; +import com.kongzue.dialog.util.BaseDialog; +import com.kongzue.dialog.util.DialogSettings; +import com.kongzue.dialog.v3.MessageDialog; +import com.lzy.okgo.OkGo; import com.lzy.okgo.model.HttpParams; import com.navinfo.outdoor.R; import com.navinfo.outdoor.activity.FragmentManagement; @@ -23,6 +31,9 @@ import com.navinfo.outdoor.bean.HasSubmitBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; +import com.navinfo.outdoor.room.PoiDatabase; +import com.navinfo.outdoor.util.FlushTokenUtil; +import com.navinfo.outdoor.util.ToastUtil; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -116,6 +127,7 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe public void initRequest() { if (Constant.USHERED!=null){ + HttpInterface.initHttpInter(Constant.USHERED); if (HttpInterface.GET_COMMIT_LIST!=null){ initPoiSubMitWork();//poi initCaningSubMitWork();//充电站 @@ -124,7 +136,6 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe initOtherSubMitWork();//其他 } } - } private void initOtherSubMitWork() { @@ -133,6 +144,7 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe httpParams.put("pageSize", 10); httpParams.put("pageNum", 1); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.GET_COMMIT_LIST) .cls(HasSubmitBean.class) @@ -158,6 +170,10 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe } } + }else if (hasSubmitBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { + Toast.makeText(getContext(), hasSubmitBean.getMessage(), Toast.LENGTH_SHORT).show(); } } @@ -175,6 +191,7 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe httpParams.put("pageSize", 10); httpParams.put("pageNum", 1); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.GET_COMMIT_LIST) .cls(HasSubmitBean.class) @@ -199,6 +216,10 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe }); } } + }else if (hasSubmitBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { + Toast.makeText(getContext(), hasSubmitBean.getMessage(), Toast.LENGTH_SHORT).show(); } } @@ -216,6 +237,7 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe httpParams.put("pageSize", 10); httpParams.put("pageNum", 1); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.GET_COMMIT_LIST) .cls(HasSubmitBean.class) @@ -239,8 +261,11 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe } }); } - } + }else if (hasSubmitBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { + Toast.makeText(getContext(), hasSubmitBean.getMessage(), Toast.LENGTH_SHORT).show(); } } @@ -257,6 +282,7 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe httpParams.put("pageSize", 10); httpParams.put("pageNum", 1); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.GET_COMMIT_LIST) .cls(HasSubmitBean.class) @@ -280,14 +306,17 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe } }); } - } + }else if (hasSubmitBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { + Toast.makeText(getContext(), hasSubmitBean.getMessage(), Toast.LENGTH_SHORT).show(); } } - @Override public void onError(Throwable e, int id) { dismissLoadingDialog(); + ToastUtil.show(getContext(),"请求失败",1000); } }); } @@ -297,7 +326,9 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe httpParams.put("type", 1); httpParams.put("pageSize", 10); httpParams.put("pageNum", 1); + showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.GET_COMMIT_LIST) .cls(HasSubmitBean.class) @@ -323,6 +354,10 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe } } + }else if (hasSubmitBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { + Toast.makeText(getContext(), hasSubmitBean.getMessage(), Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/IssueFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/IssueFragment.java index 992c3e9..56ddd3e 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/IssueFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/IssueFragment.java @@ -26,6 +26,7 @@ import com.navinfo.outdoor.bean.TaskPrefectureBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.umeng.umcrash.UMCrash; import org.json.JSONObject; @@ -67,6 +68,7 @@ public class IssueFragment extends BaseFragment implements View.OnClickListener httpParams.put("pageNum", issuePage); httpParams.put("pageSize", 10); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.MSG_LISt) .cls(TaskPrefectureBean.class) @@ -79,6 +81,8 @@ public class IssueFragment extends BaseFragment implements View.OnClickListener if (response.getCode() == 200){ issueProblemAdapter.setExplainList(response.getBody().getList()); issuePage++; + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); }else { Toast.makeText(getActivity(), response.getMessage()+"", Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/MessageFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/MessageFragment.java index b946fa9..ceb6507 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/MessageFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/MessageFragment.java @@ -28,6 +28,7 @@ import com.navinfo.outdoor.bean.TaskPrefectureBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; +import com.navinfo.outdoor.util.FlushTokenUtil; import java.io.File; import java.text.DateFormat; @@ -97,6 +98,7 @@ public class MessageFragment extends BaseFragment implements View.OnClickListen httpParams.put("pageNum", messagePage); httpParams.put("pageSize", 10); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.MSG_LISt) .cls(TaskPrefectureBean.class) @@ -109,6 +111,8 @@ public class MessageFragment extends BaseFragment implements View.OnClickListen if (taskPrefectureBean.getCode() == 200){ messageAdapter.setMessageList(taskPrefectureBean.getBody().getList()); messagePage++; + }else if (taskPrefectureBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); }else { Toast.makeText(getActivity(), taskPrefectureBean.getMessage()+"", Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/MineFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/MineFragment.java index ebfeb3c..d4c91d5 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/MineFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/MineFragment.java @@ -30,6 +30,7 @@ import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; import com.navinfo.outdoor.util.DoubleUtil; +import com.navinfo.outdoor.util.FlushTokenUtil; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -47,7 +48,6 @@ import java.util.Objects; * 2021-5-25 */ public class MineFragment extends BaseFragment implements View.OnClickListener { - private TextView tvMoney; private File logFile; private StringBuilder mainBuilder; @@ -104,11 +104,12 @@ public class MineFragment extends BaseFragment implements View.OnClickListener { rlAbout.setOnClickListener(this); Button btnQuit = findViewById(R.id.btn_quit); btnQuit.setOnClickListener(this); - TextView mainGrade = (TextView) findViewById(R.id.main_grade); + TextView mainGrade = findViewById(R.id.main_grade); if (Constant.LEVEL != 0) { mainGrade.setText("LV." + Constant.LEVEL); } if (Constant.USHERED != null) { + HttpInterface.initHttpInter(Constant.USHERED); if (HttpInterface.GET_PRICE!=null){ initNetWork(); } @@ -119,8 +120,11 @@ public class MineFragment extends BaseFragment implements View.OnClickListener { public void onEvent(Message data) { if (data.what == Constant.HOME_MINE) { if ((boolean) data.obj) { - if (HttpInterface.GET_PRICE!=null){ - initNetWork(); + if (Constant.USHERED!=null){ + HttpInterface.initHttpInter(Constant.USHERED); + if (HttpInterface.GET_PRICE!=null){ + initNetWork(); + } } } } @@ -129,6 +133,7 @@ public class MineFragment extends BaseFragment implements View.OnClickListener { private void initNetWork() { showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.GET_PRICE) .cls(GetPriceBean.class) @@ -152,6 +157,10 @@ public class MineFragment extends BaseFragment implements View.OnClickListener { }); } } + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { + Toast.makeText(getContext(), response.getMessage(), Toast.LENGTH_SHORT).show(); } Log.d("TAG", "onSuccess: " + response.toString()); } @@ -271,10 +280,8 @@ public class MineFragment extends BaseFragment implements View.OnClickListener { if (EventBus.getDefault().isRegistered(this))//加上判断 EventBus.getDefault().unregister(this); super.onDestroy(); - mainBuilder.append("onDestroy "); + mainBuilder.append("onDestroy"); mainBuilder.append("\r\n"); FileUtils.writeFile(logFile.getAbsolutePath(), mainBuilder.toString(), true); } - - } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java index 837e8a8..b363e74 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java @@ -43,6 +43,7 @@ import com.navinfo.outdoor.activity.FragmentManagement; import com.navinfo.outdoor.activity.PhotographActivity; import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.base.BaseDrawerFragment; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.UploadUtils; import com.navinfo.outdoor.bean.Info; import com.navinfo.outdoor.bean.PoiSaveBean; @@ -135,19 +136,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis header.findViewById(R.id.iv_final).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Bundle arguments = getArguments(); - if (arguments != null) { - isSliding = arguments.getBoolean("isSliding", true); - Log.d("TAG", "onCaresses: " + isSliding); - } - if (isSliding) { - // 监听到返回按钮点击事件 - Message obtain = Message.obtain(); - obtain.what = Constant.TREASURE_FRAGMENT; - obtain.obj = isSliding; - EventBus.getDefault().post(obtain); - } - onBackPressed(); + initBack(); } }); header.findViewById(R.id.tv_explain).setOnClickListener(new View.OnClickListener() { @@ -161,6 +150,64 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis moveLatlng(latLng, null); } + @Override + public boolean onBackPressed() { + initBack(); + return true; + } + + private void initBack() { + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + if (showPoiEntity != null) { + if (showPoiEntity.getTaskStatus() == 5) { + initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity); + } else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) { + initList(); + Message obtain = Message.obtain(); + obtain.what = Constant.JOB_WORD_MONITOR; + obtain.obj = true; + EventBus.getDefault().post(obtain); + Bundle arguments = getArguments(); + if (arguments != null) { + isSliding = arguments.getBoolean("isSliding", true); + } + if (isSliding) { + Message obtain1 = Message.obtain(); + obtain1.what = Constant.TREASURE_FRAGMENT; + obtain1.obj = isSliding; + EventBus.getDefault().post(obtain1); + } + } else { + Message obtain = Message.obtain(); + obtain.what = Constant.JOB_WORD_MONITOR; + obtain.obj = true; + EventBus.getDefault().post(obtain); + Bundle arguments = getArguments(); + if (arguments != null) { + isSliding = arguments.getBoolean("isSliding", true); + } + if (isSliding) { + Message obtain1 = Message.obtain(); + obtain1.what = Constant.TREASURE_FRAGMENT; + obtain1.obj = isSliding; + EventBus.getDefault().post(obtain1); + } + } + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); + } + return false; + } + }).setOnCancelButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + return false; + } + }); + } + @Override protected void initView() { super.initView(); @@ -185,7 +232,6 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis break; } } - @Override public void onNothingSelected(AdapterView parent) { } @@ -289,7 +335,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis @Override public boolean onClick(BaseDialog baseDialog, View v) { ivPicture.setImageDrawable(null); - if (tvPicture.getTag()!=null){ + if (tvPicture.getTag() != null) { File file = new File((String) tvPicture.getTag()); file.delete(); tvPicture.setTag(null); @@ -309,7 +355,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis @Override public boolean onClick(BaseDialog baseDialog, View v) { ivPictures.setImageDrawable(null); - if (tvPictures.getTag()!=null){ + if (tvPictures.getTag() != null) { File file = new File((String) tvPictures.getTag()); file.delete(); tvPictures.setTag(null); @@ -353,21 +399,20 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis DateFormat formatter = new SimpleDateFormat("yyyyMMdd"); String newFormat = formatter.format(new Date(System.currentTimeMillis())); String pictures_time = sharedPreferences.getString("pictures_time", null); - if (pictures_time==null){ - sharedEdit.putString("pictures_time",newFormat); + if (pictures_time == null) { + sharedEdit.putString("pictures_time", newFormat); sharedEdit.apply(); logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt"); - }else { - if (pictures_time.equals(newFormat)){ + } else { + if (pictures_time.equals(newFormat)) { logFile = new File(Constant.LOG_FOLDER + "/" + pictures_time + ".txt"); - }else { + } else { logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt"); } } - otherBuilder = new StringBuilder(); otherBuilder.append("OtherActivity-onCreate-initData ,"); - if (Constant.USHERED!=null){ + if (Constant.USHERED != null) { otherBuilder.append("userId:").append(Constant.USHERED).append(","); } } @@ -546,7 +591,6 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis }); } }).start(); - // onBackPressed(); } else { Toast.makeText(getActivity(), "没有申请权限,请手动申请", Toast.LENGTH_SHORT).show(); } @@ -572,6 +616,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis HttpParams httpParams = new HttpParams(); httpParams.put("auditId", body); OkGoBuilder.getInstance() + .time(0) .Builder(getActivity()) .url(HttpInterface.OTHER_TASK_UPLOAD_PIC) .fileList(otherUploadList) @@ -579,7 +624,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis .params(httpParams) .cls(PoiUploadBean.class) .postFileAsynchronous(UploadUtils.getInstance().getOtherUploadCallback(getActivity(), showPoiEntity, otherUploadList)); - Objects.requireNonNull(getActivity()).onBackPressed();//回退 + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();//回退 WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候..."); WaitDialog.dismiss(3000); } @@ -595,6 +640,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis httpParams.put("geo", poiEntity.getGeoWkt()); httpParams.put("memo", poiEntity.getMemo()); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.SUBMIT_OTHER_TASK) .cls(PoiSaveBean.class) @@ -613,7 +659,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis @Override public void run() { InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity); - if (getActivity()!=null){ + if (getActivity() != null) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { @@ -626,7 +672,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis obtain.what = Constant.JOB_WORD_MONITOR; obtain.obj = true; EventBus.getDefault().post(obtain); - getActivity().onBackPressed(); + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); } } }); @@ -636,7 +682,9 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis } else { Toast.makeText(getActivity(), "" + poiSaveBean.getMessage(), Toast.LENGTH_SHORT).show(); } - } else { + } else if (poiSaveBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { Toast.makeText(getActivity(), "" + poiSaveBean.getMessage(), Toast.LENGTH_SHORT).show(); } } @@ -687,7 +735,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis assert file != null; File videoFile = new File(file); if (videoFile.exists()) { - if (tvPicture.getTag()!=null){ + if (tvPicture.getTag() != null) { File filePicture = new File(String.valueOf(tvPicture.getTag())); filePicture.delete(); tvPicture.setTag(null); @@ -701,7 +749,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis assert file != null; File videoFile = new File(file); if (videoFile.exists()) { - if (tvPictures.getTag()!=null){ + if (tvPictures.getTag() != null) { File filePictures = new File(String.valueOf(tvPictures.getTag())); filePictures.delete(); tvPictures.setTag(null); @@ -713,26 +761,6 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis } } - @Override - public void onDestroyView() { - super.onDestroyView(); - if (showPoiEntity != null) { - if (showPoiEntity.getTaskStatus() == 5) { - initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity); - } else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) { - initList(); - Message obtain = Message.obtain(); - obtain.what = Constant.JOB_WORD_MONITOR; - obtain.obj = true; - EventBus.getDefault().post(obtain); - } else { - Message obtain = Message.obtain(); - obtain.what = Constant.JOB_WORD_MONITOR; - obtain.obj = true; - EventBus.getDefault().post(obtain); - } - } - } private void initList() { if (otherUploadList != null) { @@ -785,6 +813,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis httpParams.put("taskIds", poiEntity.getTaskId()); httpParams.put("auditIds", ""); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(url) .params(httpParams) @@ -806,6 +835,8 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis obtain.what = Constant.JOB_WORD_MONITOR; obtain.obj = true; EventBus.getDefault().post(obtain); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + response.getMessage(), Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/PhotoFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/PhotoFragment.java index cf68f65..d37b7d2 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/PhotoFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/PhotoFragment.java @@ -2,6 +2,7 @@ package com.navinfo.outdoor.fragment; import android.os.Bundle; import android.os.Message; +import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.widget.ImageView; @@ -11,6 +12,7 @@ import android.widget.Toast; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.bumptech.glide.Glide; import com.jcodecraeer.xrecyclerview.XRecyclerView; import com.navinfo.outdoor.R; import com.navinfo.outdoor.adapter.PhotoAdapter; @@ -25,6 +27,9 @@ import org.greenrobot.eventbus.Subscribe; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Objects; @@ -84,23 +89,30 @@ public class PhotoFragment extends BaseFragment implements View.OnClickListener protected void initView() { super.initView(); PoiEntity showPoiEntity = (PoiEntity) Objects.requireNonNull(getActivity()).getIntent().getSerializableExtra("showPoiEntity"); - deleteFiles = new ArrayList<>(); - if (showPoiEntity != null) { - String id = showPoiEntity.getId(); - fileBeans = new ArrayList<>(); - List fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(id); - if (fileListByUUID.size()>=2){ - File parentFile = fileListByUUID.get(0).getParentFile(); - for (int i = 0; i < fileListByUUID.size()-1; i++) { - File file = new File(parentFile+"/" + i + ".jpg"); - fileBeans.add(new FileBean(file, false)); - } - } - } ImageView ivPhotoFinal = (ImageView) findViewById(R.id.iv_photo_final); ivPhotoFinal.setOnClickListener(this); TextView tvPhotoAlbumDelete = (TextView) findViewById(R.id.tv_photo_album_delete); tvPhotoAlbumDelete.setOnClickListener(this); + deleteFiles = new ArrayList<>(); + deleteFiles.clear(); + if (showPoiEntity != null) { + String id = showPoiEntity.getId(); + fileBeans = new ArrayList<>(); + List fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(id); + Collections.sort(fileListByUUID); + if (fileListByUUID.size()>=2){ + for (int i = 0; i < fileListByUUID.size(); i++) { + if (fileListByUUID.get(i).getPath().contains(".jpg") && !fileListByUUID.get(i).getPath().contains("paper.txt")) { + if (fileListByUUID.get(i).exists()) { + fileBeans.add(new FileBean(fileListByUUID.get(i), false)); + } + } + } + } + if (showPoiEntity.getTaskStatus()==3){ + tvPhotoAlbumDelete.setVisibility(View.GONE); + } + } RecyclerView photoRecycler = findViewById(R.id.photo_album_recycler); photoRecycler.setLayoutManager(new GridLayoutManager(getContext(), 2)); photoAdapter = new PhotoAdapter(fileBeans, getContext()); @@ -161,4 +173,5 @@ public class PhotoFragment extends BaseFragment implements View.OnClickListener EventBus.getDefault().unregister(this); super.onDestroy(); } + } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/PoiFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/PoiFragment.java index f29789f..b34619d 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/PoiFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/PoiFragment.java @@ -46,6 +46,8 @@ import com.navinfo.outdoor.activity.FragmentManagement; import com.navinfo.outdoor.activity.PhotographActivity; import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.base.BaseDrawerFragment; +import com.navinfo.outdoor.util.AWMp4ParserHelper; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.UploadUtils; import com.navinfo.outdoor.bean.GetPhoneBean; import com.navinfo.outdoor.bean.Info; @@ -119,8 +121,6 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe private RelativeLayout relativePhone; - - public static PoiFragment newInstance(Bundle bundle) { PoiFragment fragment = new PoiFragment(); fragment.setArguments(bundle); @@ -147,19 +147,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe header.findViewById(R.id.iv_final).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Bundle arguments = getArguments(); - if (arguments != null) { - isSliding = arguments.getBoolean("isSliding", true); - Log.d("TAG", "onCaresses: " + isSliding); - } - if (isSliding) { - // 监听到返回按钮点击事件 - Message obtain = Message.obtain(); - obtain.what = Constant.TREASURE_FRAGMENT; - obtain.obj = isSliding; - EventBus.getDefault().post(obtain); - } - onBackPressed(); + initBack(); } }); header.findViewById(R.id.tv_explain).setOnClickListener(new View.OnClickListener() { @@ -173,6 +161,64 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe moveLatlng(latLng, null); } + @Override + public boolean onBackPressed() { + initBack(); + return true; + } + + private void initBack() { + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + if (showPoiEntity != null) { + if (showPoiEntity.getTaskStatus() == 5) { + initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity); + } else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) { + initList(); + Message obtain = Message.obtain(); + obtain.what = Constant.JOB_WORD_MONITOR; + obtain.obj = true; + EventBus.getDefault().post(obtain); + Bundle arguments = getArguments(); + if (arguments != null) { + isSliding = arguments.getBoolean("isSliding", true); + } + if (isSliding) { + Message obtain1 = Message.obtain(); + obtain1.what = Constant.TREASURE_FRAGMENT; + obtain1.obj = isSliding; + EventBus.getDefault().post(obtain1); + } + } else { + Message obtain = Message.obtain(); + obtain.what = Constant.JOB_WORD_MONITOR; + obtain.obj = true; + EventBus.getDefault().post(obtain); + Bundle arguments = getArguments(); + if (arguments != null) { + isSliding = arguments.getBoolean("isSliding", true); + } + if (isSliding) { + Message obtain1 = Message.obtain(); + obtain1.what = Constant.TREASURE_FRAGMENT; + obtain1.obj = isSliding; + EventBus.getDefault().post(obtain1); + } + } + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); + } + return false; + } + }).setOnCancelButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + return false; + } + }); + } + @Override protected void initView() { super.initView(); @@ -199,6 +245,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe checkBoxLife.setTextColor(Color.WHITE); checkBoxLife.setChecked(true); } + @Override public void onCancel() { BitmapDescriptor poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_show); @@ -298,7 +345,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe @Override public boolean onClick(BaseDialog baseDialog, View v) { ivPanorama.setImageDrawable(null); - if (tvPanorama.getTag()!=null){ + if (tvPanorama.getTag() != null) { File file = new File((String) tvPanorama.getTag()); file.delete(); tvPanorama.setTag(null); @@ -317,7 +364,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe @Override public boolean onClick(BaseDialog baseDialog, View v) { ivName.setImageDrawable(null); - if (tvPoiNamePic.getTag()!=null){ + if (tvPoiNamePic.getTag() != null) { File file = new File((String) tvPoiNamePic.getTag()); file.delete(); tvPoiNamePic.setTag(null); @@ -336,7 +383,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe @Override public boolean onClick(BaseDialog baseDialog, View v) { ivElse.setImageDrawable(null); - if (tvElse.getTag()!=null){ + if (tvElse.getTag() != null) { File file = new File((String) tvElse.getTag()); file.delete(); tvElse.setTag(null); @@ -355,7 +402,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe @Override public boolean onClick(BaseDialog baseDialog, View v) { ivInternal.setImageDrawable(null); - if (tvInternal.getTag()!=null){ + if (tvInternal.getTag() != null) { File file = new File((String) tvInternal.getTag()); file.delete(); tvInternal.setTag(null); @@ -375,7 +422,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe @Override public boolean onClick(BaseDialog baseDialog, View v) { ivCard.setImageDrawable(null); - if (tvCard.getTag()!=null){ + if (tvCard.getTag() != null) { File file = new File((String) tvCard.getTag()); file.delete(); tvCard.setTag(null); @@ -547,6 +594,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe } showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.GET_PHONES) .params(new HttpParams("geo", encode)) @@ -570,6 +618,10 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe } }); } + }else if (getPhoneBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { + Toast.makeText(getActivity(), getPhoneBean.getMessage(), Toast.LENGTH_SHORT).show(); } } @@ -618,20 +670,20 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe DateFormat formatter = new SimpleDateFormat("yyyyMMdd"); String newFormat = formatter.format(new Date(System.currentTimeMillis())); String pictures_time = sharedPreferences.getString("pictures_time", null); - if (pictures_time==null){ - sharedEdit.putString("pictures_time",newFormat); + if (pictures_time == null) { + sharedEdit.putString("pictures_time", newFormat); sharedEdit.apply(); logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt"); - }else { - if (pictures_time.equals(newFormat)){ + } else { + if (pictures_time.equals(newFormat)) { logFile = new File(Constant.LOG_FOLDER + "/" + pictures_time + ".txt"); - }else { + } else { logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt"); } } poiBuilder = new StringBuilder(); poiBuilder.append("PoiActivity-onCreate-initData ,"); - if (Constant.USHERED!=null){ + if (Constant.USHERED != null) { poiBuilder.append("userId:").append(Constant.USHERED).append(","); } } @@ -759,6 +811,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe httpParams.put("geo", encode); httpParams.put("name", editNameContent.getText().toString()); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.TASK_NAME) .cls(TaskNameBean.class) @@ -767,9 +820,6 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe .getRequest(new Callback() { @Override public void onSuccess(TaskNameBean taskNameBean, int id) { - if (getActivity() == null) { - return; - } dismissLoadingDialog(); if (taskNameBean.getCode() == 200) { btnUploading.setEnabled(true); @@ -789,7 +839,9 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe } else { Toast.makeText(getActivity(), "没有类似名称,可以作业", Toast.LENGTH_SHORT).show(); } - } else { + } else if (taskNameBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { editNameContent.setTextColor(Color.RED); btnUploading.setEnabled(false); btnSaveLocal.setEnabled(false); @@ -799,9 +851,6 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe @Override public void onError(Throwable e, int id) { - if (getActivity() == null) { - return; - } dismissLoadingDialog(); Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show(); Log.d("TAG", "onError: " + e.getMessage()); @@ -863,6 +912,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe HttpParams httpParams = new HttpParams(); httpParams.put("auditId", body); OkGoBuilder.getInstance() + .time(0) .Builder(getActivity()) .url(HttpInterface.POI_TASK_UPLOAD_PIC) .cls(OtherUploadPicBean.class) @@ -870,7 +920,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe .fileList(poiPicList) .params(httpParams) .postFileAsynchronous(UploadUtils.getInstance().getPoiUploadCallback(getActivity(), showPoiEntity, poiPicList)); - Objects.requireNonNull(getActivity()).onBackPressed();//回退 + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();//回退 WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候..."); WaitDialog.dismiss(3000); @@ -888,6 +938,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe showLoadingDialog(); setLoadingDialogText("保存中..."); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.SUBMIT_POI_TASK) .cls(PoiSaveBean.class) @@ -918,7 +969,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe obtain.what = Constant.JOB_WORD_MONITOR; obtain.obj = true; EventBus.getDefault().post(obtain); - getActivity().onBackPressed(); + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); } } }); @@ -927,6 +978,8 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe } else { Toast.makeText(getActivity(), "" + poiSaveBean.getMessage(), Toast.LENGTH_SHORT).show(); } + }else if (poiSaveBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + poiSaveBean.getMessage(), Toast.LENGTH_SHORT).show(); } @@ -973,7 +1026,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe assert file != null; File videoFile = new File(file); if (videoFile.exists()) { - if (tvPanorama.getTag()!=null){ + if (tvPanorama.getTag() != null) { File filePanorama = new File((String) tvPanorama.getTag()); filePanorama.delete(); tvPanorama.setTag(null); @@ -987,7 +1040,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe assert file != null; File videoFile = new File(file); if (videoFile.exists()) { - if (tvPoiNamePic.getTag()!=null){ + if (tvPoiNamePic.getTag() != null) { File fileName = new File((String) tvPoiNamePic.getTag()); fileName.delete(); tvPoiNamePic.setTag(null); @@ -1001,7 +1054,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe assert file != null; File videoFile = new File(file); if (videoFile.exists()) { - if (tvInternal.getTag()!=null){ + if (tvInternal.getTag() != null) { File fileInternal = new File((String) tvInternal.getTag()); fileInternal.delete(); tvInternal.setTag(null); @@ -1015,7 +1068,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe assert file != null; File videoFile = new File(file); if (videoFile.exists()) { - if (tvCard.getTag()!=null){ + if (tvCard.getTag() != null) { File fileCard = new File((String) tvCard.getTag()); fileCard.delete(); tvCard.setTag(null); @@ -1029,7 +1082,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe assert file != null; File videoFile = new File(file); if (videoFile.exists()) { - if (tvElse.getTag()!=null){ + if (tvElse.getTag() != null) { File fileElse = new File((String) tvElse.getTag()); fileElse.delete(); tvElse.setTag(null); @@ -1047,27 +1100,6 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe initPoiSharePre(); } - @Override - public void onDestroyView() { - super.onDestroyView(); - if (showPoiEntity != null) { - if (showPoiEntity.getTaskStatus() == 5) { - initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity); - } else if (showPoiEntity.getTaskStatus() == 0 | showPoiEntity.getTaskStatus() == 1) { - initList(); - Message obtain = Message.obtain(); - obtain.what = Constant.JOB_WORD_MONITOR; - obtain.obj = true; - EventBus.getDefault().post(obtain); - } else { - Message obtain = Message.obtain(); - obtain.what = Constant.JOB_WORD_MONITOR; - obtain.obj = true; - EventBus.getDefault().post(obtain); - } - - } - } private void initList() { if (poiPicList != null) { @@ -1133,6 +1165,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe httpParams.put("taskIds", poiEntity.getTaskId()); httpParams.put("auditIds", ""); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(url) .params(httpParams) @@ -1154,6 +1187,8 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe obtain.what = Constant.JOB_WORD_MONITOR; obtain.obj = true; EventBus.getDefault().post(obtain); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + response.getMessage(), Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/PoiTaskFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/PoiTaskFragment.java index fbcbaf5..16642ee 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/PoiTaskFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/PoiTaskFragment.java @@ -26,6 +26,7 @@ import com.navinfo.outdoor.bean.TaskPrefectureBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.umeng.commonsdk.debug.D; import java.util.ArrayList; @@ -116,6 +117,7 @@ public class PoiTaskFragment extends BaseFragment implements View.OnClickListene httpParams.put("pageNum", page); showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.GET_COMMIT_LIST) .cls(HasSubmitBean.class) @@ -129,6 +131,8 @@ public class PoiTaskFragment extends BaseFragment implements View.OnClickListene if (hasSubmitBean.getBody()!=null){ initHasSubmitBean(hasSubmitBean,aBoolean); } + }else if (hasSubmitBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); }else { Toast.makeText(getActivity(), hasSubmitBean.getMessage()+"", Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java index 5683d80..44423c6 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java @@ -52,6 +52,7 @@ import com.navinfo.outdoor.room.PoiDao; import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.util.AWMp4ParserHelper; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.GeometryTools; import com.navinfo.outdoor.util.UploadUtils; @@ -120,19 +121,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick header.findViewById(R.id.iv_final).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Bundle arguments = getArguments(); - if (arguments != null) { - isSliding = arguments.getBoolean("isSliding", true); - Log.d("TAG", "onCaresses: " + isSliding); - } - if (isSliding) { - // 监听到返回按钮点击事件 - Message obtain = Message.obtain(); - obtain.what = Constant.TREASURE_FRAGMENT; - obtain.obj = isSliding; - EventBus.getDefault().post(obtain); - } - onBackPressed(); + initBack(); } }); header.findViewById(R.id.tv_explain).setOnClickListener(new View.OnClickListener() { @@ -146,6 +135,71 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick moveLatlng(latLng, null); } + @Override + public boolean onBackPressed() { + initBack(); + return true; + } + + private void initBack() { + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定","取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + if (showPoiEntity != null) { + if (showPoiEntity.getTaskStatus() == 5) { + initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity); + } else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) { + if (showPoiEntity.getId() != null) { + List fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId()); + for (int i = 0; i < fileListByUUID.size(); i++) { + fileListByUUID.get(i).delete(); + } + File filePath = AWMp4ParserHelper.getInstance().getFilePath(showPoiEntity.getId()); + filePath.delete(); + } + Message obtain = Message.obtain(); + obtain.what = Constant.JOB_WORD_MONITOR; + obtain.obj = true; + EventBus.getDefault().post(obtain); + Bundle arguments = getArguments(); + if (arguments != null) { + isSliding = arguments.getBoolean("isSliding", true); + } + if (isSliding) { + Message obtain1 = Message.obtain(); + obtain1.what = Constant.TREASURE_FRAGMENT; + obtain1.obj = isSliding; + EventBus.getDefault().post(obtain1); + } + } else { + Message obtain = Message.obtain(); + obtain.what = Constant.JOB_WORD_MONITOR; + obtain.obj = true; + EventBus.getDefault().post(obtain); + Bundle arguments = getArguments(); + if (arguments != null) { + isSliding = arguments.getBoolean("isSliding", true); + } + if (isSliding) { + Message obtain1 = Message.obtain(); + obtain1.what = Constant.TREASURE_FRAGMENT; + obtain1.obj = isSliding; + EventBus.getDefault().post(obtain1); + } + } + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); + } + return false; + } + }).setOnCancelButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + return false; + } + }); + } + @Override protected void initView() { super.initView(); @@ -251,17 +305,40 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick markerPoiVideo.setZIndex(4); moveLatlng(latLng, null); } else { - String x = showPoiEntity.getX(); - String y = showPoiEntity.getY(); - if (x != null && y != null) { - latLng = new LatLng(); - latLng.setLongitude(Double.parseDouble(x)); - latLng.setLatitude(Double.parseDouble(y)); + String detail = showPoiEntity.getDetail(); + if (detail!=null){ + String geo = Geohash.getInstance().decode(detail); + Geometry geometry = GeometryTools.createGeometry(geo); + switch (geometry.getGeometryType()) { + case "Point": //点 + latLng = GeometryTools.createLatLng(geo); + break; + case "LineString": //线 + case "Polygon": //面 + List latLineString = GeometryTools.getLatLags(geo); + assert latLineString != null; + latLng = latLineString.get(0); + rearLatLng = latLineString.get(latLineString.size() - 1); + break; + } BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show); markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f)); markerPoiVideo.setZIndex(4); moveLatlng(latLng, null); + }else { + String x = showPoiEntity.getX(); + String y = showPoiEntity.getY(); + if (x != null && y != null) { + latLng = new LatLng(); + latLng.setLongitude(Double.parseDouble(x)); + latLng.setLatitude(Double.parseDouble(y)); + BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show); + markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f)); + markerPoiVideo.setZIndex(4); + moveLatlng(latLng, null); + } } + } String describe = showPoiEntity.getMemo();//任务描述 if (describe != null && !describe.equals("")) { @@ -291,7 +368,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick } private void disables() { - fmPoiVideoPic.setEnabled(false); etRoadName.setEnabled(false); ivPoiVideoPicture.setEnabled(false); tvShort.setEnabled(false); @@ -364,9 +440,11 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick Intent intents = new Intent(getActivity(), PicturesActivity.class); File filePath = AWMp4ParserHelper.getInstance().obtainJpgFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath()); intents.putExtra(Constant.INTENT_JPG_PATH, filePath.getAbsolutePath()); - intents.putExtra("poiEntity", showPoiEntity); intents.putExtra(Constant.INTENT_VIDEO_OBLATION, 0); intents.putExtra(Constant.INTENT_POI_VIDEO_TYPE, 2); + intents.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType()+""); + intents.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt()); + intents.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail()); startActivityForResult(intents, 0x102); } break; @@ -382,9 +460,11 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick Intent intent = new Intent(getActivity(), PicturesActivity.class); File fileJpgPath = AWMp4ParserHelper.getInstance().obtainJpgFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath()); intent.putExtra(Constant.INTENT_JPG_PATH, fileJpgPath.getAbsolutePath()); - intent.putExtra("poiEntity", showPoiEntity); intent.putExtra(Constant.INTENT_VIDEO_OBLATION, 0); intent.putExtra(Constant.INTENT_POI_VIDEO_TYPE, 1); + intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType()+""); + intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt()); + intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail()); startActivityForResult(intent, 0x101); } break; @@ -501,13 +581,14 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick httpParams.put("datetime", time); httpParams.put("file", fileZip); OkGoBuilder.getInstance() + .time(0) .Builder(getActivity()) .url(HttpInterface.POI_VIDEO_UPLOAD_PIC) .cls(OtherUploadPicBean.class) .params(httpParams) .token(Constant.ACCESS_TOKEN) .postRequest(UploadUtils.getInstance().getPoiVideoUploadCallback(getActivity(), showPoiEntity, fileZip)); - Objects.requireNonNull(getActivity()).onBackPressed();//回退 + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();//回退 WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候..."); WaitDialog.dismiss(3000); } @@ -521,6 +602,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick httpParams.put("memo", poiEntity.getMemo()); showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.INSIDE_API_LIST) .cls(PoiVideoBean.class) @@ -551,26 +633,26 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick obtain.what = Constant.JOB_WORD_MONITOR; obtain.obj = true; EventBus.getDefault().post(obtain); - getActivity().onBackPressed(); + getActivity().getSupportFragmentManager().popBackStack(); } } }); - } } }).start(); } else { - Toast.makeText(getActivity(), "" + poiVideoBean.getMessage(), Toast.LENGTH_SHORT).show(); + Toast.makeText(getContext(), "" + poiVideoBean.getMessage(), Toast.LENGTH_SHORT).show(); } - } else { - Toast.makeText(getActivity(), "" + poiVideoBean.getMessage(), Toast.LENGTH_SHORT).show(); + }else if (poiVideoBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { + Toast.makeText(getContext(), poiVideoBean.getMessage(), Toast.LENGTH_SHORT).show(); } } - @Override public void onError(Throwable e, int id) { dismissLoadingDialog(); - Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show(); + Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); Log.d("TAG", "onError: " + e.getMessage()); } }); @@ -623,33 +705,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick Log.d("TAG", "initRoadSharePre: " + newPoiEntity); } - @Override - public void onDestroyView() { - super.onDestroyView(); - if (showPoiEntity != null) { - if (showPoiEntity.getTaskStatus() == 5) { - initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);//结束领取 - } else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) { - if (showPoiEntity.getId() != null) { - List fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId()); - for (int i = 0; i < fileListByUUID.size(); i++) { - fileListByUUID.get(i).delete(); - } - File filePath = AWMp4ParserHelper.getInstance().getFilePath(showPoiEntity.getId()); - filePath.delete(); - } - Message obtain = Message.obtain(); - obtain.what = Constant.JOB_WORD_MONITOR; - obtain.obj = true; - EventBus.getDefault().post(obtain); - } else { - Message obtain = Message.obtain(); - obtain.what = Constant.JOB_WORD_MONITOR; - obtain.obj = true; - EventBus.getDefault().post(obtain); - } - } - } @Override public void onPause() { @@ -685,6 +740,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick httpParams.put("taskIds", poiEntity.getTaskId()); httpParams.put("auditIds", ""); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(url) .params(httpParams) @@ -713,6 +769,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick obtain.what = Constant.JOB_WORD_MONITOR; obtain.obj = true; EventBus.getDefault().post(obtain); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + response.getMessage(), Toast.LENGTH_SHORT).show(); } @@ -776,7 +834,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr((List) fmPoiVideoPic.getTag()); poiEntity.setPhoto(photoStr); if (lineString != null) { - poiEntity.setGeoWkt(lineString); + poiEntity.setDetail(lineString); } } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/RegisterFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/RegisterFragment.java index 3d56fb9..7ba8535 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/RegisterFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/RegisterFragment.java @@ -157,6 +157,7 @@ public class RegisterFragment extends BaseFragment implements View.OnClickListen httpParams.put("type", 1); showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.USER_MESSAGE) .cls(MessageCodeBean.class) @@ -235,6 +236,7 @@ public class RegisterFragment extends BaseFragment implements View.OnClickListen httpParams.put("datetime", time); showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.USER_REGISTER) .token(null) diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java index 3a73d2a..b3715e3 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java @@ -40,6 +40,7 @@ import com.navinfo.outdoor.activity.FragmentManagement; import com.navinfo.outdoor.activity.PicturesActivity; import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.base.BaseDrawerFragment; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.UploadUtils; import com.navinfo.outdoor.bean.OtherUploadPicBean; import com.navinfo.outdoor.bean.RoadSaveBean; @@ -69,6 +70,7 @@ import org.greenrobot.eventbus.Subscribe; import java.io.File; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -80,9 +82,8 @@ import java.util.Objects; public class RoadFragment extends BaseDrawerFragment implements View.OnClickListener { private TextView tvPictures; - private EditText etRoadName; + private EditText etRoadName, etDesc; private ImageView ivRoadPicture; - private EditText etDesc; private Button btnRoadSave; private PoiDao poiDao; private File fileZip; @@ -119,17 +120,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList header.findViewById(R.id.iv_final).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Bundle arguments = getArguments(); - if (arguments != null) { - isSliding = arguments.getBoolean("isSliding", true); - } - if (isSliding) { - Message obtain = Message.obtain(); - obtain.what = Constant.TREASURE_FRAGMENT; - obtain.obj = isSliding; - EventBus.getDefault().post(obtain); - } - onBackPressed(); + initBack(); } }); header.findViewById(R.id.tv_road_explain).setOnClickListener(new View.OnClickListener() { @@ -143,6 +134,70 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList moveLatlng(latLng, null); } + private void initBack() { + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定","取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + if (showPoiEntity != null) { + if (showPoiEntity.getTaskStatus() == 5) { + initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity); + } else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) { + if (showPoiEntity.getId() != null) { + List fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId()); + for (int i = 0; i < fileListByUUID.size(); i++) { + fileListByUUID.get(i).delete(); + } + File filePath = AWMp4ParserHelper.getInstance().getFilePath(showPoiEntity.getId()); + filePath.delete(); + } + Message obtain = Message.obtain(); + obtain.what = Constant.JOB_WORD_MONITOR; + obtain.obj = true; + EventBus.getDefault().post(obtain); + Bundle arguments = getArguments(); + if (arguments != null) { + isSliding = arguments.getBoolean("isSliding", true); + } + if (isSliding) { + Message obtain1 = Message.obtain(); + obtain1.what = Constant.TREASURE_FRAGMENT; + obtain1.obj = isSliding; + EventBus.getDefault().post(obtain1); + } + } else { + Message obtain = Message.obtain(); + obtain.what = Constant.JOB_WORD_MONITOR; + obtain.obj = true; + EventBus.getDefault().post(obtain); + Bundle arguments = getArguments(); + if (arguments != null) { + isSliding = arguments.getBoolean("isSliding", true); + } + if (isSliding) { + Message obtain1 = Message.obtain(); + obtain1.what = Constant.TREASURE_FRAGMENT; + obtain1.obj = isSliding; + EventBus.getDefault().post(obtain1); + } + } + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); + } + return false; + } + }).setOnCancelButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + return false; + } + }); + } + + @Override + public boolean onBackPressed() { + initBack(); + return true; + } @Override protected void initView() { @@ -247,17 +302,40 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList markerRoad.setZIndex(4); moveLatlng(latLng, null); } else { - String x = showPoiEntity.getX(); - String y = showPoiEntity.getY(); - if (x != null && y != null) { - latLng = new LatLng(); - latLng.setLongitude(Double.parseDouble(x)); - latLng.setLatitude(Double.parseDouble(y)); + String detail = showPoiEntity.getDetail(); + if (detail!=null){ + String geo = Geohash.getInstance().decode(detail); + Geometry geometry = GeometryTools.createGeometry(geo); + switch (geometry.getGeometryType()) { + case "Point": //点 + latLng = GeometryTools.createLatLng(geo); + break; + case "LineString": //线 + case "Polygon": //面 + List latLineString = GeometryTools.getLatLags(geo); + assert latLineString != null; + latLng = latLineString.get(0); + rearLatLng = latLineString.get(latLineString.size() - 1); + break; + } BitmapDescriptor roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road_show); markerRoad = tencentMap.addMarker(new MarkerOptions(latLng).icon(roadDescriptor).anchor(0.5f, 1.0f)); markerRoad.setZIndex(4); moveLatlng(latLng, null); + }else { + String x = showPoiEntity.getX(); + String y = showPoiEntity.getY(); + if (x != null && y != null) { + latLng = new LatLng(); + latLng.setLongitude(Double.parseDouble(x)); + latLng.setLatitude(Double.parseDouble(y)); + BitmapDescriptor roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road_show); + markerRoad = tencentMap.addMarker(new MarkerOptions(latLng).icon(roadDescriptor).anchor(0.5f, 1.0f)); + markerRoad.setZIndex(4); + moveLatlng(latLng, null); + } } + } String describe = showPoiEntity.getMemo();//任务描述 if (describe != null && !describe.equals("")) { @@ -278,25 +356,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList } fmRoadPic.setTag(fileListByUUID); } - /* String[] photos = photoList.split(","); - List videoFileList = new ArrayList<>(); - boolean isImageLoad = false; - if (photos.length > 0) { - for (String photo : photos) { - if (!StringUtils.isEmpty(photo)) { - File videoFile = new File(photo); - videoFileList.add(new File(photo)); - if (videoFile.getPath().contains(".jpg") && !videoFile.getPath().contains("paper.txt")) { - if (videoFile.exists() && !isImageLoad) { - // 使用glide加载视频的第一帧 - AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500); - isImageLoad = true; - } - } - } - } - fmRoadPic.setTag(videoFileList); - }*/ } assert showPoiEntity != null; if (showPoiEntity.getTaskStatus() == 3) { @@ -304,9 +363,31 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList } } + private void initPhoto(String photoList) { + String[] photos = photoList.split(","); + List videoFileList = new ArrayList<>(); + boolean isImageLoad = false; + if (photos.length > 0) { + for (String photo : photos) { + if (!StringUtils.isEmpty(photo)) { + File videoFile = new File(photo); + videoFileList.add(new File(photo)); + if (videoFile.getPath().contains(".jpg") && !videoFile.getPath().contains("paper.txt")) { + if (videoFile.exists() && !isImageLoad) { + // 使用glide加载视频的第一帧 + AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500); + isImageLoad = true; + } + } + } + } + fmRoadPic.setTag(videoFileList); + } + + } + //禁用控件 private void disables() { - fmRoadPic.setEnabled(false); etRoadName.setEnabled(false); ivRoadPicture.setEnabled(false); tvPictures.setEnabled(false); @@ -375,7 +456,9 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList intent.putExtra(Constant.INTENT_JPG_PATH, finalFile.getAbsolutePath()); intent.putExtra(Constant.INTENT_VIDEO_OBLATION, 0); intent.putExtra(Constant.INTENT_POI_VIDEO_TYPE, 3); - intent.putExtra("poiEntity", showPoiEntity); + intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType()+""); + intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt()); + intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail()); startActivityForResult(intent, 0x101); } break; @@ -459,7 +542,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList }); } }).start(); - //onBackPressed(); } else { Toast.makeText(getActivity(), "没有申请权限,请手动申请", Toast.LENGTH_SHORT).show(); } @@ -492,13 +574,14 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList httpParams.put("datetime", time); httpParams.put("file", fileZip); OkGoBuilder.getInstance() + .time(0) .Builder(getActivity()) .url(HttpInterface.ROAD_TASK_UPLOAD_PIC) .params(httpParams) .token(Constant.ACCESS_TOKEN) .cls(OtherUploadPicBean.class) .postRequest(UploadUtils.getInstance().getRoadUploadCallback(getActivity(), showPoiEntity, fileZip)); - Objects.requireNonNull(getActivity()).onBackPressed();//回退 + Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();//回退 WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候..."); WaitDialog.dismiss(3000); @@ -514,6 +597,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList httpParams.put("workType", poiEntity.getWork_type()); httpParams.put("memo", poiEntity.getMemo()); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.ROAD_TASK_SUBMIT) .cls(RoadSaveBean.class) @@ -544,8 +628,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList Message obtain = Message.obtain(); obtain.what = Constant.JOB_WORD_MONITOR; obtain.obj = true; - EventBus.getDefault().post(obtain); - getActivity().onBackPressed(); + EventBus.getDefault().post(obtain); + getActivity().getSupportFragmentManager().popBackStack(); } } }); @@ -555,6 +639,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList } else { Toast.makeText(getActivity(), "" + roadSaveBean.getMessage(), Toast.LENGTH_SHORT).show(); } + }else if (roadSaveBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + roadSaveBean.getMessage(), Toast.LENGTH_SHORT).show(); } @@ -618,34 +704,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList Log.d("TAG", "initRoadSharePre: " + newPoiEntity); } - @Override - public void onDestroyView() { - super.onDestroyView(); - if (showPoiEntity != null) { - if (showPoiEntity.getTaskStatus() == 5) { - initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity); - } else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) { - if (showPoiEntity.getId() != null) { - List fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId()); - for (int i = 0; i < fileListByUUID.size(); i++) { - fileListByUUID.get(i).delete(); - } - File filePath = AWMp4ParserHelper.getInstance().getFilePath(showPoiEntity.getId()); - filePath.delete(); - } - Message obtain = Message.obtain(); - obtain.what = Constant.JOB_WORD_MONITOR; - obtain.obj = true; - EventBus.getDefault().post(obtain); - } else { - Message obtain = Message.obtain(); - obtain.what = Constant.JOB_WORD_MONITOR; - obtain.obj = true; - EventBus.getDefault().post(obtain); - } - } - } - @Override public void onPause() { super.onPause(); @@ -666,7 +724,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList if (markerRoad != null) { markerRoad.remove(); } - roadBuilder.append("onDestroy ,"); + roadBuilder.append("onDestroy "); roadBuilder.append("\r\n"); FileUtils.writeFile(logFile.getAbsolutePath(), roadBuilder.toString(), true); } @@ -680,6 +738,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList httpParams.put("taskIds", poiEntity.getTaskId()); httpParams.put("auditIds", ""); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(url) .params(httpParams) @@ -708,6 +767,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList obtain.what = Constant.JOB_WORD_MONITOR; obtain.obj = true; EventBus.getDefault().post(obtain); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "" + response.getMessage(), Toast.LENGTH_SHORT).show(); } @@ -772,10 +833,9 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr((List) fmRoadPic.getTag()); poiEntity.setPhoto(photoStr); if (encodeList != null) { - poiEntity.setGeoWkt(encodeList); + poiEntity.setDetail(encodeList); } } - return poiEntity; } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/StaySubmitFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/StaySubmitFragment.java index 0e2c632..ece28e7 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/StaySubmitFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/StaySubmitFragment.java @@ -39,6 +39,7 @@ import com.navinfo.outdoor.http.OkGoBuilder; import com.navinfo.outdoor.room.PoiDao; import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiEntity; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.PoiSaveUtils; import org.greenrobot.eventbus.EventBus; @@ -335,6 +336,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList httpParams.put("taskIds", taskIds.toString()); httpParams.put("auditIds", auditIds.toString()); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.UNRECEIVED_POLYGON_TASK) .params(httpParams) @@ -346,7 +348,9 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList dismissLoadingDialog(); if (response.getCode() == 200) { staySubmitAdapter.setAllCheckedDelete(); - } else { + } else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/TaskExplainFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/TaskExplainFragment.java index 04d27b1..44ec43c 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/TaskExplainFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/TaskExplainFragment.java @@ -28,6 +28,7 @@ import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; import com.jcodecraeer.xrecyclerview.ProgressStyle; import com.jcodecraeer.xrecyclerview.XRecyclerView; +import com.navinfo.outdoor.util.FlushTokenUtil; import org.json.JSONObject; @@ -143,6 +144,7 @@ public class TaskExplainFragment extends BaseFragment implements View.OnClickLis httpParams.put("pageNum", taskPage); httpParams.put("pageSize", 20); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.LIST_TASK_EXPLAIN) .cls(TaskPrefectureBean.class) @@ -154,6 +156,8 @@ public class TaskExplainFragment extends BaseFragment implements View.OnClickLis dismissLoadingDialog(); if (response.getCode() == 200){ initTaskPrefectureBean(response,aNet); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); }else { Toast.makeText(getActivity(), response.getMessage()+"", Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/TaskExplainFragment2.java b/app/src/main/java/com/navinfo/outdoor/fragment/TaskExplainFragment2.java index 267d4ec..73b05d4 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/TaskExplainFragment2.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/TaskExplainFragment2.java @@ -28,6 +28,7 @@ import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; import com.jcodecraeer.xrecyclerview.ProgressStyle; import com.jcodecraeer.xrecyclerview.XRecyclerView; +import com.navinfo.outdoor.util.FlushTokenUtil; import org.json.JSONObject; @@ -141,6 +142,7 @@ public class TaskExplainFragment2 extends BaseFragment implements View.OnClickLi httpParams.put("pageSize", 20); showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.LIST_TASK) .cls(TaskPrefectureBean.class) @@ -152,6 +154,8 @@ public class TaskExplainFragment2 extends BaseFragment implements View.OnClickLi dismissLoadingDialog(); if (response.getCode() == 200){ initTaskPrefectureBean(response,aBoolean); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); }else { Toast.makeText(getActivity(), response.getMessage()+"", Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/TaskPrefectureFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/TaskPrefectureFragment.java index 177e838..72b2e2d 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/TaskPrefectureFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/TaskPrefectureFragment.java @@ -28,6 +28,7 @@ import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; import com.jcodecraeer.xrecyclerview.ProgressStyle; import com.jcodecraeer.xrecyclerview.XRecyclerView; +import com.navinfo.outdoor.util.FlushTokenUtil; import org.json.JSONObject; @@ -133,6 +134,7 @@ public class TaskPrefectureFragment extends BaseFragment implements View.OnClick httpParams.put("pageNum", taskPage); httpParams.put("pageSize", "20"); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.LIST_TASK) .cls(TaskPrefectureBean.class) @@ -177,6 +179,8 @@ public class TaskPrefectureFragment extends BaseFragment implements View.OnClick taskPage++; } } + }else if (taskPrefectureBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), taskPrefectureBean.getMessage(), Toast.LENGTH_SHORT).show(); Log.d("TAG", "" + taskPrefectureBean.getMessage()); diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java index 7d5cb8c..0d35bbf 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java @@ -53,6 +53,7 @@ import com.navinfo.outdoor.activity.FragmentManagement; import com.navinfo.outdoor.activity.MainActivity; import com.navinfo.outdoor.adapter.MarkerAdapter; import com.navinfo.outdoor.api.Constant; +import com.navinfo.outdoor.api.UserApplication; import com.navinfo.outdoor.base.BaseDrawerFragment; import com.navinfo.outdoor.base.BaseFragment; import com.navinfo.outdoor.bean.GetPhoneBean; @@ -66,6 +67,7 @@ import com.navinfo.outdoor.room.ChargingPileEntity; import com.navinfo.outdoor.room.PoiDao; import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiEntity; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.GeometryTools; import com.navinfo.outdoor.util.MapManager; @@ -121,26 +123,21 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen private TextureMapView mapView; private TencentMap tencentMap; private CheckBox cbMapType; - private ImageView ivZoomAdd; - private ImageView ivZoomDel; + private ImageView ivZoomAdd, ivZoomDel,ivLocation, ivSubmit, ivRaffish,ivFilter,ivMessage,ivMassNotification; private MyLocationStyle locationStyle; - private ImageView ivLocation; - private ImageView ivSubmit; - private ImageView ivRaffish; + private SlidingUpPanelLayout sliding_layout; - private ImageView ivFilter; private FrameLayout frameLayout; private GatherGetFragment gatherGetFragment; - public ImageView ivMessage; private PoiDao poiDao; private String centerEncode; private List removables; private List removableScreenMarker; private List removablesLocality; - /** + /* * bitmapDescriptor1 */ - // private BitmapDescriptor bitmapDescriptor1, bitmapDescriptor2, bitmapDescriptor3, bitmapDescriptor4, bitmapDescriptor5; + //private BitmapDescriptor bitmapDescriptor1, bitmapDescriptor2, bitmapDescriptor3, bitmapDescriptor4, bitmapDescriptor5; private Marker bigMarker; private List upload; private final int MARKER_DOT = 3; @@ -150,7 +147,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen private HashMap> removableHashMap; private ArrayList latList; private ArrayList poiEntityArrayList; - private ImageView ivMassNotification; private int messageType = 0;//0: 已读消息 1:新消息 private SharedPreferences.Editor sharedEdit; private SharedPreferences sharedPreferences; @@ -158,19 +154,47 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen private File logFile; private StringBuilder treasureBuilder; private Marker gatherMarker; - private boolean isHandler=false; - private Handler handler=new Handler(new Handler.Callback() { + + /*private boolean isHandler = false; + private Handler handler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(@NonNull Message msg) { - if (msg.what==0x101){ - if (!isHandler){ + if (msg.what == 0x101) { + if (!isHandler) { dismissLoadingDialog(); OkGo.getInstance().cancelTag(this); + Constant.isPresent = true; + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "寻宝删选接口请求失败", "重新请求", "退出程序") + .setOnOkButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + treasureBuilder.append("onFinish-获取到当前位置,"); + PoiDatabase poiDatabase = PoiDatabase.getInstance(getContext()); + poiDao = poiDatabase.getPoiDao(); + refreshFilterData(); + //上传用户位置金纬度 + iniUserLocation(); + //确定手机号 + initPhone(); + //检查是否有没有填完的页面 + initSharePre(); + return false; + } + }).setOnCancelButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + getActivity().finish(); + return false; + } + }); + }else { + Toast.makeText(getActivity(), "寻宝删选接口请求成功", Toast.LENGTH_SHORT).show(); } } return false; } - }); + });*/ public static TreasureFragment newInstance(Bundle bundle) { TreasureFragment fragment = new TreasureFragment(); @@ -183,121 +207,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen return R.layout.treasure_fragment; } - /** - * 刷新筛选界面数据 - */ - private void refreshFilterData() { - String dataTime = sharedPreferences.getString("dataTime", null); - int type = sharedPreferences.getInt("type", 0); - if (type == 0) {//隐藏 - ivMassNotification.setVisibility(View.GONE); - } else {//显示S - ivMassNotification.setVisibility(View.VISIBLE); - } - if (dataTime == null) { - initMessageNotice(); - } else { - String newData = addDateMinot(dataTime, 3);//是否三个小时之后 - @SuppressLint("SimpleDateFormat") DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(System.currentTimeMillis()); - String presentData = formatter.format(calendar.getTime());//当前时间 - int result = presentData.compareTo(newData); - if (result >= 0) { - //进行请求 - initMessageNotice(); - } else {//无需请求 - } - } - Message msg = Message.obtain(); - msg.what = Constant.FILTER_DATA_CLEAR; - EventBus.getDefault().post(msg); - dismissLoadingDialog(); - removableHashMap.clear(); - if (Constant.USHERED != null) { - initThread(); // 刷新筛选的本地数据 - } - if (Constant.currentLocation != null) { - //延时60秒 - Message message = new Message(); - message.what=0x101; - handler.sendMessageDelayed(message,60000); - initList(Constant.currentLocation); // 刷新筛选的网络数据 - } else { - Toast.makeText(getActivity(), "未开启定位服务", Toast.LENGTH_SHORT).show(); - } - } - - /* - * 给时间加上几个小时 - * @param day 当前时间 格式:yyyy-MM-dd HH:mm:ss - * @param hour 需要加的时间 - */ - public static String addDateMinot(String day, int hour) { - @SuppressLint("SimpleDateFormat") - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date date = null; - try { - date = format.parse(day); - } catch (Exception ex) { - ex.printStackTrace(); - } - if (date == null) - return ""; - System.out.println("front:" + format.format(date)); //显示输入的日期 - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - cal.add(Calendar.HOUR, hour);// 24小时制 - date = cal.getTime(); - System.out.println("after:" + format.format(date)); //显示更新后的日期 - cal = null; - return format.format(date); - } - - private void initMessageNotice() { - HttpParams httpParams = new HttpParams("type", messageType + ""); - OkGoBuilder.getInstance() - .Builder(getActivity()) - .url(HttpInterface.MESSAGE_INFO_PUSH) - .params(httpParams) - .cls(MessageNoticeBean.class) - .token(Constant.ACCESS_TOKEN) - .getRequest(new Callback() { - @Override - public void onSuccess(MessageNoticeBean messageNoticeBean, int id) { - dismissLoadingDialog(); - if (messageNoticeBean.getCode() == 200) { - List noticeBeanBody = messageNoticeBean.getBody(); - if (noticeBeanBody != null) { - ivMassNotification.setVisibility(View.VISIBLE); - messageType = 1; - } else { - ivMassNotification.setVisibility(View.GONE); - messageType = 0; - } - //获取当前时间 - DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(System.currentTimeMillis()); - String format = formatter.format(calendar.getTime()); - Log.d("TAG", "onSuccess: " + format); - sharedEdit.putInt("type", messageType); - sharedEdit.putString("dataTime", format); - sharedEdit.commit(); - - } else { - Toast.makeText(getActivity(), messageNoticeBean.getMessage() + "", Toast.LENGTH_SHORT).show(); - } - } - - @Override - public void onError(Throwable e, int id) { - dismissLoadingDialog(); - Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show(); - } - }); - } - @SuppressLint("CommitPrefEdits") @Override protected void initView() { @@ -307,7 +216,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen //fragment 管理器 supportFragmentManager = Objects.requireNonNull(getActivity()).getSupportFragmentManager(); builder = new AlertDialog.Builder(Objects.requireNonNull(getActivity())); - sliding_layout = findViewById(R.id.sliding_layout); frameLayout = findViewById(R.id.frame_layout); ivRaffish = findViewById(R.id.iv_refrish); ivRaffish.setOnClickListener(this); @@ -326,6 +234,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen ivMassNotification = findViewById(R.id.iv_mas_notification);//定时消息小红点 MapManager.getInstance().init(getActivity(), tencentMap); cbMapType = (CheckBox) findViewById(R.id.cb_map_type); + sliding_layout = findViewById(R.id.sliding_layout); sliding_layout.setScrollableViewHelper(new NestedScrollableViewHelper()); //地图转换 cbMapType.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @@ -360,22 +269,21 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen //开启定位权限 checkNetWork(); removables = new ArrayList<>();//存储网络数据的marker数据(线,面,点) - removablesLocality = new ArrayList<>(); //存储本地的marker数据(线,面,点) + removablesLocality = new ArrayList<>();//存储本地的marker数据(线,面,点) removableScreenMarker = new ArrayList<>();//存储点击屏幕上的marker的marker数据(线,面,点) - //key :wkt,value :存储的数据类型 + //key wkt value :存储的数据类型 removableHashMap = new HashMap<>(); //存储的多点latlng latList = new ArrayList<>(); tencentMap.addOnMapLoadedCallback(new TencentMap.OnMapLoadedCallback() { @Override public void onMapLoaded() { - if (Constant.currentLocation != null) { // 地图中心点位置设置为当前用户所在位置 CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition( new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度 - tencentMap.getCameraPosition().zoom, //目标缩放级别 + 18, //目标缩放级别 0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0) 0)); //目标旋转角 0~360° (正北方为0) tencentMap.animateCamera(cameraSigma, new TencentMap.CancelableCallback() { @@ -388,6 +296,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen refreshFilterData(); //上传用户位置金纬度 iniUserLocation(); + //得到电话区号,电话位数 initPhone(); //检查是否有没有填完的页面 initSharePre(); @@ -404,50 +313,128 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen startActivity(intent); Toast.makeText(getActivity(), "请先开启位置信息,在重新打开程序", Toast.LENGTH_SHORT).show(); getActivity().finish(); - } Constant.markerClickListener = markerClickListener; tencentMap.setOnMarkerClickListener(Constant.markerClickListener); } }); - } - /* //监听回传 - public void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode==101){ - //开启定位权限 - checkNetWork(); - } - super.onActivityResult(requestCode, resultCode, data); - }*/ - - /** - * 得到电话区号,电话位数 + /* + * 刷新筛选界面数据 */ - private void initPhone() { - String encode = Geohash.getInstance().encode(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); - if (encode == null) { - Toast.makeText(getActivity(), "没有确定经纬度", Toast.LENGTH_SHORT).show(); - return; + private void refreshFilterData() { + String dataTime = sharedPreferences.getString("dataTime", null); + int type = sharedPreferences.getInt("type", 0); + if (type == 0) {//隐藏 + ivMassNotification.setVisibility(View.GONE); + } else {//显示S + ivMassNotification.setVisibility(View.VISIBLE); } - HttpParams httpParams = new HttpParams(); - httpParams.put("geo", encode); + if (dataTime == null) { + initMessageNotice(); + } else { + String newData = addDateMinot(dataTime, 3);//是否三个小时之后 + @SuppressLint("SimpleDateFormat") DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(System.currentTimeMillis()); + String presentData = formatter.format(calendar.getTime());//当前时间 + int result = presentData.compareTo(newData); + if (result >= 0) { + //进行请求 + initMessageNotice(); + } else {//无需请求 + Log.d("tag", "refreshFilterData: 无需请求"); + } + } + Message msg = Message.obtain(); + msg.what = Constant.FILTER_DATA_CLEAR; + EventBus.getDefault().post(msg); + dismissLoadingDialog(); + removableHashMap.clear(); + if (Constant.USHERED != null) { + initThread(); // 刷新筛选的本地数据 + } + if (Constant.currentLocation != null) { + /* //延时60秒 + Message message = new Message(); + message.what = 0x101; + handler.sendMessageDelayed(message, 60000); + isHandler = false;*/ + initList(Constant.currentLocation); // 刷新筛选的网络数据 + } else { + Toast.makeText(getActivity(), "未开启定位服务", Toast.LENGTH_SHORT).show(); + } + } + + /* + * 给时间加上几个小时 + * @param day 当前时间 格式:yyyy-MM-dd HH:mm:ss + * @param hour 需要加的时间 + */ + public static String addDateMinot(String day, int hour) { + @SuppressLint("SimpleDateFormat") + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = null; + try { + date = format.parse(day); + } catch (Exception ex) { + ex.printStackTrace(); + } + if (date == null) + return ""; + System.out.println("front:" + format.format(date)); //显示输入的日期 + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.add(Calendar.HOUR, hour);// 24小时制 + date = cal.getTime(); + System.out.println("after:" + format.format(date)); //显示更新后的日期 + cal = null; + return format.format(date); + } + + private void initMessageNotice() { + if (Constant.USHERED == null) { + return; + } else { + if (HttpInterface.MESSAGE_INFO_PUSH == null) { + return; + } + } + HttpParams httpParams = new HttpParams("type", messageType + ""); OkGoBuilder.getInstance() .Builder(getActivity()) - .url(HttpInterface.GET_PHONES) + .time(30) + .url(HttpInterface.MESSAGE_INFO_PUSH) .params(httpParams) - .cls(GetPhoneBean.class) + .cls(MessageNoticeBean.class) .token(Constant.ACCESS_TOKEN) - .getRequest(new Callback() { + .getRequest(new Callback() { @Override - public void onSuccess(GetPhoneBean getPhoneBean, int id) { + public void onSuccess(MessageNoticeBean messageNoticeBean, int id) { dismissLoadingDialog(); - if (getPhoneBean.getCode() == 200) { - String code = getPhoneBean.getBody().getCode(); - Integer telLength = getPhoneBean.getBody().getTelLength(); - Constant.CODE = code; - Constant.TelLength = telLength; + if (messageNoticeBean.getCode() == 200) { + List noticeBeanBody = messageNoticeBean.getBody(); + if (noticeBeanBody != null) { + ivMassNotification.setVisibility(View.VISIBLE); + messageType = 1; + } else { + ivMassNotification.setVisibility(View.GONE); + messageType = 0; + } + //获取当前时间 + DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(System.currentTimeMillis()); + String format = formatter.format(calendar.getTime()); + Log.d("TAG", "onSuccess: " + format); + sharedEdit.putInt("type", messageType); + sharedEdit.putString("dataTime", format); + sharedEdit.commit(); + }else if (messageNoticeBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + } else { + Toast.makeText(getActivity(), messageNoticeBean.getMessage() + "", Toast.LENGTH_SHORT).show(); } } @@ -455,8 +442,57 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen public void onError(Throwable e, int id) { dismissLoadingDialog(); Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show(); + Log.d("TAG", "onError: "+e.getMessage()); } }); + + } + + /* 得到电话区号,电话位数*/ + private void initPhone() { + if (Constant.USHERED == null) { + return; + }else { + if (HttpInterface.GET_PHONES == null) { + return; + } + } + String encode = Geohash.getInstance().encode(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); + if (encode == null) { + Toast.makeText(getActivity(), "没有确定经纬度", Toast.LENGTH_SHORT).show(); + return; + } + HttpParams httpParams = new HttpParams(); + httpParams.put("geo", encode); + OkGoBuilder okGoBuilder = OkGoBuilder.getInstance() + .Builder(getActivity()) + .url(HttpInterface.GET_PHONES) + .params(httpParams) + .cls(GetPhoneBean.class) + .token(Constant.ACCESS_TOKEN); + okGoBuilder.getRequest(new Callback() { + @Override + public void onSuccess(GetPhoneBean getPhoneBean, int id) { + dismissLoadingDialog(); + if (getPhoneBean.getCode() == 200) { + String code = getPhoneBean.getBody().getCode(); + Integer telLength = getPhoneBean.getBody().getTelLength(); + Constant.CODE = code; + Constant.TelLength = telLength; + }else if (getPhoneBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + } else { + Toast.makeText(getActivity(), getPhoneBean.getMessage(), Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onError(Throwable e, int id) { + dismissLoadingDialog(); + Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show(); + Log.d("TAG", "onError: "+e.getMessage()); + } + }); } private static class NestedScrollableViewHelper extends ScrollableViewHelper { @@ -483,40 +519,68 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen } } + /** + * 上传用户位置 + */ private void iniUserLocation() { + if (Constant.USHERED == null) { + return; + }else { + if (HttpInterface.USER_LOCATION == null) { + return; + } + } String encode = Geohash.getInstance().encode(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); HttpParams httpParams = new HttpParams(); httpParams.put("geom", encode); long time = System.currentTimeMillis(); httpParams.put("datetime", time); - OkGoBuilder.getInstance().Builder(getActivity()) + OkGoBuilder okGoBuilder = OkGoBuilder.getInstance() + .Builder(getActivity()) + .time(30) .url(HttpInterface.USER_LOCATION) .cls(UserBean.class) .params(httpParams) - .token(Constant.ACCESS_TOKEN) - .postRequest(new Callback() { - @Override - public void onSuccess(UserBean response, int id) { - if (response.getCode() == 200) { - Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show(); - Log.d("TAG", "onSuccess: " + response.getCode() + response.getMessage() + "" + response.getBody()); - } - } + .token(Constant.ACCESS_TOKEN); + okGoBuilder.postRequest(new Callback() { + @Override + public void onSuccess(UserBean response, int id) { + dismissLoadingDialog(); + if (response.getCode() == 200) {//上传用户位置金纬度 寻宝删选接口请求成功 + Toast.makeText(getActivity(), "上传用户位置成功", Toast.LENGTH_SHORT).show(); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + } else { + Toast.makeText(getActivity(), response.getMessage()+"", Toast.LENGTH_SHORT).show(); + } + Log.d("TAG", "onSuccess:" + response.getMessage() + ""); + } - @Override - public void onError(Throwable e, int id) { - Log.d("TAG", "onSuccess:" + e.getMessage() + ""); - } - }); + @Override + public void onError(Throwable e, int id) { + dismissLoadingDialog(); + Toast.makeText(getActivity(), e.getMessage() + "", Toast.LENGTH_SHORT).show(); + Log.d("TAG", "onSuccess:" + e.getMessage() + ""); + } + }); } + /** + * 网络删选接口 + * @param tencentLocation + */ private void initList(TencentLocation tencentLocation) { + if (Constant.USHERED == null) { + return; + }else { + if (HttpInterface.TASK_LIST == null) { + return; + } + } int task_type = Constant.TASK_TYPE; int limit_type = Constant.LIMIT_TYPE; int taskStatus = Constant.TASK_STARTUP; - if (taskStatus == 1 || taskStatus == 2 || taskStatus == 3) { + if (taskStatus == 1) { Message obtain = Message.obtain(); obtain.what = Constant.JOB_SEARCH_WORD; obtain.obj = null; @@ -528,6 +592,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen if (mapCenterPoint != null) { centerEncode = Geohash.getInstance().encode(mapCenterPoint.latitude, mapCenterPoint.longitude); } + String userEncode = Geohash.getInstance().encode(tencentLocation.getLatitude(), tencentLocation.getLongitude()); OkGo.getInstance().cancelTag(this); Log.d("TAG", "initList: " + Constant.USHERED); @@ -536,220 +601,245 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen httpParams.put("userGeo", userEncode); httpParams.put("centerGeo", centerEncode); httpParams.put("pageSize", Constant.NUMBER); - int treasurePage = 1; - httpParams.put("pageNum", treasurePage); + httpParams.put("pageNum", 1); httpParams.put("type", task_type); httpParams.put("isExclusive", limit_type); - + if (taskStatus==2){ + if (Constant.USHERED!=null){ + httpParams.put("received", Constant.USHERED); + } + } showLoadingDialog(); OkGoBuilder okGoBuilder = OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.TASK_LIST) .cls(JobSearchBean.class) .params(httpParams) .token(Constant.ACCESS_TOKEN); okGoBuilder.getRequest(new Callback() { - @Override - public void onSuccess(JobSearchBean response, int id) { - dismissLoadingDialog(); - isHandler=true; - if (response.getCode() == 200) { - JobSearchBean.BodyBean body = response.getBody(); - if (body != null) { - upload = response.getBody().getUpload(); - if (upload != null) { - ivSubmit.setEnabled(true); - } else { - ivSubmit.setEnabled(false); - } - Log.d("TAG", "onSuccess: " + response.getBody().toString()); - for (int i = 0; i < removables.size(); i++) { - removables.get(i).remove(); - } - removables.clear(); - List list = response.getBody().getList(); - for (int i = 0; i < list.size(); i++) { - JobSearchBean.BodyBean.ListBean listBean = list.get(i); - String encodeStr = list.get(i).getGeo(); - // 解密geo - String geo = Geohash.getInstance().decode(encodeStr); - Log.d("TAG", "onSuccess: " + geo); - Geometry geometry = GeometryTools.createGeometry(geo); - LatLng latLng = null; - switch (geometry.getGeometryType()) { - case "LineString": //线 - case "MultiLineString"://多线 - BitmapDescriptor bitmapLine = null; - if (listBean.getType() == 3) {//poi录像 - bitmapLine = BitmapDescriptorFactory.fromResource(R.drawable.road_arrows); - } else if (listBean.getType() == 4) {//道路录像 - bitmapLine = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_arrows); - } - List latLineString = GeometryTools.getLatLags(geo); - // 构造 PolylineOptions - PolylineOptions polylineOptions = new PolylineOptions() - .addAll(latLineString) - // 折线设置圆形线头 - .lineCap(true) - // 折线的颜色为绿色 - .color(Color.parseColor("#0096FF")) - // 折线宽度为5像素 - .width(28) - // 还可以添加描边颜色 - //.borderColor(0xffff0000) - // 描边颜色的宽度,线宽还是 25 像素,不过填充的部分宽度为 `width` - 2 * `borderWidth` - //.borderWidth(1); - .arrow(true) - .arrowSpacing(80) - .arrowTexture(bitmapLine); - // 绘制折线 - Polyline polyline = tencentMap.addPolyline(polylineOptions); - if (polyline != null) { - polyline.setZIndex(MARKER_LINE); - removables.add(polyline); - if (latLineString != null && latLineString.size() > 0) { - latLng = latLineString.get(0); - } - } - - break; - case "Point": //点 - latLng = GeometryTools.createLatLng(geo); - break; - case "Polygon": //面 - List latPolygon = GeometryTools.getLatLags(geo); - Polygon polygon = tencentMap.addPolygon(new PolygonOptions(). - //连接封闭图形的点 - addAll(latPolygon). - //填充颜色为红色 - fillColor(Color.parseColor("#97E0E7EC")). - //边线颜色为黑色 - strokeColor(0xff000000). - //边线宽度15像素 - strokeWidth(5)); - if (polygon != null) { - polygon.setZIndex(MARKER_FACE); - removables.add(polygon); - com.vividsolutions.jts.geom.Point centroid = geometry.getCentroid(); - double x = centroid.getX(); - double y = centroid.getY(); - latLng = new LatLng(); - latLng.setLatitude(y); - latLng.setLongitude(x); - } - break; + @Override + public void onSuccess(JobSearchBean response, int id) { + dismissLoadingDialog(); + if (response.getCode() == 200) { + JobSearchBean.BodyBean body = response.getBody(); + if (body != null) { + upload = response.getBody().getUpload(); + if (upload != null) { + ivSubmit.setEnabled(true); + } else { + ivSubmit.setEnabled(false); + } + Log.d("TAG", "onSuccess: " + response.getBody().toString()); + for (int i = 0; i < removables.size(); i++) { + removables.get(i).remove(); + } + removables.clear(); + List list = response.getBody().getList(); + for (int i = 0; i < list.size(); i++) { + JobSearchBean.BodyBean.ListBean listBean = list.get(i); + String encodeStr = list.get(i).getGeo(); + // 解密geo + String geo = Geohash.getInstance().decode(encodeStr); + Log.d("TAG", "onSuccess: " + geo); + Geometry geometry = GeometryTools.createGeometry(geo); + LatLng latLng = null; + switch (geometry.getGeometryType()) { + case "LineString": //线 + case "MultiLineString"://多线 + BitmapDescriptor bitmapLine = null; + if (listBean.getType() == 3) {//poi录像 + bitmapLine = BitmapDescriptorFactory.fromResource(R.drawable.road_arrows); + } else if (listBean.getType() == 4) {//道路录像 + bitmapLine = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_arrows); } - switch (list.get(i).getType()) { - case 1://poi - BitmapDescriptor poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi); - //poiDescriptor.getForager().setScale(50); - assert latLng != null; - Marker poiMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiDescriptor).alpha(0.9f) - .anchor(0.5f, 1.0f) - .flat(true) - .clockwise(false)); - poiMarker.setZIndex(MARKER_DOT); - poiMarker.setTag(listBean); - removables.add(poiMarker); - String poiGeo = initGeo(latLng); - geoMarker(poiGeo, poiMarker); - poiMarker.setClickable(true); - break; - case 2://充电站 - BitmapDescriptor chargeDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge); - assert latLng != null; - Marker stationMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(chargeDescriptor).alpha(0.9f) - .anchor(0.5f, 1.0f) - .flat(true) - .clockwise(false)); - stationMarker.setZIndex(MARKER_DOT); - stationMarker.setTag(listBean); - removables.add(stationMarker); - String stationGeo = initGeo(latLng); - geoMarker(stationGeo, stationMarker); - stationMarker.setClickable(true); - - break; - case 3://poi录像 - BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video); - assert latLng != null; - Marker poiVideoMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).alpha(0.9f) - .anchor(0.5f, 1.0f) - .flat(true) - .clockwise(false)); - poiVideoMarker.setTag(listBean); - poiVideoMarker.setZIndex(MARKER_DOT); - removables.add(poiVideoMarker); - String poiVideoGeo = initGeo(latLng); - geoMarker(poiVideoGeo, poiVideoMarker); - poiVideoMarker.setClickable(true); - break; - case 4://道路录像 - BitmapDescriptor roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road); - assert latLng != null; - Marker roadMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(roadDescriptor).alpha(0.9f) - .anchor(0.5f, 1.0f) - .flat(true) - .clockwise(false)); - roadMarker.setZIndex(MARKER_DOT); - roadMarker.setTag(listBean); - removables.add(roadMarker); - String roadGeo = initGeo(latLng); - geoMarker(roadGeo, roadMarker); - roadMarker.setClickable(true); - break; - case 5://其他 - BitmapDescriptor otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other); - assert latLng != null; - Marker otherMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor).alpha(0.9f) - .anchor(0.5f, 1.0f) - .flat(true) - .clockwise(false)); - otherMarker.setZIndex(MARKER_DOT); - otherMarker.setTag(listBean); - removables.add(otherMarker); - String otherGeo = initGeo(latLng); - geoMarker(otherGeo, otherMarker); - otherMarker.setClickable(true); - break; - case 6://面状任务 - BitmapDescriptor Descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_facet); - assert latLng != null; - Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Descriptor).alpha(0.9f) - .anchor(0.5f, 1.0f) - .flat(true) - .clockwise(false)); - planarMarker.setZIndex(MARKER_DOT); - planarMarker.setTag(listBean); - removables.add(planarMarker); - String planarGeo = initGeo(latLng); - geoMarker(planarGeo, planarMarker); - planarMarker.setClickable(true); - break; + List latLineString = GeometryTools.getLatLags(geo); + // 构造 PolylineOptions + PolylineOptions polylineOptions = new PolylineOptions() + .addAll(latLineString) + // 折线设置圆形线头 + .lineCap(true) + // 折线的颜色为绿色 + .color(Color.parseColor("#0096FF")) + // 折线宽度为5像素 + .width(28) + // 还可以添加描边颜色 + //.borderColor(0xffff0000) + // 描边颜色的宽度,线宽还是 25 像素,不过填充的部分宽度为 `width` - 2 * `borderWidth` + //.borderWidth(1); + .arrow(true) + .arrowSpacing(80) + .arrowTexture(bitmapLine); + // 绘制折线 + Polyline polyline = tencentMap.addPolyline(polylineOptions); + if (polyline != null) { + polyline.setZIndex(MARKER_LINE); + removables.add(polyline); + if (latLineString != null && latLineString.size() > 0) { + latLng = latLineString.get(0); + } } - } + break; + case "Point": //点 + latLng = GeometryTools.createLatLng(geo); + break; + case "Polygon": //面 + List latPolygon = GeometryTools.getLatLags(geo); + Polygon polygon = tencentMap.addPolygon(new PolygonOptions(). + //连接封闭图形的点 + addAll(latPolygon). + //填充颜色为红色 + fillColor(Color.parseColor("#97E0E7EC")). + //边线颜色为黑色 + strokeColor(0xff000000). + //边线宽度15像素 + strokeWidth(5)); + if (polygon != null) { + polygon.setZIndex(MARKER_FACE); + removables.add(polygon); + com.vividsolutions.jts.geom.Point centroid = geometry.getCentroid(); + double x = centroid.getX(); + double y = centroid.getY(); + latLng = new LatLng(); + latLng.setLatitude(y); + latLng.setLongitude(x); + } + break; } - latList.clear(); - for (Map.Entry> entry : removableHashMap.entrySet()) { - String key = entry.getKey(); - LatLng lng = GeometryTools.createLatLng(key); - latList.add(lng); + switch (list.get(i).getType()) { + case 1://poi + BitmapDescriptor poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi); + //poiDescriptor.getForager().setScale(50); + assert latLng != null; + Marker poiMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiDescriptor).alpha(0.9f) + .anchor(0.5f, 1.0f) + .flat(true) + .clockwise(false)); + if (listBean != null) { + poiMarker.setTag(listBean); + } + poiMarker.setZIndex(MARKER_DOT); + removables.add(poiMarker); + String poiGeo = initGeo(latLng); + geoMarker(poiGeo, poiMarker); + poiMarker.setClickable(true); + break; + case 2://充电站 + BitmapDescriptor chargeDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge); + assert latLng != null; + Marker stationMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(chargeDescriptor).alpha(0.9f) + .anchor(0.5f, 1.0f) + .flat(true) + .clockwise(false)); + if (listBean != null) { + stationMarker.setTag(listBean); + } + stationMarker.setZIndex(MARKER_DOT); + removables.add(stationMarker); + String stationGeo = initGeo(latLng); + geoMarker(stationGeo, stationMarker); + stationMarker.setClickable(true); + + break; + case 3://poi录像 + BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video); + assert latLng != null; + Marker poiVideoMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).alpha(0.9f) + .anchor(0.5f, 1.0f) + .flat(true) + .clockwise(false)); + if (listBean != null) { + poiVideoMarker.setTag(listBean); + } + poiVideoMarker.setZIndex(MARKER_DOT); + removables.add(poiVideoMarker); + String poiVideoGeo = initGeo(latLng); + geoMarker(poiVideoGeo, poiVideoMarker); + poiVideoMarker.setClickable(true); + break; + case 4://道路录像 + BitmapDescriptor roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road); + assert latLng != null; + Marker roadMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(roadDescriptor).alpha(0.9f) + .anchor(0.5f, 1.0f) + .flat(true) + .clockwise(false)); + if (listBean != null) { + roadMarker.setTag(listBean); + } + roadMarker.setZIndex(MARKER_DOT); + removables.add(roadMarker); + String roadGeo = initGeo(latLng); + geoMarker(roadGeo, roadMarker); + roadMarker.setClickable(true); + break; + case 5://其他 + BitmapDescriptor otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other); + assert latLng != null; + Marker otherMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor).alpha(0.9f) + .anchor(0.5f, 1.0f) + .flat(true) + .clockwise(false)); + if (listBean != null) { + otherMarker.setTag(listBean); + } + otherMarker.setZIndex(MARKER_DOT); + removables.add(otherMarker); + String otherGeo = initGeo(latLng); + geoMarker(otherGeo, otherMarker); + otherMarker.setClickable(true); + break; + case 6://面状任务 + BitmapDescriptor Descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_facet); + assert latLng != null; + Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Descriptor).alpha(0.9f) + .anchor(0.5f, 1.0f) + .flat(true) + .clockwise(false)); + if (listBean != null) { + planarMarker.setTag(listBean); + } + planarMarker.setZIndex(MARKER_DOT); + removables.add(planarMarker); + String planarGeo = initGeo(latLng); + geoMarker(planarGeo, planarMarker); + planarMarker.setClickable(true); + break; } - Message obtain = Message.obtain(); - obtain.what = Constant.JOB_SEARCH_WORD; - obtain.obj = response; - EventBus.getDefault().post(obtain); } } - - @Override - public void onError(Throwable e, int id) { - dismissLoadingDialog(); - Log.d("TAG", "onError: " + e.getMessage() + ""); + latList.clear(); + for (Map.Entry> entry : removableHashMap.entrySet()) { + String key = entry.getKey(); + LatLng lng = GeometryTools.createLatLng(key); + latList.add(lng); } - }); + Message obtain = Message.obtain(); + obtain.what = Constant.JOB_SEARCH_WORD; + obtain.obj = response; + EventBus.getDefault().post(obtain); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + } + else { + Toast.makeText(getActivity(), "任务搜索接口:" + response.getMessage(), Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onError(Throwable e, int id) { + dismissLoadingDialog(); + Toast.makeText(getActivity(), e.getMessage()+"", Toast.LENGTH_SHORT).show(); + Log.d("TAG", "onError: " + e.getMessage() + ""); + } + }); } + /** + * 坐标点转成geo + * @param latLng + * @return + */ public String initGeo(LatLng latLng) { return GeometryTools.createGeometry(latLng).toString(); } @@ -767,8 +857,29 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen } } + /** + * marker 选中的状态 + * @param poiEntity + * @param aBoolean + */ public void initMarker(PoiEntity poiEntity, boolean aBoolean) { String geoWkt = poiEntity.getGeoWkt(); + if (geoWkt==null){ + if (poiEntity.getDetail()!=null){ + geoWkt = poiEntity.getDetail(); + }else { + if (poiEntity.getX() != null && poiEntity.getY() != null) { + String encode = Geohash.getInstance().encode(Double.parseDouble(poiEntity.getY()), Double.parseDouble(poiEntity.getX())); + if (encode==null){ + return; + }else { + geoWkt=encode; + } + }else { + return; + } + } + } Log.d("TAG", "onSuccess: " + geoWkt); String geo = Geohash.getInstance().decode(geoWkt);//解密 Geometry geometry = GeometryTools.createGeometry(geo); @@ -814,7 +925,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen latLng = latLineString.get(0); } } - break; case "Polygon": //面 List latPolygon = GeometryTools.getLatLags(geo); @@ -882,6 +992,9 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen } } + /** + * 本地数据库数据 + */ private void initThread() { int taskStatus = Constant.TASK_STARTUP; int type = Constant.TASK_TYPE; @@ -898,7 +1011,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen if (allPoiStatus != null) { poiDao.deleteAll(allPoiStatus); } - if (getActivity()!=null){ + if (getActivity() != null) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { @@ -915,7 +1028,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen String geo = Geohash.getInstance().decode(geoWkt);//解密geo Geometry geometry = GeometryTools.createGeometry(geo); switch (geometry.getGeometryType()) { - case "Point" : //点 + case "Point": //点 latLng = GeometryTools.createLatLng(geo); break; case "LineString": //线 @@ -971,14 +1084,76 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen latLng.setLatitude(y); latLng.setLongitude(x); } - /*if (latPolygon != null && latPolygon.size() > 0) { - latLng = latPolygon.get(0); - }*/ break; } } else { - if (allTaskStatus.get(i).getX() != null && allTaskStatus.get(i).getY() != null) { - latLng = new LatLng(Double.parseDouble(allTaskStatus.get(i).getY()), Double.parseDouble(allTaskStatus.get(i).getX())); + String detail = allTaskStatus.get(i).getDetail(); + if (detail!=null){ + String geo = Geohash.getInstance().decode(detail);//解密geo + Geometry geometry = GeometryTools.createGeometry(geo); + switch (geometry.getGeometryType()) { + case "Point": //点 + latLng = GeometryTools.createLatLng(geo); + break; + case "LineString": //线 + case "MultiLineString"://多线 + BitmapDescriptor bitmapLine = null; + int color = 0; + if (poiEntity.getType() == 3) {//poi录像 + bitmapLine = BitmapDescriptorFactory.fromResource(R.drawable.road_arrows); + } else if (poiEntity.getType() == 4) {//道路录像 + bitmapLine = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_arrows); + } + if (poiEntity.getTaskStatus() == 1) { + color = Color.parseColor("#FFE70C"); + } else { + color = Color.parseColor("#BDBDBD"); + } + List latLineString = GeometryTools.getLatLags(geo); + // 构造 PolylineOnions + PolylineOptions polylineOptions = new PolylineOptions() + .addAll(latLineString) + // 折线设置圆形线头 + .lineCap(true) + .color(color) + // 折线宽度为5像素 + .width(28) + .arrow(true) + .arrowSpacing(80) + .arrowTexture(bitmapLine); + // 绘制折线 + Polyline polyline = tencentMap.addPolyline(polylineOptions); + if (polyline != null) { + polyline.setZIndex(MARKER_LINE); + removablesLocality.add(polyline); + if (latLineString != null && latLineString.size() > 0) { + latLng = latLineString.get(0); + } + } + break; + case "Polygon": //面 + List latPolygon = GeometryTools.getLatLags(geo); + Polygon polygon = tencentMap.addPolygon(new PolygonOptions().//连接封闭图形的点 + addAll(latPolygon).//填充颜色为浅蓝色 + fillColor(Color.parseColor("#97E0E7EC")).//边线颜色为黑色 + strokeColor(0xff00ff00).//边线宽度15像素 + strokeWidth(5)); + if (polygon != null) { + polygon.setZIndex(MARKER_FACE); + removablesLocality.add(polygon); + Point centroid = geometry.getCentroid(); + double x = centroid.getX(); + double y = centroid.getY(); + latLng = new LatLng(); + latLng.setLatitude(y); + latLng.setLongitude(x); + } + break; + } + }else { + if (allTaskStatus.get(i).getX() != null && allTaskStatus.get(i).getY() != null) { + latLng = new LatLng(Double.parseDouble(allTaskStatus.get(i).getY()), Double.parseDouble(allTaskStatus.get(i).getX())); + } } } switch (poiEntity.getType()) { @@ -1116,113 +1291,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen }).start(); } - private void initSharePre() { - //根据保存时所用的name属性,获取SharedPreferences对象 - SharedPreferences dataFile = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0); - //根据数据类型,调用对应的get方法,通过键取得对应的值。 - String dataFileString = dataFile.getString("poiEntity", null); - if (dataFileString != null) { - PoiEntity poiEntity = new Gson().fromJson(dataFileString, PoiEntity.class); - switch (poiEntity.getType()) { - case 1: - DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; - DialogSettings.cancelable = false; - MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你poi页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() { - @Override - public boolean onClick(BaseDialog baseDialog, View v) { - treasureBuilder.append("initSharePre-点击了poi,"); - Bundle bundle = new Bundle(); - bundle.putSerializable("poiEntity", poiEntity); - PoiFragment poiFragment = PoiFragment.newInstance(bundle); - showSlidingFragment(poiFragment); - initRemovePoiSharePre(); - return false; - } - }); - break; - case 2: - DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; - DialogSettings.cancelable = false; - MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你充电站页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() { - @Override - public boolean onClick(BaseDialog baseDialog, View v) { - treasureBuilder.append("initSharePre-点击了充电站,"); - Bundle bundle = new Bundle(); - bundle.putSerializable("poiEntity", poiEntity); - ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle); - showSlidingFragment(chargingStationFragment); - initRemovePoiSharePre(); - return false; - } - }); - break; - case 3: - DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; - DialogSettings.cancelable = false; - MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你poi录像页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() { - @Override - public boolean onClick(BaseDialog baseDialog, View v) { - treasureBuilder.append("initSharePre-点击了poi录像,"); - Bundle bundle = new Bundle(); - bundle.putSerializable("poiEntity", poiEntity); - PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle); - showSlidingFragment(poiVideoFragment); - initRemovePoiSharePre(); - return false; - } - }); - break; - case 4: - DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; - DialogSettings.cancelable = false; - MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你道路页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() { - @Override - public boolean onClick(BaseDialog baseDialog, View v) { - treasureBuilder.append("initSharePre-点击了道路,"); - Bundle bundle = new Bundle(); - bundle.putSerializable("poiEntity", poiEntity); - RoadFragment roadFragment = RoadFragment.newInstance(bundle); - showSlidingFragment(roadFragment); - initRemovePoiSharePre(); - return false; - } - }); - break; - case 5: - DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; - DialogSettings.cancelable = false; - MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你其他页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() { - @Override - public boolean onClick(BaseDialog baseDialog, View v) { - treasureBuilder.append("initSharePre-点击了其他,"); - Bundle bundle = new Bundle(); - bundle.putSerializable("poiEntity", poiEntity); - OtherFragment otherFragment = OtherFragment.newInstance(bundle); - showSlidingFragment(otherFragment); - initRemovePoiSharePre(); - return false; - } - }); - break; - } - } - } - - public void initRemovePoiSharePre() { - //获取SharedPreferences对象,方法中两个参数的意思为:第一个name - //表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成 - //一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看 - //方法注释得知,建议以0或者MODE_PRIVATE为默认值。 - SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0); - //获取Editor对象 - SharedPreferences.Editor edit = poi.edit(); - //根据要保存的数据的类型,调用对应的put方法, - //以键值对的形式添加新值。 - edit.putString("poiEntity", null); - //提交新值。必须执行,否则前面的操作都无效。 - edit.apply(); - } - @Subscribe public void onEvent(Message data) { if (data.what == Constant.FILTER_LIST_ITEM) { // 点击筛选的item @@ -1385,65 +1453,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen } } - /* - * 控制主界面各个按钮的显示状态 - */ - private void setMainButtonVisitable(int visitable) { - ivZoomAdd.setVisibility(visitable); - ivZoomDel.setVisibility(visitable); - ivLocation.setVisibility(visitable); - ivRaffish.setVisibility(visitable); - cbMapType.setVisibility(visitable); - ivSubmit.setVisibility(visitable); - ivFilter.setVisibility(visitable); - ivMessage.setVisibility(visitable); - } - - /* - * 设置定位图标样式 - */ - private void setLocMarkerStyle() { - locationStyle = new MyLocationStyle(); - locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER); - //创建图标 - BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap()); - locationStyle.icon(bitmapDescriptor); - //设置定位圆形区域的边框宽度; - locationStyle.strokeWidth(1); - //设置圆区域的颜色 - // locationStyle.fillColor(R.color.colormap); - // locationStyle.anchor(1000,2000); - tencentMap.setMyLocationStyle(locationStyle); - } - - /* - * 定位的一些初始化设置 - */ - private void initLocation() { - //设置定位周期(位置监听器回调周期)为3s - //locationRequest.setInterval(3000); - //地图上设置定位数据源 - tencentMap.setLocationSource(new MyTecentLocationSource(getActivity())); - //设置当前位置可见 - tencentMap.setMyLocationEnabled(true); - //设置定位图标样式 - setLocMarkerStyle(); - tencentMap.setMyLocationStyle(locationStyle); - } - - private Bitmap getBitMap() { - Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.location_north_fill); - int width = bitmap.getWidth(); - int height = bitmap.getHeight(); - int newWidth = 55; - int newHeight = 55; - float widthScale = ((float) newWidth) / width; - float heightScale = ((float) newHeight) / height; - Matrix matrix = new Matrix(); - matrix.postScale(widthScale, heightScale); - bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); - return bitmap; - } @Override protected void initData() { @@ -1471,6 +1480,118 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen treasureBuilder.append("userId:").append(Constant.USHERED).append(","); } } + /** + * 奔溃后的数据 + */ + private void initSharePre() { + //根据保存时所用的name属性,获取SharedPreferences对象 + SharedPreferences dataFile = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0); + //根据数据类型,调用对应的get方法,通过键取得对应的值。 + String dataFileString = dataFile.getString("poiEntity", null); + if (dataFileString != null) { + PoiEntity poiEntity = new Gson().fromJson(dataFileString, PoiEntity.class); + switch (poiEntity.getType()) { + case 1: + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + DialogSettings.cancelable = false; + MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你poi页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + treasureBuilder.append("initSharePre-点击了poi,"); + Bundle bundle = new Bundle(); + bundle.putSerializable("poiEntity", poiEntity); + PoiFragment poiFragment = PoiFragment.newInstance(bundle); + showSlidingFragment(poiFragment); + initRemovePoiSharePre(); + return false; + } + }); + break; + case 2: + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + DialogSettings.cancelable = false; + MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你充电站页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + treasureBuilder.append("initSharePre-点击了充电站,"); + Bundle bundle = new Bundle(); + bundle.putSerializable("poiEntity", poiEntity); + ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle); + showSlidingFragment(chargingStationFragment); + initRemovePoiSharePre(); + return false; + } + }); + break; + case 3: + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + DialogSettings.cancelable = false; + MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你poi录像页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + treasureBuilder.append("initSharePre-点击了poi录像,"); + Bundle bundle = new Bundle(); + bundle.putSerializable("poiEntity", poiEntity); + PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle); + showSlidingFragment(poiVideoFragment); + initRemovePoiSharePre(); + return false; + } + }); + break; + case 4: + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + DialogSettings.cancelable = false; + MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你道路页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + treasureBuilder.append("initSharePre-点击了道路,"); + Bundle bundle = new Bundle(); + bundle.putSerializable("poiEntity", poiEntity); + RoadFragment roadFragment = RoadFragment.newInstance(bundle); + showSlidingFragment(roadFragment); + initRemovePoiSharePre(); + return false; + } + }); + break; + case 5: + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + DialogSettings.cancelable = false; + MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你其他页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + treasureBuilder.append("initSharePre-点击了其他,"); + Bundle bundle = new Bundle(); + bundle.putSerializable("poiEntity", poiEntity); + OtherFragment otherFragment = OtherFragment.newInstance(bundle); + showSlidingFragment(otherFragment); + initRemovePoiSharePre(); + return false; + } + }); + break; + } + } + } + + /** + * 当选择后将sp中数据删除 + */ + public void initRemovePoiSharePre() { + //获取SharedPreferences对象,方法中两个参数的意思为:第一个name + //表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成 + //一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看 + //方法注释得知,建议以0或者MODE_PRIVATE为默认值。 + SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0); + //获取Editor对象 + SharedPreferences.Editor edit = poi.edit(); + //根据要保存的数据的类型,调用对应的put方法, + //以键值对的形式添加新值。 + edit.putString("poiEntity", null); + //提交新值。必须执行,否则前面的操作都无效。 + edit.apply(); + } @Override public void onStart() { @@ -1479,7 +1600,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen EventBus.getDefault().register(this); } mapView.onStart(); - } @Override @@ -1512,7 +1632,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen treasureBuilder.append("onDestroy"); treasureBuilder.append("\r\n"); FileUtils.writeFile(logFile.getAbsolutePath(), treasureBuilder.toString(), true); - + if (bigMarker != null) { bigMarker.remove(); } @@ -1542,13 +1662,12 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen case R.id.iv_location://定位: treasureBuilder.append("点击了定位的按钮,"); if (Constant.currentLocation != null) { - CameraPosition cameraPosition = tencentMap.getCameraPosition(); CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition( - new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度 - cameraPosition==null?7:cameraPosition.zoom, //目标缩放级别 - 0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0) - 0)); //目标旋转角 0~360° (正北方为0) + new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()),//中心点坐标,地图目标经纬度 + 18,//目标缩放级别 + 0,//目标倾斜角[0.0 ~ 45.0] (垂直地图时为0) + 0));//目标旋转角 0~360° (正北方为0) tencentMap.animateCamera(cameraSigma); } else { Toast.makeText(getActivity(), "无定位", Toast.LENGTH_SHORT).show(); @@ -1557,78 +1676,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen break; case R.id.iv_submit://弹窗 treasureBuilder.append("点击了弹窗 上报的按钮,"); - debounce(ivSubmit); - if (upload == null) { - Toast.makeText(getActivity(), "网络请求失败", Toast.LENGTH_SHORT).show(); - return; - } - //分享 - CharSequence title = "请选择上报类型"; - // 如果当前fragment是筛选,则移除该fragment - FilterFragment filterFragments = (FilterFragment) supportFragmentManager.findFragmentByTag(FilterFragment.class.getName()); - if (filterFragments != null) { - FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction(); - fragmentTransaction.remove(filterFragments); - fragmentTransaction.commit(); - } - DialogSettings.style = DialogSettings.STYLE.STYLE_MIUI; - List itemList = new ArrayList<>(); - if (upload.contains(1)) { - itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_poi, "POI")); - } - if (upload.contains(2)) { - itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_charge, "充电站")); - } - if (upload.contains(3)) { - itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_poi_video, "POI录像")); - } - if (upload.contains(4)) { - itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_road, "道路")); - } - if (upload.contains(5)) { - itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_other, "其他")); - } - Bundle bundle = new Bundle(); - PoiEntity poiEntity = new PoiEntity(); - // 上报时以当前用户位置为准 - if (Constant.currentLocation == null) { - ToastUtil.showShort(getContext(), "无法获取当前位置,请检查GPS是否打开!"); - return; - } - //LatLng mapCenterPoint = getMapCenterPoint(); - LatLng newPoiLatLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); - poiEntity.setX(newPoiLatLng.getLongitude() + ""); - poiEntity.setY(newPoiLatLng.getLatitude() + ""); - bundle.putSerializable("poiEntity", poiEntity); - ShareDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), itemList, new ShareDialog.OnItemClickListener() { - @Override - public boolean onClick(ShareDialog shareDialog, int index, ShareDialog.Item item) { - if (item.getText().equals("POI")) { - PoiFragment poiFragment = PoiFragment.newInstance(bundle); - showSlidingFragment(poiFragment); - treasureBuilder.append("点击弹窗上的poi,"); - } else if (item.getText().equals("充电站")) { - ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle); - showSlidingFragment(chargingStationFragment); - treasureBuilder.append("点击弹窗上的充电站,"); - } else if (item.getText().equals("POI录像")) { - poiEntity.setWork_type(1); - bundle.putSerializable("poiEntity", poiEntity); - PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle); - showSlidingFragment(poiVideoFragment); - treasureBuilder.append("点击弹窗上的poi录像,"); - } else if (item.getText().equals("道路")) { - RoadFragment roadFragment = RoadFragment.newInstance(bundle); - showSlidingFragment(roadFragment); - treasureBuilder.append("点击弹窗上的道路,"); - } else if (item.getText().equals("其他")) { - OtherFragment otherFragment = OtherFragment.newInstance(bundle); - showSlidingFragment(otherFragment); - treasureBuilder.append("点击弹窗上的其他,"); - } - return false; - } - }).setTitle(title); + initSubmit(); break; case R.id.iv_filter: treasureBuilder.append("点击了删选的按钮,"); @@ -1649,6 +1697,83 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen } } + /** + * 弹窗 + */ + private void initSubmit() { + debounce(ivSubmit); + if (upload == null) { + Toast.makeText(getActivity(), "访问未授权", Toast.LENGTH_SHORT).show(); + return; + } + //分享 + CharSequence title = "请选择上报类型"; + // 如果当前fragment是筛选,则移除该fragment + FilterFragment filterFragments = (FilterFragment) supportFragmentManager.findFragmentByTag(FilterFragment.class.getName()); + if (filterFragments != null) { + FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction(); + fragmentTransaction.remove(filterFragments); + fragmentTransaction.commit(); + } + DialogSettings.style = DialogSettings.STYLE.STYLE_MIUI; + List itemList = new ArrayList<>(); + if (upload.contains(1)) { + itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_poi, "POI")); + } + if (upload.contains(2)) { + itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_charge, "充电站")); + } + if (upload.contains(3)) { + itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_poi_video, "POI录像")); + } + if (upload.contains(4)) { + itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_road, "道路")); + } + if (upload.contains(5)) { + itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_other, "其他")); + } + Bundle bundle = new Bundle(); + PoiEntity poiEntity = new PoiEntity(); + // 上报时以当前用户位置为准 + if (Constant.currentLocation == null) { + ToastUtil.showShort(getContext(), "无法获取当前位置,请检查GPS是否打开!"); + return; + } + //LatLng mapCenterPoint = getMapCenterPoint(); + LatLng newPoiLatLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); + poiEntity.setX(newPoiLatLng.getLongitude() + ""); + poiEntity.setY(newPoiLatLng.getLatitude() + ""); + bundle.putSerializable("poiEntity", poiEntity); + ShareDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), itemList, new ShareDialog.OnItemClickListener() { + @Override + public boolean onClick(ShareDialog shareDialog, int index, ShareDialog.Item item) { + if (item.getText().equals("POI")) { + PoiFragment poiFragment = PoiFragment.newInstance(bundle); + showSlidingFragment(poiFragment); + treasureBuilder.append("点击弹窗上的poi,"); + } else if (item.getText().equals("充电站")) { + ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle); + showSlidingFragment(chargingStationFragment); + treasureBuilder.append("点击弹窗上的充电站,"); + } else if (item.getText().equals("POI录像")) { + poiEntity.setWork_type(1); + bundle.putSerializable("poiEntity", poiEntity); + PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle); + showSlidingFragment(poiVideoFragment); + treasureBuilder.append("点击弹窗上的poi录像,"); + } else if (item.getText().equals("道路")) { + RoadFragment roadFragment = RoadFragment.newInstance(bundle); + showSlidingFragment(roadFragment); + treasureBuilder.append("点击弹窗上的道路,"); + } else if (item.getText().equals("其他")) { + OtherFragment otherFragment = OtherFragment.newInstance(bundle); + showSlidingFragment(otherFragment); + treasureBuilder.append("点击弹窗上的其他,"); + } + return false; + } + }).setTitle(title); + } /** * 将fragment显示到抽屉内 @@ -1690,6 +1815,12 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen fragmentTransaction.hide(poiVideoFragment); } } + if (!(fragment instanceof OtherFragment)) { + OtherFragment otherFragment = (OtherFragment) supportFragmentManager.findFragmentByTag(OtherFragment.class.getName()); + if (otherFragment != null) { + fragmentTransaction.hide(otherFragment); + } + } fragmentTransaction.show(fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); @@ -1704,11 +1835,10 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen checkMyLocation(); } else { // 当前网络不可用 dismissLoadingDialog(); - ToastUtil.showShort(getContext(), Constant.NETWORK_UNAVAILABLE); + Toast.makeText(getActivity(), Constant.NETWORK_UNAVAILABLE, Toast.LENGTH_SHORT).show(); } } - /** * 检查所需权限 */ @@ -1757,6 +1887,66 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen }); } + + /* 设置定位图标样式*/ + private void setLocMarkerStyle() { + locationStyle = new MyLocationStyle(); + locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER); + //创建图标 + BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap()); + locationStyle.icon(bitmapDescriptor); + //设置定位圆形区域的边框宽度; + locationStyle.strokeWidth(1); + //设置圆区域的颜色 + // locationStyle.fillColor(R.color.colormap); + // locationStyle.anchor(1000,2000); + tencentMap.setMyLocationStyle(locationStyle); + } + + /* 定位的一些初始化设置*/ + private void initLocation() { + //设置定位周期(位置监听器回调周期)为3s + //locationRequest.setInterval(3000); + //地图上设置定位数据源 + tencentMap.setLocationSource(new MyTecentLocationSource(getActivity())); + //设置当前位置可见 + tencentMap.setMyLocationEnabled(true); + //设置定位图标样式 + setLocMarkerStyle(); + tencentMap.setMyLocationStyle(locationStyle); + } + + private Bitmap getBitMap() { + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.location_north_fill); + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + int newWidth = 55; + int newHeight = 55; + float widthScale = ((float) newWidth) / width; + float heightScale = ((float) newHeight) / height; + Matrix matrix = new Matrix(); + matrix.postScale(widthScale, heightScale); + bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); + return bitmap; + } + + /* + * 控制主界面各个按钮的显示状态 + */ + private void setMainButtonVisitable(int visitable) { + ivZoomAdd.setVisibility(visitable); + ivZoomDel.setVisibility(visitable); + ivLocation.setVisibility(visitable); + ivRaffish.setVisibility(visitable); + cbMapType.setVisibility(visitable); + ivSubmit.setVisibility(visitable); + ivFilter.setVisibility(visitable); + ivMessage.setVisibility(visitable); + } + + /** + * marker 的监听 + */ TencentMap.OnMarkerClickListener markerClickListener = new TencentMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { @@ -2058,6 +2248,11 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen }); } + /** + * 设置map 的大小 + * + * @param newConfig + */ @Override public void onConfigurationChanged(@NonNull Configuration newConfig) { super.onConfigurationChanged(newConfig); diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/UserAttestationFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/UserAttestationFragment.java index efaa33b..b910d52 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/UserAttestationFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/UserAttestationFragment.java @@ -36,6 +36,7 @@ import com.navinfo.outdoor.bean.NameAuthenticationBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; +import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.PhotoUtils; import java.io.File; @@ -65,7 +66,7 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC private TextView tvCard2; private ImageView ivHera3; private TextView tvCard3; - /* private LinearLayout linearHint; + /*private LinearLayout linearHint; private TextView tvTitle; private LinearLayout linearLayout; private View userAttestView;*/ @@ -73,7 +74,6 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC private File logFile; private StringBuilder userAttestationBuilder; - public static UserAttestationFragment newInstance(Bundle bundle) { UserAttestationFragment fragment = new UserAttestationFragment(); fragment.setArguments(bundle); @@ -85,7 +85,6 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC return R.layout.user_attestation_fragment; } - @Override protected void initData() { super.initData(); @@ -106,14 +105,11 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt"); } } - userAttestationBuilder = new StringBuilder(); userAttestationBuilder.append("UserAttestationFragment-onCreate-initData ,"); if (Constant.USHERED!=null){ userAttestationBuilder.append("userId:").append(Constant.USHERED).append(","); } - - } @Override @@ -238,9 +234,6 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC } } - /*** - * - */ public boolean checkNumber(String text) { Pattern patternSachs1 = Pattern .compile("^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$"); @@ -252,7 +245,7 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC } - /** + /* * 中文姓名效验 */ static boolean chineseNameTest(String name) { @@ -263,7 +256,6 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC } private void nameAuthentication() { - if (etAttestationName.getText().toString().equals("")) { Toast.makeText(getActivity(), "姓名不能为空,请输入姓名", Toast.LENGTH_SHORT).show(); return; @@ -284,7 +276,6 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC Toast.makeText(getActivity(), "请拍照 手持身份证", Toast.LENGTH_SHORT).show(); return; } - ArrayList takePhoneList = new ArrayList<>(); String takePhotoPath1 = (String) tvCard1.getTag(); takePhoneList.add(new File(takePhotoPath1)); @@ -300,7 +291,9 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC httpParams.put("userid", Constant.USHERED); httpParams.put("name", attestationName); httpParams.put("idnum", namePhone); - OkGoBuilder.getInstance().Builder(getActivity()) + OkGoBuilder.getInstance() + .time(30) + .Builder(getActivity()) .url(HttpInterface.USER_AUTH_ADD) .cls(NameAuthenticationBean.class) .token(Constant.ACCESS_TOKEN) @@ -324,11 +317,12 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC return false; } }); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { Toast.makeText(getActivity(), "提交失败!", Toast.LENGTH_SHORT).show(); } } - @Override public void onError(Throwable e, int id) { dismissLoadingDialog(); @@ -394,10 +388,18 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC if (idCardNumberBean.getWords_result().get公民身份号码() != null) { String words = idCardNumberBean.getWords_result().get公民身份号码().getWords(); etNamePhone.setText(words); - userAttestationBuilder.append("识别成功 ,"); + userAttestationBuilder.append("身份号识别成功 ,"); } else { - Toast.makeText(getActivity(), "识别失败,可以重新识别或则进行手动输入", Toast.LENGTH_SHORT).show(); - userAttestationBuilder.append("识别失败,可以重新识别或则进行手动输入 ,"); + Toast.makeText(getActivity(), "身份号识别失败,可以重新识别或则进行手动输入", Toast.LENGTH_SHORT).show(); + userAttestationBuilder.append("身份号识别失败,可以重新识别或则进行手动输入 ,"); + } + if (idCardNumberBean.getWords_result().get姓名()!=null){ + String words = idCardNumberBean.getWords_result().get姓名().getWords(); + etAttestationName.setText(words); + userAttestationBuilder.append("姓名识别成功 ,"); + }else { + Toast.makeText(getActivity(), "姓名识别失败,可以重新识别或则进行手动输入", Toast.LENGTH_SHORT).show(); + userAttestationBuilder.append("姓名识别失败,可以重新识别或则进行手动输入 ,"); } } } else { @@ -410,7 +412,6 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC Toast.makeText(getContext(), "请先拍照", Toast.LENGTH_SHORT).show(); } } - } @Override @@ -432,4 +433,5 @@ public class UserAttestationFragment extends BaseFragment implements View.OnC userAttestationBuilder.append("\r\n"); FileUtils.writeFile(logFile.getAbsolutePath(), userAttestationBuilder.toString(), true); } + } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/VideoFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/VideoFragment.java index c0dc97a..3c357da 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/VideoFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/VideoFragment.java @@ -31,7 +31,6 @@ import java.util.Objects; * 视频-fragment */ public class VideoFragment extends BaseFragment implements View.OnClickListener { - private ArrayList fileBeans; private ArrayList deleteFiles; private VideoAdapter videoAdapter; @@ -89,7 +88,6 @@ public class VideoFragment extends BaseFragment implements View.OnClickListener } else { textFile.add(fileListByUUID.get(i)); } - } } ImageView ivPhotoFinal = (ImageView) findViewById(R.id.iv_video_final); diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/WithdrawFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/WithdrawFragment.java index b4c9ce6..3b86664 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/WithdrawFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/WithdrawFragment.java @@ -32,6 +32,7 @@ import com.navinfo.outdoor.bean.UserPriceExchangeBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; +import com.navinfo.outdoor.util.FlushTokenUtil; import java.io.File; import java.text.DateFormat; @@ -43,28 +44,12 @@ import java.util.Objects; * 提现页面的fragment */ public class WithdrawFragment extends BaseFragment implements View.OnClickListener { - private TextView tvUnit; - private TextView tvAlready; - private TextView tvTotal; - private double canExchangePrice; + private TextView tvUnit, tvAlready, tvTotal, poiPushMoney, poiReportMoney, poiVideoPushMoney, poiVideoReportMoney, roadPushMoney, roadReportMoney, chargingPushMoney, chargingReportMoney, otherPushMoney, otherReportMoney; + private StringBuilder withdrawBuilder; private EditText etAllPrice; - private TextView poiPushMoney; - private TextView poiReportMoney; - private TextView poiVideoPushMoney; - private TextView poiVideoReportMoney; - private TextView roadPushMoney; - private TextView roadReportMoney; - private TextView chargingPushMoney; - private TextView chargingReportMoney; - private TextView otherPushMoney; - private TextView otherReportMoney; private CheckBox checkBox; private File logFile; - private StringBuilder withdrawBuilder; - private TextView tvAll; - private ImageView ivWithDraw; - private TextView tvText; - private Button btWithdraw; + private double canExchangePrice; public static WithdrawFragment newInstance(Bundle bundle) { WithdrawFragment fragment = new WithdrawFragment(); @@ -110,19 +95,19 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen tvUnit = findViewById(R.id.tv_unit);//可提现 tvAlready = findViewById(R.id.tv_already);//已提现 tvTotal = findViewById(R.id.tv_total);//总资产 - tvAll = findViewById(R.id.tv_all); + TextView tvAll = findViewById(R.id.tv_all); tvAll.setOnClickListener(this); etAllPrice = findViewById(R.id.et_allPrice); - ivWithDraw = findViewById(R.id.iv_withdraw); + ImageView ivWithDraw = findViewById(R.id.iv_withdraw); ivWithDraw.setOnClickListener(this); - tvText = findViewById(R.id.tv_text); + TextView tvText = findViewById(R.id.tv_text); tvText.setOnClickListener(this); checkBox = findViewById(R.id.checkBox); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { - if (Constant.ID_NUMBER == null || Constant.BACKGROUND == null) { + if (Constant.BACKGROUND == null) { Toast.makeText(getActivity(), "没有绑定银行卡,请先绑定银行卡", Toast.LENGTH_SHORT).show(); checkBox.setChecked(false); withdrawBuilder.append("点击了银行卡的勾选,"); @@ -133,7 +118,7 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen } } }); - btWithdraw = findViewById(R.id.button); + Button btWithdraw = findViewById(R.id.button); btWithdraw.setOnClickListener(this); poiPushMoney = findViewById(R.id.poi_push_money); poiReportMoney = findViewById(R.id.poi_report_money); @@ -145,12 +130,15 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen chargingReportMoney = findViewById(R.id.charging_report_money); otherPushMoney = findViewById(R.id.other_push_money); otherReportMoney = findViewById(R.id.other_report_money); - initNetWork(); + if (Constant.USHERED != null) { + initNetWork(); + } } private void initNetWork() { showLoadingDialog(); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.GET_PRICE) .cls(GetPriceBean.class) @@ -162,7 +150,7 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen dismissLoadingDialog(); if (response.getCode() == 200) { GetPriceBean.BodyBean body = response.getBody(); - if (getActivity()!=null){ + if (getActivity() != null) { getActivity().runOnUiThread(new Runnable() { @SuppressLint("SetTextI18n") @Override @@ -170,13 +158,13 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen tvTotal.setText(body.getUserPrice() + ""); canExchangePrice = body.getCanExchangePrice(); tvUnit.setText(canExchangePrice + ""); - tvAlready.setText(body.getHaveExchangePrice()+""); - poiPushMoney.setText(body.getPoiPushPrice()+"元"); - poiReportMoney.setText(body.getPoiNonepushPrice()+"元"); - poiVideoPushMoney.setText(body.getPoivideoPushPrice()+"元"); - poiVideoReportMoney.setText(body.getPoivideoNonepushPrice()+"元"); - roadPushMoney.setText(body.getRoadPushPrice()+"元"); - roadReportMoney.setText(body.getRoadNonepushPrice()+"元"); + tvAlready.setText(body.getHaveExchangePrice() + ""); + poiPushMoney.setText(body.getPoiPushPrice() + "元"); + poiReportMoney.setText(body.getPoiNonepushPrice() + "元"); + poiVideoPushMoney.setText(body.getPoivideoPushPrice() + "元"); + poiVideoReportMoney.setText(body.getPoivideoNonepushPrice() + "元"); + roadPushMoney.setText(body.getRoadPushPrice() + "元"); + roadReportMoney.setText(body.getRoadNonepushPrice() + "元"); chargingPushMoney.setText(body.getCsPushPrice() + "元"); chargingReportMoney.setText(body.getCsNonepushPrice() + "元"); otherPushMoney.setText(body.getOtherPushPrice() + "元"); @@ -184,6 +172,10 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen } }); } + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + }else { + Toast.makeText(getContext(), response.getMessage(), Toast.LENGTH_SHORT).show(); } Log.d("TAG", "onSuccess: " + response.toString()); } @@ -243,7 +235,7 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen break; case R.id.tv_all: withdrawBuilder.append("点击了全部 ,"); - if (canExchangePrice!=0){ + if (canExchangePrice != 0) { etAllPrice.setText(canExchangePrice + ""); } break; @@ -257,6 +249,7 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen httpParams.put("exchangeMoney", etAllPrice.getText().toString()); httpParams.put("payType", 1); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.USER_PRICE_EXCHANGE) .cls(UserPriceExchangeBean.class) @@ -268,7 +261,7 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen dismissLoadingDialog(); if (response.getCode() == 200) { DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; - DialogSettings.cancelable=false; + DialogSettings.cancelable = false; MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "该提现申请已提交", "确定").setOnOkButtonClickListener(new OnDialogButtonClickListener() { @Override public boolean onClick(BaseDialog baseDialog, View v) { @@ -277,12 +270,14 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen return false; } }); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); } else { - Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show(); withdrawBuilder.append("提现了失败 ,"); + Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show(); } etAllPrice.getText().clear(); - Log.d("TAG", "onSuccess: " + response.getMessage()+response.getCode()); + Log.d("TAG", "onSuccess: " + response.getMessage() + response.getCode()); } @Override diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/WithdrawalRecordFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/WithdrawalRecordFragment.java index fc4b0d9..1b6bd61 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/WithdrawalRecordFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/WithdrawalRecordFragment.java @@ -22,6 +22,7 @@ import com.navinfo.outdoor.bean.WithdrawalBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; +import com.navinfo.outdoor.util.FlushTokenUtil; import java.util.ArrayList; import java.util.Objects; @@ -90,6 +91,7 @@ public class WithdrawalRecordFragment extends BaseFragment implements View.OnCli httpParams.put("pageNum", withPage); OkGoBuilder.getInstance() + .time(30) .Builder(getActivity()) .url(HttpInterface.PRICE_EXCHANGE) .cls(WithdrawalBean.class) @@ -102,7 +104,9 @@ public class WithdrawalRecordFragment extends BaseFragment implements View.OnCli if (withdrawalBean.getCode() == 200){ withdrawalAdapter.setDataBeans(withdrawalBean.getBody().getList()); withPage++; - }else { + }else if (withdrawalBean.getCode()==203){ + FlushTokenUtil.flushToken(getActivity()); + } else { Toast.makeText(getActivity(), withdrawalBean.getMessage()+"", Toast.LENGTH_SHORT).show(); } rxlWithdraw.loadMoreComplete(); diff --git a/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java b/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java index 1093f44..2f2b0f1 100644 --- a/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java +++ b/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java @@ -4,14 +4,13 @@ import com.navinfo.outdoor.api.Constant; public class HttpInterface { public static final String IP_= "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口 - public static final String IP= "http://dtxbmaps.navinfo.com/dtxb_test/m4";//测试接口 - public static final String USER_PATH ="/user/";//我的 public static final String MSG_LIST_PATH ="/msgList/";//发现 public static final String USER_LOGIN_PATH ="/userlogin/";//登录 public static final String PRICE_PATH ="/price/";//提现 public static final String TASK_PATH ="/task/";//任务 + /* public static final String TEST_GUIDANCE_IP = "http://172.21.98.90:9999/m4";//引导页完成接口 public static final String APK_IP = "http://172.23.139.4:8001/"; @@ -72,65 +71,65 @@ public class HttpInterface { * Path=/m4/price/** */ //172.23.139.4:8004/userPrice/1/getPrice - public static String GET_PRICE;//我的-总资产 + public static String GET_PRICE=null;//我的-总资产 //172.23.139.4:8004/userPrice/1/userPriceExchange?exchangeMoney=10&payType=1 - public static String USER_PRICE_EXCHANGE;//我的-财务信息-提现 + public static String USER_PRICE_EXCHANGE=null;//我的-财务信息-提现 //dtxbmaps.navinfo.com/dtxb/m4/price/priceExchange/1/getList?datetime=1628647356815 - public static String PRICE_EXCHANGE;//提现记录 + public static String PRICE_EXCHANGE=null;//提现记录 /*任务 * Path=/m4/task/** */ ///m4/task/task/10/receiveTasks 参数:taskIds - public static String RECEIVE_TASK;//批量领取 + public static String RECEIVE_TASK=null;//批量领取 //172.23.139.4:8003/m4/task/1/getList - public static String TASK_LIST; //任务搜索 + public static String TASK_LIST=null; //任务搜索 //172.23.139.4:8003/othertask/1/receivedOthertask - public static String RECEIVED_OTHER_TASK;//其他-领取任务 + public static String RECEIVED_OTHER_TASK=null;//其他-领取任务 //172.23.139.4:8003/poitask/1/receivedPoitask/1 - public static String RECEIVED_POI_TASK;//poi-领取任务 + public static String RECEIVED_POI_TASK=null;//poi-领取任务 //172.23.139.4:8003/poitask/1/submitPoitask?taskId=5001&name=测试修改名称&address=测试修改地址&existence=1&geo=1rn7exd5uhxy&memo=测试备注...33. - public static String SUBMIT_POI_TASK;//poi-保存本地 + public static String SUBMIT_POI_TASK=null;//poi-保存本地 //172.23.139.4:8003/othertask/1/submitOhtertask?taskId=5001&name=测试修改名称&address=测试修改地址&existence=1&geo=1rn7exd5uhxy&memo=测试备注 - public static String SUBMIT_OTHER_TASK;//其他-保存本地 + public static String SUBMIT_OTHER_TASK=null;//其他-保存本地 //172.23.139.4:8003/othertask/1/uploadpic - public static String OTHER_TASK_UPLOAD_PIC;//其他-上传 + public static String OTHER_TASK_UPLOAD_PIC=null;//其他-上传 //172.23.139.4:8003/ctask/1/receivedCtask/8608 - public static String RECEIVED_CTASK;//充电站-领取任务 + public static String RECEIVED_CTASK=null;//充电站-领取任务 //172.23.139.4:8003/ctask/1/submitCtask?id=8608&name=充电站&address=地址&telephone=18812345678|14712345678&geo=1rn7exd5uhxy&memo=测试备注&sptype=1 - public static String SUBMIT_CTASK;//充电站-保存本地 + public static String SUBMIT_CTASK=null;//充电站-保存本地 //172.23.139.4:8003/cstask/1/submitCstask?taskId=0&name=充电站&geo=1rn7exd5uhxy&memo=测试备注&sptype=1&ffid=104&existence=1&detail={"cp_openType":"1,2","cp_floor":1,"cp_availableState":0,"sign_exist":0} - public static String SUBMIT_CSTASK;//充电桩保存 + public static String SUBMIT_CSTASK=null;//充电桩保存 //172.23.139.4:8003/poitask/1/uploadpic - public static String POI_TASK_UPLOAD_PIC;//poi-上传 + public static String POI_TASK_UPLOAD_PIC=null;//poi-上传 //172.23.139.4:8003/roadtask/1/receivedRoadtask/8569 - public static String RECEIVED_ROAD_TASK;//道路任务获取 + public static String RECEIVED_ROAD_TASK=null;//道路任务获取 //172.23.139.4:8003/poivideotask/1/receivedPoivideotask/8569 - public static String RECEIVED_POI_VIDEO_TASK;//poi录像任务获取 + public static String RECEIVED_POI_VIDEO_TASK=null;//poi录像任务获取 // 172.23.139.4:8003/poivideotask/1/submitPoivideotask - public static String INSIDE_API_LIST;//poi录像 保存 + public static String INSIDE_API_LIST=null;//poi录像 保存 //172.23.139.4:8003/poivideotask/1/uploadpic - public static String POI_VIDEO_UPLOAD_PIC;//poi录像-上传 + public static String POI_VIDEO_UPLOAD_PIC=null;//poi录像-上传 //172.23.139.4:8003/roadtask/1/submitRoadtask?taskId=0&name=段哥&address=二娃&memo=1rn7exd5uhxy&workType=2 - public static String ROAD_TASK_SUBMIT;//道路录像-保存本地 + public static String ROAD_TASK_SUBMIT=null;//道路录像-保存本地 //172.23.139.4:8003/roadtask/1/uploadpic - public static String ROAD_TASK_UPLOAD_PIC;//道路录像—上传 + public static String ROAD_TASK_UPLOAD_PIC=null;//道路录像—上传 //172.23.139.4:8003/m4/task/1/getPhone?geo=1rn7exd5uhxy - public static String GET_PHONES;//电话区号和电话位数 + public static String GET_PHONES=null;//电话区号和电话位数 //172.23.139.4:8003/cstask/1/uploadpic - public static String CS_TASK_UP_LOAD_PIC;//充电桩-上传 + public static String CS_TASK_UP_LOAD_PIC=null;//充电桩-上传 //172.23.139.4:8003/ctask/1/uploadpic - public static String C_TASK_UP_LOAD_PIC;//充电站-上传 + public static String C_TASK_UP_LOAD_PIC=null;//充电站-上传 //172.23.139.4:8003/m4/task/1/taskName?geo=1rn7exd5uhxy&name=四维 - public static String TASK_NAME;//poi-查重 + public static String TASK_NAME=null;//poi-查重 //172.23.139.4:8003/m4/task/1/getCommitList?type=2&pageSize=10&pageNum=1 - public static String GET_COMMIT_LIST;//纪录——已提交 - public static String RECEIVED_POLYGON_TASK; //面状任务任务领取 + public static String GET_COMMIT_LIST=null;//纪录——已提交 + public static String RECEIVED_POLYGON_TASK=null; //面状任务任务领取 //172.23.139.4:8003/m4/task/1/unReceivedTask?taskIds=&auditIds=214,278 取消领取的接口 - public static String UNRECEIVED_POLYGON_TASK;//所有類型结束领取 - public static String COMPLETE;//面状任务结束领取 - public static String SUBMIT_POLYGON_TASK;//面状任务开始采集 + public static String UNRECEIVED_POLYGON_TASK=null;//所有類型结束领取 + public static String COMPLETE=null;//面状任务结束领取 + public static String SUBMIT_POLYGON_TASK=null;//面状任务开始采集 //dtxbmaps.navinfo.com/dtxb_test/m4/msgList/InfoPush/28/push?type=0 - public static String MESSAGE_INFO_PUSH;//消息通知 + public static String MESSAGE_INFO_PUSH=null;//消息通知 public static void initHttpInter(String USERID) { /* 我的 diff --git a/app/src/main/java/com/navinfo/outdoor/http/OkGoBuilder.java b/app/src/main/java/com/navinfo/outdoor/http/OkGoBuilder.java index fbfeab5..229623c 100644 --- a/app/src/main/java/com/navinfo/outdoor/http/OkGoBuilder.java +++ b/app/src/main/java/com/navinfo/outdoor/http/OkGoBuilder.java @@ -8,6 +8,8 @@ import com.github.lazylibrary.util.MD5; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.lzy.okgo.OkGo; +import com.lzy.okgo.cache.CacheEntity; +import com.lzy.okgo.cache.CacheMode; import com.lzy.okgo.model.HttpHeaders; import com.lzy.okgo.model.HttpParams; import com.lzy.okgo.model.Response; @@ -25,9 +27,11 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; import okhttp3.FormBody; import okhttp3.MediaType; +import okhttp3.OkHttpClient; import okhttp3.RequestBody; /** @@ -41,6 +45,8 @@ public class OkGoBuilder { */ private String url; private String file; + private int time; + /** * 参数 */ @@ -55,6 +61,7 @@ public class OkGoBuilder { private String token; private String upString; + /** * 单列模式 **/ @@ -91,6 +98,11 @@ public class OkGoBuilder { return this; } + public OkGoBuilder time(int time) { + this.time = time; + return this; + } + public OkGoBuilder file(String file) { this.file = file; return this; @@ -122,14 +134,33 @@ public class OkGoBuilder { this.clazz = clazz; return this; } + + + public void initTimeOut(int time) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.readTimeout(time, TimeUnit.SECONDS); + //全局的写入超时时间 + builder.writeTimeout(time, TimeUnit.SECONDS); + //全局的连接超时时间 + builder.connectTimeout(time, TimeUnit.SECONDS); + OkGo.getInstance().init(UserApplication.getUserApplication()).setOkHttpClient(builder.build()) + //全局统一缓存模式,默认不使用缓存,可以不传 + .setCacheMode(CacheMode.NO_CACHE) + //全局统一缓存时间,默认永不过期,可以不传 + .setCacheTime(CacheEntity.CACHE_NEVER_EXPIRE) + .setRetryCount(0); + + } + /** * post 发现-能力测评: */ - public void postCapacity(Callback callback){ + public void postCapacity(Callback callback) { if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用 - callback.onError(new Throwable("网络不可用"),2); + callback.onError(new Throwable("网络不可用"), 2); return; } + initTimeOut(time); long time = System.currentTimeMillis(); params.put("datetime", time); OkGo @@ -146,7 +177,8 @@ public class OkGoBuilder { callback.onSuccess(response.body(), 1); } else { Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show(); - } } + } + } @Override public void onError(Response response) { @@ -170,48 +202,48 @@ public class OkGoBuilder { */ public void postRequest(Callback callback) { if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用 - callback.onError(new Throwable("网络不可用"),2); + callback.onError(new Throwable("网络不可用"), 2); return; } - OkGo - // 请求方式和请求url - .post(url) - .isMultipart(true) - .headers(getHeader()) - .params(params) + initTimeOut(time); + OkGo + // 请求方式和请求url + .post(url) + .isMultipart(true) + .headers(getHeader()) + .params(params) // .upJson(json) - // 请求的 tag, 主要用于取消对应的请求 - .tag(this) - - // 设置当前请求的缓存key,建议每个不同功能的请求设置一个 + // 请求的 tag, 主要用于取消对应的请求 + .tag(this) + // 设置当前请求的缓存key,建议每个不同功能的请求设置一个 // .cacheKey("cacheKey") - // 缓存模式,详细请看缓存介绍 + // 缓存模式,详细请看缓存介绍 // .cacheMode(CacheMode.DEFAULT) - .execute(new DialogCallback(clazz) { - @Override - public void onSuccess(Response response) { - if (response.code() == 200) { - callback.onSuccess(response.body(), 1); - } else { - Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show(); - } + .execute(new DialogCallback(clazz) { + @Override + public void onSuccess(Response response) { + if (response.code() == 200) { + callback.onSuccess(response.body(), 1); + } else { + Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show(); } + } - @Override - public void onError(Response response) { - super.onError(response); - Throwable throwable = response.getException(); - if (throwable != null) { - throwable.printStackTrace(); - callback.onError(throwable, 2); - /* - * 友盟+ - * 使用自定义错误,查看时请在错误列表页面选择【自定义异常】 - */ - UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException"); - } + @Override + public void onError(Response response) { + super.onError(response); + Throwable throwable = response.getException(); + if (throwable != null) { + throwable.printStackTrace(); + callback.onError(throwable, 2); + /* + * 友盟+ + * 使用自定义错误,查看时请在错误列表页面选择【自定义异常】 + */ + UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException"); } - }); + } + }); } public HttpHeaders getHeader() { @@ -251,6 +283,7 @@ public class OkGoBuilder { if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用 return null; } + initTimeOut(time); long time = System.currentTimeMillis(); params.put("datetime", time); try { @@ -280,9 +313,10 @@ public class OkGoBuilder { */ public void postFileAsynchronous(Callback callback) { if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用 - callback.onError(new Throwable("网络不可用"),2); + callback.onError(new Throwable("网络不可用"), 2); return; } + initTimeOut(time); long time = System.currentTimeMillis(); params.put("datetime", time); OkGo @@ -331,12 +365,12 @@ public class OkGoBuilder { */ public void getRequest(Callback callback) { if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用 - callback.onError(new Throwable("网络不可用"),2); + callback.onError(new Throwable("网络不可用"), 2); return; } + initTimeOut(time); long time = System.currentTimeMillis(); params.put("datetime", time); - OkGo // 请求方式和请求url .get(url) @@ -356,7 +390,6 @@ public class OkGoBuilder { } else { Toast.makeText(activity, response.message(), Toast.LENGTH_SHORT).show(); } - } @Override @@ -382,6 +415,7 @@ public class OkGoBuilder { Toast.makeText(activity, "网络不可用,请检查网络", Toast.LENGTH_SHORT).show(); return null; } + initTimeOut(time); long time = System.currentTimeMillis(); params.put("datetime", time); try { diff --git a/app/src/main/java/com/navinfo/outdoor/room/PoiDatabase.java b/app/src/main/java/com/navinfo/outdoor/room/PoiDatabase.java index a1b4d8a..1bf7da8 100644 --- a/app/src/main/java/com/navinfo/outdoor/room/PoiDatabase.java +++ b/app/src/main/java/com/navinfo/outdoor/room/PoiDatabase.java @@ -37,7 +37,7 @@ public abstract class PoiDatabase extends RoomDatabase { return instance; } private static PoiDatabase create(final Context context) { - File dbFolder = new File(Constant.POI_DAO); // 数据库文件夹路径 + File dbFolder = new File(Constant.POI_DAO+""); // 数据库文件夹路径 if (!dbFolder.exists()) { SdkFolderCreate.mkdirs(dbFolder.getAbsolutePath()); } diff --git a/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java b/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java index 2ec6173..2462f20 100644 --- a/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java +++ b/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java @@ -33,14 +33,14 @@ public class PoiEntity implements Serializable { private String precision;//金额 private String photo;//照片信息 private boolean checked; - private String geoWkt; // 数据的wkt + private String geoWkt; //原先的数据的wkt //ROOM不支持直接存储集合 @TypeConverters(PhotoInfoConverter.class) private List photoInfo;//照片信息 private int existence;//是否存在 不存在对应 0 存在对应 1 无法验证对应 2 private String x;//经度 private String y;//纬度 - private String detail;//深度信息 + private String detail;//需要保存的数据的wkt private String dist;//距离用户位置 private int taskStatus;//任务状态 0.未领取 1.已领取,5 立即采集,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集) private int type;//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务" diff --git a/app/src/main/java/com/navinfo/outdoor/util/FlushTokenUtil.java b/app/src/main/java/com/navinfo/outdoor/util/FlushTokenUtil.java new file mode 100644 index 0000000..a7c842a --- /dev/null +++ b/app/src/main/java/com/navinfo/outdoor/util/FlushTokenUtil.java @@ -0,0 +1,167 @@ +package com.navinfo.outdoor.util; + +import android.app.Activity; +import android.content.Context; +import android.content.SharedPreferences; +import android.util.Log; +import android.view.View; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; + +import com.kongzue.dialog.interfaces.OnDialogButtonClickListener; +import com.kongzue.dialog.util.BaseDialog; +import com.kongzue.dialog.util.DialogSettings; +import com.kongzue.dialog.v3.MessageDialog; +import com.lzy.okgo.model.HttpParams; +import com.navinfo.outdoor.api.Constant; +import com.navinfo.outdoor.bean.LoginOauthTokenBean; +import com.navinfo.outdoor.bean.UserDetailBean; +import com.navinfo.outdoor.http.Callback; +import com.navinfo.outdoor.http.HttpInterface; +import com.navinfo.outdoor.http.OkGoBuilder; + +import java.util.Objects; + +/** + * 刷新token 203 + */ +public class FlushTokenUtil { + + private static SharedPreferences.Editor navInfoEditor; + + public static void flushToken(Activity activity) { + Constant.isPresent=true; + DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; + MessageDialog.show((AppCompatActivity) Objects.requireNonNull(activity), "提示", "登录已过期,是否重新登录", "确定").setOnOkButtonClickListener(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + initLogin(activity); + return false; + } + }); + } + + private static void initLogin(Activity activity){ + SharedPreferences navInfo = activity.getSharedPreferences(Constant.SHARED_PREFERENCES, Context.MODE_PRIVATE); + navInfoEditor = navInfo.edit(); + if (Constant.USHERED == null) { + return; + }else { + if (HttpInterface.USER_LOGIN_OAUTH_TOKEN == null) { + return; + } + } + try { + HttpParams httpParams = new HttpParams(); + long time = System.currentTimeMillis(); + httpParams.put("grant_type", "refresh_token"); + httpParams.put("refresh_token", Constant.REFRESH_TOKEN); + httpParams.put("datetime", time); + OkGoBuilder okGoBuilder = OkGoBuilder.getInstance() + .time(30) + .Builder(activity) + .url(HttpInterface.USER_LOGIN_OAUTH_TOKEN) + .cls(LoginOauthTokenBean.class) + .params(httpParams); + okGoBuilder.postRequest(new Callback() { + @Override + public void onSuccess(LoginOauthTokenBean response, int id) { + if (response.getCode() == 200) { + LoginOauthTokenBean.BodyBean body = response.getBody(); + if (body.getUserId() != null && !body.getUserId().equals("")) { + Constant.initRootFolder(body.getUserId()); + HttpInterface.initHttpInter(body.getUserId()); + } + navInfoEditor.putString("access_token", body.getAccess_token()); + Constant.ACCESS_TOKEN = body.getAccess_token(); + navInfoEditor.putString("refresh_token", body.getRefresh_token()); + Constant.REFRESH_TOKEN = body.getRefresh_token(); + navInfoEditor.putString("user_id", body.getUserId()); + Constant.USHERED = body.getUserId(); + navInfoEditor.apply(); + if (HttpInterface.USER_DETAIL_BY_USER_ID == null) { + Toast.makeText(activity, "token :更新成功", Toast.LENGTH_SHORT).show(); + } else { + initGetUserInfo(activity);//获取用户信息 + } + + } else { + Toast.makeText(activity, response.getMessage(), Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onError(Throwable e, int id) { + Toast.makeText(activity, e.getMessage(), Toast.LENGTH_SHORT).show(); + Log.d("TAG", "onError: " + e.getMessage()); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static void initGetUserInfo(Activity activity) { + OkGoBuilder okGoBuilder = OkGoBuilder.getInstance() + .time(30) + .Builder(activity) + .url(HttpInterface.USER_DETAIL_BY_USER_ID) + .token(Constant.ACCESS_TOKEN) + .params(new HttpParams()) + .cls(UserDetailBean.class); + okGoBuilder.getRequest(new Callback() { + @Override + public void onSuccess(UserDetailBean response, int id) { + if (response.getCode() == 200) { + UserDetailBean.BodyBean body = response.getBody(); + if (body != null) { + navInfoEditor.putString("username", body.getUsername()); + Constant.USER_NAME = body.getUsername(); + navInfoEditor.putString("mobile", body.getMobile()); + Constant.MOBILE = body.getMobile(); + navInfoEditor.putInt("sex", body.getSex());//0:女 1:男 + Constant.SEX = body.getSex(); + navInfoEditor.putString("qq", body.getQq()); + Constant.QQ = body.getQq(); + navInfoEditor.putString("wechat", body.getWechat()); + Constant.WCHAR = body.getWechat(); + navInfoEditor.putInt("level", body.getLevel()); + Constant.LEVEL = body.getLevel(); + UserDetailBean.BodyBean.UserBankcardBean userBankcard = body.getUserBankcard(); + if (userBankcard != null) {//存储银行卡信息 + navInfoEditor.putString("bankAccount", userBankcard.getBankAccount());//银行卡号 + Constant.BACKGROUND = userBankcard.getBankAccount(); + navInfoEditor.putString("idNumber", userBankcard.getIdNumber());//身份证号 + Constant.ID_NUMBER = userBankcard.getIdNumber(); + navInfoEditor.putString("bankName", userBankcard.getBankName());//銀行姓名 + Constant.BACKGROUND_NAME = userBankcard.getBankName(); + } + UserDetailBean.BodyBean.UserAuthBean userAuth = body.getUserAuth(); + if (userAuth != null) {//存储身份证信息 + navInfoEditor.putString("name", userAuth.getName());//身份证姓名 + Constant.NAME = userAuth.getName(); + navInfoEditor.putString("idnum", userAuth.getIdnum());//身份证号码 + Constant.ID_NUM = userAuth.getIdnum(); + navInfoEditor.putInt("auditstatus", userAuth.getAuditstatus());//审核状态 + Constant.AUDIOTAPES = userAuth.getAuditstatus(); + navInfoEditor.putString("auditmsg", userAuth.getAuditmsg());//审核信息 + Constant.AUDITING = userAuth.getAuditmsg(); + } + navInfoEditor.commit(); + Toast.makeText(activity, "token :更新成功", Toast.LENGTH_SHORT).show(); + } + } else { + Toast.makeText(activity, response.getMessage(), Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onError(Throwable e, int id) { + Toast.makeText(activity, e.getMessage(), Toast.LENGTH_SHORT).show(); + Log.d("TAG", "onError: " + e.getMessage()); + } + }); + } + +} diff --git a/app/src/main/java/com/navinfo/outdoor/util/PoiEntityDeleteUtil.java b/app/src/main/java/com/navinfo/outdoor/util/PoiEntityDeleteUtil.java index 084c0a2..0a6b5b3 100644 --- a/app/src/main/java/com/navinfo/outdoor/util/PoiEntityDeleteUtil.java +++ b/app/src/main/java/com/navinfo/outdoor/util/PoiEntityDeleteUtil.java @@ -38,6 +38,8 @@ public class PoiEntityDeleteUtil { for (int i = 0; i < fileListByUUID.size(); i++) { fileListByUUID.get(i).delete(); } + File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId()); + filePath.delete(); } diff --git a/app/src/main/java/com/navinfo/outdoor/util/PoiSaveUtils.java b/app/src/main/java/com/navinfo/outdoor/util/PoiSaveUtils.java index abfef2d..73b080f 100644 --- a/app/src/main/java/com/navinfo/outdoor/util/PoiSaveUtils.java +++ b/app/src/main/java/com/navinfo/outdoor/util/PoiSaveUtils.java @@ -182,7 +182,10 @@ public class PoiSaveUtils { return -1; } try { - Response execute = OkGoBuilder.getInstance().url(url) + Response execute = OkGoBuilder + .getInstance() + .url(url) + .time(30) .Builder(mContext) .token(Constant.ACCESS_TOKEN).params(httpParams).getSynchronization(); if (execute == null) { @@ -237,23 +240,10 @@ public class PoiSaveUtils { */ public void uploadPoiNet(PoiEntity poiEntity) { if (poiEntity == null) { - mContext.runOnUiThread(new Runnable() { - @Override - public void run() { - Toast.makeText(mContext, "无法获取POI数据", Toast.LENGTH_SHORT).show(); - } - }); - return; } int bodyId = poiEntity.getBodyId(); if (bodyId == 0) { - mContext.runOnUiThread(new Runnable() { - @Override - public void run() { - Toast.makeText(mContext, "该数据未保存到服务,无法上传", Toast.LENGTH_SHORT).show(); - } - }); return; } ArrayList photoFile = new ArrayList<>(); @@ -341,6 +331,7 @@ public class PoiSaveUtils { HttpParams httpParams = new HttpParams(); httpParams.put("auditId", poiEntity.getBodyId()); Response execute = OkGoBuilder.getInstance() + .time(0) .Builder(mContext) .url(url) .params(httpParams) @@ -434,6 +425,7 @@ public class PoiSaveUtils { httpParams.put("detail", String.valueOf(hashMap)); try { Response execute = OkGoBuilder.getInstance() + .time(30) .Builder(mContext) .url(HttpInterface.SUBMIT_CSTASK) .token(Constant.ACCESS_TOKEN) @@ -494,12 +486,6 @@ public class PoiSaveUtils { */ private int chargingPileUploadNetWork(ChargingPileEntity chargingPileEntity) { if (chargingPileEntity == null || chargingPileEntity.getBodyId() == 0) { - mContext.runOnUiThread(new Runnable() { - @Override - public void run() { - Toast.makeText(mContext, "没有保存本地", Toast.LENGTH_SHORT).show(); - } - }); return -1; } @@ -514,6 +500,7 @@ public class PoiSaveUtils { HttpParams httpParams = new HttpParams(); httpParams.put("auditId", chargingPileEntity.getBodyId()); Response execute = OkGoBuilder.getInstance() + .time(0) .Builder(mContext) .url(HttpInterface.CS_TASK_UP_LOAD_PIC) .token(Constant.ACCESS_TOKEN) @@ -555,7 +542,7 @@ public class PoiSaveUtils { // @Override // public void onSuccess(Response poiUploadBeanResponse) { // dismissLoadingDialog(); -// Toast.makeText(getActivity(), "上传成功", Toast.LENGTH_SHORT).show(); +// .makeText(getActivity(), "上传成功", Toast.LENGTH_SHORT).show(); // isChargingPoleUploaded = true; // if (isChargeStationUploaded && isChargingPoleUploaded) { // getActivity().runOnUiThread(new Runnable() { diff --git a/app/src/main/java/com/navinfo/outdoor/util/UploadUtils.java b/app/src/main/java/com/navinfo/outdoor/util/UploadUtils.java index 431dd86..47de6a8 100644 --- a/app/src/main/java/com/navinfo/outdoor/util/UploadUtils.java +++ b/app/src/main/java/com/navinfo/outdoor/util/UploadUtils.java @@ -72,6 +72,8 @@ public class UploadUtils { }); } }).start(); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(mContext); } else { Message obtain1 = Message.obtain(); obtain1.what = Constant.NEST_WORD_SUBMIT; @@ -127,6 +129,8 @@ public class UploadUtils { }); } }).start(); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(mContext); } else { Message obtain1 = Message.obtain(); obtain1.what = Constant.NEST_WORD_SUBMIT; @@ -188,6 +192,8 @@ public class UploadUtils { }); } }).start(); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(mContext); } else { Message obtain1 = Message.obtain(); obtain1.what = Constant.NEST_WORD_SUBMIT; @@ -243,6 +249,8 @@ public class UploadUtils { }); } }).start(); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(mContext); } else { Message obtain1 = Message.obtain(); obtain1.what = Constant.NEST_WORD_SUBMIT; @@ -299,6 +307,8 @@ public class UploadUtils { }); } }).start(); + }else if (response.getCode()==203){ + FlushTokenUtil.flushToken(mContext); } else { Message obtain1 = Message.obtain(); obtain1.what = Constant.NEST_WORD_SUBMIT; diff --git a/app/src/main/res/layout/activity_pictures.xml b/app/src/main/res/layout/activity_pictures.xml index 7e00d9e..dd64522 100644 --- a/app/src/main/res/layout/activity_pictures.xml +++ b/app/src/main/res/layout/activity_pictures.xml @@ -59,15 +59,24 @@ app:layout_constraintWidth_default="percent" app:layout_constraintWidth_percent="0.4" /> + + android:background="?android:attr/selectableItemBackground" + android:layout_height="wrap_content"> + app:layout_constraintTop_toTopOf="@id/iv_tas_capacity" + /> + app:layout_constraintTop_toTopOf="@+id/iv_tas_capacity"> @@ -39,7 +39,7 @@ + android:text="试题测试" /> @@ -157,7 +157,7 @@ android:id="@+id/poiVideo_audit_process" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="1" + android:text="0" android:textSize="12sp" /> @@ -257,7 +257,7 @@ android:id="@+id/road_audit_process" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="1" + android:text="0" android:textSize="12sp" /> @@ -352,7 +352,7 @@ android:id="@+id/charging_audit_process" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="1" + android:text="0" android:textSize="12sp" /> @@ -449,7 +449,7 @@ android:id="@+id/other_audit_process" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="1" + android:text="0" android:textSize="12sp" /> diff --git a/app/src/main/res/layout/fragment_other.xml b/app/src/main/res/layout/fragment_other.xml index 1a4dc41..b3b7774 100644 --- a/app/src/main/res/layout/fragment_other.xml +++ b/app/src/main/res/layout/fragment_other.xml @@ -12,7 +12,6 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> - @@ -400,7 +397,6 @@ android:text="上传" /> - \ No newline at end of file diff --git a/app/src/main/res/layout/tas_explain_item.xml b/app/src/main/res/layout/tas_explain_item.xml index a6eb5ae..497d39e 100644 --- a/app/src/main/res/layout/tas_explain_item.xml +++ b/app/src/main/res/layout/tas_explain_item.xml @@ -1,36 +1,39 @@ - + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="?android:attr/selectableItemBackground" + android:orientation="vertical"> + + + - + app:layout_constraintTop_toTopOf="@id/iv_tas_explain" /> + + \ No newline at end of file