Merge remote-tracking branch 'OutDoor/master'

This commit is contained in:
wds
2021-08-04 16:59:58 +08:00
16 changed files with 357 additions and 246 deletions

View File

@@ -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<StaySubmitAdapter.ViewHolder> {
private List<PoiEntity> allRoad = new ArrayList<>();
private Vector<PoiEntity> allRoad = new Vector<>();
private Context context;
public StaySubmitAdapter(Context context) {
@@ -55,15 +56,17 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
new Thread(new Runnable() {
@Override
public void run() {
Iterator iterator = allRoad.iterator();
while (iterator.hasNext()) {
PoiEntity poiEntity = (PoiEntity) iterator.next();
if (poiEntity.isChecked()) {
PoiDatabase.getInstance(context).getPoiDao().deletePoiEntity(poiEntity);
iterator.remove();
synchronized (allRoad) {
Iterator iterator = allRoad.iterator();
while (iterator.hasNext()) {
PoiEntity poiEntity = (PoiEntity) iterator.next();
if (poiEntity.isChecked()) {
PoiDatabase.getInstance(context).getPoiDao().deletePoiEntity(poiEntity);
iterator.remove();
}
}
handler.sendEmptyMessage(0x105);
}
handler.sendEmptyMessage(0x105);
}
}).start();
@@ -84,10 +87,11 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
holder.tvDay.setText(poiEntity.getCreateTime());
//获取checkBox点击的记录
holder.cbUnSubmit.setChecked(allRoad.get(position).isChecked());
holder.cbUnSubmit.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
holder.cbUnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
allRoad.get(position).setChecked(isChecked);
public void onClick(View v) {
holder.cbUnSubmit.setChecked(!poiEntity.isChecked());
poiEntity.setChecked(!poiEntity.isChecked());
}
});
if (poiEntity.getIsLocalData() == 1){

View File

@@ -438,9 +438,9 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
private void initShowPoi() {
// 添加信息:
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
if (showPoiEntity.getTaskStatus()==1||showPoiEntity.getTaskStatus()==5){
if (showPoiEntity.getTaskStatus() == 1 || showPoiEntity.getTaskStatus() == 5) {
tvExamine.setVisibility(View.GONE);
}else {
} else {
tvExamine.setVisibility(View.VISIBLE);
}
String name = showPoiEntity.getName();//名称
@@ -579,7 +579,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
obtain.what = Constant.CHARGING_STATION;
obtain.obj = showStation;
EventBus.getDefault().post(obtain);
}else {
} else {
Message obtains = Message.obtain();
obtains.what = Constant.CHARGING_STATION_PILE;
obtains.obj = null;
@@ -1093,30 +1093,38 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
@Override
public void onSuccess(ChargingStationBean chargingStationBean, int id) {
dismissLoadingDialog();
bodyId = chargingStationBean.getBody();
poiEntity.setBodyId(bodyId);
poiEntity.setTaskStatus(3);
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
// 充电站数据已经保存在服务上,批量保存充电桩数据
saveChargingPileByChargingStation(poiEntity);
getActivity().runOnUiThread(new Runnable() {
if (chargingStationBean.getCode() == 200) {
bodyId = chargingStationBean.getBody();
if (bodyId != null && bodyId != 0) {
poiEntity.setBodyId(bodyId);
poiEntity.setTaskStatus(3);
new Thread(new Runnable() {
@Override
public void run() {
if (isLocal) {
stationUploadByNetWork(poiEntity, chargingStationList);
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
// 充电站数据已经保存在服务上,批量保存充电桩数据
saveChargingPileByChargingStation(poiEntity);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (isLocal) {
stationUploadByNetWork(poiEntity, chargingStationList);
// chargingPileUploadNetWork(chargingPileBody, fileList);
} else {
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
onBackPressed();
}
Log.d("TAG", "onSuccess: " + chargingStationBean.getBody());
} else {
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
onBackPressed();
}
Log.d("TAG", "onSuccess: " + chargingStationBean.getBody());
}
});
}
});
}).start();
} else {
Toast.makeText(getContext(), "" + chargingStationBean.getMessage(), Toast.LENGTH_SHORT).show();
}
}).start();
} else {
Toast.makeText(getContext(), "" + chargingStationBean.getMessage(), Toast.LENGTH_SHORT).show();
}
}
@Override
@@ -1453,9 +1461,9 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
public void run() {
PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId());
if (poiDaoPoiEntity != null) {
if (poiDaoPoiEntity.getTaskStatus()==5){
poiDao.deletePoiEntity(poiDaoPoiEntity);
}
if (poiDaoPoiEntity.getTaskStatus() == 5) {
poiDao.deletePoiEntity(poiDaoPoiEntity);
}
}
}
}).start();

View File

@@ -680,9 +680,12 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
poiListEntity.setX(latPolygon.get(0).longitude + "");
poiListEntity.setY(latPolygon.get(0).latitude + "");
}
// 通知地图界面显示当前编辑数据的marker
senMessageMarker(poiEntity.getType(), poiEntity.getY(), poiEntity.getX());
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiListEntity);
if (poiListEntity.getTaskStatus()!=1){
// 通知地图界面显示当前编辑数据的marker
senMessageMarker(poiEntity.getType(), poiEntity.getY(), poiEntity.getX());
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiListEntity);
}
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -789,9 +792,12 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
poiListEntity.setX(latPolygon.get(0).longitude + "");
poiListEntity.setY(latPolygon.get(0).latitude + "");
}
// 通知地图界面显示当前编辑数据的marker
senMessageMarker(poiEntity.getType(), poiEntity.getY(), poiEntity.getX());
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiListEntity);
if (poiListEntity.getTaskStatus()!=1){
// 通知地图界面显示当前编辑数据的marker
senMessageMarker(poiEntity.getType(), poiEntity.getY(), poiEntity.getX());
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiListEntity);
}
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {

View File

@@ -526,26 +526,37 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
@Override
public void onSuccess(PoiSaveBean poiSaveBean, int id) {
dismissLoadingDialog();
Integer body = poiSaveBean.getBody();
poiEntity.setBodyId(body);
poiEntity.setTaskStatus(3);
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
getActivity().runOnUiThread(new Runnable() {
if (poiSaveBean.getCode()==200){
Integer body = poiSaveBean.getBody();
if (body!=null&&body!=0){
poiEntity.setBodyId(body);
poiEntity.setTaskStatus(3);
new Thread(new Runnable() {
@Override
public void run() {
if (isLocal){
otherUploadByNet(body,otherUploadList);
}else {
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
onBackPressed();
}
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (isLocal){
otherUploadByNet(body,otherUploadList);
}else {
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
onBackPressed();
}
}
});
}
});
}).start();
}else {
Toast.makeText(getActivity(), ""+poiSaveBean.getMessage(), Toast.LENGTH_SHORT).show();
}
}).start();
}else {
Toast.makeText(getActivity(), ""+poiSaveBean.getMessage(), Toast.LENGTH_SHORT).show();
}
}
@Override

View File

@@ -799,26 +799,36 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
@Override
public void onSuccess(PoiSaveBean poiSaveBean, int id) {
dismissLoadingDialog();
Integer body = poiSaveBean.getBody();
poiEntity.setBodyId(body);
poiEntity.setTaskStatus(3);
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
getActivity().runOnUiThread(new Runnable() {
if (poiSaveBean.getCode()==200){
Integer body = poiSaveBean.getBody();
if (body!=null&&body!=0){
poiEntity.setBodyId(body);
poiEntity.setTaskStatus(3);
new Thread(new Runnable() {
@Override
public void run() {
if (isLocal) {
poiUploadByNetWork(body, poiPicList);//上传
} else {
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
onBackPressed();
}
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (isLocal) {
poiUploadByNetWork(body, poiPicList);//上传
} else {
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
onBackPressed();
}
}
});
}
});
}).start();
}else {
Toast.makeText(getActivity(), ""+poiSaveBean.getMessage(), Toast.LENGTH_SHORT).show();
}
}).start();
}else {
Toast.makeText(getActivity(), ""+poiSaveBean.getMessage(), Toast.LENGTH_SHORT).show();
}
}
@Override

View File

@@ -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;
@@ -91,6 +92,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
private Button btnPoiVideoUpload;
private String videoPath;
private File fileZip;
private FrameLayout fmPoiVideoPic;
public static PoiVideoFragment newInstance(Bundle bundle) {
PoiVideoFragment fragment = new PoiVideoFragment();
@@ -151,12 +153,13 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
rbWalking = (RadioButton) findViewById(R.id.rb_walking);
rbManual = (RadioButton) findViewById(R.id.rb_manual);
etDesc = (EditText) findViewById(R.id.et_desc);
fmPoiVideoPic = findViewById(R.id.fm_poi_video_picture);
btnRoadSave = (Button) findViewById(R.id.btn_poi_video_save);
btnRoadSave.setOnClickListener(this::onClick);
btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
btnPoiVideoUpload.setOnClickListener(this::onClick);
rgType = (RadioGroup) findViewById(R.id.rg_type);
ivPoiVideoPicture.setOnClickListener(new View.OnClickListener() {
fmPoiVideoPic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (v.getTag() == null) {
@@ -164,19 +167,19 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
return;
}
File videoFile = (File) v.getTag();
Intent intent = new Intent(getContext(), PicturesActivity.class);
Intent intent = new Intent(getContext(), PictureActivity.class);
intent.putExtra(Constant.INTENT_VIDEO_PATH, videoFile.getAbsolutePath());
startActivityForResult(intent, 0x101);
}
});
ivPoiVideoPicture.setOnLongClickListener(new View.OnLongClickListener() {
fmPoiVideoPic.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
MessageDialog.show((AppCompatActivity) getContext(), "提示", "对否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
File videoFile = (File) ivPoiVideoPicture.getTag();
File videoFile = (File) fmPoiVideoPic.getTag();
if (videoFile != null) {
videoFile.delete();
//获取文件名
@@ -215,7 +218,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
if (videoFile.exists()) {
// 使用glide加载视频的第一帧
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
ivPoiVideoPicture.setTag(videoFile);
fmPoiVideoPic.setTag(videoFile);
}
}
}
@@ -271,7 +274,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
// 根据用户点击的时间为视频名称赋值
DateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String videoFormatName = formatter.format(new Date());
Intent intent = new Intent(getContext(), PicturesActivity.class);
Intent intent = new Intent(getContext(), PictureActivity.class);
intent.putExtra(Constant.INTENT_VIDEO_PATH, Constant.PICTURE_FOLDER + "/" + videoFormatName + ".mp4");
startActivityForResult(intent, 0x101);
@@ -280,8 +283,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
case R.id.btn_poi_video_upload:
showLoadingDialog();
ArrayList<File> 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);
}
}
}

View File

@@ -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<File> 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<String> 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);
}
}
}

View File

@@ -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;
}
});

View File

@@ -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 {
//
// }
}
}
}