private void updateUserInfo() { mUserNameView.setText(mUserInfo.getName()); mHeaderPicView.setImageUrl(mUserInfo.getProtrait(), getImageLoder()); Integer post = 0; // TODO 获取文章数 mPostsView.setText(String.valueOf(post)); Integer goods = 0; // TODO 获取赞数 mGoodsView.setText(String.valueOf(goods)); String age = new String(); try { Date birthday = new SimpleDateFormat("yyyy-MM-dd").parse(mUserInfo.getBirthday()); Calendar ca = Calendar.getInstance(); ca.setTime(birthday); int birthYear = ca.get(Calendar.YEAR); ca.setTime(new Date()); int currentYear = ca.get(Calendar.YEAR); age = String.valueOf(currentYear - birthYear); } catch (Exception e) { } mAgeView.setText(age); mCityView.setText(mUserService.loadPlaceName(mUserInfo.getCity())); mDescriptionView.setText(mUserInfo.getDescription()); mSexIconView.setImageResource(UserService.SEX_DRAWABLE_MAP.get(mUserInfo.getSex())); }
private void startEditorDialog(int requestCode) { Intent intent = new Intent(PersonalInfoActivity.this, EditorDialogActivity.class); switch (requestCode) { case REQUEST_CODE_AGE: intent.putExtra(EditorDialogActivity.KEY_TITLE, getString(R.string.personalinfo_age)); intent.putExtra(EditorDialogActivity.KEY_TYPE, EditorDialogActivity.TYPE_DATE); Date date = new Date(); try { date = new SimpleDateFormat("yyyy-MM-dd").parse(mUserInfo.getBirthday()); } catch (Exception e) { } intent.putExtra(EditorDialogActivity.KEY_DATE, date); break; case REQUEST_CODE_PLACE: intent.putExtra(EditorDialogActivity.KEY_TITLE, getString(R.string.personalinfo_city)); intent.putExtra(EditorDialogActivity.KEY_TYPE, EditorDialogActivity.TYPE_PLACE); Integer placeid = 0; try { placeid = Integer.valueOf(mUserInfo.getCity()); } catch (Exception e) { } intent.putExtra(EditorDialogActivity.KEY_PLACE, placeid); break; case REQUEST_CODE_DESCRIPTION: intent.putExtra( EditorDialogActivity.KEY_TITLE, getString(R.string.personalinfo_description)); intent.putExtra(EditorDialogActivity.KEY_TYPE, EditorDialogActivity.TYPE_MULTI_TEXT); intent.putExtra(EditorDialogActivity.KEY_TEXT, mUserInfo.getDescription()); break; case REQUEST_CODE_SEX: intent.putExtra(EditorDialogActivity.KEY_TITLE, getString(R.string.personalinfo_sex)); intent.putExtra(EditorDialogActivity.KEY_TYPE, EditorDialogActivity.TYPE_SEX); intent.putExtra(EditorDialogActivity.KEY_SEX, mUserInfo.getSex()); default: break; } startActivityForResult(intent, requestCode); }