|
|
@@ -3,6 +3,7 @@ package com.uas.appme.settings.activity;
|
|
|
import android.Manifest;
|
|
|
import android.app.Activity;
|
|
|
import android.app.AlertDialog;
|
|
|
+import android.app.ProgressDialog;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.net.Uri;
|
|
|
@@ -17,9 +18,11 @@ import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.andreabaccega.widget.FormEditText;
|
|
|
+import com.android.volley.AuthFailureError;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.android.volley.Response;
|
|
|
+import com.android.volley.VolleyError;
|
|
|
import com.common.LogUtil;
|
|
|
import com.common.data.JSONUtil;
|
|
|
import com.common.data.ListUtils;
|
|
|
@@ -27,18 +30,22 @@ import com.common.data.StringUtil;
|
|
|
import com.common.hmac.Md5Util;
|
|
|
import com.common.system.PermissionUtil;
|
|
|
import com.common.ui.CameraUtil;
|
|
|
+import com.common.ui.ImageUtil;
|
|
|
+import com.common.ui.ProgressDialogUtil;
|
|
|
import com.core.app.MyApplication;
|
|
|
import com.core.base.BaseActivity;
|
|
|
import com.core.model.SelectBean;
|
|
|
-import com.core.net.http.ViewUtil;
|
|
|
+import com.core.net.volley.ObjectResult;
|
|
|
+import com.core.net.volley.Result;
|
|
|
+import com.core.net.volley.StringJsonObjectRequest;
|
|
|
import com.core.utils.CommonUtil;
|
|
|
import com.core.utils.ToastUtil;
|
|
|
+import com.core.utils.helper.AvatarHelper;
|
|
|
import com.core.widget.view.Activity.SelectActivity;
|
|
|
-import com.lidroid.xutils.HttpUtils;
|
|
|
-import com.lidroid.xutils.exception.HttpException;
|
|
|
-import com.lidroid.xutils.http.ResponseInfo;
|
|
|
-import com.lidroid.xutils.http.callback.RequestCallBack;
|
|
|
-import com.lidroid.xutils.http.client.HttpRequest;
|
|
|
+import com.core.xmpp.model.AddAttentionResult;
|
|
|
+import com.loopj.android.http.AsyncHttpClient;
|
|
|
+import com.loopj.android.http.AsyncHttpResponseHandler;
|
|
|
+import com.loopj.android.http.RequestParams;
|
|
|
import com.me.network.app.http.HttpClient;
|
|
|
import com.me.network.app.http.Method;
|
|
|
import com.me.network.app.http.rx.ResultListener;
|
|
|
@@ -50,7 +57,10 @@ import com.uas.appme.settings.model.BSettingPlaceBean;
|
|
|
import com.uas.appme.settings.model.PersonSetingBean;
|
|
|
import com.umeng.socialize.utils.Log;
|
|
|
|
|
|
+import org.apache.http.Header;
|
|
|
+
|
|
|
import java.io.File;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -83,6 +93,7 @@ public class PersonSettingActivity extends BaseActivity implements View.OnClickL
|
|
|
private static final int REQUEST_CODE_CAPTURE_PHOTO = 1;// 拍照
|
|
|
private static final int REQUEST_CODE_PICK_PHOTO = 2;//单选照片
|
|
|
private String photoselect=null;
|
|
|
+ private ProgressDialog mProgressDialog;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -130,7 +141,7 @@ public class PersonSettingActivity extends BaseActivity implements View.OnClickL
|
|
|
sc_industry = getIntent().getStringExtra("sc_industry");
|
|
|
sc_industrycode = getIntent().getStringExtra("sc_industrycode");
|
|
|
|
|
|
-
|
|
|
+ mProgressDialog = ProgressDialogUtil.init(mContext, null, getString(R.string.please_wait));
|
|
|
}
|
|
|
private void initData() {
|
|
|
|
|
|
@@ -149,7 +160,9 @@ public class PersonSettingActivity extends BaseActivity implements View.OnClickL
|
|
|
if (!"医疗".equals(sc_industry))
|
|
|
user_department_tv.setText("部门");
|
|
|
|
|
|
- HttpClient httpClient = new HttpClient.Builder(Constant.BASE_BOOKING_SETTING_URL).isDebug(true).build(true);
|
|
|
+ HttpClient httpClient =
|
|
|
+// new HttpClient.Builder(Constant.BASE_BOOKING_SETTING_URL).isDebug(true).build(true);\
|
|
|
+ new HttpClient.Builder(Constant.BASE_BOOKING_SETTING_URL).isDebug(true).build(true);
|
|
|
httpClient.Api().send(new HttpClient.Builder()
|
|
|
.url("user/appPlaceList")
|
|
|
.add("companyid",CommonUtil.getSharedPreferences(MyApplication.getInstance(),"erp_uu"))
|
|
|
@@ -190,9 +203,10 @@ public class PersonSettingActivity extends BaseActivity implements View.OnClickL
|
|
|
sm_id = model.getResult().get(position).getSm_id();
|
|
|
mBtnSave.setText(getString(R.string.common_update_button));
|
|
|
getSupportActionBar().setTitle(getString(R.string.common_update_button));
|
|
|
-
|
|
|
sm_userid = model.getResult().get(position).getSm_userid();
|
|
|
-
|
|
|
+ AvatarHelper.getInstance().display(sm_userid, image_im, true, true); //显示头像照片
|
|
|
+ photoselect = AvatarHelper.getAvatarUrl(sm_userid,true);
|
|
|
+ Log.i("files0x01",photoselect);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -342,8 +356,11 @@ public class PersonSettingActivity extends BaseActivity implements View.OnClickL
|
|
|
}
|
|
|
|
|
|
private void saveJudge() {
|
|
|
-
|
|
|
-// doSaveImage();
|
|
|
+ File file= new File(photoselect);
|
|
|
+ if (!file.exists()) {// 文件不存在
|
|
|
+ ToastMessage("请添加头像照片");
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (mUserNameTv.testValidity() && mUserSexTv.testValidity()
|
|
|
&& mUserTelTv.testValidity()){
|
|
|
if (!StringUtil.isEmpty(mUserEmailTv.getText().toString())) {
|
|
|
@@ -358,82 +375,6 @@ public class PersonSettingActivity extends BaseActivity implements View.OnClickL
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void doSaveImage() {
|
|
|
- if (StringUtil.isEmpty(photoselect)) return;
|
|
|
- File waterBitmapToFile= new File(photoselect);
|
|
|
- if (!waterBitmapToFile.isFile()){
|
|
|
- return;
|
|
|
- }else {
|
|
|
- com.lidroid.xutils.http.RequestParams params = new com.lidroid.xutils.http.RequestParams();
|
|
|
- params.addQueryStringParameter("master", CommonUtil.getSharedPreferences(ct, "erp_master"));
|
|
|
- params.addHeader("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
- params.addBodyParameter("userid", MyApplication.getInstance().mLoginUser.getUserId());
|
|
|
- params.addBodyParameter("file1", waterBitmapToFile);
|
|
|
- String url = "http://113.105.74.140:8080/upload/UploadServlet";
|
|
|
- final HttpUtils http = new HttpUtils();
|
|
|
- http.send(HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() {
|
|
|
- @Override
|
|
|
- public void onStart() {
|
|
|
- progressDialog.show();
|
|
|
- ViewUtil.ToastMessage(ct, getString(com.uas.appworks.R.string.sending_picture)+"...");
|
|
|
- }
|
|
|
- @Override
|
|
|
- public void onLoading(long total, long current, boolean isUploading) {
|
|
|
- if (isUploading) {
|
|
|
- } else {
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onSuccess(ResponseInfo<String> responseInfo) {
|
|
|
- if (JSONUtil.validate(responseInfo.result) && JSON.parseObject(responseInfo.result).getBoolean("success")) {
|
|
|
- LogUtil.prinlnLongMsg("UploadServlet", responseInfo.result + "");
|
|
|
-
|
|
|
- try {
|
|
|
- JSONObject object = JSON.parseObject(responseInfo.result);
|
|
|
- JSONObject dataobject = object.getJSONObject("data");
|
|
|
- if (dataobject == null) return;
|
|
|
- JSONArray imagearray = dataobject.getJSONArray("images");
|
|
|
- if (ListUtils.isEmpty(imagearray)) return;
|
|
|
- String oUrl = imagearray.getJSONObject(0).getString("oUrl");
|
|
|
- if (!StringUtil.isEmpty(oUrl))
|
|
|
- doUpdateUrl(oUrl);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(HttpException error, String msg) {
|
|
|
- ViewUtil.ToastMessage(ct, getString(com.uas.appworks.R.string.common_save_failed) + msg);
|
|
|
- progressDialog.dismiss();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- private void doUpdateUrl(String oUrl) {
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("sc_imageurl",oUrl);
|
|
|
- params.put("sc_uu",CommonUtil.getSharedPreferences(MyApplication.getInstance(),"erp_uu"));
|
|
|
- HttpClient httpClient = new HttpClient.Builder(Constant.BASE_BOOKING_SETTING_URL).isDebug(true).build(true);
|
|
|
- httpClient.getHeaders().remove("Content-Type");
|
|
|
- httpClient.Api().send(new HttpClient.Builder()
|
|
|
- .url("user/appStorurl")
|
|
|
- .add("map",JSONUtil.map2JSON(params))
|
|
|
- .add("token",MyApplication.getInstance().mAccessToken)
|
|
|
- .method(Method.POST)
|
|
|
- .build(),new ResultSubscriber<>(new ResultListener<Object>() {
|
|
|
- @Override
|
|
|
- public void onResponse(Object o) {
|
|
|
- LogUtil.prinlnLongMsg("hi/appStorurl", o.toString()+"ddd");
|
|
|
- if (!JSONUtil.validate(o.toString()) || o == null) return;
|
|
|
- if (o.toString().contains("result") && JSON.parseObject(o.toString()).getBoolean("result")){
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }));
|
|
|
- }
|
|
|
private void saveRequest() {
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
@@ -452,7 +393,9 @@ public class PersonSettingActivity extends BaseActivity implements View.OnClickL
|
|
|
params.put("sm_email",mUserEmailTv.getText().toString());
|
|
|
LogUtil.prinlnLongMsg("appPersonSet",JSONUtil.map2JSON(params));
|
|
|
|
|
|
- HttpClient httpClient = new HttpClient.Builder(Constant.BASE_BOOKING_SETTING_URL).isDebug(true).build(true);
|
|
|
+ HttpClient httpClient =
|
|
|
+// new HttpClient.Builder(Constant.BASE_BOOKING_SETTING_URL).isDebug(true).build(true);
|
|
|
+ new HttpClient.Builder(Constant.BASE_BOOKING_SETTING_URL).isDebug(true).build(true);
|
|
|
httpClient.Api().send(new HttpClient.Builder()
|
|
|
.url("user/appPersonSet")
|
|
|
.add("map", JSONUtil.map2JSON(params))
|
|
|
@@ -467,19 +410,137 @@ public class PersonSettingActivity extends BaseActivity implements View.OnClickL
|
|
|
.build(),new ResultSubscriber<>(new ResultListener<Object>() {
|
|
|
@Override
|
|
|
public void onResponse(Object o) {
|
|
|
- if (!JSONUtil.validate(o.toString()) || o == null) return;
|
|
|
LogUtil.prinlnLongMsg("appPersonSet", o.toString()+"");
|
|
|
- if (o.toString().contains("result") && JSON.parseObject(o.toString()).getBoolean("result")){
|
|
|
- Toast.makeText(ct,getString(R.string.common_save_success),Toast.LENGTH_LONG).show();
|
|
|
- setResult(20);
|
|
|
- finish();
|
|
|
- }else
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (!JSONUtil.validate(o.toString()) || o == null) return;
|
|
|
+ if (o.toString().contains("result") && JSON.parseObject(o.toString()).getBoolean("result")){
|
|
|
+ if (o.toString().contains("imid")){
|
|
|
+ String imid = JSON.parseObject(o.toString()).getString("imid");
|
|
|
+ if (StringUtil.isEmpty(imid)) return;
|
|
|
+ unLoadHeader(imid);
|
|
|
+ }else
|
|
|
+ jumpTo();
|
|
|
+
|
|
|
+ }else
|
|
|
+ ToastMessage(getString(R.string.save_failed));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
ToastMessage(getString(R.string.save_failed));
|
|
|
+ }
|
|
|
}
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void jumpTo() {
|
|
|
+ if (!StringUtil.isEmpty(sm_id)){
|
|
|
+ Toast.makeText(ct,getString(R.string.update_success),Toast.LENGTH_LONG).show();
|
|
|
+ setResult(20);
|
|
|
+ }else {
|
|
|
+ Toast.makeText(ct,getString(R.string.common_save_success),Toast.LENGTH_LONG).show();
|
|
|
+ startActivity(new Intent(PersonSettingActivity.this,PersonSettingListActivity.class)
|
|
|
+ .putExtra("sc_industry",sc_industry)
|
|
|
+ .putExtra("sc_industrycode",sc_industrycode));
|
|
|
+ }
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void unLoadHeader(String imid) {
|
|
|
+ File file= new File(photoselect);
|
|
|
+ if (!file.exists()) {// 文件不存在
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ file = ImageUtil.compressBitmapToFile(photoselect,100,360,480); //压缩
|
|
|
+ // 显示正在上传的ProgressDialog
|
|
|
+ ProgressDialogUtil.show(mProgressDialog, getString(R.string.upload_avataring));
|
|
|
+ RequestParams params = new RequestParams();
|
|
|
+// String loginUserId = MyApplication.getInstance().mLoginUser.getUserId();
|
|
|
+ params.put("userId", imid);
|
|
|
+ try {
|
|
|
+ params.put("file1", file);
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ AsyncHttpClient client = new AsyncHttpClient();
|
|
|
+ LogUtil.i("url=" + mConfig.AVATAR_UPLOAD_URL);
|
|
|
+ LogUtil.i("params=" + params.toString());
|
|
|
+ client.post(mConfig.AVATAR_UPLOAD_URL, params, new AsyncHttpResponseHandler() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
|
|
|
+ boolean success = false;
|
|
|
+ if (arg0 == 200) {
|
|
|
+ Result result = null;
|
|
|
+ try {
|
|
|
+ result = JSON.parseObject(new String(arg2), Result.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (result != null && result.getResultCode() == Result.CODE_SUCCESS) {
|
|
|
+ success = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ProgressDialogUtil.dismiss(mProgressDialog);
|
|
|
+ if (success) {
|
|
|
+ ToastUtil.showToast(PersonSettingActivity.this, R.string.upload_avatar_success);
|
|
|
+ String name = CommonUtil.getName();
|
|
|
+ String phone = mUserTelTv.getText().toString().trim().replaceAll(" ", "");
|
|
|
+ String modeid1 = "0398e112-97a3-40b0-8430-0e871ef22524";
|
|
|
+
|
|
|
+ String modeid2 = "fd4ac30e-b176-4410-ac0e-e39c8b71dfe0";
|
|
|
+
|
|
|
+ sendMessages(modeid1,name,phone);
|
|
|
+ sendMessages(modeid2,name,phone);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ ToastUtil.showToast(PersonSettingActivity.this, R.string.upload_avatar_failed);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
|
|
|
+ ProgressDialogUtil.dismiss(mProgressDialog);
|
|
|
+ ToastUtil.showToast(PersonSettingActivity.this, R.string.upload_avatar_failed);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendMessages( final String modeid, final String name, final String phone) {
|
|
|
+ StringJsonObjectRequest<AddAttentionResult> request = new StringJsonObjectRequest<AddAttentionResult>(
|
|
|
+ Request.Method.POST, "http://message.ubtob.com/sms/send", new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError arg0) {
|
|
|
+// dimssLoading();
|
|
|
+ }
|
|
|
+ }, new StringJsonObjectRequest.Listener<AddAttentionResult>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(ObjectResult<AddAttentionResult> result) {
|
|
|
+ Toast.makeText(ct,"短信发送成功",Toast.LENGTH_LONG).show();
|
|
|
+ jumpTo();
|
|
|
+
|
|
|
+ }
|
|
|
+ }, AddAttentionResult.class, null) {
|
|
|
+ @Override
|
|
|
+ public byte[] getBody() throws AuthFailureError {
|
|
|
+ String param = "{\"receiver\":\"" + phone + "\",\"params\":[\"" + name + "\"],\"templateId\":\"" + modeid + "\"}";
|
|
|
+ LogUtil.i("param=" + param);
|
|
|
+ return param.getBytes();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() {
|
|
|
+ HashMap<String, String> headers = new HashMap<String, String>();
|
|
|
+ headers.put("Accept", "application/json");
|
|
|
+ headers.put("Content-Type", "application/json; charset=UTF-8");
|
|
|
+ return headers;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ MyApplication.getInstance().getFastVolley().addDefaultRequest("Volley", request);
|
|
|
+ }
|
|
|
+
|
|
|
private void showSelectSexDialog() {
|
|
|
// 1是男,0是女,2是全部
|
|
|
String[] sexs = new String[]{ getString(com.uas.appcontact.R.string.user_body), getString(com.uas.appcontact.R.string.user_girl)};
|