33
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
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 android.widget.TextView;
|
||||
|
||||
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.widget.LoadingPage.ResultState;
|
||||
|
||||
/**
|
||||
* @author ssy
|
||||
* @date 2015-8-31 下午2:47:47
|
||||
*
|
||||
* 功能说明:我的-个人资料-编辑科室电话
|
||||
*/
|
||||
public class EditOfficePhoneActivity extends BaseActivity {
|
||||
|
||||
private EditText et_email;
|
||||
private TextView tv_show;
|
||||
private String uuid;
|
||||
private String mobile;
|
||||
private String officePhone;
|
||||
public static String modifyUrl = Url.getmodify;
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
// TODO Auto-generated method stub
|
||||
top_title.setText("修改科室电话");
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
// 采用共用编辑邮箱的页面EditEmailActivity
|
||||
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);
|
||||
tv_show = (TextView) view.findViewById(R.id.tv_show);
|
||||
Button bt_save = (Button) view.findViewById(R.id.bt_save);
|
||||
bt_save.setOnClickListener(this);
|
||||
// 设置输入类型为phone
|
||||
// et_email.setInputType(InputType.TYPE_CLASS_PHONE);
|
||||
// 设置数据限制长度为12位
|
||||
// et_email.setFilters(new InputFilter[] { new
|
||||
// InputFilter.LengthFilter(12) });
|
||||
// 设置hint提示语
|
||||
et_email.setHint("请输入您的科室电话");
|
||||
tv_show.setText("请填写您的真实科室电话,以便联系上您");
|
||||
initData();
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据 initData
|
||||
*
|
||||
* void
|
||||
*/
|
||||
private void initData() {
|
||||
// TODO Auto-generated method stub
|
||||
Intent intent = getIntent();
|
||||
String officePhone = intent.getStringExtra("officePhone");
|
||||
if (!TextUtils.isEmpty(officePhone)) {
|
||||
et_email.setText(officePhone);
|
||||
}
|
||||
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://保存数据
|
||||
officePhone = et_email.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(officePhone)) {
|
||||
ToastUtil.showToast("请填写科室电话");
|
||||
} else {
|
||||
// showProgressDialog("保存中...");
|
||||
// getList(modifyUrl);
|
||||
Intent intent = getIntent();
|
||||
intent.putExtra("officePhone", officePhone);
|
||||
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("officePhone", officePhone);// 科室电话
|
||||
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, "officePhone", officePhone);
|
||||
Intent intent = getIntent();
|
||||
intent.putExtra("officePhone", officePhone);
|
||||
this.setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
ToastUtil.showToast("保存成功");
|
||||
} else {
|
||||
ToastUtil.showToast("保存失败,请重试");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user