| xqd
@@ -0,0 +1,542 @@
|
|
|
+package com.zhilin.patrol.ui.fragment;
|
|
|
+
|
|
|
+import android.Manifest;
|
|
|
+import android.annotation.TargetApi;
|
|
|
+import android.content.Intent;
|
|
|
+import android.content.pm.PackageManager;
|
|
|
+import android.os.Build;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.os.Environment;
|
|
|
+import android.support.annotation.Nullable;
|
|
|
+import android.support.v4.app.Fragment;
|
|
|
+import android.text.Editable;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.text.TextWatcher;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.EditText;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.zhilin.patrol.R;
|
|
|
+import com.zhilin.patrol.bean.AddressAreaEntity;
|
|
|
+import com.zhilin.patrol.bean.LoginEntity;
|
|
|
+import com.zhilin.patrol.bean.MapLocationInfo;
|
|
|
+import com.zhilin.patrol.bean.PatrolFormEntity;
|
|
|
+import com.zhilin.patrol.bean.PointFormEntity;
|
|
|
+import com.zhilin.patrol.bean.QuestionKindEntity;
|
|
|
+import com.zhilin.patrol.http.HttpUrl;
|
|
|
+import com.zhilin.patrol.tool.CheckPermissionUtils;
|
|
|
+import com.zhilin.patrol.tool.DialogUtil;
|
|
|
+import com.zhilin.patrol.tool.IpUtils;
|
|
|
+import com.zhilin.patrol.tool.JsonUtils;
|
|
|
+import com.zhilin.patrol.tool.LocationUtils;
|
|
|
+import com.zhilin.patrol.tool.Utils;
|
|
|
+import com.zhilin.patrol.ui.activity.AddressSelectActivity;
|
|
|
+import com.zhilin.patrol.ui.activity.InfoUploadActivity;
|
|
|
+import com.zhilin.patrol.ui.activity.MainActivity;
|
|
|
+import com.zhilin.patrol.ui.activity.PatrolUploadActivity;
|
|
|
+import com.zhilin.patrol.views.AlertDialog;
|
|
|
+import com.zhilin.patrol.views.CustomProgressDialog;
|
|
|
+import com.zhy.http.okhttp.OkHttpUtils;
|
|
|
+import com.zhy.http.okhttp.callback.Callback;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import butterknife.BindView;
|
|
|
+import butterknife.ButterKnife;
|
|
|
+import butterknife.OnClick;
|
|
|
+import okhttp3.Call;
|
|
|
+import okhttp3.Response;
|
|
|
+
|
|
|
+public class PointRecordFragment extends Fragment {
|
|
|
+
|
|
|
+ public static final String TYPE = "type";
|
|
|
+ public String TAG="PointRecordFragment";
|
|
|
+ private int mType;
|
|
|
+ @BindView(R.id.ll_point)
|
|
|
+ LinearLayout mPointLayout;
|
|
|
+ @BindView(R.id.et_content)
|
|
|
+ EditText mRemarkEt;//备注
|
|
|
+ @BindView(R.id.et_district)
|
|
|
+ EditText mDistrictEt;
|
|
|
+ @BindView(R.id.et_stree)
|
|
|
+ EditText mStreeEt;
|
|
|
+ @BindView(R.id.tv_default_community)
|
|
|
+ TextView mDefCommTv;
|
|
|
+ @BindView(R.id.tv_actual_point)
|
|
|
+ TextView mActualTv;
|
|
|
+ @BindView(R.id.et_shequ)
|
|
|
+ EditText mShequEt;
|
|
|
+ @BindView(R.id.et_community)
|
|
|
+ EditText mCummEt;
|
|
|
+ @BindView(R.id.tv_default_address)
|
|
|
+ TextView mAddressTv;
|
|
|
+ @BindView(R.id.tv_content_num)
|
|
|
+ TextView mContentNumTv;//备注长度
|
|
|
+ @BindView(R.id.btn_submit)
|
|
|
+ Button btnSubmit;
|
|
|
+
|
|
|
+ /** 客户文件目录 */
|
|
|
+ private String mImageDir = Environment.getExternalStorageDirectory() + "/patrol/";
|
|
|
+
|
|
|
+ String[] mPermissions = {
|
|
|
+ Manifest.permission.ACCESS_COARSE_LOCATION,
|
|
|
+ Manifest.permission.ACCESS_FINE_LOCATION,
|
|
|
+ Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
|
|
+ Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
|
+ Manifest.permission.CAMERA,
|
|
|
+ Manifest.permission.READ_PHONE_STATE};
|
|
|
+ /** 附近小区集合 */
|
|
|
+ private ArrayList mAddressAreaList;
|
|
|
+ private LocationUtils mLocationUtils;
|
|
|
+ private CustomProgressDialog mProgressDialog;
|
|
|
+ /** 选中的小区 */
|
|
|
+ private AddressAreaEntity.InfoListBean mListBean;
|
|
|
+ /** 定位信息 */
|
|
|
+ private MapLocationInfo mMapLocationInfo;
|
|
|
+ private LoginEntity.InfoListBean.UserInfoBean mUserInfo;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ Bundle arguments = getArguments();
|
|
|
+ mType = arguments.getInt(TYPE);
|
|
|
+ Log.i("111","aaarrra"+mType);
|
|
|
+ }
|
|
|
+ @Nullable
|
|
|
+ @Override
|
|
|
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
+ View view = inflater.inflate(R.layout.fragment_point_upload, container, false);
|
|
|
+ ButterKnife.bind(this, view);
|
|
|
+ mUserInfo = (LoginEntity.InfoListBean.UserInfoBean) getActivity().getIntent().getSerializableExtra("userInfo");
|
|
|
+ mRemarkEt.addTextChangedListener(new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable editable) {
|
|
|
+ mContentNumTv.setText(mRemarkEt.getText().length() + "/200");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mProgressDialog = new CustomProgressDialog(getActivity());
|
|
|
+// mLocationUtils = LocationUtils.getInstance();
|
|
|
+ mLocationUtils=new LocationUtils();
|
|
|
+ Log.i(TAG,"去定位");
|
|
|
+ mLocationUtils.onCreate(new LocationUtils.LocationListener() {
|
|
|
+ @Override
|
|
|
+ public void locationSuccess(MapLocationInfo mapLocationInfo, String message) {
|
|
|
+ if (TextUtils.isEmpty(mapLocationInfo.getAddress())) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ mMapLocationInfo = mapLocationInfo;
|
|
|
+ }
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+ Log.i(TAG,"定位ok");
|
|
|
+ Log.i(TAG,mMapLocationInfo.toString());
|
|
|
+ defalutAddress();//确定默认小区
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void locationFail(String message) {
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ checkPermissions();
|
|
|
+
|
|
|
+ return view;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
|
|
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
|
+ for (int i = 0; i < grantResults.length; i++) {
|
|
|
+ if (PackageManager.PERMISSION_GRANTED != grantResults[i]) {
|
|
|
+ new AlertDialog(getActivity()).builder()
|
|
|
+ .setTitle(PointRecordFragment.this.getString(R.string.tv_tishi))
|
|
|
+ .setMsg("获取权限失败,是否重新尝试?")
|
|
|
+ .setPositiveButton("重试", new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ checkPermissions();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton("取消", new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }).show();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ locationAddress();
|
|
|
+ //申请权限后创建图片文件夹
|
|
|
+ Utils.createDir(mImageDir);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void requestAddress2() {
|
|
|
+ Log.i(TAG,"requestAddress2");
|
|
|
+ mProgressDialog.showDialog("正在获取附近小区...");
|
|
|
+ Log.i(TAG,"getIpAddress");
|
|
|
+ String ipAddress = IpUtils.getIpAddress(getActivity());
|
|
|
+ Log.i(TAG,"post");
|
|
|
+ OkHttpUtils.post()
|
|
|
+ .url(HttpUrl.GET_NEAR_ADDRESS_URL)
|
|
|
+ .addParams("userCode", mUserInfo.getUserCode())
|
|
|
+ .addParams("userRole", mUserInfo.getUserRole() + "")
|
|
|
+ .addParams("userIP", ipAddress)
|
|
|
+ .addParams("disName", mMapLocationInfo.getDistrict())
|
|
|
+ .addParams("longitude", mMapLocationInfo.getLongitude() + "")
|
|
|
+ .addParams("latitude", mMapLocationInfo.getLatitude() + "")
|
|
|
+ .build().execute(new Callback<AddressAreaEntity>() {
|
|
|
+ @Override
|
|
|
+ public AddressAreaEntity parseNetworkResponse(Response response, int id) throws Exception {
|
|
|
+ Log.i(TAG,"jsonStr");
|
|
|
+ String jsonStr = response.body().string();
|
|
|
+ Log.i(TAG,jsonStr);
|
|
|
+ return (AddressAreaEntity) JsonUtils.parseJson2Obj(jsonStr, AddressAreaEntity.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Call call, Exception e, int id) {
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+ DialogUtil.showNetFailDialog(getActivity());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResponse(AddressAreaEntity entity, int id) {
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+ List<AddressAreaEntity.InfoListBean> infoList = entity.getInfoList();
|
|
|
+ int mindDistancenumber=0;
|
|
|
+ String addressdefault="附近没有小区";
|
|
|
+ Log.i(TAG,"循环遍历");
|
|
|
+ Log.i(TAG, infoList.toString());
|
|
|
+ Log.i(TAG, infoList.size()+" ");
|
|
|
+ if(infoList.size()!=0) {
|
|
|
+ int[] arr=new int[infoList.size()];
|
|
|
+ for (int i = 0; i <= infoList.size()-1; i++) {
|
|
|
+ arr[i]=Integer.parseInt(infoList.get(i).getDistance());
|
|
|
+ Log.i(TAG, infoList.get(i).getDistance()+"distance");
|
|
|
+ }
|
|
|
+ Log.i(TAG, arr+"arr1");
|
|
|
+ for(int i=0;i<=infoList.size()-1;i++){
|
|
|
+ for (int j = 0; j <= infoList.size() - i-2; j++) {
|
|
|
+ if (arr[j]>arr[j+1]) {
|
|
|
+ int itemp3=arr[j];
|
|
|
+ arr[j]= arr[j+1];
|
|
|
+ arr[j+1]=itemp3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Log.i(TAG, arr+"arr");
|
|
|
+ int minddistance=0;
|
|
|
+ Log.i(TAG, "得到最小距离");
|
|
|
+ for (int n = 0; n <= infoList.size()-1; n++) {
|
|
|
+ int Distancenumber = arr[0];
|
|
|
+ if (Integer.parseInt(infoList.get(n).getDistance())==Distancenumber) {
|
|
|
+ mindDistancenumber=Distancenumber;
|
|
|
+ addressdefault = infoList.get(n).getAddress();
|
|
|
+ infoList.get(n).setSelected(true);
|
|
|
+ mListBean=infoList.get(n);
|
|
|
+ Log.i(TAG, infoList.get(n).isSelected() +"==isSelected");
|
|
|
+ Log.i(TAG, addressdefault+"addressdefault");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(infoList.size()==0&&mindDistancenumber==0) {
|
|
|
+ Log.i(TAG,"附近没有小区");
|
|
|
+// mDefCommTv.setText(addressdefault);
|
|
|
+ init();
|
|
|
+ }else{
|
|
|
+
|
|
|
+ Log.i(TAG,"默认小区地址");
|
|
|
+ mDefCommTv.setText(addressdefault+" "+mindDistancenumber+"m");
|
|
|
+ mAddressTv.setText(mListBean.toStingTv());
|
|
|
+ if(!mAddressTv.getText().toString().isEmpty()){
|
|
|
+ mAddressTv.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ mShequEt.setText(mListBean.getArea());
|
|
|
+ mDistrictEt.setText(mListBean.getDisName());
|
|
|
+ mStreeEt.setText(mListBean.getStreet());
|
|
|
+// mCummEt.setText(mListBean.getAddress());
|
|
|
+ init();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Log.i(TAG, "退出requestAddress2");
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+ }
|
|
|
+ private void defalutAddress(){
|
|
|
+ Log.i(TAG,"准备获取小区");
|
|
|
+ Log.i(TAG,mMapLocationInfo.toString());
|
|
|
+ requestAddress2();
|
|
|
+ Log.i(TAG,"获取到小区");
|
|
|
+//
|
|
|
+ }
|
|
|
+ private void toAddressSelect() {
|
|
|
+ if (mAddressAreaList == null) {
|
|
|
+ requestAddress();
|
|
|
+ } else {
|
|
|
+ Log.i(TAG,mAddressAreaList.toString()+"附近小区list");
|
|
|
+ toAddressSelectActivity();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 跳转到选择小区页面
|
|
|
+ */
|
|
|
+ private void toAddressSelectActivity() {
|
|
|
+ Intent intent = new Intent(getActivity(), AddressSelectActivity.class);
|
|
|
+ intent.putExtra("userInfo", mUserInfo);
|
|
|
+ intent.putExtra("AddressAreaList", mAddressAreaList);
|
|
|
+ startActivityForResult(intent, 2);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 请求地址
|
|
|
+ */
|
|
|
+ public void requestAddress() {
|
|
|
+ Log.i(TAG,"requestAddress");
|
|
|
+ mProgressDialog.showDialog("正在获取附近小区...");
|
|
|
+ String ipAddress = IpUtils.getIpAddress(getActivity());
|
|
|
+ Log.i(TAG,mUserInfo.getUserCode());
|
|
|
+ Log.i(TAG,mUserInfo.getUserRole() + "");
|
|
|
+ Log.i(TAG,ipAddress);
|
|
|
+ Log.i(TAG,mMapLocationInfo.getDistrict());
|
|
|
+ Log.i(TAG,mMapLocationInfo.getLongitude() + "");
|
|
|
+ Log.i(TAG,mMapLocationInfo.getLatitude() + "");
|
|
|
+
|
|
|
+ OkHttpUtils.post()
|
|
|
+ .url(HttpUrl.GET_NEAR_ADDRESS_URL)
|
|
|
+ .addParams("userCode", mUserInfo.getUserCode())
|
|
|
+ .addParams("userRole", mUserInfo.getUserRole() + "")
|
|
|
+ .addParams("userIP", ipAddress)
|
|
|
+ .addParams("disName", mMapLocationInfo.getDistrict())
|
|
|
+ .addParams("longitude", mMapLocationInfo.getLongitude() + "")
|
|
|
+ .addParams("latitude", mMapLocationInfo.getLatitude() + "")
|
|
|
+ .build().execute(new Callback<AddressAreaEntity>() {
|
|
|
+ @Override
|
|
|
+ public AddressAreaEntity parseNetworkResponse(Response response, int id) throws Exception {
|
|
|
+ String jsonStr = response.body().string();
|
|
|
+ return (AddressAreaEntity) JsonUtils.parseJson2Obj(jsonStr, AddressAreaEntity.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Call call, Exception e, int id) {
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+ DialogUtil.showNetFailDialog(getActivity());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResponse(AddressAreaEntity entity, int id) {
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+ if (entity == null) {
|
|
|
+ DialogUtil.showErrDialog(getActivity(), "返回信息为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!"1000".endsWith(entity.getReturnCode())) {
|
|
|
+ DialogUtil.showErrDialog(getActivity(), entity.getReturnMsg());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<AddressAreaEntity.InfoListBean> infoList = entity.getInfoList();
|
|
|
+
|
|
|
+ if (infoList == null) {
|
|
|
+ DialogUtil.showErrDialog(getActivity(), "返回数组为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (infoList != null) {
|
|
|
+ mAddressAreaList = new ArrayList();
|
|
|
+ for (AddressAreaEntity.InfoListBean bean : infoList) {
|
|
|
+ mAddressAreaList.add(bean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Log.i(TAG,mAddressAreaList.toString()+"得到附近小区list");
|
|
|
+ toAddressSelectActivity();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ if (requestCode == 2 && resultCode == 1) {//返回小区选择
|
|
|
+ mListBean = (AddressAreaEntity.InfoListBean) data.getSerializableExtra("ListBean");
|
|
|
+ mAddressAreaList = (ArrayList) data.getSerializableExtra("AddressAreaList");
|
|
|
+ mDefCommTv.setText(mListBean.getAddress() + " " + mListBean.getDistance() + "m");
|
|
|
+ mAddressTv.setText(mListBean.toStingTv());
|
|
|
+ if(!mAddressTv.getText().toString().isEmpty()){
|
|
|
+ mAddressTv.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ mShequEt.setText(mListBean.getArea());
|
|
|
+ mDistrictEt.setText(mListBean.getDisName());
|
|
|
+ mStreeEt.setText(mListBean.getStreet());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 定位
|
|
|
+ */
|
|
|
+ private void locationAddress() {
|
|
|
+// mProgressDialog.showDialog("正在定位...");
|
|
|
+ mLocationUtils.startLocationInfo();
|
|
|
+ }
|
|
|
+ @TargetApi(Build.VERSION_CODES.M)
|
|
|
+ private void checkPermissions() {
|
|
|
+ mPermissions = CheckPermissionUtils.getNeededPermission(getActivity(), mPermissions);
|
|
|
+ if (mPermissions.length > 0) {
|
|
|
+ requestPermissions(mPermissions, 999);
|
|
|
+ }
|
|
|
+ if (mPermissions.length == 0) {
|
|
|
+ //申请过一次这里的permissions.length就为0 了
|
|
|
+ //申请权限后创建图片文件夹
|
|
|
+ Utils.createDir(mImageDir);
|
|
|
+ locationAddress();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void init() {
|
|
|
+ Log.i("111","aaaa"+mType);
|
|
|
+
|
|
|
+ if(mType==1){
|
|
|
+ mPointLayout.setVisibility(View.VISIBLE);
|
|
|
+ Log.i("111","aaaa"+mMapLocationInfo.toStringTv());
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+
|
|
|
+ mDistrictEt.setText(mMapLocationInfo.getDistrict());
|
|
|
+ mStreeEt.setText(mMapLocationInfo.getStreet());
|
|
|
+ }
|
|
|
+ else if(mType==2){
|
|
|
+ mPointLayout.setVisibility(View.GONE);
|
|
|
+ mActualTv.setText("新增点位信息:");
|
|
|
+ Log.i("111","aaaa"+mMapLocationInfo.toStringTv());
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+ mDistrictEt.setText(mMapLocationInfo.getDistrict());
|
|
|
+ mStreeEt.setText(mMapLocationInfo.getStreet());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ @OnClick({R.id.tv_default_community,R.id.btn_submit})
|
|
|
+ public void onClick(View view) {
|
|
|
+ if (view.getId() == R.id.tv_default_community) {//选择小区
|
|
|
+ Log.i("1","1");
|
|
|
+ toAddressSelect();
|
|
|
+ }
|
|
|
+ if (view.getId() == R.id.btn_submit) {//提交
|
|
|
+ String cummEt = mCummEt.getText().toString().trim();
|
|
|
+ String shequEt=mShequEt.getText().toString().trim();
|
|
|
+ String streetEt=mStreeEt.getText().toString().trim();
|
|
|
+ String districtEt=mDistrictEt.getText().toString().trim();
|
|
|
+ if (TextUtils.isEmpty(districtEt)) {
|
|
|
+ Utils.showToast(getActivity(), "请输入区名");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (TextUtils.isEmpty(streetEt)) {
|
|
|
+ Utils.showToast(getActivity(), "请输入街道名");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (TextUtils.isEmpty(shequEt)) {
|
|
|
+ Utils.showToast(getActivity(), "请输入社区名");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (TextUtils.isEmpty(cummEt)) {
|
|
|
+ Utils.showToast(getActivity(), "请输入小区名");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ postPoint();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ private void postPoint(){
|
|
|
+ mProgressDialog.showDialog("正在提交...");
|
|
|
+ if(mType==1){
|
|
|
+ OkHttpUtils.post()
|
|
|
+ .url(HttpUrl.ADDADDRESS_POST)
|
|
|
+ .addParams("district", mListBean == null ? "" : mListBean.getDisName())
|
|
|
+ .addParams("street", mListBean == null ? "" : mListBean.getStreet())
|
|
|
+ .addParams("area", mListBean == null ? "" : mListBean.getArea())
|
|
|
+ .addParams("addrCode", mListBean == null ? "" : mListBean.getAddrCode())
|
|
|
+ .addParams("longitude", mMapLocationInfo.getLongitude() + "")
|
|
|
+ .addParams("latitude", mMapLocationInfo.getLatitude() + "")
|
|
|
+ .addParams("address", mCummEt.getText().toString().trim()+"")
|
|
|
+ .build().execute(new Callback<PointFormEntity>() {
|
|
|
+ @Override
|
|
|
+ public PointFormEntity parseNetworkResponse(Response response, int id) throws Exception {
|
|
|
+ String jsonStr = response.body().string();
|
|
|
+ return (PointFormEntity) JsonUtils.parseJson2Obj(jsonStr, PointFormEntity.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Call call, Exception e, int id) {
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+ DialogUtil.showNetFailDialog(getActivity());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResponse(PointFormEntity entity, int id) {
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+ if (entity == null) {
|
|
|
+ DialogUtil.showErrDialog(getActivity(), "返回信息为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!"1000".endsWith(entity.getReturnCode())) {
|
|
|
+ DialogUtil.showErrDialog(getActivity(), entity.getReturnMsg());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ DialogUtil.showErrDialog(getActivity(), "点位修改成功!");
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else if(mType==2){
|
|
|
+ OkHttpUtils.post()
|
|
|
+ .url(HttpUrl.ADDADDRESS_POST)
|
|
|
+ .addParams("district", mDistrictEt.getText().toString().trim()+"")
|
|
|
+ .addParams("street", mStreeEt.getText().toString().trim()+"")
|
|
|
+ .addParams("area", mShequEt.getText().toString().trim()+"")
|
|
|
+ .addParams("longitude", mMapLocationInfo.getLongitude() + "")
|
|
|
+ .addParams("latitude", mMapLocationInfo.getLatitude() + "")
|
|
|
+ .addParams("address", mCummEt.getText().toString().trim()+"")
|
|
|
+ .build().execute(new Callback<PatrolFormEntity>() {
|
|
|
+ @Override
|
|
|
+ public PatrolFormEntity parseNetworkResponse(Response response, int id) throws Exception {
|
|
|
+ String jsonStr = response.body().string();
|
|
|
+ return (PatrolFormEntity) JsonUtils.parseJson2Obj(jsonStr, PatrolFormEntity.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Call call, Exception e, int id) {
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+ DialogUtil.showNetFailDialog(getActivity());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResponse(PatrolFormEntity entity, int id) {
|
|
|
+ mProgressDialog.dismiss();
|
|
|
+ if (entity == null) {
|
|
|
+ DialogUtil.showErrDialog(getActivity(), "返回信息为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!"1000".endsWith(entity.getReturnCode())) {
|
|
|
+ DialogUtil.showErrDialog(getActivity(), entity.getReturnMsg());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ DialogUtil.showErrDialog(getActivity(), "新增点位成功!");
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ public static PointRecordFragment newInstance(int type) {
|
|
|
+ PointRecordFragment fragment = new PointRecordFragment();
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putInt(TYPE, type);
|
|
|
+ fragment.setArguments(bundle);
|
|
|
+ return fragment;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|