/** 保存用户个人信息 */ private void saveUserInfo() { if (curUser == null) { ToastUtils.showToast("请先登录"); Intent toLogin = new Intent(MineInfoEditActivity.this, LoginActivity.class); startActivity(toLogin); finish(); } else { Log.i("当前用户的ID: ", curUser.getObjectId()); curUser.update( this, curUser.getObjectId(), new UpdateListener() { @Override public void onSuccess() { Intent back = new Intent(MineInfoEditActivity.this, MineInfoActivity.class); setResult(RESULT_OK, back); // 返回成功码 finish(); ToastUtils.showToast("资料修改成功"); } @Override public void onFailure(int arg0, String arg1) { ToastUtils.showToast("资料修改失败: " + arg0 + " " + arg1); } }); } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RESULT_REQUEST_PHOTO) { if (resultCode == Activity.RESULT_OK) { if (data != null) { fileUri = data.getData(); } fileCropUri = CameraPhotoUtil.getOutputMediaFileUri(); cropImageUri(fileUri, fileCropUri, 640, 640, RESULT_REQUEST_PHOTO_CROP); } } else if (requestCode == RESULT_REQUEST_PHOTO_CROP) { if (resultCode == Activity.RESULT_OK) { try { String filePath = CameraPhotoUtil.getPath(this, fileCropUri); uploadFile(filePath); } catch (Exception e) { e.printStackTrace(); } } } else if (requestCode == RESULT_REQUEST_AUTH_HBUT) { if (resultCode == Activity.RESULT_OK) { curUser = BmobUser.getCurrentUser(this, User.class); aq.id(R.id.et_mineinfo_stuid).text(curUser.getStuID()); } } else if (requestCode == RESULT_REQUEST_DOR_PART) { if (resultCode == RESULT_OK) { String dorPart = data.getStringExtra(InputRowActivity.KEY_RESULT_DATA); curUser.setDorPart(dorPart); aq.id(R.id.et_mineinfo_dorpart).text(dorPart); } } else if (requestCode == RESULT_REQUEST_DOR_NUM) { if (resultCode == RESULT_OK) { String dorNum = data.getStringExtra(InputRowActivity.KEY_RESULT_DATA); curUser.setDorNum(dorNum); aq.id(R.id.et_mineinfo_dornum).text(dorNum); } } else if (requestCode == RESULT_REQUEST_PHONE) { if (resultCode == RESULT_OK) { String phone = data.getStringExtra(InputRowActivity.KEY_RESULT_DATA); curUser.setPhone(phone); aq.id(R.id.et_mineinfo_phone).text(phone); } } else if (requestCode == RESULT_REQUEST_QQ) { if (resultCode == RESULT_OK) { String qq = data.getStringExtra(InputRowActivity.KEY_RESULT_DATA); curUser.setQQ(qq); aq.id(R.id.et_mineinfo_qq).text(qq); } } }
/** 绑定学号 */ private void setStuID() { if (curUser.getStuID().equals("")) { new Handler() .postDelayed( new Runnable() { @Override public void run() { // 绑定学号 Intent toAuthHbut = new Intent(MineInfoEditActivity.this, AuthHBUTActivity.class); startActivityForResult(toAuthHbut, RESULT_REQUEST_AUTH_HBUT); } }, 1000); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder .setTitle("警告") .setMessage("当前小菜账号已经绑定学号 " + curUser.getStuID() + "是否重新绑定 ?") .setNegativeButton( "取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ToastUtils.showToast("取消绑定"); } }) .setPositiveButton( "确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // 绑定学号 Intent toAuthHbut = new Intent(MineInfoEditActivity.this, AuthHBUTActivity.class); startActivityForResult(toAuthHbut, RESULT_REQUEST_AUTH_HBUT); } }); AlertDialog dialog = builder.create(); dialog.show(); dialogTitleLineColor(dialog); } }
private void initView() { // aq = ShopApplication.getAQuery(); aq = new AQuery(this); curUser = BmobUser.getCurrentUser(this, User.class); if (curUser == null) return; aq.id(R.id.et_mineinfo_username).text(curUser.getNickname()); aq.id(R.id.et_mineinfo_sex).text(curUser.getSex()); aq.id(R.id.et_mineinfo_stuid).text(curUser.getStuID()); aq.id(R.id.et_mineinfo_school).text(curUser.getSchool()); aq.id(R.id.et_mineinfo_cademy).text(curUser.getCademy()); aq.id(R.id.et_mineinfo_class).text(curUser.getClassName()); if (!curUser.getClassName().equals("")) aq.id(R.id.et_mineinfo_time).text("20" + curUser.getClassName().substring(0, 2)); aq.id(R.id.et_mineinfo_dorpart).text(curUser.getDorPart()); aq.id(R.id.et_mineinfo_dornum).text(curUser.getDorNum()); aq.id(R.id.et_mineinfo_phone).text(curUser.getPhone()); aq.id(R.id.et_mineinfo_qq).text(curUser.getQQ()); if (null != curUser.getPicUser()) aq.id(R.id.img_mine_info_icon).image(curUser.getPicUser().getFileUrl(this)); else aq.id(R.id.img_mine_info_icon).image(R.drawable.ic_xiaocai_weixin); aq.id(R.id.rl_mine_info_icon).clicked(this); aq.id(R.id.rl_mine_info_username).clicked(this); aq.id(R.id.rl_mine_info_sex).clicked(this); aq.id(R.id.rl_mine_info_stuid).clicked(this); aq.id(R.id.rl_mine_info_school).clicked(this); aq.id(R.id.rl_mine_info_cademy).clicked(this); aq.id(R.id.rl_mine_info_dorpart).clicked(this); aq.id(R.id.rl_mine_info_dornum).clicked(this); aq.id(R.id.rl_mine_info_phone).clicked(this); aq.id(R.id.rl_mine_info_qq).clicked(this); }
private void refreshUserIcon() { aq.id(R.id.img_mine_info_icon).image(curUser.getPicUser().getUrl()); }