Commit 78398331 by 王佳洋

合并修改昵称

parent baf849fe
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" /> android:theme="@style/platform_NoTitleTheme" />
<activity <activity
android:name=".mine.SetInfoActivity" android:name=".mine.ModifyInfoActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" /> android:theme="@style/platform_NoTitleTheme" />
<activity <activity
......
...@@ -117,6 +117,25 @@ class UserHttpImpl private constructor() : UserHttp { ...@@ -117,6 +117,25 @@ class UserHttpImpl private constructor() : UserHttp {
.flatMap { getUserApi().setUserInfo(it) } .flatMap { getUserApi().setUserInfo(it) }
} }
override fun modifyUserBaseInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<Boolean>> {
UserHelper.getUserInfo()?.let {
param.uid = it.uid.orEmpty()
param.accessToken = it.accessToken.orEmpty()
}
return RxUtils.mapObservable(param)
.flatMap { getUserApi().modifyUserBaseInfo(it) }
}
override fun getUserAuditInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>> {
UserHelper.getUserInfo()?.let {
param.uid = it.uid.orEmpty()
param.accessToken = it.accessToken.orEmpty()
}
return RxUtils.mapObservable(param)
.flatMap { getUserApi().getUserAuditInfo(it) }
}
//验证账号密码 //验证账号密码
override fun checkPhonePass(cmd: CheckPhonePassBean): Observable<BaseResponse<CheckPassword>> { override fun checkPhonePass(cmd: CheckPhonePassBean): Observable<BaseResponse<CheckPassword>> {
return RxUtils.mapObservable(cmd) return RxUtils.mapObservable(cmd)
......
package com.yidianling.user.mine
import android.annotation.SuppressLint
import android.text.Spannable
import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import android.view.View
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import com.alibaba.android.arouter.launcher.ARouter
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.modular.findRouteService
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.api.service.IImService
import com.yidianling.user.R
import com.yidianling.user.api.service.IUserService
import com.yidianling.user.http.UserHttpImpl
import com.yidianling.user.http.UserHttpImpl.Companion.getInstance
import com.yidianling.user.http.request.ModifyBaseInfo
import com.yidianling.user.http.request.UserModifyAuditRespDto
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.user_mine_activity_set_info.*
/**
* 昵称修改
* 简介修改
*/
const val nickName = 1
const val introduction = 2
class ModifyInfoActivity : BaseActivity() {
override fun getStatusViewOptions(): StatusBarOptions {
return StatusBarOptions(isAddStatusView = true, statusBarDarkMode = true)
}
private val mShake: Animation by lazy {
AnimationUtils.loadAnimation(this, R.anim.user_mine_shake)
}
override fun layoutResId(): Int = R.layout.user_mine_activity_set_info
@SuppressLint("SetTextI18n")
override fun initDataAndEvent() {
val from = intent.getIntExtra("from", 0)
val userInfo = findRouteService(IUserService::class.java).getUserInfo()
det_set_info.setText(userInfo?.nick_name)
mDisposable.add(
UserHttpImpl.getInstance().getUserAuditInfo(ModifyBaseInfo(null, 101))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { response: BaseAPIResponse<UserModifyAuditRespDto> ->
if (response.code == "200") {
val (_, auditStatus, _, _, _, _, _, last7Day, modifyAfter) = response.data
if (last7Day) { // 7天内
tv_tip1.text = "抱歉,七天内只能修改一次昵称"
tv_tip1.visibility = View.VISIBLE
tb_title_bar.setRightTextEnable(false)
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_9d9ea7))
det_set_info.setTextColor(resources.getColor(R.color.color_9d9ea7))
when (auditStatus) {
1 -> { // 审核中
det_set_info.keyListener = null
det_set_info.setOnClickListener {
ToastUtil.toastShort(
"昵称审核中,预计24小时内审核完成"
)
}
det_set_info.setText(modifyAfter)
tv_tip2.visibility = View.VISIBLE
tv_tip2.text = "昵称审核中,预计24小时内审核完成,暂无法修改。"
}
2 -> { // 审核失败
det_set_info.isEnabled = false
tv_tip2.visibility = View.VISIBLE
iv_warn.visibility = View.VISIBLE
val ss = SpannableString("审核失败 ,昵称中含有违规文字。如有疑问联系客服小壹")
ss.setSpan(
ForegroundColorSpan(resources.getColor(R.color.color_1DA1F2)),
22,
ss.length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)
tv_tip2.text = ss
tv_tip2.setOnClickListener {
ARouter.getInstance().navigation(
IImService::class.java
).startKefuChat(this, "", 0, 0)
}
}
else -> { // 3: 审核成功
det_set_info.keyListener = null
det_set_info.setOnClickListener {
ToastUtil.toastShort(
"抱歉,七天内只能修改一次"
)
}
det_set_info.setText(modifyAfter)
tv_tip2.visibility = View.GONE
userInfo?.nick_name = modifyAfter
}
}
} else {
tv_tip1.text = "七天内可修改一次昵称"
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_1DA1F2))
tb_title_bar.setOnRightTextClick { _: View?, _: Boolean ->
if (checkInput()) {
mDisposable.add(
getInstance().modifyUserBaseInfo(
ModifyBaseInfo(
det_set_info.text.toString(),
101
)
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
ToastUtil.toastShort("提交成功,昵称审核中,预计24小时内审核完成")
setResult(RESULT_OK, intent)
finish()
}
)
}
}
}
}
})
}
private fun checkInput(): Boolean {
if (det_set_info.text.isEmpty()) {
ToastUtil.toastShort("请输入昵称")
det_set_info.startAnimation(mShake)
return false
}
if (det_set_info.text.length > 6) {
ToastUtil.toastShort("昵称最多6个字哦")
det_set_info.startAnimation(mShake)
return false
}
return true
}
}
\ No newline at end of file
...@@ -64,13 +64,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers; ...@@ -64,13 +64,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
@Route(path = "/user/personInfo") @Route(path = "/user/personInfo")
public class PersonalInfoActivity extends BaseActivity implements View.OnClickListener { public class PersonalInfoActivity extends BaseActivity implements View.OnClickListener {
public static final int REQUEST_NAME = 1;
UserResponseBean.UserInfo userInfoData; UserResponseBean.UserInfo userInfoData;
private static final int REQUEST_IMAGE = 2;
TitleBar tb_title; TitleBar tb_title;
ImageView persion_head_iv; ImageView persion_head_iv;
ImageView person_head_hint_iv; ImageView person_head_hint_iv;
...@@ -240,9 +235,7 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi ...@@ -240,9 +235,7 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
} }
}); });
} else if (id == R.id.jtv_nick) {//昵称 } else if (id == R.id.jtv_nick) {//昵称
Intent intent = new Intent(this, SetInfoActivity.class); Intent intent = new Intent(this, ModifyInfoActivity.class);
intent.putExtra("mOldString", jtv_nick.getRightText());
intent.putExtra("mTitle", "修改昵称");
startActivityForResult(intent, REQUEST_NAME); startActivityForResult(intent, REQUEST_NAME);
} else if (id == R.id.jtv_sex) {//性别 } else if (id == R.id.jtv_sex) {//性别
List<String> sexs = new ArrayList<String>(); List<String> sexs = new ArrayList<String>();
...@@ -449,7 +442,9 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi ...@@ -449,7 +442,9 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
break; break;
case REQUEST_NAME: { case REQUEST_NAME: {
updateInfo("nickName", SetInfoActivity.getInput(data)); jtv_nick.setRightText(value);
userInfo.setNick_name(value);
ModularServiceManager.INSTANCE.provide(IImService.class).updateUserName(value); // 更新用户昵称到云信
break; break;
} }
} }
...@@ -526,14 +521,6 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi ...@@ -526,14 +521,6 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
break; break;
} }
break; break;
case "nickName":
jtv_nick.setRightText(value);
userInfo.setNick_name(value);
//更新用户昵称到云信
try {
ModularServiceManager.INSTANCE.provide(IImService.class).updateUserName(value);
}catch (Exception e) {}
break;
case "profession": case "profession":
setCareer(Integer.valueOf(value)); setCareer(Integer.valueOf(value));
userInfo.setProfession(Integer.valueOf(value)); userInfo.setProfession(Integer.valueOf(value));
...@@ -550,10 +537,9 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi ...@@ -550,10 +537,9 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
//封面背景 //封面背景
userInfo.setHome_bg(value); userInfo.setHome_bg(value);
break; break;
case "home_desc": // case "home_desc": // 简介
//简介 // userInfo.setDescription(value);
userInfo.setDescription(value); // break;
break;
} }
EventBus.getDefault().post(userInfoData); EventBus.getDefault().post(userInfoData);
}, new ThrowableConsumer() { }, new ThrowableConsumer() {
......
package com.yidianling.user.mine;
import android.content.Intent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.bean.StatusBarOptions;
import com.ydl.ydlcommon.view.DeleteEditTextView;
import com.ydl.ydlcommon.view.TitleBar;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.user.R;
import org.jetbrains.annotations.NotNull;
/**
* 短信息填写
* Created by softrice on 15/9/29.
*/
public class SetInfoActivity extends BaseActivity {
public static final String INPUT = "INPUT";
@NotNull
@Override
public StatusBarOptions getStatusViewOptions() {
return new StatusBarOptions(true,true);
}
public static Intent getIntent(String input) {
Intent intent = new Intent();
intent.putExtra(INPUT, input);
return intent;
}
public static String getInput(Intent intent) {
if (intent == null) {
return null;
}
return intent.getStringExtra(INPUT);
}
String mTitle;
String mOldString;
DeleteEditTextView det_set_info;
TitleBar tb_title_bar;
Animation shake;
@Override
protected int layoutResId() {
return R.layout.user_mine_activity_set_info;
}
@Override
protected void initDataAndEvent() {
det_set_info = findViewById(R.id.det_set_info);
tb_title_bar = findViewById(R.id.tb_title_bar);
mTitle = getIntent().getStringExtra("mTitle");
mOldString = getIntent().getStringExtra("mOldString");
init();
}
void init() {
shake = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.user_mine_shake);
tb_title_bar.setTitle(mTitle);
det_set_info.setText(mOldString);
tb_title_bar.setOnRightTextClick(new TitleBar.OnTitleBarTextClick() {
@Override
public void onClick(View view, boolean isActive) {
if (checkInput()) {
ToastUtil.toastShort("保存成功");
setResult(RESULT_OK, getIntent(det_set_info.getText().toString()));
finish();
}
}
});
}
boolean checkInput() {
if (det_set_info.getText().length() == 0) {
ToastUtil.toastShort("请输入昵称");
det_set_info.startAnimation(shake);
return false;
}
if (det_set_info.getText().length() > 6) {
ToastUtil.toastShort("昵称最多6个字哦");
det_set_info.startAnimation(shake);
return false;
}
return true;
}
}
...@@ -20,6 +20,7 @@ import com.ydl.ydlcommon.utils.ActivityManager ...@@ -20,6 +20,7 @@ import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.AndroidSystemHelper import com.ydl.ydlcommon.utils.AndroidSystemHelper
import com.ydl.ydlcommon.utils.StatusBarUtils import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.statusBar.StatusBarUtil import com.ydl.ydlcommon.utils.statusBar.StatusBarUtil
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.subjects.BehaviorSubject import io.reactivex.subjects.BehaviorSubject
import io.reactivex.subjects.Subject import io.reactivex.subjects.Subject
import kotlin.properties.Delegates import kotlin.properties.Delegates
...@@ -37,6 +38,9 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable { ...@@ -37,6 +38,9 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable {
var statusView: View? = null var statusView: View? = null
private var loadingDialogFragment: LoadingDialogFragment? = null private var loadingDialogFragment: LoadingDialogFragment? = null
@JvmField
val mDisposable = CompositeDisposable()
override fun provideLifecycleSubject(): Subject<ActivityEvent> { override fun provideLifecycleSubject(): Subject<ActivityEvent> {
return mLifecycleSubject; return mLifecycleSubject;
} }
...@@ -157,6 +161,7 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable { ...@@ -157,6 +161,7 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
mDisposable.takeIf { !it.isDisposed }?.dispose()
ActivityManager.getInstance().removeStack(this) ActivityManager.getInstance().removeStack(this)
AndroidSystemHelper.fixInputMethodManagerLeak(this) AndroidSystemHelper.fixInputMethodManagerLeak(this)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment