diff --git a/app/build.gradle b/app/build.gradle index a78f9ee..43917f5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion '29.0.2' - // ndkVersion '23.0.7123448' + ndkVersion '23.0.7123448' defaultConfig { applicationId "com.navinfo.outdoor" diff --git a/app/src/main/java/com/navinfo/outdoor/adapter/StaySubmitAdapter.java b/app/src/main/java/com/navinfo/outdoor/adapter/StaySubmitAdapter.java index 097dac7..6b0a676 100644 --- a/app/src/main/java/com/navinfo/outdoor/adapter/StaySubmitAdapter.java +++ b/app/src/main/java/com/navinfo/outdoor/adapter/StaySubmitAdapter.java @@ -22,9 +22,10 @@ import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Vector; public class StaySubmitAdapter extends RecyclerView.Adapter { - private List allRoad = new ArrayList<>(); + private Vector allRoad = new Vector<>(); private Context context; public StaySubmitAdapter(Context context) { @@ -55,15 +56,17 @@ public class StaySubmitAdapter extends RecyclerView.Adapter videoFileList = new ArrayList<>(); - if (ivPoiVideoPicture.getTag() != null) { - File videoFile = (File) ivPoiVideoPicture.getTag(); + if (fmPoiVideoPic.getTag() != null) { + File videoFile = (File) fmPoiVideoPic.getTag(); videoFileList.add(videoFile); File file = new File(videoFile.getPath()+".txt"); videoFileList.add(file); @@ -372,7 +375,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick poiEntity.setTaskId(showPoiEntity.getTaskId()); } } - File videoFile = (File) ivPoiVideoPicture.getTag(); + File videoFile = (File) fmPoiVideoPic.getTag(); if (videoFile == null ) { Toast.makeText(getActivity(), "请录像", Toast.LENGTH_SHORT).show(); return; @@ -505,31 +508,36 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick @Override public void onSuccess(PoiVideoBean poiVideoBean, int id) { dismissLoadingDialog(); - Integer poiVideoBody = poiVideoBean.getBody(); - if (poiVideoBody != null && poiVideoBody != 0) { - poiEntity.setBodyId(poiVideoBody); - poiEntity.setTaskStatus(3); - new Thread(new Runnable() { - @Override - public void run() { - InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity); - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - if (isLocal) { - poiVideoUpload(poiVideoBody, fileZip); - } else { - Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show(); - onBackPressed(); + if (poiVideoBean.getCode()==200){ + Integer poiVideoBody = poiVideoBean.getBody(); + if (poiVideoBody != null && poiVideoBody != 0) { + poiEntity.setBodyId(poiVideoBody); + poiEntity.setTaskStatus(3); + new Thread(new Runnable() { + @Override + public void run() { + InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity); + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (isLocal) { + poiVideoUpload(poiVideoBody, fileZip); + } else { + Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show(); + onBackPressed(); + } } - } - }); - } - }).start(); - } else { + }); + } + }).start(); + } else { + Toast.makeText(getActivity(), ""+poiVideoBean.getMessage(), Toast.LENGTH_SHORT).show(); + } + }else { Toast.makeText(getActivity(), ""+poiVideoBean.getMessage(), Toast.LENGTH_SHORT).show(); } + } @Override @@ -552,7 +560,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick File videoFile = new File(videoPath); if (videoFile.exists()) { AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500); - ivPoiVideoPicture.setTag(videoFile); + fmPoiVideoPic.setTag(videoFile); } } } 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 1b537bd..4c298a6 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java @@ -14,6 +14,7 @@ import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.RadioButton; import android.widget.RadioGroup; @@ -86,6 +87,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList private Button roadUpload; private String videoPath; private File fileZip; + private FrameLayout fmRoadPic; public static RoadFragment newInstance(Bundle bundle) { RoadFragment fragment = new RoadFragment(); @@ -147,12 +149,13 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList rbWalking = (RadioButton) findViewById(R.id.rb_walking); rbManual = (RadioButton) findViewById(R.id.rb_manual); etDesc = (EditText) findViewById(R.id.et_desc); + fmRoadPic = findViewById(R.id.fm_road_picture); btnRoadSave = (Button) findViewById(R.id.btn_road_save); btnRoadSave.setOnClickListener(this::onClick); rgType = (RadioGroup) findViewById(R.id.rg_type); roadUpload = findViewById(R.id.road_upload); roadUpload.setOnClickListener(this::onClick); - ivRoadPicture.setOnClickListener(new View.OnClickListener() { + fmRoadPic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (v.getTag() == null) { @@ -192,7 +195,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList if (videoFile.exists()) { // 使用glide加载视频的第一帧 AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500); - ivRoadPicture.setTag(videoFile); + fmRoadPic.setTag(videoFile); } } } @@ -263,9 +266,9 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList case R.id.road_upload: showLoadingDialog(); ArrayList videoFileList = new ArrayList<>(); - if (ivRoadPicture.getTag() != null) { + if (fmRoadPic.getTag() != null) { - File videoFile = (File) ivRoadPicture.getTag(); + File videoFile = (File) fmRoadPic.getTag(); videoFileList.add(videoFile); File file = new File(videoFile.getPath() + ".txt"); videoFileList.add(file); @@ -346,11 +349,11 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList poiEntity.setTaskId(showPoiEntity.getTaskId()); } } - if (ivRoadPicture.getTag() == null) { + if (fmRoadPic.getTag() == null) { Toast.makeText(getActivity(), "请录像", Toast.LENGTH_SHORT).show(); return; } else { - File videoFile = (File) ivRoadPicture.getTag(); + File videoFile = (File) fmRoadPic.getTag(); String path = videoFile.getPath() + ".txt"; poiEntity.setPhoto(videoFile.getAbsolutePath()); List strings = FileUtils.readFileToList(path, "utf-8"); @@ -482,30 +485,35 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList @Override public void onSuccess(RoadSaveBean roadSaveBean, int id) { dismissLoadingDialog(); - Integer roadBody = roadSaveBean.getBody(); - if (roadBody!=null&&roadBody!=0){ - poiEntity.setBodyId(roadBody); - poiEntity.setTaskStatus(3); - new Thread(new Runnable() { - @Override - public void run() { - InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity); - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - if (isLocal) { - poiVideoUpload(roadBody, fileZip); - } else { - Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show(); - onBackPressed(); - } - } - }); - } - }).start(); - }else { - Toast.makeText(getContext(), ""+roadSaveBean.getMessage(), Toast.LENGTH_SHORT).show(); - } + if (roadSaveBean.getCode()==200){ + Integer roadBody = roadSaveBean.getBody(); + if (roadBody!=null&&roadBody!=0){ + poiEntity.setBodyId(roadBody); + poiEntity.setTaskStatus(3); + new Thread(new Runnable() { + @Override + public void run() { + InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity); + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (isLocal) { + poiVideoUpload(roadBody, fileZip); + } else { + Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show(); + onBackPressed(); + } + } + }); + } + }).start(); + }else { + Toast.makeText(getContext(), ""+roadSaveBean.getMessage(), Toast.LENGTH_SHORT).show(); + } + }else { + Toast.makeText(getContext(), ""+roadSaveBean.getMessage(), Toast.LENGTH_SHORT).show(); + } + } @@ -530,7 +538,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList File videoFile = new File(videoPath); if (videoFile.exists()) { AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500); - ivRoadPicture.setTag(videoFile); + fmRoadPic.setTag(videoFile); } } } 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 39facc4..2dd4b26 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/StaySubmitFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/StaySubmitFragment.java @@ -198,7 +198,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList @Override public boolean onClick(BaseDialog baseDialog, View v) { staySubmitAdapter.setAllCheckedDelete(); - refreshData(); +// refreshData(); return false; } }); 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 cb869a4..8b39156 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/UserAttestationFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/UserAttestationFragment.java @@ -118,11 +118,33 @@ public class UserAttestationFragment extends BaseFragment implements View.OnClic startActivityForResult(ivAttestation3, 300); break; case R.id.btn_attestation: + /** + * static boolean ChineseNameTest(String name) { + * if (!name.matches("[\u4e00-\u9fa5]{2,4}")) { + * System.out.println("只能输入2到4个汉字"); + * return false; + * }else return true; + * } + */ + if (etAttestationName.getText().toString() == null || etAttestationName.getText().toString().equals("")) { + Toast.makeText(getContext(), "姓名不能为空,请输入姓名", Toast.LENGTH_SHORT).show(); + return; + } + if (!chineseNameTest(etAttestationName.getText().toString())){ + Toast.makeText(getActivity(), "请输入中文名字", Toast.LENGTH_SHORT).show(); + return; + } + if (!checkNum(etNamePhone.getText().toString().trim())) { + Toast.makeText(getContext(), "身份证号错误,请重新输入", Toast.LENGTH_SHORT).show(); + return; + } nameAuthentication(); break; } } - + /*** + * + */ public boolean checkNum(String text) { Pattern patternSfzhm1 = Pattern .compile("^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$"); @@ -135,7 +157,16 @@ public class UserAttestationFragment extends BaseFragment implements View.OnClic else return true; } + /** + * 中文效验 + */ + static boolean chineseNameTest(String name) { + if (!name.matches("[\u4e00-\u9fa5]{2,4}")) { + System.out.println("只能输入2到4个汉字"); + return false; + }else return true; + } private void nameAuthentication() { if (etAttestationName.getText().toString() == null || etAttestationName.getText().toString().equals("")) { Toast.makeText(getContext(), "姓名不能为空,请输入姓名", Toast.LENGTH_SHORT).show(); @@ -222,73 +253,70 @@ public class UserAttestationFragment extends BaseFragment implements View.OnClic if (requestCode == 100 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - int height = bitmap.getHeight(); - int width = bitmap.getWidth(); - if (height > width) { - DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE; - MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { - @Override - public boolean onClick(BaseDialog baseDialog, View v) { - Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentPanorama, 100); - return false; - } - }); - } else { - - String takePhotoPath1 = PhotoPathUtil.getTakePhotoPath(data, "a", ""); - ivAttestation1.setTag(takePhotoPath1); - ivAttestation1.setImageBitmap(bitmap);//显示图像 - ivHera1.setVisibility(View.GONE); - tvCard1.setVisibility(View.GONE); - } + String takePhotoPath1 = PhotoPathUtil.getTakePhotoPath(data, "a", ""); + ivAttestation1.setTag(takePhotoPath1); + ivAttestation1.setImageBitmap(bitmap);//显示图像 + ivHera1.setVisibility(View.GONE); + tvCard1.setVisibility(View.GONE); +// int height = bitmap.getHeight(); +// int width = bitmap.getWidth(); +// if (height > width) { +// DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE; +// MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { +// @Override +// public boolean onClick(BaseDialog baseDialog, View v) { +// Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); +// startActivityForResult(intentPanorama, 100); +// return false; +// } +// }); +// } } if (requestCode == 200 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - int height = bitmap.getHeight(); - int width = bitmap.getWidth(); - if (height > width) { - DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE; - MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { - @Override - public boolean onClick(BaseDialog baseDialog, View v) { - Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentPanorama, 200); - return false; - } - }); - } else { - String takePhotoPath2 = PhotoPathUtil.getTakePhotoPath(data, "a", ""); - ivAttestation2.setTag(takePhotoPath2); - ivAttestation2.setImageBitmap(bitmap);//显示图像 - ivHera2.setVisibility(View.GONE); - tvCard2.setVisibility(View.GONE); - } + String takePhotoPath2 = PhotoPathUtil.getTakePhotoPath(data, "a", ""); + ivAttestation2.setTag(takePhotoPath2); + ivAttestation2.setImageBitmap(bitmap);//显示图像 + ivHera2.setVisibility(View.GONE); + tvCard2.setVisibility(View.GONE); +// int height = bitmap.getHeight(); +// int width = bitmap.getWidth(); +// if (height > width) { +// DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE; +// MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { +// @Override +// public boolean onClick(BaseDialog baseDialog, View v) { +// Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); +// startActivityForResult(intentPanorama, 200); +// return false; +// } +// }); +// } } if (requestCode == 300 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - int height = bitmap.getHeight(); - int width = bitmap.getWidth(); - if (height > width) { - DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE; - MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { - @Override - public boolean onClick(BaseDialog baseDialog, View v) { - Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); - startActivityForResult(intentPanorama, 300); - return false; - } - }); - } else { - String takePhotoPath3 = PhotoPathUtil.getTakePhotoPath(data, "a", ""); - ivAttestation3.setTag(takePhotoPath3); - ivAttestation3.setImageBitmap(bitmap);//显示图像 - ivHera3.setVisibility(View.GONE); - tvCard3.setVisibility(View.GONE); - } + String takePhotoPath3 = PhotoPathUtil.getTakePhotoPath(data, "a", ""); + ivAttestation3.setTag(takePhotoPath3); + ivAttestation3.setImageBitmap(bitmap);//显示图像 + ivHera3.setVisibility(View.GONE); + tvCard3.setVisibility(View.GONE); +// int height = bitmap.getHeight(); +// int width = bitmap.getWidth(); +// if (height > width) { +// DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE; +// MessageDialog.show((AppCompatActivity) getContext(), "提示", "请重新拍照,要求横屏拍照", "确定").setOkButton(new OnDialogButtonClickListener() { +// @Override +// public boolean onClick(BaseDialog baseDialog, View v) { +// Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE"); +// startActivityForResult(intentPanorama, 300); +// return false; +// } +// }); +// } else { +// +// } } } - } diff --git a/app/src/main/res/layout/activity_user.xml b/app/src/main/res/layout/activity_user.xml index 657e471..ea06a0a 100644 --- a/app/src/main/res/layout/activity_user.xml +++ b/app/src/main/res/layout/activity_user.xml @@ -72,8 +72,8 @@