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
1028f7be
Commit
1028f7be
authored
Aug 23, 2022
by
王佳洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.UI调整
2.bug修复
parent
6d8db533
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
120 additions
and
15 deletions
+120
-15
build.gradle
build.gradle
+1
-1
ExpertSearchAdapter.kt
m-consultant/src/main/java/com/yidianling/consultant/adapter/ExpertSearchAdapter.kt
+1
-1
CourseListDialog.kt
m-course/src/main/java/com/yidianling/course/widget/CourseListDialog.kt
+1
-1
CourseSpeedDialog.kt
m-course/src/main/java/com/yidianling/course/widget/CourseSpeedDialog.kt
+1
-1
HomeConsultItemView.kt
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeConsultItemView.kt
+1
-1
AvaterDialog.kt
m-user/src/main/java/com/yidianling/user/mine/AvaterDialog.kt
+35
-0
ModifyAvatarActivity.kt
m-user/src/main/java/com/yidianling/user/mine/ModifyAvatarActivity.kt
+2
-2
bg_top_corner_8_white.xml
m-user/src/main/res/drawable/bg_top_corner_8_white.xml
+7
-0
activity_modify_avatar.xml
m-user/src/main/res/layout/activity_modify_avatar.xml
+0
-1
activity_modify_info.xml
m-user/src/main/res/layout/activity_modify_info.xml
+5
-4
dialog_album_photo.xml
m-user/src/main/res/layout/dialog_album_photo.xml
+59
-0
BaseDialogFragment.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/base/BaseDialogFragment.kt
+6
-3
colors.xml
ydl-platform/src/main/res/values/colors.xml
+1
-0
No files found.
build.gradle
View file @
1028f7be
...
...
@@ -14,7 +14,7 @@ buildscript {
ydlrouter_version
=
'1.2.3'
constrait_support_version
=
'1.0.2'
componentVersion
=
"0.3.0.2
0
-wjy-SNAPSHOT"
componentVersion
=
"0.3.0.2
2
-wjy-SNAPSHOT"
}
repositories
{
mavenCentral
()
...
...
m-consultant/src/main/java/com/yidianling/consultant/adapter/ExpertSearchAdapter.kt
View file @
1028f7be
...
...
@@ -590,7 +590,7 @@ class ExpertSearchAdapter(
val
userService
=
findRouteService
(
IUserService
::
class
.
java
)
if
(!
userService
.
isBindPhone
()
&&
context
is
Activity
)
{
CommonDialog
(
context
)
.
setMessage
(
"为了及时接收消息通知,请立即绑定
收集
"
)
.
setMessage
(
"为了及时接收消息通知,请立即绑定
手机
"
)
.
setLeftOnclick
(
"忍痛放弃"
)
{}
.
setRightClick
(
"果断绑定"
)
{
userService
.
wxBindToInputhonePage
(
context
)
// 跳转绑定手机号页面
...
...
m-course/src/main/java/com/yidianling/course/widget/CourseListDialog.kt
View file @
1028f7be
...
...
@@ -32,7 +32,7 @@ class CourseListDialog : BaseDialogFragment() {
private
lateinit
var
recycler_list
:
RecyclerView
override
fun
getLayoutResourceId
():
Int
=
R
.
layout
.
dialog_course_list
override
fun
g
etGravity
():
Int
=
Gravity
.
BOTTOM
override
fun
s
etGravity
():
Int
=
Gravity
.
BOTTOM
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
context
?.
let
{
ctx
->
...
...
m-course/src/main/java/com/yidianling/course/widget/CourseSpeedDialog.kt
View file @
1028f7be
...
...
@@ -26,7 +26,7 @@ class CourseSpeedDialog : BaseDialogFragment() {
private
lateinit
var
tv_cancel
:
TextView
override
fun
getLayoutResourceId
():
Int
=
R
.
layout
.
dialog_course_speed
override
fun
g
etGravity
():
Int
=
Gravity
.
BOTTOM
override
fun
s
etGravity
():
Int
=
Gravity
.
BOTTOM
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
context
?.
let
{
...
...
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeConsultItemView.kt
View file @
1028f7be
...
...
@@ -139,7 +139,7 @@ class HomeConsultItemView(private var mContext: Context, private var homeEvent:
val
userService
=
findRouteService
(
IUserService
::
class
.
java
)
if
(!
userService
.
isBindPhone
()
&&
context
is
Activity
)
{
CommonDialog
(
context
)
.
setMessage
(
"为了及时接收消息通知,请立即绑定
收集
"
)
.
setMessage
(
"为了及时接收消息通知,请立即绑定
手机
"
)
.
setLeftOnclick
(
"忍痛放弃"
)
{}
.
setRightClick
(
"果断绑定"
)
{
userService
.
wxBindToInputhonePage
(
context
as
Activity
)
// 跳转绑定手机号页面
...
...
m-user/src/main/java/com/yidianling/user/mine/AvaterDialog.kt
0 → 100644
View file @
1028f7be
package
com.yidianling.user.mine
import
android.os.Bundle
import
android.view.Gravity
import
android.view.View
import
android.widget.TextView
import
androidx.fragment.app.DialogFragment
import
com.ydl.ydlcommon.base.BaseDialogFragment
import
com.yidianling.user.R
/**
* 修改头像dialog
*/
class
AvaterDialog
:
BaseDialogFragment
()
{
override
fun
getLayoutResourceId
():
Int
=
R
.
layout
.
dialog_album_photo
override
fun
setGravity
():
Int
=
Gravity
.
BOTTOM
lateinit
var
listener
:
(
Int
,
DialogFragment
)
->
Unit
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
val
tv_album
=
view
.
findViewById
<
TextView
>(
R
.
id
.
tv_album
)
tv_album
.
setOnClickListener
{
listener
.
invoke
(
0
,
this
)
}
val
tv_photo
=
view
.
findViewById
<
TextView
>(
R
.
id
.
tv_photo
)
tv_photo
.
setOnClickListener
{
listener
.
invoke
(
1
,
this
)
}
val
tv_cancel
=
view
.
findViewById
<
TextView
>(
R
.
id
.
tv_cancel
)
tv_cancel
.
setOnClickListener
{
listener
.
invoke
(
2
,
this
)
}
}
}
\ No newline at end of file
m-user/src/main/java/com/yidianling/user/mine/ModifyAvatarActivity.kt
View file @
1028f7be
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"
)
{
ToastUtil
.
toastShort
(
it
.
msg
)
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.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.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
()
{
showFragment
(
AvaterDialog
().
apply
{
listener
=
{
position
,
dialog
->
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
()
}
},
"avater"
)
}
/** * 调用相机 */
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"
)
{
ToastUtil
.
toastShort
(
it
.
msg
)
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/res/drawable/bg_top_corner_8_white.xml
0 → 100644
View file @
1028f7be
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<corners
android:topLeftRadius=
"8dp"
android:topRightRadius=
"8dp"
/>
<solid
android:color=
"@android:color/white"
/>
</shape>
\ No newline at end of file
m-user/src/main/res/layout/activity_modify_avatar.xml
View file @
1028f7be
...
...
@@ -8,7 +8,6 @@
<com.ydl.ydlcommon.view.TitleBar
android:id=
"@+id/tip_bar"
android:background=
"@color/color_2E2E30"
app:layout_constraintTop_toTopOf=
"parent"
android:layout_width=
"match_parent"
android:layout_height=
"44dp"
...
...
m-user/src/main/res/layout/activity_modify_info.xml
View file @
1028f7be
...
...
@@ -4,6 +4,7 @@
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/color_F9F9FD"
android:orientation=
"vertical"
>
<com.ydl.ydlcommon.view.TitleBar
...
...
@@ -12,6 +13,7 @@
android:layout_height=
"44dp"
android:background=
"@color/platform_white"
app:pa_left_start_icon=
"@drawable/platform_common_back"
android:layout_marginBottom=
"16dp"
app:pa_right_text=
"保存"
app:pa_title_text=
"修改昵称"
/>
...
...
@@ -20,13 +22,12 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"26dp"
android:layout_marginTop=
"16dp"
android:layout_marginBottom=
"12dp"
android:textColor=
"@color/color_9d9ea7"
android:textSize=
"14sp"
android:visibility=
"
invisibl
e"
android:visibility=
"
gon
e"
tools:text=
"七天内可修改一次昵称"
tools:visibility=
"visible"
/>
tools:visibility=
"visible"
/>
<com.ydl.ydlcommon.view.DeleteEditTextView
android:id=
"@+id/det_set_info"
...
...
@@ -40,7 +41,7 @@
android:paddingEnd=
"10dp"
android:paddingTop=
"15dp"
android:gravity=
"start"
android:textSize=
"1
4
sp"
android:textSize=
"1
8
sp"
android:textColor=
"@color/color_1C1F28"
android:paddingBottom=
"15dp"
/>
...
...
m-user/src/main/res/layout/dialog_album_photo.xml
0 → 100644
View file @
1028f7be
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/bg_top_corner_8_white"
>
<TextView
android:id=
"@+id/tv_album"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:paddingTop=
"16dp"
android:paddingBottom=
"16dp"
android:text=
"相册"
android:textColor=
"@color/color_1C1F28"
android:textSize=
"16sp"
app:layout_constraintTop_toTopOf=
"parent"
/>
<View
android:id=
"@+id/divide_1"
android:layout_width=
"match_parent"
android:layout_height=
"0.5dp"
app:layout_constraintTop_toBottomOf=
"@id/tv_album"
android:background=
"@color/color_EFEFF1"
/>
<TextView
android:id=
"@+id/tv_photo"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:paddingTop=
"16dp"
android:paddingBottom=
"16dp"
android:text=
"拍照"
android:textColor=
"@color/color_1C1F28"
android:textSize=
"16sp"
app:layout_constraintTop_toBottomOf=
"@id/divide_1"
/>
<View
android:id=
"@+id/divide_2"
android:layout_width=
"match_parent"
android:layout_height=
"0.5dp"
app:layout_constraintTop_toBottomOf=
"@id/tv_photo"
android:background=
"@color/color_EFEFF1"
/>
<TextView
android:id=
"@+id/tv_cancel"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:paddingTop=
"16dp"
android:paddingBottom=
"16dp"
android:text=
"取消"
android:textColor=
"@color/color_1C1F28"
android:textSize=
"16sp"
app:layout_constraintTop_toBottomOf=
"@id/divide_2"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
ydl-platform/src/main/java/com/ydl/ydlcommon/base/BaseDialogFragment.kt
View file @
1028f7be
...
...
@@ -8,6 +8,7 @@ import android.view.ViewDebug.ExportedProperty
import
android.view.ViewDebug.IntToString
import
android.view.ViewGroup
import
androidx.annotation.LayoutRes
import
androidx.annotation.StyleRes
import
androidx.fragment.app.DialogFragment
import
com.ydl.ydlcommon.R
...
...
@@ -18,7 +19,7 @@ abstract class BaseDialogFragment : DialogFragment() {
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setStyle
(
STYLE_NO_TITLE
,
R
.
style
.
bottomUpDialog
)
setStyle
(
STYLE_NO_TITLE
,
setTheme
()
)
}
override
fun
onCreateView
(
...
...
@@ -33,7 +34,7 @@ abstract class BaseDialogFragment : DialogFragment() {
super
.
onStart
()
dialog
?.
window
?.
run
{
attributes
=
attributes
?.
apply
{
gravity
=
g
etGravity
()
gravity
=
s
etGravity
()
width
=
getWidth
()
height
=
getHeight
()
}
...
...
@@ -42,7 +43,9 @@ abstract class BaseDialogFragment : DialogFragment() {
@LayoutRes
abstract
fun
getLayoutResourceId
():
Int
open
fun
getGravity
():
Int
=
Gravity
.
NO_GRAVITY
open
fun
setGravity
():
Int
=
Gravity
.
NO_GRAVITY
@StyleRes
open
fun
setTheme
():
Int
=
R
.
style
.
bottomUpDialog
@ExportedProperty
(
category
=
"layout"
,
...
...
ydl-platform/src/main/res/values/colors.xml
View file @
1028f7be
...
...
@@ -135,4 +135,5 @@
<color
name=
"color_2E2E30"
>
#2E2E30
</color>
<color
name=
"color_191919"
>
#191919
</color>
<color
name=
"color_E5E5E5"
>
#E5E5E5
</color>
<color
name=
"color_F9F9FD"
>
#F9F9FD
</color>
</resources>
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