修改用户信息(更换头像未完成)
This commit is contained in:
@ -18,6 +18,8 @@ import android.widget.TextView;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.LoginUtils;
|
||||
import com.gh.gamecenter.entity.UserInfoEntity;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
@ -26,7 +28,7 @@ import butterknife.OnClick;
|
||||
* Created by khy on 30/06/17.
|
||||
*/
|
||||
|
||||
public class UserInfoEditActivity extends BaseActivity {
|
||||
public class UserInfoEditActivity extends BaseActivity implements LoginUtils.onChangeUserInfoListener {
|
||||
@BindView(R.id.userinfo_sex_man)
|
||||
TextView mUserinfoSexMan;
|
||||
@BindView(R.id.userinfo_sex_woman)
|
||||
@ -49,13 +51,12 @@ public class UserInfoEditActivity extends BaseActivity {
|
||||
TextView mSaveTv;
|
||||
|
||||
private String mEditType;
|
||||
private String mEditContent;
|
||||
private UserInfoEntity mUserInfoEntity;
|
||||
|
||||
@NonNull
|
||||
public static Intent getIntent(Context context, String editType, String editContent) {
|
||||
public static Intent getIntent(Context context, String editType) {
|
||||
Intent intent = new Intent(context, UserInfoEditActivity.class);
|
||||
intent.putExtra("editType", editType);
|
||||
intent.putExtra("editContent", editContent);
|
||||
return intent;
|
||||
}
|
||||
|
||||
@ -68,7 +69,7 @@ public class UserInfoEditActivity extends BaseActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mEditType = getIntent().getStringExtra("editType");
|
||||
mEditContent = getIntent().getStringExtra("editContent");
|
||||
mUserInfoEntity = LoginUtils.getUserInfo(this);
|
||||
|
||||
// 添加分享图标
|
||||
mSaveTv = new TextView(this);
|
||||
@ -87,7 +88,9 @@ public class UserInfoEditActivity extends BaseActivity {
|
||||
R.id.reuse_actionbar);
|
||||
reuse_actionbar.addView(mSaveTv, params);
|
||||
|
||||
initView();
|
||||
if (mUserInfoEntity != null) {
|
||||
initView();
|
||||
}
|
||||
|
||||
mSaveTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -109,8 +112,9 @@ public class UserInfoEditActivity extends BaseActivity {
|
||||
mSaveTv.setVisibility(View.VISIBLE);
|
||||
mUserinfoNicknameEt.addTextChangedListener(new UserInfoEditTextWatcher(mUserinfoNicknameEt));
|
||||
title = "修改昵称";
|
||||
if (!TextUtils.isEmpty(mEditContent)) {
|
||||
mUserinfoNicknameEt.setText(mEditContent);
|
||||
String name = mUserInfoEntity.getName();
|
||||
if (!TextUtils.isEmpty(name)) {
|
||||
mUserinfoNicknameEt.setText(name);
|
||||
}
|
||||
break;
|
||||
case "contact":
|
||||
@ -118,8 +122,9 @@ public class UserInfoEditActivity extends BaseActivity {
|
||||
mSaveTv.setVisibility(View.VISIBLE);
|
||||
mUserinfoContactEt.addTextChangedListener(new UserInfoEditTextWatcher(mUserinfoContactEt));
|
||||
title = "联系方式";
|
||||
if (!TextUtils.isEmpty(mEditContent)) {
|
||||
mUserinfoContactEt.setText(mEditContent);
|
||||
String contact = mUserInfoEntity.getContact();
|
||||
if (!TextUtils.isEmpty(contact)) {
|
||||
mUserinfoContactEt.setText(contact);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -130,22 +135,17 @@ public class UserInfoEditActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void saveData() {
|
||||
Intent data = new Intent();
|
||||
if ("nickName".equals(mEditType)) {
|
||||
String value = mUserinfoNicknameEt.getText().toString();
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
data.putExtra("editContent", value);
|
||||
setResult(0x131, data);
|
||||
finish();
|
||||
LoginUtils.changeUserInfo(this, this, value, mEditType);
|
||||
} else {
|
||||
toast("昵称不能为空");
|
||||
}
|
||||
} else if ("contact".equals(mEditType)) {
|
||||
String value = mUserinfoContactEt.getText().toString();
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
data.putExtra("editContent", value);
|
||||
setResult(0x133, data);
|
||||
finish();
|
||||
LoginUtils.changeUserInfo(this, this, value, mEditType);
|
||||
} else {
|
||||
toast("请输入QQ或邮箱");
|
||||
}
|
||||
@ -162,20 +162,20 @@ public class UserInfoEditActivity extends BaseActivity {
|
||||
mUserinfoContactEt.setText("");
|
||||
break;
|
||||
case R.id.userinfo_sex_man:
|
||||
Intent data = new Intent();
|
||||
data.putExtra("editContent", "男");
|
||||
setResult(0x132, data);
|
||||
finish();
|
||||
LoginUtils.changeUserInfo(this, this, "男", mEditType);
|
||||
break;
|
||||
case R.id.userinfo_sex_woman:
|
||||
Intent data2 = new Intent();
|
||||
data2.putExtra("editContent", "女");
|
||||
setResult(0x132, data2);
|
||||
finish();
|
||||
LoginUtils.changeUserInfo(this, this, "女", mEditType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange() {
|
||||
setResult(0x131);
|
||||
finish();
|
||||
}
|
||||
|
||||
private class UserInfoEditTextWatcher implements TextWatcher {
|
||||
private EditText mEditText;
|
||||
|
||||
@ -192,11 +192,11 @@ public class UserInfoEditActivity extends BaseActivity {
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
int tvCount = s.length();
|
||||
if (mEditText == mUserinfoNicknameEt) {
|
||||
if (tvCount > 0) {
|
||||
mUserinfoNicknameIv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mUserinfoNicknameIv.setVisibility(View.GONE);
|
||||
}
|
||||
if (tvCount > 0) {
|
||||
mUserinfoNicknameIv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mUserinfoNicknameIv.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
if (tvCount > 0) {
|
||||
mUserinfoContactIv.setVisibility(View.VISIBLE);
|
||||
|
||||
Reference in New Issue
Block a user