Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
e742fa88
Commit
e742fa88
authored
Aug 16, 2022
by
王佳洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,修改昵称新增需求完成
2,手机号校验完成
parent
09a07c54
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
144 additions
and
396 deletions
+144
-396
ExpertSearchAdapter.kt
m-consultant/src/main/java/com/yidianling/consultant/adapter/ExpertSearchAdapter.kt
+16
-0
HomeConsultItemView.kt
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeConsultItemView.kt
+15
-1
home_consult_item_view.xml
m-home/src/ydl/res/layout/home_consult_item_view.xml
+1
-1
NewH5_JavascriptHandler.kt
m-js/src/main/java/com/ydl/js/NewH5_JavascriptHandler.kt
+41
-17
ModifyAvatarActivity.kt
m-user/src/main/java/com/yidianling/user/mine/ModifyAvatarActivity.kt
+2
-314
ModifyInfoActivity.kt
m-user/src/main/java/com/yidianling/user/mine/ModifyInfoActivity.kt
+69
-63
No files found.
m-consultant/src/main/java/com/yidianling/consultant/adapter/ExpertSearchAdapter.kt
View file @
e742fa88
package
com.yidianling.consultant.adapter
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Context
import
android.graphics.Typeface
import
android.text.SpannableStringBuilder
...
...
@@ -19,10 +20,12 @@ import com.ydl.webview.NewH5Activity
import
com.ydl.ydl_image.config.SimpleImageOpConfiger
import
com.ydl.ydl_image.module.GlideApp
import
com.ydl.ydlcommon.base.config.HttpConfig
import
com.ydl.ydlcommon.modular.findRouteService
import
com.ydl.ydlcommon.utils.LogUtil
import
com.ydl.ydlcommon.utils.URLUtils
import
com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import
com.ydl.ydlcommon.utils.remind.ToastHelper
import
com.ydl.ydlcommon.view.dialog.CommonDialog
import
com.yidianling.consultant.IExpertSearchView
import
com.yidianling.consultant.R
import
com.yidianling.consultant.constants.ConsultBIConstants
...
...
@@ -30,6 +33,7 @@ import com.yidianling.consultant.listener.OnExpertClickListener
import
com.yidianling.consultant.model.bean.ExpertServiceItem
import
com.yidianling.consultant.modular.utils.TempH5RouteUtils
import
com.yidianling.consultant.router.ConsultantIn
import
com.yidianling.user.api.service.IUserService
import
kotlinx.android.synthetic.main.consultant_activity_hot_search.*
import
kotlinx.android.synthetic.main.consultant_expert_search_feedbackrate.view.*
import
kotlinx.android.synthetic.main.consultant_expert_search_header_view.view.*
...
...
@@ -583,6 +587,18 @@ class ExpertSearchAdapter(
if
(!
TextUtils
.
isEmpty
(
doctor
.
uid
))
{
val
userService
=
findRouteService
(
IUserService
::
class
.
java
)
if
(!
userService
.
isBindPhone
()
&&
context
is
Activity
)
{
CommonDialog
(
context
)
.
setMessage
(
"为了及时接收消息通知,请立即绑定收集"
)
.
setLeftOnclick
(
"忍痛放弃"
)
{}
.
setRightClick
(
"果断绑定"
)
{
userService
.
wxBindToInputhonePage
(
context
)
// 跳转绑定手机号页面
}
.
setCancelAble
(
false
)
.
show
()
return
@setOnClickListener
}
//跳转私聊
ConsultantIn
.
startP2PSession
(
context
as
AppCompatActivity
,
doctor
.
uid
!!
)
ActionCountUtils
.
count
(
ConsultBIConstants
.
UserMainEvent
.
YDL_PRIVATE_CHAT_CLICK
)
...
...
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeConsultItemView.kt
View file @
e742fa88
...
...
@@ -9,15 +9,18 @@ import android.widget.FrameLayout
import
com.ydl.ydl_image.config.SimpleImageOpConfiger
import
com.ydl.ydl_image.manager.YDLImageCacheManager
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.ydl.ydlcommon.modular.findRouteService
import
com.ydl.ydlcommon.utils.StringUtils
import
com.ydl.ydlcommon.utils.URLUtils
import
com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import
com.ydl.ydlcommon.view.dialog.CommonDialog
import
com.yidianling.common.tools.RxImageTool
import
com.yidianling.consultant.api.IConsultantService
import
com.yidianling.home.R
import
com.yidianling.home.constants.HomeBIConstants
import
com.yidianling.home.event.IHomeBaseEvent
import
com.yidianling.home.model.bean.HomeConsultBean
import
com.yidianling.user.api.service.IUserService
import
kotlinx.android.synthetic.ydl.home_consult_item_view.view.*
/**
...
...
@@ -72,7 +75,6 @@ class HomeConsultItemView(private var mContext: Context, private var homeEvent:
)*/
//补充点击事件埋点
ActionCountUtils
.
count
(
HomeBIConstants
.
YDL_USER_EXPERT_INTRODUCTION_CLICK
,
bean
.
uid
.
toString
())
val
url
=
URLUtils
.
appendParmas
(
bean
.
linkUrl
,
"cateId"
,
cateId
)
ModularServiceManager
.
provide
(
IConsultantService
::
class
.
java
).
dueToTypeJumpAutoOrGuide
(
mContext
as
Activity
,
11
,
...
...
@@ -134,6 +136,18 @@ class HomeConsultItemView(private var mContext: Context, private var homeEvent:
*/
private
fun
setConfideButton
(
bodyBean
:
HomeConsultBean
.
ListBean
)
{
tv_consult_chat
.
setOnClickListener
{
val
userService
=
findRouteService
(
IUserService
::
class
.
java
)
if
(!
userService
.
isBindPhone
()
&&
context
is
Activity
)
{
CommonDialog
(
context
)
.
setMessage
(
"为了及时接收消息通知,请立即绑定收集"
)
.
setLeftOnclick
(
"忍痛放弃"
)
{}
.
setRightClick
(
"果断绑定"
)
{
userService
.
wxBindToInputhonePage
(
context
as
Activity
)
// 跳转绑定手机号页面
}
.
setCancelAble
(
false
)
.
show
()
return
@setOnClickListener
}
ModularServiceManager
.
provide
(
IConsultantService
::
class
.
java
).
dueToTypeJumpAutoOrGuide
(
mContext
as
Activity
,
11
,
...
...
m-home/src/ydl/res/layout/home_consult_item_view.xml
View file @
e742fa88
...
...
@@ -17,8 +17,8 @@
android:id=
"@+id/tv_consult_chat"
android:layout_width=
"44dp"
android:layout_height=
"44dp"
android:layout_alignParentEnd=
"true"
android:layout_alignTop=
"@+id/img_consult_head"
android:layout_alignParentEnd=
"true"
android:layout_marginTop=
"@dimen/platform_dp_13"
android:layout_marginEnd=
"@dimen/platform_dp_15"
android:background=
"@drawable/home_consult_chat_bg"
...
...
m-js/src/main/java/com/ydl/js/NewH5_JavascriptHandler.kt
View file @
e742fa88
package
com.ydl.js
import
android.app.Activity
import
android.content.Context
import
android.webkit.JavascriptInterface
import
androidx.fragment.app.FragmentActivity
import
com.google.gson.Gson
...
...
@@ -18,6 +20,7 @@ import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import
com.ydl.ydlcommon.utils.log.AliYunLogConfig
import
com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper
import
com.ydl.ydlcommon.utils.log.LogHelper
import
com.ydl.ydlcommon.view.dialog.CommonDialog
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.user.api.service.IUserService
...
...
@@ -56,14 +59,16 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
wvEnventPro
?.
jumpLogin
(
jsData
.
cmd
?.
params
)
return
}
val
userService
=
findRouteService
(
IUserService
::
class
.
java
)
if
(
jsData
.
url
.
equals
(
"http"
))
{
if
(
jsData
.
cmd
?.
params
?.
toUid
!=
0
)
{
if
(
checkBindPhone
(
webView
?.
context
,
userService
))
return
wvEnventPro
?.
chat
(
findRouteService
(
IUserService
::
class
.
java
)
.
getUserInfo
()
?.
uid
?.
toInt
()
?:
0
,
userService
.
getUserInfo
()
?.
uid
?.
toInt
()
?:
0
,
jsData
.
cmd
?.
params
?.
toUid
?:
0
,
0
,
findRouteService
(
IUserService
::
class
.
java
)
.
getUserInfo
()
?.
accessToken
,
userService
.
getUserInfo
()
?.
accessToken
,
jsData
.
cmd
?.
params
?.
isFromQingShu
?:
0
,
jsData
.
cmd
?.
params
?.
closeReplaceChat
?:
false
)
...
...
@@ -72,11 +77,11 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
}
}
else
if
(
jsData
.
url
.
equals
(
"ydl_app"
))
{
wvEnventPro
?.
ydlNative
(
jsData
.
cmd
)
jumpAction
(
jsData
)
jumpAction
(
jsData
,
userService
)
}
}
fun
jumpAction
(
jsData
:
H5JsBean
)
{
private
fun
jumpAction
(
jsData
:
H5JsBean
,
userService
:
IUserService
)
{
LogUtil
.
d
(
"jumpAction"
)
when
(
jsData
.
cmd
!!
.
action_name
)
{
"fm"
->
if
(
jsData
.
cmd
!!
.
params
!!
.
id
>
0
)
{
...
...
@@ -126,23 +131,26 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
"chat"
->
//私聊
if
(
wvEnventPro
!=
null
)
{
wvEnventPro
?.
chat
(
findRouteService
(
IUserService
::
class
.
java
).
getUserResponse
()
?.
uid
?.
toInt
()
?:
0
,
jsData
.
cmd
!!
.
params
!!
.
toUid
,
0
,
JsModularService
.
getIUserService
().
getUserInfo
()
?.
accessToken
,
jsData
.
cmd
!!
.
params
!!
.
isFromQingShu
,
jsData
.
cmd
!!
.
params
!!
.
closeReplaceChat
if
(
checkBindPhone
(
webView
?.
context
,
userService
))
return
wvEnventPro
.
chat
(
userService
.
getUserResponse
()
?.
uid
?.
toInt
()
?:
0
,
jsData
.
cmd
!!
.
params
!!
.
toUid
,
0
,
JsModularService
.
getIUserService
().
getUserInfo
()
?.
accessToken
,
jsData
.
cmd
!!
.
params
!!
.
isFromQingShu
,
jsData
.
cmd
!!
.
params
!!
.
closeReplaceChat
)
// 埋点
ActionCountUtils
.
count
(
"ydl_user_main_page|private_chat_click"
)
}
"chat_send_message"
->
"chat_send_message"
->
{
//跳转私聊:并发送消息
if
(
wvEnventPro
!=
null
)
{
wvEnventPro
!!
.
chatSendMessage
(
findRouteService
(
IUserService
::
class
.
java
).
getUserResponse
()
?.
uid
?.
toInt
()
?:
0
,
jsData
.
cmd
!!
.
params
!!
.
toUid
,
0
,
JsModularService
.
getIUserService
().
getUserInfo
()
?.
accessToken
,
jsData
.
cmd
!!
.
params
!!
.
isFromQingShu
)
}
if
(
checkBindPhone
(
webView
?.
context
,
userService
))
return
wvEnventPro
?.
chatSendMessage
(
userService
.
getUserResponse
()
?.
uid
?.
toInt
()
?:
0
,
jsData
.
cmd
!!
.
params
!!
.
toUid
,
0
,
JsModularService
.
getIUserService
().
getUserInfo
()
?.
accessToken
,
jsData
.
cmd
!!
.
params
!!
.
isFromQingShu
)
}
"chat_team"
->
//群聊
if
(
wvEnventPro
!=
null
)
{
...
...
@@ -169,7 +177,8 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
"set_time_warn"
->
//提醒专家设置时间
if
(
wvEnventPro
!=
null
)
{
wvEnventPro
!!
.
sendSubscriptionTimeMessage
(
""
+
jsData
.
cmd
?.
params
?.
toUid
)
if
(
checkBindPhone
(
webView
?.
context
,
userService
))
return
wvEnventPro
.
sendSubscriptionTimeMessage
(
""
+
jsData
.
cmd
?.
params
?.
toUid
)
}
"user_home"
->
if
(
wvEnventPro
!=
null
)
{
wvEnventPro
!!
.
openMember
(
""
+
jsData
.
cmd
?.
params
?.
uid
)
...
...
@@ -507,4 +516,19 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
}
}
private
fun
checkBindPhone
(
context
:
Context
?,
userService
:
IUserService
):
Boolean
{
if
(!
userService
.
isBindPhone
()
&&
context
is
Activity
)
{
CommonDialog
(
context
)
.
setMessage
(
"为了及时接收消息通知,请立即绑定收集"
)
.
setLeftOnclick
(
"忍痛放弃"
)
{}
.
setRightClick
(
"果断绑定"
)
{
userService
.
wxBindToInputhonePage
(
context
)
// 跳转绑定手机号页面
}
.
setCancelAble
(
false
)
.
show
()
return
true
}
return
false
}
}
m-user/src/main/java/com/yidianling/user/mine/ModifyAvatarActivity.kt
View file @
e742fa88
package
com.yidianling.user.mine
import
android.annotation.SuppressLint
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
import
android.provider.MediaStore
import
android.text.Spannable
import
android.text.SpannableString
import
android.text.style.ForegroundColorSpan
import
android.view.View
import
android.widget.ImageView
import
android.widget.TextView
import
com.alibaba.android.arouter.launcher.ARouter
import
com.bumptech.glide.Glide
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
import
com.ydl.ydlcommon.utils.extend.visible
import
com.ydl.ydlcommon.view.ListNoCancelDialog
import
com.ydl.ydlcommon.view.TitleBar
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.request.BaseInfo
import
com.yidianling.user.http.request.ModifyBaseInfo
import
com.yidianling.user.http.request.UserModifyAuditRespDto
import
de.greenrobot.event.EventBus
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
import
java.io.File
import
java.io.IOException
class
ModifyAvatarActivity
:
BaseActivity
()
{
override
fun
getStatusViewOptions
():
StatusBarOptions
{
return
StatusBarOptions
(
isAddStatusView
=
true
,
statusBarDarkMode
=
false
).
apply
{
statusColor
=
"#E6000000"
}
}
private
val
ALBUM
=
0
x0
// 相册
private
val
CAMERA
=
0
x1
// 照相
private
val
CROP
=
0
x2
// 裁剪
private
val
mAvatarDir
=
"${FileUtils.getStorageDirectory()}/img/head_img/"
// 头像目录
private
val
mAvatarPath
=
"${mAvatarDir}avatar_camera.jpg"
// 头像
private
val
mAvatarFile
=
File
(
mAvatarPath
)
// 头像文件
private
val
mUserInfo
=
findRouteService
(
IUserService
::
class
.
java
).
getUserInfo
()
override
fun
layoutResId
():
Int
=
R
.
layout
.
activity_modify_avatar
private
lateinit
var
tip_bar
:
TitleBar
private
lateinit
var
tv_tip1
:
TextView
private
lateinit
var
iv_avatar
:
ImageView
private
lateinit
var
iv_warn
:
ImageView
private
lateinit
var
tv_tip2
:
TextView
private
lateinit
var
tv_modify
:
TextView
private
fun
findView
()
{
tip_bar
=
findViewById
(
R
.
id
.
tip_bar
)
tv_tip1
=
findViewById
(
R
.
id
.
tv_tip1
)
iv_avatar
=
findViewById
(
R
.
id
.
iv_avatar
)
iv_warn
=
findViewById
(
R
.
id
.
iv_warn
)
tv_tip2
=
findViewById
(
R
.
id
.
tv_tip2
)
tv_modify
=
findViewById
(
R
.
id
.
tv_modify
)
}
@SuppressLint
(
"SetTextI18n"
)
override
fun
initDataAndEvent
()
{
findView
()
tip_bar
.
setOnLeftTextClick
{
_
,
_
->
setResult
(
RESULT_OK
)
// 刷新个人资料页
finish
()
}
mUserInfo
?:
return
mDisposables
.
add
(
UserHttpImpl
.
getInstance
()
.
getUserAuditInfo
(
BaseInfo
(
102
))
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
response
:
BaseAPIResponse
<
UserModifyAuditRespDto
>
->
if
(
response
.
code
!=
"200"
)
return
@subscribe
val
(
_
,
auditStatus
,
_
,
_
,
_
,
_
,
_
,
last7Day
,
modifyAfter
)
=
response
.
data
when
(
auditStatus
)
{
1
->
{
// 审核中
underReview
()
Glide
.
with
(
this
)
.
load
(
modifyAfter
)
.
into
(
iv_avatar
)
}
2
->
{
// 审核失败
tv_tip1
.
text
=
"七天内可修改一次头像"
Glide
.
with
(
this
)
.
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
.
setOnClickListener
{
// 客服
ARouter
.
getInstance
().
navigation
(
IImService
::
class
.
java
).
startKefuChat
(
this
,
""
,
0
,
0
)
}
setModifyAvatar
()
}
3
->
{
// 审核成功 || 提交审核
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
)
{
tv_tip1
.
text
=
"抱歉,七天内只能修改一次头像"
tv_modify
.
isEnabled
=
false
tv_modify
.
setBackgroundResource
(
R
.
drawable
.
bg_c3c4ca_corner_8
)
}
else
{
tv_tip1
.
text
=
"七天内可修改一次头像"
setModifyAvatar
()
}
}
}
})
}
private
fun
setModifyAvatar
()
{
tv_modify
.
setOnClickListener
{
requestPermissions
{
optionDialog
()
}
}
}
private
fun
requestPermissions
(
block
:
()
->
Unit
)
{
if
(
XXPermissions
.
isGrantedPermission
(
this
,
Permission
.
CAMERA
))
{
block
.
invoke
()
}
else
{
XXPermissions
.
with
(
this
)
.
permission
(
Permission
.
CAMERA
)
.
request
(
object
:
OnPermissionCallback
{
override
fun
onGranted
(
permissions
:
MutableList
<
String
>?,
all
:
Boolean
)
{
block
.
invoke
()
}
override
fun
onDenied
(
permissions
:
MutableList
<
String
>?,
never
:
Boolean
)
{
ToastUtil
.
toastLong
(
this
@ModifyAvatarActivity
,
"缺少使用相机和读取存储权限,无法获取图片"
)
}
})
}
}
private
fun
optionDialog
()
{
ListNoCancelDialog
.
Builder
(
this
,
listOf
(
"相册"
,
"拍照"
),
0
).
setOnItemClickLister
(
object
:
ListNoCancelDialog
.
Builder
.
OnItemClickLister
{
override
fun
onItemClick
(
dialog
:
Dialog
,
view
:
View
?,
position
:
Int
)
{
val
file
=
File
(
mAvatarDir
)
if
(!
file
.
exists
())
file
.
mkdirs
()
when
(
position
)
{
0
->
{
// 相册
val
intent
=
Intent
(
Intent
.
ACTION_PICK
,
null
)
intent
.
setDataAndType
(
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
,
"image/*"
)
startActivityForResult
(
intent
,
ALBUM
)
}
1
->
{
// 拍照
callCamera
()
}
}
dialog
.
dismiss
()
}
override
fun
onItemLongClick
(
dialog
:
Dialog
?,
view
:
View
?,
position
:
Int
)
{}
}).
create
().
show
()
}
/**
* 调用相机
*/
private
fun
callCamera
()
{
val
intent
=
Intent
()
packageManager
.
getLaunchIntentForPackage
(
"com.android.camera"
)
?.
run
{
intent
.
setPackage
(
"com.android.camera"
)
}
intent
.
action
=
MediaStore
.
ACTION_IMAGE_CAPTURE
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
N
)
{
// api 24
intent
.
putExtra
(
"android.intent.extras.CAMERA_FACING"
,
Camera
.
CameraInfo
.
CAMERA_FACING_FRONT
)
// 调用前置摄像头
intent
.
putExtra
(
"autofocus"
,
true
)
// 自动对焦
intent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
Uri
.
fromFile
(
mAvatarFile
))
intent
.
putExtra
(
"outputFormat"
,
Bitmap
.
CompressFormat
.
JPEG
.
toString
())
startActivityForResult
(
intent
,
CAMERA
)
}
else
{
try
{
mAvatarFile
.
createNewFile
()
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
val
uri
:
Uri
=
FileUtils
.
getImageContentUri
(
this
,
mAvatarFile
)
intent
.
putExtra
(
"android.intent.extras.CAMERA_FACING"
,
Camera
.
CameraInfo
.
CAMERA_FACING_FRONT
)
// 调用前置摄像头
intent
.
putExtra
(
"autofocus"
,
true
)
// 自动对焦
intent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
uri
)
intent
.
putExtra
(
"outputFormat"
,
Bitmap
.
CompressFormat
.
JPEG
.
toString
())
startActivityForResult
(
intent
,
CAMERA
)
}
}
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
resultCode
==
RESULT_OK
)
{
when
(
requestCode
)
{
ALBUM
->
{
// 相册
data
?.
let
{
startPhotoZoom
(
it
.
data
)
}
}
CAMERA
->
{
// 拍照
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
N
)
{
// api 24
if
(
mAvatarFile
.
exists
())
{
startPhotoZoom
(
Uri
.
fromFile
(
mAvatarFile
))
}
}
else
{
startPhotoZoom
(
FileUtils
.
getImageContentUri
(
this
,
mAvatarFile
))
}
}
CROP
->
{
mUserInfo
?:
return
showProgressDialog
(
"保存中..."
)
val
path
=
FileUtils
.
getPathByUri4kitkat
(
this
,
Uri
.
fromFile
(
mAvatarFile
))
var
bitmap
=
BitmapFactory
.
decodeFile
(
path
)
bitmap
=
FileUtils
.
getZoomImage
(
bitmap
,
200.0
)
val
outPutFile
=
FileUtils
.
saveBitmap
(
bitmap
,
path
)
mDisposables
.
add
(
UserHttpImpl
.
getInstance
().
uploadFile
(
outPutFile
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
dismissProgressDialog
()
if
(!
it
.
data
)
return
@subscribe
ToastUtil
.
toastShort
(
"头像审核中,预计24小时内审核完成"
)
underReview
()
iv_avatar
.
setImageBitmap
(
bitmap
)
}
)
}
}
}
}
/**
* 审核中
*/
@SuppressLint
(
"SetTextI18n"
)
private
fun
underReview
()
{
tv_tip1
.
text
=
"抱歉,七天内只能修改一次头像"
tv_tip2
.
text
=
"审核中,预计24小时内审核完成,暂无法修改。"
tv_modify
.
setBackgroundResource
(
R
.
drawable
.
bg_c3c4ca_corner_8
)
tv_modify
.
isEnabled
=
false
}
/**
* 裁剪图片方法实现
*/
private
fun
startPhotoZoom
(
uri
:
Uri
?)
{
val
intent
=
Intent
(
"com.android.camera.action.CROP"
).
apply
{
setDataAndType
(
uri
,
"image/*"
)
putExtra
(
"crop"
,
"true"
)
// 设置裁剪
putExtra
(
"scaleUpIfNeeded"
,
true
)
// 图片拉伸,就不会出现黑框了
//宽高的比例
putExtra
(
"aspectX"
,
1
)
putExtra
(
"aspectY"
,
1
)
//裁剪图片宽高
putExtra
(
"outputX"
,
200
)
putExtra
(
"outputY"
,
200
)
}
intent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
Uri
.
fromFile
(
mAvatarFile
))
intent
.
putExtra
(
"outputFormat"
,
Bitmap
.
CompressFormat
.
PNG
.
toString
())
// return-data=true传递的为缩略图,小米手机默认传递大图,所以会导致onActivityResult调用失败
intent
.
putExtra
(
"return-data"
,
false
)
// intent.putExtra("noFaceDetection", false) // 是否需要人脸识别
startActivityForResult
(
intent
,
CROP
)
}
}
\ No newline at end of file
package
com.yidianling.user.mine
import
android.annotation.SuppressLint
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
import
android.provider.MediaStore
import
android.text.Spannable
import
android.text.SpannableString
import
android.text.style.ForegroundColorSpan
import
android.view.View
import
android.widget.ImageView
import
android.widget.TextView
import
com.alibaba.android.arouter.launcher.ARouter
import
com.bumptech.glide.Glide
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
import
com.ydl.ydlcommon.utils.extend.visible
import
com.ydl.ydlcommon.view.ListNoCancelDialog
import
com.ydl.ydlcommon.view.TitleBar
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.request.BaseInfo
import
com.yidianling.user.http.request.ModifyBaseInfo
import
com.yidianling.user.http.request.UserModifyAuditRespDto
import
de.greenrobot.event.EventBus
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
import
java.io.File
import
java.io.IOException
class
ModifyAvatarActivity
:
BaseActivity
()
{
override
fun
getStatusViewOptions
():
StatusBarOptions
{
return
StatusBarOptions
(
isAddStatusView
=
true
,
statusBarDarkMode
=
false
).
apply
{
statusColor
=
"#E6000000"
}
}
private
val
ALBUM
=
0
x0
//
相册
private
val
CAMERA
=
0
x1
//
照相
private
val
CROP
=
0
x2
//
裁剪
private
val
mAvatarDir
=
"${FileUtils.getStorageDirectory()}/img/head_img/"
//
头像目录
private
val
mAvatarPath
=
"${mAvatarDir}avatar_camera.jpg"
//
头像
private
val
mAvatarFile
=
File
(
mAvatarPath
)
//
头像文件
private
val
mUserInfo
=
findRouteService
(
IUserService
::
class
.
java
).
getUserInfo
()
override
fun
layoutResId
():
Int
=
R
.
layout
.
activity_modify_avatar
private
lateinit
var
tip_bar
:
TitleBar
private
lateinit
var
tv_tip1
:
TextView
private
lateinit
var
iv_avatar
:
ImageView
private
lateinit
var
iv_warn
:
ImageView
private
lateinit
var
tv_tip2
:
TextView
private
lateinit
var
tv_modify
:
TextView
private
fun
findView
()
{
tip_bar
=
findViewById
(
R
.
id
.
tip_bar
)
tv_tip1
=
findViewById
(
R
.
id
.
tv_tip1
)
iv_avatar
=
findViewById
(
R
.
id
.
iv_avatar
)
iv_warn
=
findViewById
(
R
.
id
.
iv_warn
)
tv_tip2
=
findViewById
(
R
.
id
.
tv_tip2
)
tv_modify
=
findViewById
(
R
.
id
.
tv_modify
)
}
@SuppressLint
(
"SetTextI18n"
)
override
fun
initDataAndEvent
()
{
findView
()
tip_bar
.
setOnLeftTextClick
{
_
,
_
->
setResult
(
RESULT_OK
)
//
刷新个人资料页
finish
()
}
mUserInfo
?:
return
mDisposables
.
add
(
UserHttpImpl
.
getInstance
()
.
getUserAuditInfo
(
BaseInfo
(
102
))
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
response
:
BaseAPIResponse
<
UserModifyAuditRespDto
>
->
if
(
response
.
code
!=
"200"
)
return
@subscribe
val
(
_
,
auditStatus
,
_
,
_
,
_
,
_
,
_
,
last7Day
,
modifyAfter
)
=
response
.
data
when
(
auditStatus
)
{
1
->
{
//
审核中
underReview
()
Glide
.
with
(
this
)
.
load
(
modifyAfter
)
.
into
(
iv_avatar
)
}
2
->
{
//
审核失败
tv_tip1
.
text
=
"七天内可修改一次头像"
Glide
.
with
(
this
)
.
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
.
setOnClickListener
{
//
客服
ARouter
.
getInstance
().
navigation
(
IImService
::
class
.
java
).
startKefuChat
(
this
,
""
,
0
,
0
)
}
setModifyAvatar
()
}
3
->
{
//
审核成功
||
提交审核
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
)
{
tv_tip1
.
text
=
"抱歉,七天内只能修改一次头像"
tv_modify
.
isEnabled
=
false
tv_modify
.
setBackgroundResource
(
R
.
drawable
.
bg_c3c4ca_corner_8
)
}
else
{
tv_tip1
.
text
=
"七天内可修改一次头像"
setModifyAvatar
()
}
}
}
})
}
private
fun
setModifyAvatar
()
{
tv_modify
.
setOnClickListener
{
requestPermissions
{
optionDialog
()
}
}
}
private
fun
requestPermissions
(
block
:
()
->
Unit
)
{
if
(
XXPermissions
.
isGrantedPermission
(
this
,
Permission
.
CAMERA
))
{
block
.
invoke
()
}
else
{
XXPermissions
.
with
(
this
)
.
permission
(
Permission
.
CAMERA
)
.
request
(
object
:
OnPermissionCallback
{
override
fun
onGranted
(
permissions
:
MutableList
<
String
>?,
all
:
Boolean
)
{
block
.
invoke
()
}
override
fun
onDenied
(
permissions
:
MutableList
<
String
>?,
never
:
Boolean
)
{
ToastUtil
.
toastLong
(
this
@ModifyAvatarActivity
,
"缺少使用相机和读取存储权限,无法获取图片"
)
}
})
}
}
private
fun
optionDialog
()
{
ListNoCancelDialog
.
Builder
(
this
,
listOf
(
"相册"
,
"拍照"
),
0
).
setOnItemClickLister
(
object
:
ListNoCancelDialog
.
Builder
.
OnItemClickLister
{
override
fun
onItemClick
(
dialog
:
Dialog
,
view
:
View
?,
position
:
Int
)
{
val
file
=
File
(
mAvatarDir
)
if
(!
file
.
exists
())
file
.
mkdirs
()
when
(
position
)
{
0
->
{
//
相册
val
intent
=
Intent
(
Intent
.
ACTION_PICK
,
null
)
intent
.
setDataAndType
(
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
,
"image/*"
)
startActivityForResult
(
intent
,
ALBUM
)
}
1
->
{
//
拍照
callCamera
()
}
}
dialog
.
dismiss
()
}
override
fun
onItemLongClick
(
dialog
:
Dialog
?,
view
:
View
?,
position
:
Int
)
{}
}).
create
().
show
()
}
/** * 调用相机 */
private
fun
callCamera
()
{
val
intent
=
Intent
()
packageManager
.
getLaunchIntentForPackage
(
"com.android.camera"
)
?.
run
{
intent
.
setPackage
(
"com.android.camera"
)
}
intent
.
action
=
MediaStore
.
ACTION_IMAGE_CAPTURE
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
N
)
{
//
api
24
intent
.
putExtra
(
"android.intent.extras.CAMERA_FACING"
,
Camera
.
CameraInfo
.
CAMERA_FACING_FRONT
)
//
调用前置摄像头
intent
.
putExtra
(
"autofocus"
,
true
)
//
自动对焦
intent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
Uri
.
fromFile
(
mAvatarFile
))
intent
.
putExtra
(
"outputFormat"
,
Bitmap
.
CompressFormat
.
JPEG
.
toString
())
startActivityForResult
(
intent
,
CAMERA
)
}
else
{
try
{
mAvatarFile
.
createNewFile
()
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
val
uri
:
Uri
=
FileUtils
.
getImageContentUri
(
this
,
mAvatarFile
)
intent
.
putExtra
(
"android.intent.extras.CAMERA_FACING"
,
Camera
.
CameraInfo
.
CAMERA_FACING_FRONT
)
//
调用前置摄像头
intent
.
putExtra
(
"autofocus"
,
true
)
//
自动对焦
intent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
uri
)
intent
.
putExtra
(
"outputFormat"
,
Bitmap
.
CompressFormat
.
JPEG
.
toString
())
startActivityForResult
(
intent
,
CAMERA
)
}
}
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
resultCode
==
RESULT_OK
)
{
when
(
requestCode
)
{
ALBUM
->
{
//
相册
data
?.
let
{
startPhotoZoom
(
it
.
data
)
}
}
CAMERA
->
{
//
拍照
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
N
)
{
//
api
24
if
(
mAvatarFile
.
exists
())
{
startPhotoZoom
(
Uri
.
fromFile
(
mAvatarFile
))
}
}
else
{
startPhotoZoom
(
FileUtils
.
getImageContentUri
(
this
,
mAvatarFile
))
}
}
CROP
->
{
mUserInfo
?:
return
showProgressDialog
(
"保存中..."
)
val
path
=
FileUtils
.
getPathByUri4kitkat
(
this
,
Uri
.
fromFile
(
mAvatarFile
))
var
bitmap
=
BitmapFactory
.
decodeFile
(
path
)
bitmap
=
FileUtils
.
getZoomImage
(
bitmap
,
200.0
)
val
outPutFile
=
FileUtils
.
saveBitmap
(
bitmap
,
path
)
mDisposables
.
add
(
UserHttpImpl
.
getInstance
().
uploadFile
(
outPutFile
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
dismissProgressDialog
()
if
(
it
.
code
!=
"200"
)
return
@subscribe
ToastUtil
.
toastShort
(
"头像审核中,预计24小时内审核完成"
)
underReview
()
iv_avatar
.
setImageBitmap
(
bitmap
)
}
)
}
}
}
}
/** * 审核中 */
@SuppressLint
(
"SetTextI18n"
)
private
fun
underReview
()
{
tv_tip1
.
text
=
"抱歉,七天内只能修改一次头像"
tv_tip2
.
text
=
"审核中,预计24小时内审核完成,暂无法修改。"
tv_modify
.
setBackgroundResource
(
R
.
drawable
.
bg_c3c4ca_corner_8
)
tv_modify
.
isEnabled
=
false
}
/** * 裁剪图片方法实现 */
private
fun
startPhotoZoom
(
uri
:
Uri
?)
{
val
intent
=
Intent
(
"com.android.camera.action.CROP"
).
apply
{
setDataAndType
(
uri
,
"image/*"
)
putExtra
(
"crop"
,
"true"
)
//
设置裁剪
putExtra
(
"scaleUpIfNeeded"
,
true
)
//
图片拉伸,就不会出现黑框了
//
宽高的比例
putExtra
(
"aspectX"
,
1
)
putExtra
(
"aspectY"
,
1
)
//
裁剪图片宽高
putExtra
(
"outputX"
,
200
)
putExtra
(
"outputY"
,
200
)
}
intent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
Uri
.
fromFile
(
mAvatarFile
))
intent
.
putExtra
(
"outputFormat"
,
Bitmap
.
CompressFormat
.
PNG
.
toString
())
//
return
-
data
=
true
传递的为缩略图,小米手机默认传递大图,所以会导致
onActivityResult
调用失败
intent
.
putExtra
(
"return-data"
,
false
)
//
intent
.
putExtra
(
"noFaceDetection"
,
false
)
//
是否需要人脸识别
startActivityForResult
(
intent
,
CROP
)
}
}
\ No newline at end of file
...
...
m-user/src/main/java/com/yidianling/user/mine/ModifyInfoActivity.kt
View file @
e742fa88
package
com.yidianling.user.mine
import
android.annotation.SuppressLint
import
android.text.Editable
import
android.text.Spannable
import
android.text.SpannableString
import
android.text.TextWatcher
import
android.text.style.ForegroundColorSpan
import
android.view.View
import
android.view.animation.Animation
...
...
@@ -21,6 +23,7 @@ import com.yidianling.common.tools.RxImageTool
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.im.api.service.IImService
import
com.yidianling.user.R
import
com.yidianling.user.api.bean.UserResponseBean
import
com.yidianling.user.api.service.IUserService
import
com.yidianling.user.http.UserHttpImpl.Companion.getInstance
import
com.yidianling.user.http.request.BaseInfo
...
...
@@ -66,6 +69,8 @@ class ModifyInfoActivity : BaseActivity() {
override
fun
initDataAndEvent
()
{
findView
()
val
from
=
intent
.
getIntExtra
(
"from"
,
0
)
val
userInfo
=
findRouteService
(
IUserService
::
class
.
java
).
getUserInfo
()
userInfo
?:
return
if
(
INTRODUCTION
==
from
)
{
tb_title_bar
.
title
=
"简介"
det_set_info
.
layoutParams
.
height
=
RxImageTool
.
dp2px
(
180f
)
...
...
@@ -76,8 +81,6 @@ class ModifyInfoActivity : BaseActivity() {
setResult
(
RESULT_OK
)
// 刷新个人资料页
finish
()
}
val
userInfo
=
findRouteService
(
IUserService
::
class
.
java
).
getUserInfo
()
userInfo
?:
return
mDisposables
.
add
(
getInstance
().
getUserAuditInfo
(
BaseInfo
(
if
(
NICKNAME
==
from
)
101
else
103
))
.
subscribeOn
(
Schedulers
.
io
())
...
...
@@ -90,80 +93,47 @@ class ModifyInfoActivity : BaseActivity() {
1
->
{
// 审核中
tv_tip1
.
visible
()
tv_tip1
.
text
=
"抱歉,七天内只能修改一次昵称"
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
(
"昵称审核中,预计24小时内审核完成"
)
}
det_set_info
.
setText
(
modifyAfter
)
setCanNotSave
()
setEditText
(
modifyAfter
,
"昵称审核中,预计24小时内审核完成"
)
tv_tip2
.
visible
()
tv_tip2
.
text
=
"昵称审核中,预计24小时内审核完成,暂无法修改。"
}
2
->
{
// 审核失败
tv_tip1
.
visible
()
tv_tip1
.
text
=
"七天内可修改一次昵称"
checkNickSaveButton
(
userInfo
)
det_set_info
.
setText
(
userInfo
.
nick_name
)
iv_warn
.
visible
()
customerService
(
"审核失败 ,昵称中含有违规文字。如有疑问联系客服小壹"
)
}
3
->
{
// 审核成功 || 提交审核
modifyAfter
?.
let
{
nick
->
det_set_info
.
setText
(
nick
)
userInfo
.
nick_name
=
nick
findRouteService
(
IImService
::
class
.
java
).
updateUserName
(
nick
)
// 更新用户昵称到云信
}
if
(
last7Day
)
{
tv_tip1
.
visible
()
tv_tip1
.
text
=
"抱歉,七天内只能修改一次昵称"
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
))
det_set_info
.
keyListener
=
null
det_set_info
.
isFocusableInTouchMode
=
false
det_set_info
.
setOnClickListener
{
ToastUtil
.
toastShort
(
"抱歉,七天内只能修改一次"
)
}
setCanNotSave
()
setEditText
(
modifyAfter
,
"抱歉,七天内只能修改一次"
)
}
else
{
tv_tip1
.
visible
()
tv_tip1
.
text
=
"七天内可修改一次昵称"
tb_title_bar
.
setRightTextColor
(
resources
.
getColor
(
R
.
color
.
color_1DA1F2
))
tb_title_bar
.
setOnRightTextClick
{
_
:
View
?,
_
:
Boolean
->
if
(
checkNickInput
())
{
modifyUserBaseInfo
(
101
)
{
ToastUtil
.
toastShort
(
"提交成功,昵称审核中,预计24小时内审核完成"
)
finish
()
}
}
}
checkNickSaveButton
(
userInfo
)
det_set_info
.
setText
(
modifyAfter
)
}
}
}
}
else
if
(
INTRODUCTION
==
from
)
{
when
(
auditStatus
)
{
1
->
{
// 审核中
tb_title_bar
.
setRightTextColor
(
resources
.
getColor
(
R
.
color
.
color_9d9ea7
))
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
(
"简介审核中,预计24小时内审核完成"
)
}
setCanNotSave
()
setEditText
(
modifyAfter
,
"简介审核中,预计24小时内审核完成"
)
tv_tip2
.
visible
()
tv_tip2
.
text
=
"审核中 预计24小时内审核完成,暂无法修改"
}
2
->
{
// 审核失败
tb_title_bar
.
setRightTextColor
(
resources
.
getColor
(
R
.
color
.
color_1DA1F2
)
)
setCanSave
(
)
det_set_info
.
setText
(
userInfo
.
description
)
iv_warn
.
visible
()
customerService
(
"审核失败,简介中含违规文字如有疑问联系客服小壹"
)
...
...
@@ -173,13 +143,7 @@ class ModifyInfoActivity : BaseActivity() {
det_set_info
.
setText
(
it
)
userInfo
.
description
=
it
}
tb_title_bar
.
setRightTextColor
(
resources
.
getColor
(
R
.
color
.
color_1DA1F2
))
tb_title_bar
.
setOnClickListener
{
modifyUserBaseInfo
(
103
)
{
ToastUtil
.
toastShort
(
"提交成功,简介审核中,预计24小时内审核完成"
)
finish
()
}
}
setCanSave
()
}
}
}
...
...
@@ -206,18 +170,59 @@ class ModifyInfoActivity : BaseActivity() {
}
}
private
fun
checkNickInput
():
Boolean
{
if
(
det_set_info
.
text
.
isEmpty
())
{
ToastUtil
.
toastShort
(
"请输入昵称"
)
det_set_info
.
startAnimation
(
mShake
)
return
false
private
fun
setCanSave
()
{
tb_title_bar
.
setRightTextColor
(
resources
.
getColor
(
R
.
color
.
color_1DA1F2
))
tb_title_bar
.
setOnClickListener
{
modifyUserBaseInfo
(
103
)
{
ToastUtil
.
toastShort
(
"提交成功,简介审核中,预计24小时内审核完成"
)
finish
()
}
}
}
private
fun
setCanNotSave
()
{
tb_title_bar
.
setRightTextEnable
(
false
)
tb_title_bar
.
setRightTextColor
(
resources
.
getColor
(
R
.
color
.
color_9d9ea7
))
}
private
fun
setEditText
(
text
:
String
?,
tip
:
String
)
{
det_set_info
.
setText
(
text
)
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
(
tip
)
}
if
(
det_set_info
.
text
.
length
>
6
)
{
ToastUtil
.
toastShort
(
"昵称最多6个字哦"
)
det_set_info
.
startAnimation
(
mShake
)
return
false
}
private
fun
checkNickSaveButton
(
userInfo
:
UserResponseBean
.
UserInfo
)
{
tb_title_bar
.
setOnRightTextClick
{
_
:
View
?,
_
:
Boolean
->
modifyUserBaseInfo
(
101
)
{
ToastUtil
.
toastShort
(
"提交成功,昵称审核中,预计24小时内审核完成"
)
finish
()
}
}
return
true
det_set_info
.
addTextChangedListener
(
object
:
TextWatcher
{
override
fun
beforeTextChanged
(
s
:
CharSequence
?,
start
:
Int
,
count
:
Int
,
after
:
Int
)
{}
override
fun
onTextChanged
(
s
:
CharSequence
?,
start
:
Int
,
before
:
Int
,
count
:
Int
)
{
if
(
s
?.
isEmpty
()
==
true
||
s
?.
toString
()
==
userInfo
.
nick_name
)
{
tb_title_bar
.
setRightTextEnable
(
false
)
tb_title_bar
.
setRightTextColor
(
resources
.
getColor
(
R
.
color
.
color_9d9ea7
))
}
else
{
tb_title_bar
.
setRightTextEnable
(
true
)
tb_title_bar
.
setRightTextColor
(
resources
.
getColor
(
R
.
color
.
color_1DA1F2
))
}
}
override
fun
afterTextChanged
(
s
:
Editable
?)
{}
})
}
private
fun
modifyUserBaseInfo
(
type
:
Int
,
block
:
()
->
Unit
)
{
...
...
@@ -231,7 +236,8 @@ class ModifyInfoActivity : BaseActivity() {
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
if
(
it
.
data
)
block
.
invoke
()
if
(
it
.
code
==
"200"
)
block
.
invoke
()
else
ToastUtil
.
toastShort
(
it
.
msg
)
}
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment