33
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
package cn.shangyu.gdxzExpert.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.lidroid.xutils.exception.HttpException;
|
||||
import com.lidroid.xutils.http.RequestParams;
|
||||
import com.lidroid.xutils.http.ResponseInfo;
|
||||
import com.lidroid.xutils.http.callback.RequestCallBack;
|
||||
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.bean.SettingInfoBean;
|
||||
import cn.shangyu.gdxzExpert.http.HttpHelper;
|
||||
import cn.shangyu.gdxzExpert.utils.Constant;
|
||||
import cn.shangyu.gdxzExpert.utils.GsonTools;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.utils.ValidateUtils;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
||||
|
||||
/**
|
||||
* @author ssy 苏三元
|
||||
* @date 2015-8-31 下午2:47:47
|
||||
* 功能说明:我的-个人资料-编辑邮箱
|
||||
* //注意,此xml布局页面也被修改科室电话共用EditOfficePhoneActivity
|
||||
*/
|
||||
public class EditEmailActivity extends BaseActivity {
|
||||
|
||||
private EditText et_email;
|
||||
private String email;
|
||||
private String uuid;
|
||||
private String mobile;
|
||||
public static String modifyUrl = Url.getmodify;// 修改个人资料地址
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
// TODO Auto-generated method stub
|
||||
top_title.setText("修改邮箱");
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
//注意,此xml布局页面也被修改科室电话共用
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||||
View view = UIUtils.inflate(R.layout.activity_edit_email);
|
||||
et_email = (EditText) view.findViewById(R.id.et_email);//输入邮箱
|
||||
Button bt_save = (Button) view.findViewById(R.id.bt_save);//保存
|
||||
bt_save.setOnClickListener(this);
|
||||
initData();
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
// TODO Auto-generated method stub
|
||||
Intent intent = getIntent();
|
||||
String email = intent.getStringExtra("email");
|
||||
if (!TextUtils.isEmpty(email)) {
|
||||
et_email.setText(email);
|
||||
}
|
||||
//取出保存的uuid与手机号
|
||||
uuid = SharePrefUtil.getString(ct, "uuid", "");
|
||||
mobile = SharePrefUtil.getString(ct, Constant.mobile, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultState onLoad() {
|
||||
// TODO Auto-generated method stub
|
||||
return ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
switch (v.getId()) {
|
||||
case R.id.bt_save:
|
||||
// 保存数据到上页面
|
||||
email = et_email.getText().toString().trim();
|
||||
if (ValidateUtils.isValidEmail(email)) {
|
||||
// showProgressDialog("保存中...");
|
||||
// getList(modifyUrl);
|
||||
Intent intent = getIntent();
|
||||
intent.putExtra("email", email);
|
||||
this.setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
} else {
|
||||
ToastUtil.showToast("请输入正确的邮箱格式");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 本页面提交,弃用,返回数据当上个页面提交 getList
|
||||
*
|
||||
* @param loadUrl
|
||||
* void
|
||||
*/
|
||||
private void getList(String loadUrl) {
|
||||
RequestParams params = new RequestParams();// 封装参数
|
||||
params.addBodyParameter("uuid", uuid);// 唯一标识 必填
|
||||
params.addBodyParameter("userName", mobile);// 真实姓名 必填
|
||||
params.addBodyParameter("email", email);// 邮箱
|
||||
HttpHelper.loadData(HttpMethod.POST, loadUrl, params,
|
||||
new RequestCallBack<String>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ResponseInfo<String> info) {
|
||||
processData(info.result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException arg0, String arg1) {
|
||||
closeProgressDialog();
|
||||
LogUtil.i("数据请求失败了: " + arg1);
|
||||
ToastUtil.showToast("保存失败,请重试");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析并处理数据
|
||||
*
|
||||
* @param result
|
||||
*/
|
||||
private void processData(String result) {
|
||||
closeProgressDialog();
|
||||
SettingInfoBean bean = GsonTools.fromGsonToBean(result,
|
||||
SettingInfoBean.class);
|
||||
if ("1".equals(bean.code)) {
|
||||
SharePrefUtil.saveString(ct, "email", email);
|
||||
Intent intent = getIntent();
|
||||
intent.putExtra("email", email);
|
||||
this.setResult(RESULT_OK, intent);
|
||||
ToastUtil.showToast("保存成功");
|
||||
finish();
|
||||
} else {
|
||||
ToastUtil.showToast("保存失败,请重试");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user