Skip to content

Commit

Permalink
密码限制
Browse files Browse the repository at this point in the history
  • Loading branch information
zymiroe committed Jan 8, 2014
1 parent e81ccac commit 96e046e
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 46 deletions.
25 changes: 16 additions & 9 deletions baby/src/com/keju/baby/activity/baby/BabyMyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (mCurrentPhotoFile != null && mCurrentPhotoFile.exists())
mCurrentPhotoFile.delete();
} catch (Exception e) {
//MobclickAgent.reportError(BabyMyActivity.this, StringUtil.getExceptionInfo(e));
// MobclickAgent.reportError(BabyMyActivity.this,
// StringUtil.getExceptionInfo(e));
}
break;
case Constants.CAMERA_WITH_DATA:// 拍照
Expand Down Expand Up @@ -196,6 +197,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
}
return super.onKeyDown(keyCode, event);
}

@Override
public void onClick(View v) {
switch (v.getId()) {
Expand All @@ -210,11 +212,19 @@ public void onClick(View v) {
String childbirthWay = tvDeliveryWay.getText().toString().trim();
String complication = tvComplication.getText().toString().trim();
String grade = tvApgar.getText().toString().trim();
if (NetUtil.checkNet(this)) {
new PostBabyInfor(babyName, parentNumber, babySix, babyProduction, babyWeight, babyHeight,
babyHeadCircumference, childbirthWay, complication, grade).execute();
if (StringUtil.isBlank(babyName) || StringUtil.isBlank(parentNumber) || StringUtil.isBlank(babySix)
|| StringUtil.isBlank(babyProduction) || StringUtil.isBlank(babyWeight)
|| StringUtil.isBlank(babyHeight) || StringUtil.isBlank(childbirthWay) || StringUtil.isBlank(grade)
|| StringUtil.isBlank(babyHeadCircumference) || StringUtil.isBlank(complication)) {
showShortToast("请输入完整的信息");
return;
} else {
showShortToast(R.string.NoSignalException);
if (NetUtil.checkNet(this)) {
new PostBabyInfor(babyName, parentNumber, babySix, babyProduction, babyWeight, babyHeight,
babyHeadCircumference, childbirthWay, complication, grade).execute();
} else {
showShortToast(R.string.NoSignalException);
}
}
break;
case R.id.tvGendar:
Expand All @@ -235,7 +245,7 @@ public void onClick(View v) {
showDialog(list);
break;
case R.id.tvComplication:
Bundle b= new Bundle();
Bundle b = new Bundle();
b.putString(Constants.EXTRA_DATA, tvComplication.getText().toString());
Intent intent = new Intent(this, ComplicationActivity.class);
intent.putExtras(b);
Expand Down Expand Up @@ -298,8 +308,6 @@ public void onClick(View v) {
}

}



private void createPhotoDir() {
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
Expand Down Expand Up @@ -375,7 +383,6 @@ public static Intent getCropImageIntent(Uri photoUri) {
return intent;
}


Calendar cal = Calendar.getInstance();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,19 @@
* @version 创建时间:2013-10-25 下午2:57:49
*/

public class DoctorCreatBabyAccountActivity extends BaseActivity implements OnClickListener, OnCheckedChangeListener{
private ImageView btnLeft,btnRight;
public class DoctorCreatBabyAccountActivity extends BaseActivity implements OnClickListener, OnCheckedChangeListener {
private ImageView btnLeft, btnRight;
private TextView tvTitle;
private EditText etPhone,etName,etPassword,etPasswordConfirm,etWeight,etHeight,etHead;
private TextView tvGender,tvPreProduction,tvBirthday,tvWay,tvComplication;

private EditText etPhone, etName, etPassword, etPasswordConfirm, etWeight, etHeight, etHead;
private TextView tvGender, tvPreProduction, tvBirthday, tvWay, tvComplication;
private RadioGroup rgStandard;

private List<String> list = new ArrayList<String>();
private String dateType;
private String complicationStr;
private String standardStr = "WHO";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -76,12 +77,12 @@ private void findView() {
btnRight.setOnClickListener(this);
tvTitle.setVisibility(View.VISIBLE);
tvTitle.setText("创建婴儿账户");

etPhone = (EditText) findViewById(R.id.etPhone);
etName = (EditText) findViewById(R.id.etName);
etPassword = (EditText) findViewById(R.id.etPassword);
etPasswordConfirm = (EditText) findViewById(R.id.etPasswordConfirm);

tvGender = (TextView) findViewById(R.id.tvGender);
tvPreProduction = (TextView) findViewById(R.id.tvPreProduction);
tvBirthday = (TextView) findViewById(R.id.tvBirthday);
Expand All @@ -93,6 +94,7 @@ private void findView() {
rgStandard = (RadioGroup) findViewById(R.id.rgStandard);
rgStandard.setOnCheckedChangeListener(this);
}

@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
Expand All @@ -104,20 +106,23 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
break;
}
}

private void fillData() {
tvGender.setOnClickListener(this);
tvPreProduction.setOnClickListener(this);
tvBirthday.setOnClickListener(this);
tvWay.setOnClickListener(this);
tvComplication.setOnClickListener(this);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK && requestCode == Constants.REQUEST_COMPLICATION){
if (resultCode == RESULT_OK && requestCode == Constants.REQUEST_COMPLICATION) {
complicationStr = data.getStringExtra(Constants.EXTRA_DATA);
}
}

@Override
public void onClick(View v) {
switch (v.getId()) {
Expand All @@ -126,68 +131,73 @@ public void onClick(View v) {
break;
case R.id.btnRight:
String phone = etPhone.getText().toString();
if(!StringUtil.isMobile(phone)){
if (!StringUtil.isMobile(phone)) {
showShortToast("手机号码格式不正确");
return;
}
String name = etName.getText().toString();
if(TextUtils.isEmpty(name)){
if (TextUtils.isEmpty(name)) {
showShortToast("婴儿名不能为空");
return;
}
String password = etPassword.getText().toString();
if(TextUtils.isEmpty(password)){
if (TextUtils.isEmpty(password)) {
showShortToast("密码不能为空");
return;
}
if (password.length() < 6) {
showShortToast("请输入六位数以上的密码");
return;
}
String passwordConfirm = etPasswordConfirm.getText().toString();
if(!passwordConfirm.equals(password)){
if (!passwordConfirm.equals(password)) {
showShortToast("两次输入的密码不一致");
return;
}
String gender = tvGender.getText().toString();
String preproduction = tvPreProduction.getText().toString();
if(TextUtils.isEmpty(preproduction)){
if (TextUtils.isEmpty(preproduction)) {
showShortToast("请填写预产期");
return;
}
String birthday = tvBirthday.getText().toString();
if(TextUtils.isEmpty(birthday)){
if (TextUtils.isEmpty(birthday)) {
showShortToast("请填写出生日期");
return;
}
String weight = etWeight.getText().toString();
if(TextUtils.isEmpty(weight)){
if (TextUtils.isEmpty(weight)) {
showShortToast("请填写体重");
return;
}
String height = etHeight.getText().toString();
if(TextUtils.isEmpty(height)){
if (TextUtils.isEmpty(height)) {
showShortToast("请填写身高");
return;
}
String head = etHead.getText().toString();
if(TextUtils.isEmpty(head)){
if (TextUtils.isEmpty(head)) {
showShortToast("请填写头围");
return;
}
String way = tvWay.getText().toString();
if(TextUtils.isEmpty(way)){
if (TextUtils.isEmpty(way)) {
showShortToast("请选择分娩方式");
return;
}
String complication = tvComplication.getText().toString();
if(TextUtils.isEmpty(complication)){
if (TextUtils.isEmpty(complication)) {
showShortToast("请选择合并症");
return;
}
if(complication.equals("有")){
if (complication.equals("有")) {
complication = complicationStr;
}
if(!NetUtil.checkNet(this)){
if (!NetUtil.checkNet(this)) {
showShortToast(R.string.NoSignalException);
}
new CreatBabyAccountTask(name, password, phone, gender, preproduction, birthday, weight, height, head, way, complication).execute();
new CreatBabyAccountTask(name, password, phone, gender, preproduction, birthday, weight, height, head, way,
complication).execute();
break;
case R.id.tvGender:
dialogType = "gender";
Expand Down Expand Up @@ -222,6 +232,7 @@ public void onClick(View v) {
break;
}
}

Calendar cal = Calendar.getInstance();

/**
Expand All @@ -244,12 +255,13 @@ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth
};

private void updateDate() {
if(dateType.equals("preproduction")){
if (dateType.equals("preproduction")) {
tvPreProduction.setText(DateUtil.dateToString("yyyy-MM-dd", cal.getTime()));
}else if(dateType.equals("birthday")){
} else if (dateType.equals("birthday")) {
tvBirthday.setText(DateUtil.dateToString("yyyy-MM-dd", cal.getTime()));
}
}

private ListAdapter adapter;
private Dialog dialog;
private String dialogType;
Expand All @@ -272,6 +284,7 @@ private void showDialog(List<String> list) {
lp1.width = (int) (display1.getWidth() - 20); // 设置宽度
dialog.getWindow().setAttributes(lp1);
}

/**
* 城市选择 listview 点击
*/
Expand All @@ -283,15 +296,17 @@ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
tvGender.setText((String) adapter.getItem(arg2));
} else if (dialogType.equals("diliveryWay")) {
tvWay.setText((String) adapter.getItem(arg2));
}else if(dialogType.equals("complication")){
} else if (dialogType.equals("complication")) {
tvComplication.setText((String) adapter.getItem(arg2));
if(((String) adapter.getItem(arg2)).equals("有")){
startActivityForResult(new Intent(DoctorCreatBabyAccountActivity.this, ComplicationActivity.class), Constants.REQUEST_COMPLICATION);
if (((String) adapter.getItem(arg2)).equals("有")) {
startActivityForResult(new Intent(DoctorCreatBabyAccountActivity.this, ComplicationActivity.class),
Constants.REQUEST_COMPLICATION);
}
}
dialog.dismiss();
}
};

/**
* 获取医生城市的适配器
*
Expand Down Expand Up @@ -340,13 +355,15 @@ class ViewHolder {
}

}

/**
* 创建婴儿账户
*
* @author Zhoujun
*
*
*/
private class CreatBabyAccountTask extends AsyncTask<Void, Void, JSONObject>{
private class CreatBabyAccountTask extends AsyncTask<Void, Void, JSONObject> {

private String baby_name;
private String baby_pass;
private String patriarch_tel;
Expand All @@ -358,7 +375,7 @@ private class CreatBabyAccountTask extends AsyncTask<Void, Void, JSONObject>{
private String born_head;
private String childbirth_style;
private String complication_id;

public CreatBabyAccountTask(String baby_name, String baby_pass, String patriarch_tel, String gender,
String due_date, String born_birthday, String born_weight, String born_height, String born_head,
String childbirth_style, String complication_id) {
Expand All @@ -385,30 +402,33 @@ protected void onPreExecute() {
@Override
protected JSONObject doInBackground(Void... params) {
try {
return new BusinessHelper().creatBabyAccount(baby_name, baby_pass, patriarch_tel, gender, due_date, born_birthday, born_weight, born_height, born_head, childbirth_style, complication_id,standardStr);
return new BusinessHelper().creatBabyAccount(baby_name, baby_pass, patriarch_tel, gender, due_date,
born_birthday, born_weight, born_height, born_head, childbirth_style, complication_id,
standardStr);
} catch (SystemException e) {
return null;
}
}

@Override
protected void onPostExecute(JSONObject result) {
super.onPostExecute(result);
dismissPd();
if(result != null){
if (result != null) {
try {
int status = result.getInt("code");
if(status == Constants.REQUEST_SUCCESS){
if (status == Constants.REQUEST_SUCCESS) {
showShortToast("创建婴儿账户成功");
Intent intent = new Intent(Constants.REQUEST_CREATE_BABY + "");
sendBroadcast(intent);
finish();
}else{
} else {
showShortToast(result.getString("message"));
}
} catch (JSONException e) {
showShortToast(R.string.json_exception);
}
}else{
} else {
showShortToast(R.string.connect_server_exception);
}
}
Expand Down

0 comments on commit 96e046e

Please sign in to comment.