From 4c84731beee3e452f5ced8d9a26b4dc11feed26e Mon Sep 17 00:00:00 2001 From: wangdongsheng Date: Fri, 17 Sep 2021 16:48:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B92.17=E5=8F=B7=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 +- .../outdoor/activity/LoginActivity.java | 2 - .../outdoor/activity/MainActivity.java | 1 - .../outdoor/activity/PhotographActivity.java | 14 +-- .../outdoor/activity/PicturesActivity.java | 87 ++++++++++++------- .../outdoor/activity/UserActivity.java | 6 +- .../com/navinfo/outdoor/api/Constant.java | 5 +- .../fragment/CapacityMeasurementFragment.java | 56 +++++++----- .../outdoor/fragment/GatheringFragment.java | 16 +--- .../navinfo/outdoor/http/HttpInterface.java | 40 +++------ .../com/navinfo/outdoor/http/OkGoBuilder.java | 42 +++++++++ app/src/main/res/layout/activity_login.xml | 1 - .../main/res/layout/activity_photograph.xml | 22 ++--- app/src/main/res/layout/activity_pictures.xml | 2 + 14 files changed, 176 insertions(+), 122 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d3987bb..49da15d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "com.navinfo.outdoor" minSdkVersion 22 targetSdkVersion 30 - versionCode 2 - versionName "2.0" + versionCode 3 + versionName "3.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } lintOptions { 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 8c68c07..3f411ba 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/LoginActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/LoginActivity.java @@ -114,8 +114,6 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener if (pass_word!=null&&!pass_word.equals("")){ etLoginPaw.setText(pass_word); } - - } @Override 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 6967e4c..880a78d 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/MainActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/MainActivity.java @@ -315,6 +315,5 @@ public class MainActivity extends BaseActivity { Constant.ACCESS_TOKEN= navInfo.getString("access_token", null);; HttpInterface.initAppPath(user_id); initPermission(); - } } \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/outdoor/activity/PhotographActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/PhotographActivity.java index 50627d5..9d0da95 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/PhotographActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/PhotographActivity.java @@ -79,12 +79,13 @@ public class PhotographActivity extends BaseActivity implements View.OnClickList private static final CameraLogger LOG = CameraLogger.create("Picture"); private CameraView cameraView; private String photo_path; + private int oration; + + @Override public void onClick(View v) { if (v.getId() == R.id.capture_picture) { - SystemTTS.getInstance(PhotographActivity.this).playText("11aa"); - cameraView.takePicture(); } @@ -107,6 +108,7 @@ public class PhotographActivity extends BaseActivity implements View.OnClickList super.initView(); if (getIntent()!=null){ photo_path = getIntent().getStringExtra(Constant.INTENT_PHOTO_PATH); + oration = getIntent().getIntExtra(Constant.INTENT_VIDEO_OBLATION,-1); } this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); CameraLogger.setLogLevel(CameraLogger.LEVEL_VERBOSE); @@ -118,9 +120,11 @@ public class PhotographActivity extends BaseActivity implements View.OnClickList @Override public void onPictureTaken(@NonNull PictureResult result) { super.onPictureTaken(result); - if (Objects.requireNonNull(cameraView.getPictureSize()).getWidth() < cameraView.getPictureSize().getHeight()) { - Toast.makeText(PhotographActivity.this, "不允许竖向拍摄...", Toast.LENGTH_SHORT).show(); - return; + if (oration!=1){ + if (Objects.requireNonNull(cameraView.getPictureSize()).getWidth() < cameraView.getPictureSize().getHeight()) { + Toast.makeText(PhotographActivity.this, "不允许竖向拍摄...", Toast.LENGTH_SHORT).show(); + return; + } } File file = new File(photo_path); result.toFile(file, new FileCallback() { 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 58e5c93..29baf37 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java @@ -1,8 +1,5 @@ package com.navinfo.outdoor.activity; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - import android.annotation.SuppressLint; import android.content.Intent; import android.content.pm.ActivityInfo; @@ -13,9 +10,7 @@ import android.graphics.Matrix; import android.os.Bundle; import android.os.Handler; import android.os.Message; -import android.os.PersistableBundle; import android.util.DisplayMetrics; -import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.Button; @@ -23,8 +18,12 @@ import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import com.github.lazylibrary.util.FileUtils; import com.navinfo.outdoor.R; import com.navinfo.outdoor.api.Constant; @@ -35,13 +34,11 @@ 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.otaliastudios.cameraview.CameraException; import com.otaliastudios.cameraview.CameraListener; import com.otaliastudios.cameraview.CameraLogger; import com.otaliastudios.cameraview.CameraView; import com.otaliastudios.cameraview.FileCallback; import com.otaliastudios.cameraview.PictureResult; -import com.otaliastudios.cameraview.VideoResult; import com.otaliastudios.cameraview.controls.Mode; import com.tencent.map.geolocation.TencentLocation; import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; @@ -64,7 +61,6 @@ import com.vividsolutions.jts.geom.Geometry; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import org.jetbrains.annotations.NotNull; import java.io.File; import java.text.SimpleDateFormat; @@ -89,12 +85,13 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen private Polyline polyline; private String finalVideoPath; // 摄像后最终保存的文件名 private ViewGroup layerChange; // 切换地图和相机的父控件 - private CheckBox capturePicture, cbMapType;//拍照 + private CheckBox capturePicture,cbMapType;//拍照 private boolean isMapSlide = false; private SimpleDateFormat formatter; private File paperFile; private int poi_video_type; private ImageView ivZoomAdd, ivZoomDel, ivLocation; + private TencentLocation oldCurrentLocation = null; private Handler handler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(@NonNull Message msg) { @@ -117,9 +114,9 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen private Timer timer; private TimerTask timerTask; private int videoIndex = -1; - private int oration; + private int oration; private ImageView ivPicImage; - private SystemTTS instance; + private SystemTTS systemTTS; @Override protected int getLayout() { @@ -135,7 +132,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen 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); + 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); assert finalVideoPath != null; @@ -144,17 +141,17 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen } formatter = new SimpleDateFormat("yyyyMMdd HHmmss"); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + systemTTS = SystemTTS.getInstance(PicturesActivity.this); ivMap = findViewById(R.id.iv_map); ivMap.setOnClickListener(this); ivPicImage = findViewById(R.id.iv_pic); - if (poi_video_type==1||poi_video_type==2){ + if (poi_video_type == 1 || poi_video_type == 2) { ivPicImage.setImageResource(R.mipmap.take_poi_video_arrow); - }else if (poi_video_type==3){ + } else if (poi_video_type == 3) { ivPicImage.setImageResource(R.mipmap.take_pic_arrow); } btnSwitch = findViewById(R.id.btn_switch); btnSwitch.setOnClickListener(this); - //相机记录器 CameraLogger.setLogLevel(CameraLogger.LEVEL_VERBOSE); ivZoomAdd = findViewById(R.id.iv_zoom_add); @@ -246,7 +243,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen finalVideoPath = Objects.requireNonNull(file.getParentFile()).getAbsolutePath() + "/" + (videoIndex + 1) + ".jpg"; Toast.makeText(PicturesActivity.this, "保存成功:" + (videoIndex + 1), Toast.LENGTH_SHORT).show(); } - if (poi_video_type==2){ + if (poi_video_type == 2) { Message message = new Message(); message.what = 0x103; handler.sendMessage(message); @@ -336,10 +333,10 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen case R.id.iv_location://定位: if (Constant.currentLocation != null) { CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition( - new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度 - tencentMap.getCameraPosition().zoom, //目标缩放级别 - 0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0) - 0)); //目标旋转角 0~360° (正北方为0) + new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度 + tencentMap.getCameraPosition().zoom, //目标缩放级别 + 0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0) + 0)); //目标旋转角 0~360° (正北方为0) tencentMap.animateCamera(cameraSigma); } break; @@ -468,6 +465,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen protected void onDestroy() { super.onDestroy(); camera.destroy(); + systemTTS.stopSpeak(); stopTimer(); if (polyline != null) { polyline.remove(); @@ -482,7 +480,6 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen } - @Subscribe(threadMode = ThreadMode.MAIN) public void onEventMessageMainThread(Message msg) { if (msg.what == Constant.EVENT_WHAT_LOCATION_CHANGE) { // 用户位置更新 @@ -493,13 +490,12 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen tencentMap.getCameraPosition().zoom, //目标缩放级别 0, //目标倾斜角 tencentLocation.getBearing())); //目标旋转角 0~360° (正北方为0) - float speed = tencentLocation.getSpeed(); - Log.d("TAG", "onEventMessageMainThread: "+speed); tencentMap.animateCamera(cameraSigma); } } } + @SuppressLint("SetTextI18n") public void initMarkerPaper() { // 记录当前时间、视频时间、以及当前经纬度信息 StringBuilder sb = new StringBuilder(); @@ -518,6 +514,37 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen } 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 + if (poi_video_type == 1) { + if (a > 25) {//25千米/h + systemTTS.playText("您已超速"); + } + } else if (poi_video_type == 3) { + if (a > 70) {//70千米/h + systemTTS.playText("您已超速"); + } + } + } else { + if (oldCurrentLocation != null) { + LatLng startLatLng = new LatLng(oldCurrentLocation.getLatitude(), oldCurrentLocation.getLongitude()); //旧的坐标, + LatLng endLatLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude());//新的坐标 + double geometry = GeometryTools.distanceToDouble(startLatLng, endLatLng);//米 + if (poi_video_type == 1) { + double speeds = ((geometry / 2) * 3600 / 1000); + if (speeds > 25) {//25千米/h + systemTTS.playText("您已超速"); + } + } else if (poi_video_type == 3) { + double speeds = ((geometry / 1.5) * 3600 / 1000); + if (speeds > 70) {//70千米/h + systemTTS.playText("您已超速"); + } + } + } + oldCurrentLocation = Constant.currentLocation; + } } public void initMarker() { @@ -546,13 +573,13 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen } } }; - if (poi_video_type==2){ - timer.schedule(timerTask, 0); - }else if (poi_video_type==1){ - timer.schedule(timerTask, 0, 2000); - }else if (poi_video_type==3){ - timer.schedule(timerTask, 0, 1500); - } + if (poi_video_type == 2) { + timer.schedule(timerTask, 0); + } else if (poi_video_type == 1) { + timer.schedule(timerTask, 0, 2000); + } else if (poi_video_type == 3) { + timer.schedule(timerTask, 0, 1500); + } } private void stopTimer() { 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 bdd8aa1..47bc656 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/UserActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/UserActivity.java @@ -77,6 +77,9 @@ public class UserActivity extends BaseActivity implements View.OnClickListener { btnAttestation.setOnClickListener(this); Button btnGathering = findViewById(R.id.btn_gathering); btnGathering.setOnClickListener(this); + if (Constant.ID_NUMBER!=null){ + btnGathering.setText("已绑定"); + } region = findViewById(R.id.region); region.setOnClickListener(this); LinearLayout llRegion = findViewById(R.id.ll_region); @@ -121,7 +124,6 @@ public class UserActivity extends BaseActivity implements View.OnClickListener { if (Constant.AUDIOTAPES ==-1){ Toast.makeText(this, "请先实名认证", Toast.LENGTH_SHORT).show(); }else if (Constant.AUDIOTAPES ==1){//认证通过 - Intent gatheringIntent = new Intent(this, FragmentManagement.class); gatheringIntent.putExtra("tag", 24); startActivity(gatheringIntent); @@ -200,8 +202,10 @@ public class UserActivity extends BaseActivity implements View.OnClickListener { Toast.makeText(this, "此功能未开通", Toast.LENGTH_SHORT).show(); break; } + } + private void netWork(HttpParams httpParams) { showLoadingDialog(); OkGoBuilder.getInstance() diff --git a/app/src/main/java/com/navinfo/outdoor/api/Constant.java b/app/src/main/java/com/navinfo/outdoor/api/Constant.java index 4c2c868..7a344e4 100644 --- a/app/src/main/java/com/navinfo/outdoor/api/Constant.java +++ b/app/src/main/java/com/navinfo/outdoor/api/Constant.java @@ -182,14 +182,11 @@ public class Constant { public static final String INTENT_PHOTO_PATH = "INTENT_PHOTO_PATH"; // 拍照界面指定的图片保存位置 public static final String INTENT_PICTURES_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置 public static final String INTENT_VIDEO_OBLATION = "INTENT_VIDEO_OBLATION"; // 视频拍摄时屏幕方向 0-强制横屏 其他-任意 - public static SlidingUpPanelLayout SLIDING_LAYOUT = null;//設置 - public static boolean IS_FILTER_LIST_ITEM = true;//poi页面的查重 - public static TencentMap.OnMarkerClickListener markerClickListener=null; - public static final String NAVIN_FO="9.15";//版本 + public static final String NAVIN_FO="9.17";//版本 /** * 联系我们的QQ群名称和QQ群号 diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/CapacityMeasurementFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/CapacityMeasurementFragment.java index e3b3b0e..4831d94 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/CapacityMeasurementFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/CapacityMeasurementFragment.java @@ -50,6 +50,7 @@ public class CapacityMeasurementFragment extends BaseFragment implements View.On private ArrayList examBeans; private String examId; private Gson gson; + private Button btn; public static CapacityMeasurementFragment newInstance(Bundle bundle) { CapacityMeasurementFragment fragment = new CapacityMeasurementFragment(); @@ -71,7 +72,7 @@ public class CapacityMeasurementFragment extends BaseFragment implements View.On capacityMeasurementRel.setLayoutManager(new LinearLayoutManager(getActivity())); capacityMeasureAdapter = new CapacityMeasureAdapter(getActivity()); capacityMeasurementRel.setAdapter(capacityMeasureAdapter); - Button btn = findViewById(R.id.btn); + btn = findViewById(R.id.btn); btn.setOnClickListener(this); gson = new Gson(); } @@ -118,7 +119,7 @@ public class CapacityMeasurementFragment extends BaseFragment implements View.On if (baleen != null) { capacityMeasureAdapter.setMeasureList(baleen); } - Log.d("TAG", "onSuccess: " + response.toString() ); + Log.d("TAG", "onSuccess: " + response.toString()); } @Override @@ -162,6 +163,8 @@ public class CapacityMeasurementFragment extends BaseFragment implements View.On examBeans.add(examBean); } initExamSubmit(); + } else { + Toast.makeText(getActivity(), "无数据", Toast.LENGTH_SHORT).show(); } } catch (JSONException e) { e.printStackTrace(); @@ -171,25 +174,28 @@ public class CapacityMeasurementFragment extends BaseFragment implements View.On } private void initExamSubmit() throws JSONException { - showLoadingDialog(); Map map = new HashMap<>(); - map.put("examId",examId); - map.put("answerList",examBeans); - + map.put("examId", examId); + map.put("answerList", examBeans); String json = gson.toJson(map); examBeans.clear(); - OkGo - // 请求方式和请求url - .post(HttpInterface.EXAM_SUBMIT) - .upString(json, MediaType.parse("application/json")) - // 请求的 tag, 主要用于取消对应的请求 - .tag(this) - .execute(new DialogCallback(ExamSubmitBean.class) { + showLoadingDialog(); + OkGoBuilder.getInstance() + .Builder(getActivity()) + .url(HttpInterface.EXAM_SUBMIT) + .cls(ExamSubmitBean.class) + .token(Constant.ACCESS_TOKEN) + .json(json) + .postCapacity(new Callback() { @Override - public void onSuccess(Response response) { + public void onSuccess(ExamSubmitBean response, int id) { dismissLoadingDialog(); - if (response.code()==200){ - if (response.body().equals("0")) { + if (response.getCode() == 200) { + + + + + if (response.getCode().equals("0")) { MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "不通过", "确定", "取消").setOkButton(new OnDialogButtonClickListener() { @Override public boolean onClick(BaseDialog baseDialog, View v) { @@ -201,23 +207,27 @@ public class CapacityMeasurementFragment extends BaseFragment implements View.On MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "通过", "确定", "取消").setOkButton(new OnDialogButtonClickListener() { @Override public boolean onClick(BaseDialog baseDialog, View v) { + return false; } }); } - }else { - Toast.makeText(getActivity(), response.message(), Toast.LENGTH_SHORT).show(); + + } else { + Toast.makeText(getActivity(), response.getMessage(), Toast.LENGTH_SHORT).show(); + + + } Log.d("TAG", "onSuccess: " + response.toString()); } + @Override - public void onError(Response response) { - super.onError(response); + public void onError(Throwable e, int id) { dismissLoadingDialog(); - Toast.makeText(getActivity(), response.message(), Toast.LENGTH_SHORT).show(); - Log.d("TAG", "onError: " + response.message()); + Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show(); + Log.d("TAG", "onError: " + e.getMessage()); } }); - } } \ No newline at end of file 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 fd4b960..fb8c591 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/GatheringFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/GatheringFragment.java @@ -95,16 +95,7 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe TextView tvName = (TextView) findViewById(R.id.tv_name); etBankNum = (EditText) findViewById(R.id.et_bank_num); gatheringCamera = (ImageView) findViewById(R.id.gathering_camera); - gatheringCamera.setOnClickListener(this);/* - String bankAccount = navInfo.getString("bankAccount", null); - String bank = navInfo.getString("bankName", null); - String idNumber = navInfo.getString("idNumber", null); - if (bankAccount!=null&&!bankAccount.equals("")&&bank!=null&&!bank.equals("")&&idNumber!=null&&!idNumber.equals("")){ - etBankNum.setText(idNumber); - tvBank.setText(bank); - value=bankAccount; - btnBank.setText("重新绑定"); - }*/ + gatheringCamera.setOnClickListener(this); if (Constant.NAME!=null){ tvName.setText(Constant.NAME); } @@ -173,6 +164,7 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe Intent gatheringNumberIntent = new Intent(getActivity(), PhotographActivity.class); File file = PhotoUtils.showPhotoFile("a", null); gatheringNumberIntent.putExtra(Constant.INTENT_PHOTO_PATH, file.getPath()); + gatheringNumberIntent.putExtra(Constant.INTENT_VIDEO_OBLATION, 1); startActivityForResult(gatheringNumberIntent, 131); break; } @@ -225,10 +217,6 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe Constant.BACKGROUND =value; Constant.BACKGROUND_NAME=bank; Constant.ID_NUMBER = etBankAccount; - /*navInfoEditor.putString("bankAccount", value); - navInfoEditor.putString("idNumber", etBankAccount); - navInfoEditor.putString("bankName",bank); - navInfoEditor.commit();*/ getActivity().finish(); return false; } 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 880ef94..26da599 100644 --- a/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java +++ b/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java @@ -8,25 +8,20 @@ public class HttpInterface { public static final String IP_TEXt = "http://dtxbmaps.navinfo.com/dtxb_test/m4";//测试接口 public static final String TEST_GUIDANCE_IP = "http://172.21.98.90:9999/m4";//引导页完成接口 public static final String APKIP = "http://172.23.139.4:8001/"; - 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/";//任务 - /** - * 用户版本升级 + /* 用户版本升级 */ - //dtxbmaps.navinfo.com/dtxb/m4/user/appVersion/checkVersion?version=155&operationType=android - //172.23.139.4:8001/appVersion/checkVersion?version=155&operationType=android version是版本 operationType固定值 安卓 get + // dtxbmaps.navinfo.com/dtxb/m4/user/appVersion/checkVersion?version=155&operationType=android + // 172.23.139.4:8001/appVersion/checkVersion?version=155&operationType=android version是版本 operationType固定值 安卓 get public static String APP_CHECK_VERSION; //版本升级 - public static void initAppPath(String userId) { APP_CHECK_VERSION = IP + USER_PATH + "appVersion/" + userId + "/checkVersion"; //版本升级 } - - /** - * 我的 + /* 我的 * Path=/m4/user/* */ //172.23.139.4:8001/m4/user/update @@ -41,8 +36,7 @@ public class HttpInterface { public static String USER_DETAIL_BY_USER_ID; //获取用户信息 //http://172.21.98.90:9999/m4/user/userGuide/1/insertUserGuide public static String INSERT_USER_GUIDE;//引导页完成接口 - /** - * 发现 + /*发现 * Path=/m4/msgList/** */ // public static String IP1 = "http://dtxbmaps.navinfo.com/dtxb/msg/"; @@ -56,8 +50,7 @@ public class HttpInterface { public static String EXAM_CONTENT;//发现 -能力测评获取试题接口 //http://172.23.139.4:8002/findAndMessage/1/submitExam public static String EXAM_SUBMIT;//发现 -能力测评提交试卷 post - /** - * 登录 + /*登录 * Path=/m4/userlogin/** */ //http://172.23.139.4:9999/m4/userlogin/oauth/token @@ -68,11 +61,9 @@ public class HttpInterface { public static String USER_MESSAGE = IP + USER_PATH + "phone/message";//获取验证码 type 1:注册获取 2:更新 ///m4/user/user/forgetPassword public static String USER_FORGET_PASSWORD = IP + USER_PATH + "user/forgetPassword";//忘记密码 - //Flat //dtxbmaps.navinfo.com/dtxb/m4/user/phone/message?mobile=18811794839&type=2 - /** - * 提现 金额 + /*提现 金额 * Path=/m4/price/** */ //http://172.23.139.4:8004/userPrice/1/getPrice @@ -81,8 +72,7 @@ public class HttpInterface { public static String USER_PRICE_EXCHANGE;//我的-财务信息-提现 //dtxbmaps.navinfo.com/dtxb/m4/price/priceExchange/1/getList?datetime=1628647356815 public static String PRICE_EXCHANGE;//提现记录 - /** - * 任务 + /*任务 * Path=/m4/task/** */ ///m4/task/task/10/receiveTasks 参数:taskIds @@ -138,8 +128,7 @@ public class HttpInterface { public static String MESSAGE_INFO_PUSH;//消息通知 public static void initHttpInter(String USERID) { - /** - * 我的 + /* 我的 * Path=/m4/user/* */ //172.23.139.4:8001/m4/user/update @@ -154,8 +143,7 @@ public class HttpInterface { USER_DETAIL_BY_USER_ID = IP + USER_PATH + "user/" + USERID + "/getUserDetailByUserid/" + USERID; //获取用户信息 //http://172.21.98.90:9999/m4/user/userGuide/1/insertUserGuide INSERT_USER_GUIDE = IP + USER_PATH + "userGuide/" + USERID + "/insertUserGuide";//引导页完成接口 - /** - * 发现 + /* 发现 * Path=/m4/msgList/** */ // public static String IP1 = "http://dtxbmaps.navinfo.com/dtxb/msg/"; @@ -170,8 +158,7 @@ public class HttpInterface { //http://172.23.139.4:8002/findAndMessage/1/submitExam EXAM_SUBMIT = IP + MSG_LIST_PATH + "findAndMessage/" + USERID + "/submitExam";//发现 -能力测评提交试卷 post MESSAGE_INFO_PUSH = IP + MSG_LIST_PATH + "InfoPush/" + USERID + "/push";//寻宝-消息通知 - /** - * 提现 金额 + /*提现 金额 * Path=/m4/price/** */ //http://172.23.139.4:8004/userPrice/1/getPrice @@ -180,8 +167,7 @@ public class HttpInterface { USER_PRICE_EXCHANGE = IP + PRICE_PATH + "userPrice/" + USERID + "/userPriceExchange";//我的-财务信息-提现 //dtxbmaps.navinfo.com/dtxb/m4/price/priceExchange/1/getList?datetime=1628647356815 PRICE_EXCHANGE = IP + PRICE_PATH + "priceExchange/" + USERID + "/getList";//提现记录 - /** - * 任务 + /*任务 *Path=/m4/task/** */ ///m4/task/task/10/receiveTasks 参数:taskIds @@ -234,8 +220,6 @@ public class HttpInterface { COMPLETE = IP + TASK_PATH + "polygonTask/" + USERID + "/complete";//面状任务结束领取 SUBMIT_POLYGON_TASK = IP + TASK_PATH + "polygonTask/" + USERID + "/submitPolygontask";//面状任务开始采集 } - - /** * public static String IPm8 = "http://172.23.139.4:8003/m4/"; * http://172.23.139.4:8003/m4/task/1/unReceivedTask?taskIds=&auditIds=214,278 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 2e6bd7d..0ed0f96 100644 --- a/app/src/main/java/com/navinfo/outdoor/http/OkGoBuilder.java +++ b/app/src/main/java/com/navinfo/outdoor/http/OkGoBuilder.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import okhttp3.FormBody; +import okhttp3.MediaType; import okhttp3.RequestBody; /** @@ -52,6 +53,7 @@ public class OkGoBuilder { private List files; private String token; + private String upString; /** * 单列模式 @@ -120,6 +122,46 @@ public class OkGoBuilder { this.clazz = clazz; return this; } + /** + * post 发现-能力测评: + */ + public void postCapacity(Callback callback){ + if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用 + callback.onError(new Throwable("网络不可用"),2); + return; + } + OkGo + .post(url) + .isMultipart(true) + .headers(getHeader()) + .upString(json, MediaType.parse("application/json")) + .tag(this) + .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"); + } + } + }); + } + /** diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index a1f3b11..d46e073 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -176,5 +176,4 @@ android:layout_marginBottom="20dp" /> - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_photograph.xml b/app/src/main/res/layout/activity_photograph.xml index 100a669..442247e 100644 --- a/app/src/main/res/layout/activity_photograph.xml +++ b/app/src/main/res/layout/activity_photograph.xml @@ -9,18 +9,18 @@ android:id="@+id/camera" android:layout_width="match_parent" android:layout_height="match_parent" - app:cameraPictureSizeMaxArea="3686400" - app:cameraPictureSizeMinArea="1166400" - app:cameraPictureSizeMaxHeight="1920" - app:cameraPictureSizeMinHeight="1080" - app:cameraPictureSizeMaxWidth="1920" - app:cameraPictureSizeMinWidth="1080" - app:cameraPictureSizeAspectRatio="1920:1080" - app:cameraPictureFormat="jpeg" - app:cameraPictureSizeBiggest="true" - app:cameraPictureSizeSmallest="true" - app:cameraPictureMetering="true" android:keepScreenOn="true" + app:cameraPictureFormat="jpeg" + app:cameraPictureMetering="true" + app:cameraPictureSizeAspectRatio="1920:1080" + app:cameraPictureSizeBiggest="true" + app:cameraPictureSizeMaxArea="3686400" + app:cameraPictureSizeMaxHeight="1920" + app:cameraPictureSizeMaxWidth="1920" + app:cameraPictureSizeMinArea="1166400" + app:cameraPictureSizeMinHeight="1080" + app:cameraPictureSizeMinWidth="1080" + app:cameraPictureSizeSmallest="true" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/app/src/main/res/layout/activity_pictures.xml b/app/src/main/res/layout/activity_pictures.xml index 92932aa..779aefd 100644 --- a/app/src/main/res/layout/activity_pictures.xml +++ b/app/src/main/res/layout/activity_pictures.xml @@ -33,6 +33,8 @@ app:cameraPictureSizeMinWidth="1080" app:cameraPictureSizeSmallest="true" app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />