| | |
| | | import android.widget.TextView; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.google.gson.Gson; |
| | | import com.lcjian.library.util.Environment; |
| | | import com.lcjian.library.util.SingleToast; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.entity.vo.UserInfoVO; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.GlideCircleTransform; |
| | | import com.weikou.beibeivideo.util.SelectPicUtil; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | protected void onCreate(Bundle arg0) { |
| | | super.onCreate(arg0); |
| | | setContentView(R.layout.activity_person_info); |
| | | /* |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | | */ |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
| | | int result = 0; |
| | | int resourceId = getResources().getIdentifier("status_bar_height", |
| | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | Glide.with(PersonInfoActivity.this).load(BeibeiConstant.addPreFix(jsonObject.optJSONObject("Data").optString("Portrait"))).placeholder(R.drawable.ic_portrait_default).error(R.drawable.ic_portrait_default).into(iv_portrait); |
| | | tv_nickName.setText(jsonObject.optJSONObject("Data").optString("Nickname")); |
| | | tv_birthday.setText(jsonObject.optJSONObject("Data").optString("Birthday")); |
| | | tv_sex.setText(Integer.parseInt(jsonObject.optJSONObject("Data").optString("Sex")) == 0 ? "女" : "男"); |
| | | sign = jsonObject.optJSONObject("Data").optString("Sign"); |
| | | JSONObject data = jsonObject.optJSONObject("Data"); |
| | | UserInfoVO userInfoVO = new Gson().fromJson(data.toString(), UserInfoVO.class); |
| | | |
| | | Glide.with(PersonInfoActivity.this).load(BeibeiConstant.addPreFix(userInfoVO.getPortrait())). |
| | | placeholder(R.drawable.ic_portrait_default).error(R.drawable.ic_portrait_default).into(iv_portrait); |
| | | tv_nickName.setText(userInfoVO.getNickName()); |
| | | tv_birthday.setText(userInfoVO.getBirthday()); |
| | | tv_sex.setText(Integer.parseInt(userInfoVO.getSex()) == 0 ? "女" : "男"); |
| | | sign = userInfoVO.getSign(); |
| | | tv_autograph.setText(sign); |
| | | } |
| | | } |
| | |
| | | imgBase64 = bitmapToBase64(bm); |
| | | Log.i("mresult", "图片路劲为:" + path + "----requestcode:" + requestCode); |
| | | Glide.with(PersonInfoActivity.this).load(file).transform(new GlideCircleTransform(PersonInfoActivity.this)).into(iv_portrait); |
| | | |
| | | //上传 |
| | | updatePersonInfo(null, null, null, imgBase64, null); |
| | | } |
| | | } |
| | | } |
| | |
| | | getAutograph(); |
| | | break; |
| | | case R.id.tv_top_right://完成个人信息的修改 |
| | | upLoadRegisterData(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 上传个人信息 |
| | | */ |
| | | private void upLoadRegisterData() { |
| | | |
| | | private void updatePersonInfo(String sex, String birthday, |
| | | String personSign, String portrait, String nickName) { |
| | | SharedPreferences sp = getSharedPreferences("user", Context.MODE_PRIVATE); |
| | | String uid = sp.getString("uid", ""); |
| | | String loginUid = sp.getString("LoginUid", ""); |
| | | BeibeiVideoAPI.upLoadPersonInfo(this, uid, loginUid, mSex + "", tv_birthday.getText().toString(), |
| | | tv_autograph.getText().toString(), imgBase64, tv_nickName.getText().toString(), new BasicTextHttpResponseHandler() { |
| | | String uid = UserUtil.getUid(this); |
| | | String loginUid = UserUtil.getLoginUid(this); |
| | | BeibeiVideoAPI.upLoadPersonInfo(this, uid, loginUid, sex, birthday, |
| | | personSign, portrait, nickName, new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | SharedPreferences sharedPreferences = getSharedPreferences("user", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putString("name", tv_nickName.getText().toString()); |
| | | editor.putString("name", nickName); |
| | | editor.commit(); |
| | | |
| | | SingleToast.showToast(PersonInfoActivity.this, "个人信息更新成功"); |
| | | finish(); |
| | | } |
| | | } |
| | | }); |
| | |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | Log.i("mResult", "which的值为:" + which); |
| | | tv_sex.setText(sex[mSex]); |
| | | updatePersonInfo(mSex + "", null, null, null, null); |
| | | dialog.dismiss(); |
| | | } |
| | | }) |
| | |
| | | return; |
| | | } else { |
| | | tv_autograph.setText(str); |
| | | updatePersonInfo(null, null, str, null, null); |
| | | alertDialog.dismiss(); |
| | | } |
| | | } |
| | |
| | | SingleToast.showToast(PersonInfoActivity.this, "昵称不能为空"); |
| | | } else { |
| | | tv_nickName.setText(str); |
| | | updatePersonInfo(null, null, null, null, str); |
| | | dialog.dismiss(); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | tv_birthday.setText(date); |
| | | updatePersonInfo(null, date, null, null, null); |
| | | alertDialog.dismiss(); |
| | | } |
| | | }); |