feat:优化用户修改昵称、简介体验(在当前页完成网络请求)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.nnbc123.app.ui.login;
|
package com.nnbc123.app.ui.login;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
@@ -20,9 +21,11 @@ import com.netease.nim.uikit.StatusBarUtil;
|
|||||||
import com.nnbc123.app.R;
|
import com.nnbc123.app.R;
|
||||||
import com.nnbc123.app.base.BaseActivity;
|
import com.nnbc123.app.base.BaseActivity;
|
||||||
import com.nnbc123.app.base.TitleBar;
|
import com.nnbc123.app.base.TitleBar;
|
||||||
|
import com.nnbc123.core.auth.AuthModel;
|
||||||
import com.nnbc123.core.user.UserModel;
|
import com.nnbc123.core.user.UserModel;
|
||||||
import com.nnbc123.core.user.bean.UserInfo;
|
import com.nnbc123.core.user.bean.UserInfo;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by zhouxiangfeng on 2017/5/13.
|
* Created by zhouxiangfeng on 2017/5/13.
|
||||||
*/
|
*/
|
||||||
@@ -41,8 +44,7 @@ public class ModifyInfoActivity extends BaseActivity implements View.OnClickList
|
|||||||
|
|
||||||
private TextView tvCountDown;
|
private TextView tvCountDown;
|
||||||
|
|
||||||
public static final String CONTENT = "content";
|
public static final String USER_INFO = "user_info";
|
||||||
public static final String CONTENT_NICK = "contentNick";
|
|
||||||
private CoordinatorLayout layout_coordinator;
|
private CoordinatorLayout layout_coordinator;
|
||||||
|
|
||||||
TextWatcher textWatcher = new TextWatcher() {
|
TextWatcher textWatcher = new TextWatcher() {
|
||||||
@@ -117,19 +119,17 @@ public class ModifyInfoActivity extends BaseActivity implements View.OnClickList
|
|||||||
// 个人简介允许为空,nick不能为空
|
// 个人简介允许为空,nick不能为空
|
||||||
if (modifyType == CONTENT_MODIFY) {
|
if (modifyType == CONTENT_MODIFY) {
|
||||||
String content = etEditText.getText().toString();
|
String content = etEditText.getText().toString();
|
||||||
Intent intent = new Intent();
|
UserInfo info = new UserInfo();
|
||||||
intent.putExtra(CONTENT, content);
|
info.setUid(AuthModel.get().getCurrentUid());
|
||||||
setResult(RESULT_OK, intent);
|
info.setUserDesc(content);
|
||||||
finish();
|
updateUserInfo(info);
|
||||||
|
|
||||||
} else if (modifyType == NICK_MODIFY) {
|
} else if (modifyType == NICK_MODIFY) {
|
||||||
String contentNick = etEditTextNick.getText().toString();
|
String contentNick = etEditTextNick.getText().toString();
|
||||||
|
|
||||||
if (!contentNick.trim().isEmpty()) {
|
if (!contentNick.trim().isEmpty()) {
|
||||||
Intent intent = new Intent();
|
UserInfo info = new UserInfo();
|
||||||
intent.putExtra(CONTENT_NICK, contentNick);
|
info.setUid(AuthModel.get().getCurrentUid());
|
||||||
setResult(RESULT_OK, intent);
|
info.setNick(contentNick);
|
||||||
finish();
|
updateUserInfo(info);
|
||||||
} else {
|
} else {
|
||||||
Snackbar.make(layout_coordinator, "所填内容为空!", Snackbar.LENGTH_SHORT).show();
|
Snackbar.make(layout_coordinator, "所填内容为空!", Snackbar.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@@ -189,4 +189,20 @@ public class ModifyInfoActivity extends BaseActivity implements View.OnClickList
|
|||||||
StatusBarUtil.StatusBarLightMode(this);
|
StatusBarUtil.StatusBarLightMode(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("CheckResult")
|
||||||
|
private void updateUserInfo(UserInfo userInfo){
|
||||||
|
getDialogManager().showProgressDialog(this, "请稍后");
|
||||||
|
UserModel.get().requestUpdateUserInfo(userInfo)
|
||||||
|
.compose(bindToLifecycle())
|
||||||
|
.subscribe(userInfo1 -> {
|
||||||
|
getDialogManager().dismissDialog();
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra(USER_INFO, userInfo1);
|
||||||
|
setResult(RESULT_OK, intent);
|
||||||
|
finish();
|
||||||
|
}, throwable -> {
|
||||||
|
getDialogManager().dismissDialog();
|
||||||
|
toast(throwable.getMessage());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -351,34 +351,13 @@ class UserInfoModifyActivity : BaseViewBindingActivity<ActivityUserInfoModifyBin
|
|||||||
checkStoragePermission()
|
checkStoragePermission()
|
||||||
} else if (resultCode == RESULT_OK) {
|
} else if (resultCode == RESULT_OK) {
|
||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
Method.NICK -> {
|
Method.NICK, Method.DESC -> {
|
||||||
data?.let {
|
data?.let {
|
||||||
dialogManager.showProgressDialog(
|
val newUserInfo =
|
||||||
this@UserInfoModifyActivity,
|
it.getSerializableExtra(ModifyInfoActivity.USER_INFO) as? UserInfo
|
||||||
"请稍后"
|
if (newUserInfo != null) {
|
||||||
)
|
loadUserInfo(newUserInfo)
|
||||||
val stringExtra = it.getStringExtra(ModifyInfoActivity.CONTENT_NICK)
|
}
|
||||||
binding.tvNick.text = stringExtra
|
|
||||||
val user = UserInfo()
|
|
||||||
user.uid = AuthModel.get().currentUid
|
|
||||||
user.nick = stringExtra
|
|
||||||
UserModel.get().requestUpdateUserInfo(user)
|
|
||||||
.subscribe(userInfoUpdateObserver)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Method.DESC -> {
|
|
||||||
data?.let {
|
|
||||||
dialogManager.showProgressDialog(
|
|
||||||
this@UserInfoModifyActivity,
|
|
||||||
"请稍后"
|
|
||||||
)
|
|
||||||
val stringExtra = it.getStringExtra(ModifyInfoActivity.CONTENT)
|
|
||||||
setTvDesc(stringExtra)
|
|
||||||
val user = UserInfo()
|
|
||||||
user.uid = AuthModel.get().currentUid
|
|
||||||
user.userDesc = stringExtra
|
|
||||||
UserModel.get().requestUpdateUserInfo(user)
|
|
||||||
.subscribe(userInfoUpdateObserver)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Method.AUDIO -> {
|
Method.AUDIO -> {
|
||||||
@@ -527,10 +506,7 @@ class UserInfoModifyActivity : BaseViewBindingActivity<ActivityUserInfoModifyBin
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onSuccess(info: UserInfo) {
|
override fun onSuccess(info: UserInfo) {
|
||||||
if (info.uid == userId) {
|
loadUserInfo(info)
|
||||||
mUserInfo = info
|
|
||||||
initData(mUserInfo)
|
|
||||||
}
|
|
||||||
dialogManager.dismissDialog()
|
dialogManager.dismissDialog()
|
||||||
if (showAvatarAuditing) {
|
if (showAvatarAuditing) {
|
||||||
showAvatarAuditing = false
|
showAvatarAuditing = false
|
||||||
@@ -544,6 +520,13 @@ class UserInfoModifyActivity : BaseViewBindingActivity<ActivityUserInfoModifyBin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun loadUserInfo(userInfo: UserInfo) {
|
||||||
|
if (userInfo.uid == userId) {
|
||||||
|
mUserInfo = userInfo
|
||||||
|
initData(mUserInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun showAvatarAuditingDialog() {
|
private fun showAvatarAuditingDialog() {
|
||||||
toast(R.string.avatar_auditing)
|
toast(R.string.avatar_auditing)
|
||||||
//延迟3秒重新获取用户信息更新状态
|
//延迟3秒重新获取用户信息更新状态
|
||||||
|
Reference in New Issue
Block a user