Commit 09a07c54 by 王佳洋

修改昵称,简介,头像联调完成

parent 8c1829cf
......@@ -81,7 +81,7 @@ interface UserHttp {
fun modifyUserBaseInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<Boolean>>
fun getUserAuditInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>>
fun getUserAuditInfo(type: BaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>>
fun uploadFile(file: File): Observable<BaseAPIResponse<Boolean>>
}
\ No newline at end of file
......@@ -117,18 +117,18 @@ class UserHttpImpl private constructor() : UserHttp {
.flatMap { getUserApi().modifyUserBaseInfo(it) }
}
override fun getUserAuditInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>> {
return RxUtils.mapObservable(param)
override fun getUserAuditInfo(type: BaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>> {
return RxUtils.mapObservable(type)
.flatMap { getUserApi().getUserAuditInfo(it) }
}
override fun uploadFile(file: File): Observable<BaseAPIResponse<Boolean>> {
return Observable.empty<Boolean>()
return Observable.just(true)
.compose(RxUtils.netCheck())
.flatMap {
getUserApi().uploadFile(
MultipartBody.Part.createFormData(
"file", null,
"file", file.name,
RequestBody.create(MediaType.parse("multipart/form-data"), file)
)
)
......@@ -136,7 +136,7 @@ class UserHttpImpl private constructor() : UserHttp {
if (it.code == "200")
modifyUserBaseInfo(ModifyBaseInfo(it.data, 102))
else
Observable.empty()
Observable.just(BaseAPIResponse())
}
}
......
package com.yidianling.user.http.request
import com.ydl.ydlcommon.data.http.BaseCommand
data class ModifyBaseInfo(val modifyValue: String?,
val type: Int // 101:用户昵称 102:用户头像 103:用户简介
) : BaseCommand()
\ No newline at end of file
)
data class BaseInfo(val type: Int)
\ No newline at end of file
......@@ -5,6 +5,7 @@ import android.app.Dialog
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Color
import android.hardware.Camera
import android.net.Uri
import android.os.Build
......@@ -21,6 +22,7 @@ import com.hjq.permissions.OnPermissionCallback
import com.hjq.permissions.Permission
import com.hjq.permissions.XXPermissions
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.ydl.ydlcommon.utils.FileUtils
......@@ -32,6 +34,7 @@ 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.request.BaseInfo
import com.yidianling.user.http.request.ModifyBaseInfo
import com.yidianling.user.http.request.UserModifyAuditRespDto
import de.greenrobot.event.EventBus
......@@ -43,6 +46,12 @@ import java.io.IOException
class ModifyAvatarActivity : BaseActivity() {
override fun getStatusViewOptions(): StatusBarOptions {
return StatusBarOptions(isAddStatusView = true, statusBarDarkMode = false).apply {
statusColor = "#E6000000"
}
}
private val ALBUM = 0x0 // 相册
private val CAMERA = 0x1 // 照相
private val CROP = 0x2 // 裁剪
......@@ -73,10 +82,14 @@ class ModifyAvatarActivity : BaseActivity() {
@SuppressLint("SetTextI18n")
override fun initDataAndEvent() {
findView()
tip_bar.setOnLeftTextClick { _, _ ->
setResult(RESULT_OK) // 刷新个人资料页
finish()
}
mUserInfo ?: return
mDisposables.add(
UserHttpImpl.getInstance()
.getUserAuditInfo(ModifyBaseInfo(null, 102))
.getUserAuditInfo(BaseInfo(102))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { response: BaseAPIResponse<UserModifyAuditRespDto> ->
......@@ -112,7 +125,13 @@ class ModifyAvatarActivity : BaseActivity() {
setModifyAvatar()
}
3 -> { // 审核成功 || 提交审核
mUserInfo.head = modifyAfter
modifyAfter?.let {
mUserInfo.head = it
Glide.with(this)
.load(it)
.error(R.drawable.platform_head_place_hold_pic)
.into(iv_avatar)
}
findRouteService(IImService::class.java).updateUserHead(modifyAfter) // 更新用户头像到云信
EventBus.getDefault().post(UserChangeEvent(true)) // 更新MineFragment
if (last7Day) {
......@@ -240,22 +259,19 @@ class ModifyAvatarActivity : BaseActivity() {
val path = FileUtils.getPathByUri4kitkat(this, Uri.fromFile(mAvatarFile))
var bitmap = BitmapFactory.decodeFile(path)
bitmap = FileUtils.getZoomImage(bitmap, 200.0)
try {
val outPutFile = FileUtils.saveBitmap(bitmap, path)
mDisposables.add(
UserHttpImpl.getInstance().uploadFile(outPutFile)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({}, {}) {
.subscribe {
dismissProgressDialog()
if (!it.data) return@subscribe
ToastUtil.toastShort("头像审核中,预计24小时内审核完成")
underReview()
iv_avatar.setImageBitmap(bitmap)
}
)
} catch (e: IOException) {
e.printStackTrace()
}
}
}
}
......
......@@ -23,6 +23,7 @@ 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.Companion.getInstance
import com.yidianling.user.http.request.BaseInfo
import com.yidianling.user.http.request.ModifyBaseInfo
import com.yidianling.user.http.request.UserModifyAuditRespDto
import io.reactivex.android.schedulers.AndroidSchedulers
......@@ -72,13 +73,13 @@ class ModifyInfoActivity : BaseActivity() {
det_set_info.setShowDelete(false)
}
tb_title_bar.setOnLeftTextClick { _, _ ->
setResult(RESULT_OK)
setResult(RESULT_OK) // 刷新个人资料页
finish()
}
val userInfo = findRouteService(IUserService::class.java).getUserInfo()
userInfo ?: return
mDisposables.add(
getInstance().getUserAuditInfo(ModifyBaseInfo(null, if (NICKNAME == from) 101 else 103))
getInstance().getUserAuditInfo(BaseInfo(if (NICKNAME == from) 101 else 103))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { response: BaseAPIResponse<UserModifyAuditRespDto> ->
......@@ -230,7 +231,7 @@ class ModifyInfoActivity : BaseActivity() {
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
block.invoke()
if (it.data) block.invoke()
}
)
}
......
......@@ -23,6 +23,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/color_C3C4CA"
android:layout_marginBottom="12dp"
android:gravity="center"
android:textSize="12sp"
tools:text="抱歉,七天内只能修改一次头像"/>
......@@ -30,7 +31,7 @@
<ImageView
android:id="@+id/iv_avatar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"/>
......
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