Commit 8c1829cf by 王佳洋

修改昵称和简介 接口调通

parent e06a3bed
......@@ -9,7 +9,6 @@ import android.widget.SeekBar
import com.alibaba.android.arouter.facade.annotation.Route
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.view.PlayerFloatHelper
import com.ydl.webview.H5Params
import com.ydl.ydlcommon.base.BaseActivity
......@@ -42,7 +41,6 @@ import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_play_meditation.*
import kotlinx.android.synthetic.main.activity_play_meditation.iv_close
import kotlinx.android.synthetic.main.activity_play_meditation.tv_title
import kotlinx.android.synthetic.main.layout_meditation_play_float_view.*
import kotlinx.android.synthetic.main.player_control_view.*
import java.util.*
import java.util.concurrent.TimeUnit
......
package com.yidianling.user.http
import com.google.gson.internal.LinkedTreeMap
import com.ydl.ydlcommon.base.config.YDLConstants
import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_LOGIN_BASE_URL
import com.ydl.ydlcommon.base.config.*
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.user.api.bean.UserResponseBean
......@@ -251,12 +248,14 @@ interface UserApi {
* 修改昵称、头像、简介等基本信息
*/
@POST("user/v1/baseInfo/modify")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun modifyUserBaseInfo(@Body map: Map<String,String>): Observable<BaseAPIResponse<Boolean>>
/**
* 获取用户审核信息
*/
@POST("user/v1/getUserAuditInfo")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getUserAuditInfo(@Body map: Map<String,String>): Observable<BaseAPIResponse<UserModifyAuditRespDto>>
/**
......@@ -264,6 +263,7 @@ interface UserApi {
*/
@Multipart
@POST("file/upload")
fun uploadFile(@Query("uid") uid: String, @Query("token") token: String, @Part file: MultipartBody.Part): Observable<BaseAPIResponse<String>>
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun uploadFile(@Part file: MultipartBody.Part): Observable<BaseAPIResponse<String>>
}
\ No newline at end of file
......@@ -79,9 +79,9 @@ interface UserHttp {
/**用户注销账号*/
fun accountLogOff(param: UserForbidLoginParam):Observable<BaseAPIResponse<Boolean>>
fun modifyUserBaseInfo(uid: String, token: String, param: ModifyBaseInfo): Observable<BaseAPIResponse<Boolean>>
fun modifyUserBaseInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<Boolean>>
fun getUserAuditInfo(uid: String, token: String, param: ModifyBaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>>
fun getUserAuditInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>>
fun uploadFile(uid: String, token: String, file: File): Observable<BaseAPIResponse<Boolean>>
fun uploadFile(file: File): Observable<BaseAPIResponse<Boolean>>
}
\ No newline at end of file
......@@ -112,45 +112,29 @@ class UserHttpImpl private constructor() : UserHttp {
.flatMap { getUserApi().setUserInfo(it) }
}
override fun modifyUserBaseInfo(
uid: String,
token: String,
param: ModifyBaseInfo
): Observable<BaseAPIResponse<Boolean>> {
param.uid = uid
param.accessToken = token
override fun modifyUserBaseInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<Boolean>> {
return RxUtils.mapObservable(param)
.flatMap { getUserApi().modifyUserBaseInfo(it) }
}
override fun getUserAuditInfo(
uid: String,
token: String,
param: ModifyBaseInfo
): Observable<BaseAPIResponse<UserModifyAuditRespDto>> {
param.uid = uid
param.accessToken = token
override fun getUserAuditInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>> {
return RxUtils.mapObservable(param)
.flatMap { getUserApi().getUserAuditInfo(it) }
}
override fun uploadFile(
uid: String,
token: String,
file: File
): Observable<BaseAPIResponse<Boolean>> {
override fun uploadFile(file: File): Observable<BaseAPIResponse<Boolean>> {
return Observable.empty<Boolean>()
.compose(RxUtils.netCheck())
.flatMap {
getUserApi().uploadFile(
uid, token, MultipartBody.Part.createFormData(
MultipartBody.Part.createFormData(
"file", null,
RequestBody.create(MediaType.parse("multipart/form-data"), file)
)
)
}.flatMap {
if (it.code == "200")
modifyUserBaseInfo(uid, token, ModifyBaseInfo(it.data, 102))
modifyUserBaseInfo(ModifyBaseInfo(it.data, 102))
else
Observable.empty()
}
......
......@@ -74,12 +74,9 @@ class ModifyAvatarActivity : BaseActivity() {
override fun initDataAndEvent() {
findView()
mUserInfo ?: return
mDisposable.add(
mDisposables.add(
UserHttpImpl.getInstance()
.getUserAuditInfo(
mUserInfo.uid, mUserInfo.accessToken.orEmpty(),
ModifyBaseInfo(null, 102)
)
.getUserAuditInfo(ModifyBaseInfo(null, 102))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { response: BaseAPIResponse<UserModifyAuditRespDto> ->
......@@ -98,14 +95,15 @@ class ModifyAvatarActivity : BaseActivity() {
.load(mUserInfo.head)
.into(iv_avatar)
iv_warn.visible()
tv_tip2.text = SpannableString("审核失败,该头像提交不规范,请修改后重新提交审核。如有疑问联系客服小壹").also {
it.setSpan(
ForegroundColorSpan(resources.getColor(R.color.color_1DA1F2)),
it.indexOf("客服"),
it.length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)
}
tv_tip2.text =
SpannableString("审核失败,该头像提交不规范,请修改后重新提交审核。如有疑问联系客服小壹").also {
it.setSpan(
ForegroundColorSpan(resources.getColor(R.color.color_1DA1F2)),
it.indexOf("客服"),
it.length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)
}
tv_tip2.setOnClickListener { // 客服
ARouter.getInstance().navigation(
IImService::class.java
......@@ -244,17 +242,15 @@ class ModifyAvatarActivity : BaseActivity() {
bitmap = FileUtils.getZoomImage(bitmap, 200.0)
try {
val outPutFile = FileUtils.saveBitmap(bitmap, path)
mDisposable.add(
UserHttpImpl.getInstance().uploadFile(
mUserInfo.uid, mUserInfo.accessToken.orEmpty(),
outPutFile
).subscribeOn(Schedulers.io())
mDisposables.add(
UserHttpImpl.getInstance().uploadFile(outPutFile)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({}, {}) {
dismissProgressDialog()
ToastUtil.toastShort("头像审核中,预计24小时内审核完成")
underReview()
iv_avatar.setImageBitmap(bitmap)
dismissProgressDialog()
ToastUtil.toastShort("头像审核中,预计24小时内审核完成")
underReview()
iv_avatar.setImageBitmap(bitmap)
}
)
} catch (e: IOException) {
......
......@@ -13,7 +13,6 @@ 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.ModularServiceManager.provide
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.extend.visible
import com.ydl.ydlcommon.view.DeleteEditTextView
......@@ -37,6 +36,7 @@ const val NICKNAME = 1
const val INTRODUCTION = 2
class ModifyInfoActivity : BaseActivity() {
override fun getStatusViewOptions(): StatusBarOptions {
return StatusBarOptions(isAddStatusView = true, statusBarDarkMode = true)
}
......@@ -69,13 +69,16 @@ class ModifyInfoActivity : BaseActivity() {
tb_title_bar.title = "简介"
det_set_info.layoutParams.height = RxImageTool.dp2px(180f)
det_set_info.hint = "一句话介绍下自己"
det_set_info.setShowDelete(false)
}
tb_title_bar.setOnLeftTextClick { _, _ ->
setResult(RESULT_OK)
finish()
}
val userInfo = findRouteService(IUserService::class.java).getUserInfo()
userInfo ?: return
det_set_info.setText(userInfo.nick_name)
mDisposable.add(
getInstance().getUserAuditInfo(userInfo.uid, userInfo.accessToken.orEmpty(),
ModifyBaseInfo(null, if (NICKNAME == from) 101 else 103))
mDisposables.add(
getInstance().getUserAuditInfo(ModifyBaseInfo(null, if (NICKNAME == from) 101 else 103))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { response: BaseAPIResponse<UserModifyAuditRespDto> ->
......@@ -89,6 +92,7 @@ class ModifyInfoActivity : BaseActivity() {
tb_title_bar.setRightTextEnable(false)
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_9d9ea7))
det_set_info.keyListener = null
det_set_info.isFocusableInTouchMode = false
det_set_info.setTextColor(resources.getColor(R.color.color_9d9ea7))
det_set_info.setOnClickListener {
ToastUtil.toastShort(
......@@ -102,6 +106,7 @@ class ModifyInfoActivity : BaseActivity() {
2 -> { // 审核失败
tv_tip1.visible()
tv_tip1.text = "七天内可修改一次昵称"
det_set_info.setText(userInfo.nick_name)
iv_warn.visible()
customerService("审核失败 ,昵称中含有违规文字。如有疑问联系客服小壹")
}
......@@ -118,6 +123,7 @@ class ModifyInfoActivity : BaseActivity() {
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_9d9ea7))
det_set_info.setTextColor(resources.getColor(R.color.color_9d9ea7))
det_set_info.keyListener = null
det_set_info.isFocusableInTouchMode = false
det_set_info.setOnClickListener {
ToastUtil.toastShort(
"抱歉,七天内只能修改一次"
......@@ -128,10 +134,9 @@ class ModifyInfoActivity : BaseActivity() {
tv_tip1.text = "七天内可修改一次昵称"
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_1DA1F2))
tb_title_bar.setOnRightTextClick { _: View?, _: Boolean ->
if (checkInput()) {
modifyUserBaseInfo(userInfo.uid, userInfo.accessToken.orEmpty(), 101) {
if (checkNickInput()) {
modifyUserBaseInfo(101) {
ToastUtil.toastShort("提交成功,昵称审核中,预计24小时内审核完成")
setResult(RESULT_OK, intent)
finish()
}
}
......@@ -146,6 +151,7 @@ class ModifyInfoActivity : BaseActivity() {
tb_title_bar.isEnabled = false
det_set_info.setText(modifyAfter)
det_set_info.keyListener = null
det_set_info.isFocusableInTouchMode = false
det_set_info.setTextColor(resources.getColor(R.color.color_9d9ea7))
det_set_info.setOnClickListener {
ToastUtil.toastShort(
......@@ -157,6 +163,7 @@ class ModifyInfoActivity : BaseActivity() {
}
2 -> { // 审核失败
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_1DA1F2))
det_set_info.setText(userInfo.description)
iv_warn.visible()
customerService("审核失败,简介中含违规文字如有疑问联系客服小壹")
}
......@@ -167,7 +174,7 @@ class ModifyInfoActivity : BaseActivity() {
}
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_1DA1F2))
tb_title_bar.setOnClickListener {
modifyUserBaseInfo(userInfo.uid, userInfo.accessToken.orEmpty(),103) {
modifyUserBaseInfo(103) {
ToastUtil.toastShort("提交成功,简介审核中,预计24小时内审核完成")
finish()
}
......@@ -198,7 +205,7 @@ class ModifyInfoActivity : BaseActivity() {
}
}
private fun checkInput(): Boolean {
private fun checkNickInput(): Boolean {
if (det_set_info.text.isEmpty()) {
ToastUtil.toastShort("请输入昵称")
det_set_info.startAnimation(mShake)
......@@ -212,10 +219,9 @@ class ModifyInfoActivity : BaseActivity() {
return true
}
private fun modifyUserBaseInfo(uid: String, token: String, type: Int, block: () -> Unit) {
mDisposable.add(
private fun modifyUserBaseInfo(type: Int, block: () -> Unit) {
mDisposables.add(
getInstance().modifyUserBaseInfo(
uid, token,
ModifyBaseInfo(
det_set_info.text.toString(),
type
......
package com.yidianling.user.mine;
import static com.yidianling.user.mine.ModifyInfoActivityKt.NICKNAME;
import static com.yidianling.user.mine.ModifyInfoActivityKt.INTRODUCTION;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.DialogInterface;
......@@ -161,7 +164,9 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
if (id == R.id.persion_head_rel) { // 头像
startActivityForResult(new Intent(this, ModifyAvatarActivity.class), AVATAR);
} else if (id == R.id.jtv_nick) {//昵称
startActivityForResult(new Intent(this, ModifyInfoActivity.class), NICK);
Intent intent = new Intent(this, ModifyInfoActivity.class);
intent.putExtra("from", NICKNAME);
startActivityForResult(intent, NICK);
} else if (id == R.id.jtv_sex) {//性别
List<String> sexs = new ArrayList<String>();
sexs.add("男");
......@@ -265,7 +270,9 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
});
builderm.create().show();
} else if (id == R.id.jtv_jianjie) {//个人简介
startActivity(new Intent(this, ModifyInfoActivity.class));
Intent intent = new Intent(this, ModifyInfoActivity.class);
intent.putExtra("from", INTRODUCTION);
startActivity(intent);
}
}
......
......@@ -24,7 +24,7 @@
android:layout_marginBottom="12dp"
android:textColor="@color/color_9d9ea7"
android:textSize="14sp"
android:visibility="gone"
android:visibility="invisible"
tools:text="七天内可修改一次昵称"
tools:visibility="visible" />
......@@ -37,10 +37,12 @@
android:layout_marginEnd="16dp"
android:background="@drawable/bg_corner_8_white"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="15dp"
android:gravity="start"
android:textSize="14sp"
android:textColor="@color/color_1C1F28"
android:paddingBottom="15dp"
android:singleLine="true" />
android:paddingBottom="15dp" />
<LinearLayout
android:layout_marginTop="12dp"
......
......@@ -39,7 +39,7 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable {
private var loadingDialogFragment: LoadingDialogFragment? = null
@JvmField
val mDisposable = CompositeDisposable()
val mDisposables = CompositeDisposable()
override fun provideLifecycleSubject(): Subject<ActivityEvent> {
return mLifecycleSubject;
......@@ -161,7 +161,7 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable {
override fun onDestroy() {
super.onDestroy()
mDisposable.takeIf { !it.isDisposed }?.dispose()
mDisposables.takeIf { !it.isDisposed }?.dispose()
ActivityManager.getInstance().removeStack(this)
AndroidSystemHelper.fixInputMethodManagerLeak(this)
}
......
......@@ -21,6 +21,7 @@ import com.ydl.ydlcommon.R;
public class DeleteEditTextView extends EditText {
int mCloseAreaSize;
private boolean mShowDelete = true;
public DeleteEditTextView(Context context) {
super(context);
......@@ -43,6 +44,10 @@ public class DeleteEditTextView extends EditText {
setSelection(text.length());
}
public void setShowDelete(boolean showDelete) {
this.mShowDelete = showDelete;
}
/**
* 初始化视图
*/
......@@ -77,6 +82,7 @@ public class DeleteEditTextView extends EditText {
}
void setEditTextDrawable() {
if (!mShowDelete) return;
if (getText().length() == 0 || !isFocused()) {
setCompoundDrawablesWithIntrinsicBounds(getCompoundDrawables()[0], null, null, null);
} else {
......@@ -87,7 +93,7 @@ public class DeleteEditTextView extends EditText {
@Override
public boolean onTouchEvent(MotionEvent event) {
if ((event.getAction() == 1) && isFocused()) {
if (mShowDelete && (event.getAction() == 1) && isFocused()) {
int i = (int) event.getRawX();
if (i > getRight() - mCloseAreaSize) {
setText("");
......
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