Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
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
bp
ShenghuoquanBusiness
Commits
818bab5a
Commit
818bab5a
authored
Jul 21, 2021
by
shiyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理合并代码后的运行错误
parent
0c301c6f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
0 additions
and
1161 deletions
+0
-1161
CommentService.kt
...yidian/shenghuoquan/newscontent/service/CommentService.kt
+0
-65
DeepLinkService.kt
...idian/shenghuoquan/newscontent/service/DeepLinkService.kt
+0
-56
RequestService.kt
...yidian/shenghuoquan/newscontent/service/RequestService.kt
+0
-133
UniversalService.kt
...dian/shenghuoquan/newscontent/service/UniversalService.kt
+0
-179
AliveTestActivity.kt
...an/shenghuoquan/newscontent/ui/alive/AliveTestActivity.kt
+0
-219
ShareDialog.kt
.../yidian/shenghuoquan/newscontent/ui/dialog/ShareDialog.kt
+0
-179
ShareImageDialog.kt
...an/shenghuoquan/newscontent/ui/dialog/ShareImageDialog.kt
+0
-154
SharePosterDialog.kt
...n/shenghuoquan/newscontent/ui/dialog/SharePosterDialog.kt
+0
-176
No files found.
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/service/CommentService.kt
deleted
100644 → 0
View file @
0c301c6f
package
com.yidian.shenghuoquan.newscontent.service
import
com.yidian.bcommon.constant.XEventConfig.Companion.GO_TO_COMMENT_DETAIL
import
com.yidian.bcommon.constant.XEventConfig.Companion.REPLY_COMMENT
import
com.yidian.bcommon.constant.XEventConfig.Companion.REPLY_DETAIL_COMMENT
import
com.yidian.bcommon.constant.XEventConfig.Companion.UPDATE_COMMENT
import
com.yidian.bcommon.constant.XEventConfig.Companion.UPDATE_LIKE
import
com.yidian.bcommon.utils.ToolsUtil
import
com.yidian.xarc.xrouter.ResultResolver
import
com.yidian.yac.core.zap.ZapService
import
org.json.JSONObject
class
CommentService
:
ZapService
()
{
companion
object
{
const
val
serviceName
:
String
=
"CommentService"
}
private
lateinit
var
resolver
:
ResultResolver
override
fun
onAction
(
name
:
String
,
action
:
String
,
params
:
Any
,
options
:
Any
,
resolver
:
ResultResolver
)
{
when
(
action
)
{
REPLY_COMMENT
->
{
ToolsUtil
.
doAction
(
REPLY_COMMENT
,
params
)
}
GO_TO_COMMENT_DETAIL
->
{
ToolsUtil
.
doAction
(
GO_TO_COMMENT_DETAIL
,
params
)
}
REPLY_DETAIL_COMMENT
->
{
ToolsUtil
.
doAction
(
REPLY_DETAIL_COMMENT
,
params
)
}
UPDATE_COMMENT
->
{
ToolsUtil
.
doAction
(
UPDATE_COMMENT
,
params
)
}
UPDATE_LIKE
->
{
ToolsUtil
.
doAction
(
UPDATE_LIKE
,
params
)
}
}
this
.
resolver
=
resolver
params
as
JSONObject
val
path
=
params
.
optString
(
"name"
)
val
body
=
params
.
optJSONObject
(
"body"
)
when
(
action
)
{
"addComment"
->
addComment
(
path
,
body
)
"like"
->
like
(
path
,
body
)
}
}
override
fun
onExit
()
{
}
override
fun
onInit
()
{
}
private
fun
addComment
(
path
:
String
,
params
:
JSONObject
)
{
}
private
fun
like
(
path
:
String
,
params
:
JSONObject
)
{
}
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/service/DeepLinkService.kt
deleted
100644 → 0
View file @
0c301c6f
package
com.yidian.shenghuoquan.newscontent.service
import
com.yidian.bcommon.constant.XRouterPathConstants
import
com.yidian.shenghuoquan.newscontent.ui.NewsContentActivity
import
com.yidian.xarc.xrouter.ResultResolver
import
com.yidian.xpage.XPageManager
import
com.yidian.yac.core.zap.ZapService
import
org.json.JSONObject
class
DeepLinkService
:
ZapService
()
{
companion
object
{
const
val
serviceName
:
String
=
"DeepLinkService"
}
private
lateinit
var
resolver
:
ResultResolver
override
fun
onAction
(
name
:
String
,
action
:
String
,
params
:
Any
,
options
:
Any
,
resolver
:
ResultResolver
)
{
this
.
resolver
=
resolver
params
as
JSONObject
val
parameters
=
params
.
optJSONObject
(
"parameters"
)
when
(
params
.
optString
(
"path"
))
{
"ydnews"
->
jumpNewsText
(
parameters
)
"ydvideo"
->
jumpNewsVideo
(
parameters
)
"ydauthor"
->
jumpAuthorHomePage
(
parameters
)
}
}
override
fun
onExit
()
{
}
override
fun
onInit
()
{
}
private
fun
jumpNewsText
(
params
:
JSONObject
)
{
val
docId
=
params
.
optString
(
"docid"
)
val
paramsMap
=
HashMap
<
String
,
Any
?>()
paramsMap
[
NewsContentActivity
.
ContentType
]
=
NewsContentActivity
.
TextType
paramsMap
[
NewsContentActivity
.
DocId
]
=
docId
XPageManager
.
push
(
XRouterPathConstants
.
NEWS_CONTENT
,
paramsMap
)
}
private
fun
jumpNewsVideo
(
params
:
JSONObject
)
{
val
docId
=
params
.
optString
(
"docid"
)
val
paramsMap
=
HashMap
<
String
,
Any
?>()
paramsMap
[
NewsContentActivity
.
ContentType
]
=
NewsContentActivity
.
VideoType
paramsMap
[
NewsContentActivity
.
DocId
]
=
docId
XPageManager
.
push
(
XRouterPathConstants
.
NEWS_CONTENT
,
paramsMap
)
}
private
fun
jumpAuthorHomePage
(
params
:
JSONObject
)
{
val
fromId
=
params
.
optString
(
"fromid"
)
val
paramsMap
=
HashMap
<
String
,
Any
?>()
}
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/service/RequestService.kt
deleted
100644 → 0
View file @
0c301c6f
package
com.yidian.shenghuoquan.newscontent.service
import
android.graphics.Bitmap
import
com.google.gson.Gson
import
com.yidian.bcommon.app.YdBaseApplication
import
com.yidian.bcommon.http.HttpResult
import
com.yidian.shenghuoquan.newscontent.http.ApiService
import
com.yidian.shenghuoquan.newscontent.http.httpbean.IUploadFileCallback
import
com.yidian.shenghuoquan.newscontent.http.httpbean.IUserInfoCallback
import
com.yidian.shenghuoquan.newscontent.utils.UploadFileUtils
import
com.yidian.xarc.xrouter.ResultResolver
import
com.yidian.yac.core.zap.ZapService
import
id.zelory.compressor.Compressor
import
id.zelory.compressor.constraint.format
import
id.zelory.compressor.constraint.quality
import
id.zelory.compressor.constraint.resolution
import
id.zelory.compressor.constraint.size
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
org.json.JSONObject
import
java.io.File
class
RequestService
:
ZapService
()
{
companion
object
{
const
val
serviceName
:
String
=
"RequestService"
}
private
lateinit
var
resolver
:
ResultResolver
override
fun
onAction
(
name
:
String
,
action
:
String
,
params
:
Any
,
options
:
Any
,
resolver
:
ResultResolver
)
{
this
.
resolver
=
resolver
params
as
JSONObject
val
path
=
params
.
optString
(
"path"
)
var
body
=
params
.
optJSONObject
(
"body"
)
if
(
body
==
null
)
{
body
=
JSONObject
()
}
when
(
action
)
{
"request"
->
requestApi
(
path
,
body
)
"download"
->
download
(
path
,
body
)
"uploadImage"
->
uploadFile
(
body
)
}
}
override
fun
onExit
()
{
}
override
fun
onInit
()
{
}
private
fun
download
(
path
:
String
,
params
:
JSONObject
)
{
}
private
val
userInfoImpl
=
object
:
IUserInfoCallback
{
override
fun
userInfoCallback
(
t
:
HttpResult
<
Any
?
>?)
{
val
params
=
Gson
().
toJson
(
t
)
resolver
.
success
(
JSONObject
(
params
))
}
override
fun
modifyNicknameCallback
(
t
:
HttpResult
<
Any
?
>?)
{
val
params
=
Gson
().
toJson
(
t
)
resolver
.
success
(
JSONObject
(
params
))
}
}
private
fun
requestApi
(
path
:
String
,
params
:
JSONObject
)
{
// when (path) {
// URLs.videoCommentList -> {
// val docId = params.optString("docid")
// val pageSize = params.optInt("page_size")
// val page = params.optInt("page")
// val videoCommentRequest = VideoCommentBean.Request(docId, pageSize, page)
// ApiService.videoCommentList(videoContentImpl, videoCommentRequest)
// }
// URLs.userInfo -> {
// ApiService.userInfo(userInfoImpl)
// }
// URLs.modifyNickname -> {
// val nickname = params.optString("nickname")
// val requestMap = HashMap<String, String>()
// requestMap["nickname"] = nickname
// ApiService.modifyNickname(userInfoImpl, requestMap)
// }
// URLs.likeComment -> {
// val docId = params.optString("docid")
// val commentId = params.optString("comment_id")
// val status = params.optInt("status")
// val likeRequest = LikeCommentBean.Request(docId, commentId, status)
// ApiService.likeComment(likeCommentImpl, likeRequest)
// }
// URLs.addSubscribe -> {
// val type = params.optInt("type")
// val subscribeId = params.optString("subscribe_id")
// val subscribeBean = AddSubscribeBean.Request(type, subscribeId)
// ApiService.addSubscribe(subscribeImpl, subscribeBean)
// }
// URLs.deleteSubscribe -> {
// val type = params.optInt("type")
// val subscribeIds = params.optString("subscribe_ids")
// val subscribeBean = DeleteSubscribeBean.Request(type, subscribeIds)
// ApiService.deleteSubscribe(subscribeImpl, subscribeBean)
// }
// }
}
private
val
uploadFileCallback
=
object
:
IUploadFileCallback
{
override
fun
uploadFileCallBack
(
t
:
HttpResult
<
Any
?
>?)
{
val
params
=
Gson
().
toJson
(
t
)
resolver
.
success
(
JSONObject
(
params
))
}
}
private
fun
uploadFile
(
params
:
JSONObject
)
{
if
(
YdBaseApplication
.
activityList
.
size
<=
0
)
return
val
activity
=
YdBaseApplication
.
activityList
[
YdBaseApplication
.
activityList
.
size
-
1
]
val
filePath
=
params
.
optString
(
"profile"
)
val
file
=
File
(
filePath
)
CoroutineScope
(
Dispatchers
.
IO
).
launch
{
val
compressedImageFile
=
Compressor
.
compress
(
activity
,
file
)
{
resolution
(
360
,
360
)
quality
(
80
)
format
(
Bitmap
.
CompressFormat
.
PNG
)
size
(
307200
)
}
val
requestBody
=
UploadFileUtils
.
fileToMultipartBodyPart
(
"profile"
,
compressedImageFile
)
ApiService
.
uploadFile
(
uploadFileCallback
,
requestBody
)
}
}
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/service/UniversalService.kt
deleted
100644 → 0
View file @
0c301c6f
package
com.yidian.shenghuoquan.newscontent.service
import
android.util.Log
import
android.widget.Toast
import
androidx.core.app.NotificationManagerCompat
import
com.google.gson.Gson
import
com.orhanobut.hawk.Hawk
import
com.yidian.bcommon.constant.AppConfig
import
com.yidian.bcommon.constant.HawkConfig
import
com.yidian.bcommon.constant.XEventConfig
import
com.yidian.bcommon.app.YdBaseApplication
import
com.yidian.bcommon.services.XEventService
import
com.yidian.shenghuoquan.newscontent.R
import
com.yidian.shenghuoquan.newscontent.bean.IUpdateDialogCallback
import
com.yidian.shenghuoquan.newscontent.bean.ImageItemBean
import
com.yidian.shenghuoquan.newscontent.bean.xbrid.ClientInfoBean
import
com.yidian.shenghuoquan.newscontent.bean.xevent.XEventOpenGalleryBean
import
com.yidian.shenghuoquan.newscontent.ui.dialog.UpdateVersionDialog
import
com.yidian.shenghuoquan.newscontent.utils.DataCleanManager
import
com.yidian.utils.ToastUtil
import
com.yidian.xarc.xbase.net.CheckUpdateCallback
import
com.yidian.xarc.xevent.XBaseEvent
import
com.yidian.xarc.xrouter.ResultResolver
import
com.yidian.yac.core.zap.ZapService
import
com.yidian.yac.pm.appupdate.AppUpdateEchoData
import
com.yidian.yac.pm.appupdate.AppUpdateInfo
import
com.yidian.yac.pm.appupdate.YDAppUpdateManager
import
com.yidian.yac.pm.appupdate.callback.AppUpdateCallback
import
com.yidian.yac.pm.base.UpdateInfo
import
org.json.JSONObject
import
java.io.File
class
UniversalService
:
ZapService
(){
companion
object
{
const
val
serviceName
:
String
=
"UniversalService"
}
private
lateinit
var
resolver
:
ResultResolver
private
lateinit
var
updateInfoTemp
:
AppUpdateInfo
<
AppUpdateEchoData
>
override
fun
onAction
(
name
:
String
,
action
:
String
,
params
:
Any
,
options
:
Any
,
resolver
:
ResultResolver
)
{
this
.
resolver
=
resolver
params
as
JSONObject
when
(
action
){
"makeToast"
->
showToast
(
params
)
"openGallery"
->
openGallery
(
params
)
"getClientInfo"
->
getClientInfo
()
"getAllCache"
->
getAllCache
()
"clearAllCache"
->
clearAllCache
()
"notificationStatus"
->
getNotificationStatus
()
"notificationOnSetting"
->
notificationOnSetting
()
"checkNewVersion"
->
checkUpdate
()
"popNewVersion"
->
popNewVersion
(
updateInfoTemp
)
}
}
override
fun
onExit
()
{
}
override
fun
onInit
()
{
}
private
fun
showToast
(
params
:
JSONObject
){
val
message
=
params
.
optString
(
"message"
,
""
)
Toast
.
makeText
(
YdBaseApplication
.
context
,
message
,
Toast
.
LENGTH_SHORT
).
show
()
}
private
fun
openGallery
(
params
:
JSONObject
){
val
index
=
params
.
optInt
(
"index"
)
val
imageArray
=
params
.
optJSONArray
(
"imageList"
)
val
url
=
params
.
optString
(
"url"
)
val
imageList
=
ArrayList
<
ImageItemBean
>()
repeat
(
imageArray
.
length
()){
imageList
.
add
(
ImageItemBean
(
imageArray
.
get
(
it
).
toString
()))
}
val
xbaseEvent
=
XBaseEvent
(
XEventConfig
.
OPEN_GALLERY
,
XEventOpenGalleryBean
(
index
,
imageList
,
url
))
XEventService
.
postEvent
(
xbaseEvent
)
}
private
fun
getClientInfo
(){
val
userId
=
Hawk
.
get
(
HawkConfig
.
Username
,
""
)
val
nickname
=
Hawk
.
get
(
HawkConfig
.
Nickname
,
""
)
val
portrait
=
Hawk
.
get
(
HawkConfig
.
ProfileUrl
,
""
)
val
loginStatus
=
Hawk
.
get
(
HawkConfig
.
LoginStatus
,
false
)
val
userInfo
=
ClientInfoBean
.
UserInfo
(
userId
,
nickname
,
portrait
,
loginStatus
)
val
appInfo
=
ClientInfoBean
.
AppInfo
(
AppConfig
.
cv
)
val
clientInfoBean
=
ClientInfoBean
(
userInfo
,
appInfo
)
val
params
=
Gson
().
toJson
(
clientInfoBean
)
resolver
.
success
(
JSONObject
(
params
))
}
private
fun
getAllCache
(){
val
cacheSize
=
DataCleanManager
.
getTotalCacheSizeShow
(
YdBaseApplication
.
context
)
resolver
.
success
(
cacheSize
)
}
private
fun
clearAllCache
(){
Thread
{
DataCleanManager
.
clearAllCache
(
YdBaseApplication
.
context
)
}.
start
()
resolver
.
success
(
"0K"
)
}
private
fun
getNotificationStatus
(){
if
(
YdBaseApplication
.
activityList
.
size
<=
0
)
return
val
activity
=
YdBaseApplication
.
activityList
[
YdBaseApplication
.
activityList
.
size
-
1
]
val
manage
=
NotificationManagerCompat
.
from
(
activity
)
val
isOpen
=
manage
.
areNotificationsEnabled
()
resolver
.
success
(
isOpen
)
}
private
fun
notificationOnSetting
(){
val
xbaseEvent
=
XBaseEvent
(
XEventConfig
.
OPEN_PUSH
,
""
)
XEventService
.
postEvent
(
xbaseEvent
)
}
private
fun
checkUpdate
(){
val
activity
=
YdBaseApplication
.
activityList
[
YdBaseApplication
.
activityList
.
size
-
1
]
YDAppUpdateManager
.
checkAppUpdate
(
object
:
CheckUpdateCallback
()
{
override
fun
onSucess
(
updateInfo
:
UpdateInfo
<
Any
>?)
{
updateInfoTemp
=
updateInfo
as
AppUpdateInfo
<
AppUpdateEchoData
>
val
jsonString
=
Gson
().
toJson
(
updateInfoTemp
)
val
jsonObject
=
JSONObject
(
jsonString
)
jsonObject
.
put
(
"localVersion"
,
AppConfig
.
cv
)
activity
.
runOnUiThread
{
resolver
.
success
(
jsonObject
)
}
}
override
fun
onFail
(
msg
:
String
)
{
activity
.
runOnUiThread
{
ToastUtil
.
showToast
(
activity
,
msg
)
}
}
})
}
private
val
updateDialogCallback
=
object
:
IUpdateDialogCallback
{
override
fun
downloadCallback
(
updateInfo
:
AppUpdateInfo
<
AppUpdateEchoData
>)
{
updateDownload
(
updateInfo
)
}
}
private
fun
popNewVersion
(
updateInfo
:
AppUpdateInfo
<
AppUpdateEchoData
>){
val
activity
=
YdBaseApplication
.
activityList
[
YdBaseApplication
.
activityList
.
size
-
1
]
activity
.
runOnUiThread
{
val
updateDialog
=
UpdateVersionDialog
(
activity
,
R
.
style
.
update_dialog
,
updateDialogCallback
)
updateDialog
.
setData
(
updateInfo
)
updateDialog
.
show
()
}
}
private
fun
updateDownload
(
updateInfo
:
AppUpdateInfo
<
AppUpdateEchoData
>){
YDAppUpdateManager
.
download
(
updateInfo
,
object
:
AppUpdateCallback
()
{
override
fun
onProgress
(
total
:
Long
,
current
:
Long
,
percentage
:
Int
)
{
Log
.
e
(
"zhb-yd"
,
"进度:========$percentage"
)
}
override
fun
onDownloadSuccess
(
apkFile
:
File
,
isCache
:
Boolean
)
{
YDAppUpdateManager
.
installApk
(
apkFile
)
}
override
fun
onDownloadFailed
()
{
}
override
fun
onDownloadPaused
()
{
}
override
fun
onInstallFailed
()
{
}
override
fun
onSignatureVerifiyFailed
()
{
}
},
false
)
}
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/alive/AliveTestActivity.kt
deleted
100644 → 0
View file @
0c301c6f
package
com.yidian.shenghuoquan.newscontent.ui.alive
import
android.app.ProgressDialog
import
android.os.Bundle
import
android.widget.Toast
import
com.megvii.meglive_sdk.listener.DetectCallback
import
com.megvii.meglive_sdk.listener.PreCallback
import
com.megvii.meglive_sdk.manager.MegLiveManager
import
com.yidian.bcommon.constant.AppConfig
import
com.yidian.bcommon.base.BaseActivity
import
com.yidian.bcommon.http.HttpResult
import
com.yidian.bcommon.utils.ToolsUtil
import
com.yidian.shenghuoquan.newscontent.databinding.ActivityAliveLayoutBinding
import
com.yidian.shenghuoquan.newscontent.http.ApiService
import
com.yidian.shenghuoquan.newscontent.http.httpbean.AuthPersonalGetTokenBean
import
com.yidian.shenghuoquan.newscontent.http.httpbean.AuthPersonalGetTokenCallback
import
com.yidian.shenghuoquan.newscontent.http.httpbean.IdentifyIdOcrVerifyBean
import
com.yidian.shenghuoquan.newscontent.http.httpbean.IdentifyIdOcrVerifyCallback
import
com.yidian.shenghuoquan.newscontent.utils.KS3Core
import
java.io.File
import
java.io.FileOutputStream
import
java.io.InputStream
/**
* Author: sym
* Date: 2021/5/19 6:11 PM
* Describe:onPreStart showDialogDismiss onPreFinish progressDialogDismiss
*/
class
AliveTestActivity
:
BaseActivity
<
ActivityAliveLayoutBinding
>(),
PreCallback
,
DetectCallback
{
private
var
sign
=
""
private
var
bizToken
=
""
private
var
megLiveManager
:
MegLiveManager
?
=
null
private
var
modelPath
=
""
// 模型本地存放路径
private
var
dataPath
=
""
// 模型本地存放路径
private
var
mProgressDialog
:
ProgressDialog
?
=
null
private
var
idCardName
:
String
?
=
null
private
var
idCardNo
:
String
?
=
null
override
fun
createViewBinding
():
ActivityAliveLayoutBinding
{
return
ActivityAliveLayoutBinding
.
inflate
(
layoutInflater
)
}
override
fun
getXPageName
():
String
{
return
""
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
initSign
()
setOnListener
()
idCardName
=
intent
.
getStringExtra
(
"idCardName"
)
idCardNo
=
intent
.
getStringExtra
(
"idCardNo"
)
}
private
fun
initSign
()
{
val
currtTime
=
System
.
currentTimeMillis
()
/
1000
val
expireTime
=
(
System
.
currentTimeMillis
()
+
60
*
60
*
100
)
/
1000
sign
=
GenerateSign
.
appSign
(
AppConfig
.
KUANGSHI_ALIVE_API_KEY
,
AppConfig
.
KUANGSHI_SECRET
,
currtTime
,
expireTime
)
megLiveManager
=
MegLiveManager
.
getInstance
()
modelPath
=
saveAssets
(
"faceidmodel.bin"
,
"model"
)
!!
mProgressDialog
=
ProgressDialog
(
this
)
mProgressDialog
!!
.
setCancelable
(
false
)
}
private
fun
setOnListener
()
{
viewBind
.
btActionYy
.
setOnClickListener
{
val
requestParams
=
HashMap
<
String
,
String
?>()
requestParams
[
"id_number"
]
=
idCardNo
requestParams
[
"id_card_name"
]
=
idCardName
requestParams
[
"liveness_type"
]
=
"meglive"
ApiService
.
authPersonalGetToken
(
authPersonalGetTokenCallback
,
requestParams
)
}
}
private
val
authPersonalGetTokenCallback
=
object
:
AuthPersonalGetTokenCallback
{
override
fun
getTokenSuccess
(
t
:
HttpResult
<
AuthPersonalGetTokenBean
.
Response
?
>?)
{
bizToken
=
t
?.
result
?.
biz_token
!!
megLiveManager
?.
preDetect
(
this
@AliveTestActivity
,
bizToken
,
"zh"
,
"https://api.megvii.com"
,
modelPath
,
this
@AliveTestActivity
)
}
}
private
fun
saveAssets
(
fileName
:
String
,
path
:
String
):
String
?
{
val
dir
=
File
(
getExternalFilesDir
(
"megvii"
),
path
)
if
(!
dir
.
exists
())
{
if
(!
dir
.
mkdirs
())
{
return
null
}
}
val
file
=
File
(
dir
,
fileName
)
var
fos
:
FileOutputStream
?
=
null
var
`is`
:
InputStream
?
=
null
var
ret
:
String
?
=
null
try
{
var
count
:
Int
val
buffer
=
ByteArray
(
1024
)
fos
=
FileOutputStream
(
file
)
`is`
=
this
.
assets
.
open
(
fileName
)
while
(
`is`
.
read
(
buffer
).
also
{
count
=
it
}
!=
-
1
)
{
fos
.
write
(
buffer
,
0
,
count
)
}
ret
=
file
.
absolutePath
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
return
null
}
finally
{
try
{
fos
?.
close
()
`is`
?.
close
()
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
return
ret
}
override
fun
onPreStart
()
{
showDialogDismiss
()
}
private
fun
showDialogDismiss
()
{
runOnUiThread
{
mProgressDialog
?.
show
()
}
}
override
fun
onPreFinish
(
token
:
String
?,
errorCode
:
Int
,
errorMessage
:
String
?)
{
progressDialogDismiss
()
if
(
errorCode
==
1000
)
{
megLiveManager
!!
.
setVerticalDetectionType
(
MegLiveManager
.
DETECT_VERITICAL_FRONT
)
megLiveManager
!!
.
startDetect
(
this
@AliveTestActivity
)
}
}
private
fun
progressDialogDismiss
()
{
runOnUiThread
{
if
(
mProgressDialog
!=
null
)
{
mProgressDialog
!!
.
dismiss
()
}
}
}
override
fun
onDetectFinish
(
token
:
String
?,
errorCode
:
Int
,
errorMessage
:
String
?,
data
:
String
?)
{
if
(
errorCode
==
1000
)
{
token
?.
let
{
verify
(
it
,
data
!!
.
toByteArray
())
}
}
else
{
Toast
.
makeText
(
this
@AliveTestActivity
,
errorMessage
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
private
fun
verify
(
token
:
String
,
data
:
ByteArray
)
{
showDialogDismiss
()
saveFile
(
ToolsUtil
.
randomName
(),
data
)
}
private
val
identifyIdOcrVerifyCallback
=
object
:
IdentifyIdOcrVerifyCallback
{
override
fun
identifyIdOcrVerifySuccess
(
t
:
HttpResult
<
IdentifyIdOcrVerifyBean
.
Response
?
>?)
{
progressDialogDismiss
()
if
(
t
!!
.
result
!!
.
verify_result
)
{
Toast
.
makeText
(
this
@AliveTestActivity
,
"活体检测结果成功 verify_result = true "
,
Toast
.
LENGTH_SHORT
).
show
()
}
else
{
Toast
.
makeText
(
this
@AliveTestActivity
,
"活体检测结果失败 msg = ${t.reason}"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
override
fun
identifyIdOcrVerifyFailure
(
t
:
HttpResult
<
IdentifyIdOcrVerifyBean
.
Response
?
>?)
{
progressDialogDismiss
()
}
}
// 将字节流转换成文件
@Throws
(
Exception
::
class
)
fun
saveFile
(
filename
:
String
,
data
:
ByteArray
?)
{
if
(
data
!=
null
)
{
dataPath
=
externalCacheDir
?.
absolutePath
+
"/alive/meglive"
val
file
=
File
(
dataPath
)
if
(
file
.
exists
())
{
file
.
delete
()
}
else
{
file
.
parentFile
?.
mkdirs
()
file
.
createNewFile
()
}
val
fos
=
FileOutputStream
(
file
)
fos
.
write
(
data
,
0
,
data
.
size
)
fos
.
flush
()
fos
.
close
()
KS3Core
.
INSTANCE
.
uploadObject
(
file
,
KS3Core
.
ScenarioType
.
ALIVE_DETECT
,
object
:
KS3Core
.
OnKS3TaskListener
{
override
fun
onTaskStart
()
{
}
override
fun
onTaskProgress
(
progress
:
Double
)
{
}
override
fun
onTaskFinish
()
{
}
override
fun
onTaskCancel
()
{
}
override
fun
onTaskSuccess
(
bucket
:
String
?,
objectKey
:
String
?)
{
val
requestParams
=
HashMap
<
String
,
String
?>()
requestParams
[
"biz_token"
]
=
bizToken
requestParams
[
"meglive_objectid"
]
=
objectKey
requestParams
[
"meglive_bucket"
]
=
bucket
ApiService
.
identifyIdOcrVerify
(
identifyIdOcrVerifyCallback
,
requestParams
)
}
override
fun
onTaskFailure
(
statesCode
:
Int
,
message
:
String
?)
{
}
})
}
}
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/dialog/ShareDialog.kt
deleted
100644 → 0
View file @
0c301c6f
package
com.yidian.shenghuoquan.newscontent.ui.dialog
import
android.app.Activity
import
android.app.Dialog
import
android.content.ClipData
import
android.content.ClipboardManager
import
android.content.Context
import
android.os.Bundle
import
android.util.Log
import
android.view.Gravity
import
android.view.View
import
android.view.WindowManager
import
android.widget.Toast
import
androidx.recyclerview.widget.LinearLayoutManager
import
com.umeng.socialize.ShareAction
import
com.umeng.socialize.UMShareListener
import
com.umeng.socialize.bean.SHARE_MEDIA
import
com.umeng.socialize.media.UMImage
import
com.umeng.socialize.media.UMWeb
import
com.yidian.bcommon.app.YdBaseApplication
import
com.yidian.bcommon.cardutils.adapter.OnItemClickListener
import
com.yidian.bcommon.utils.CheckApkExistUtil
import
com.yidian.nightmode.widget.YdRecyclerView
import
com.yidian.nightmode.widget.YdTextView
import
com.yidian.shenghuoquan.newscontent.R
import
com.yidian.shenghuoquan.newscontent.adapter.ShareAdapter
import
com.yidian.shenghuoquan.newscontent.bean.SharePlatformBean
class
ShareDialog
(
private
val
activity
:
Activity
,
themeResId
:
Int
)
:
Dialog
(
activity
,
themeResId
)
{
private
lateinit
var
rvSharePlatform
:
YdRecyclerView
private
lateinit
var
tvCancel
:
YdTextView
private
lateinit
var
shareAdapter
:
ShareAdapter
private
lateinit
var
contentLink
:
String
private
lateinit
var
title
:
String
private
val
imageBaseUrl
=
"http://i1.go2yd.com/image.php?url="
private
val
imageParams
=
"&type=thumbnail_200x200"
private
var
imageUrl
:
String
?
=
null
private
lateinit
var
description
:
String
private
val
dataList
:
ArrayList
<
SharePlatformBean
>
by
lazy
{
ArrayList
<
SharePlatformBean
>()
}
private
lateinit
var
wechat
:
SharePlatformBean
private
lateinit
var
wechatMoments
:
SharePlatformBean
private
lateinit
var
sinaWeibo
:
SharePlatformBean
private
lateinit
var
qq
:
SharePlatformBean
private
lateinit
var
copyLink
:
SharePlatformBean
init
{
setDialog
()
}
private
fun
setDialog
()
{
this
.
setCanceledOnTouchOutside
(
true
)
this
.
setContentView
(
R
.
layout
.
share_dialog
)
this
.
setOwnerActivity
(
activity
)
window
?.
setWindowAnimations
(
R
.
style
.
PopupWindow_anim_style
)
rvSharePlatform
=
findViewById
(
R
.
id
.
rv_sharePlatform
)
tvCancel
=
findViewById
(
R
.
id
.
tv_cancel
)
shareAdapter
=
ShareAdapter
()
initPlatform
()
setClickListener
()
}
fun
setData
(
contentLink
:
String
,
title
:
String
,
description
:
String
,
imageUrl
:
String
?)
{
this
.
contentLink
=
contentLink
this
.
title
=
title
this
.
imageUrl
=
imageUrl
this
.
description
=
description
}
private
fun
setClickListener
()
{
tvCancel
.
setOnClickListener
{
dismiss
()
}
shareAdapter
.
setOnItemClickListener
(
object
:
OnItemClickListener
<
SharePlatformBean
>
{
override
fun
onClick
(
view
:
View
?,
position
:
Int
,
item
:
SharePlatformBean
?)
{
when
(
position
)
{
in
0
..
3
->
oneKeyShare
(
position
)
4
->
copyLink
(
contentLink
)
}
}
})
}
private
fun
initPlatform
()
{
wechat
=
SharePlatformBean
(
R
.
mipmap
.
icon_share_wx
,
"微信好友"
,
ShareAdapter
.
normalType
)
wechatMoments
=
SharePlatformBean
(
R
.
mipmap
.
icon_share_pyq
,
"微信朋友圈"
,
ShareAdapter
.
normalType
)
sinaWeibo
=
SharePlatformBean
(
R
.
mipmap
.
icon_share_wb
,
"微博"
,
ShareAdapter
.
normalType
)
qq
=
SharePlatformBean
(
R
.
mipmap
.
icon_share_qq
,
"手机QQ"
,
ShareAdapter
.
normalType
)
copyLink
=
SharePlatformBean
(
R
.
mipmap
.
icon_share_link
,
"复制链接"
,
ShareAdapter
.
footType
)
dataList
.
add
(
wechat
)
dataList
.
add
(
wechatMoments
)
dataList
.
add
(
sinaWeibo
)
dataList
.
add
(
qq
)
dataList
.
add
(
copyLink
)
val
layoutManager
=
LinearLayoutManager
(
activity
)
layoutManager
.
orientation
=
LinearLayoutManager
.
HORIZONTAL
rvSharePlatform
.
layoutManager
=
layoutManager
rvSharePlatform
.
adapter
=
shareAdapter
shareAdapter
.
update
(
dataList
)
}
private
fun
copyLink
(
text
:
String
)
{
val
cmb
=
activity
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
)
as
ClipboardManager
?
cmb
?.
setPrimaryClip
(
ClipData
.
newPlainText
(
null
,
text
))
Toast
.
makeText
(
activity
,
"复制成功"
,
Toast
.
LENGTH_SHORT
).
show
()
dismiss
()
}
private
fun
oneKeyShare
(
position
:
Int
)
{
val
shareAction
=
ShareAction
(
activity
)
when
(
position
)
{
0
->
{
if
(
CheckApkExistUtil
.
checkApkExist
(
YdBaseApplication
.
context
,
CheckApkExistUtil
.
weChatPkgName
))
{
shareAction
.
platform
=
SHARE_MEDIA
.
WEIXIN
}
else
{
Toast
.
makeText
(
YdBaseApplication
.
context
,
"分享失败,未安装【微信】"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
1
->
{
if
(
CheckApkExistUtil
.
checkApkExist
(
YdBaseApplication
.
context
,
CheckApkExistUtil
.
weChatPkgName
))
{
shareAction
.
platform
=
SHARE_MEDIA
.
WEIXIN_CIRCLE
}
else
{
Toast
.
makeText
(
YdBaseApplication
.
context
,
"分享失败,未安装【微信】"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
2
->
{
if
(
CheckApkExistUtil
.
checkApkExist
(
YdBaseApplication
.
context
,
CheckApkExistUtil
.
sinaBlogPkgName
))
{
shareAction
.
platform
=
SHARE_MEDIA
.
SINA
}
else
{
Toast
.
makeText
(
YdBaseApplication
.
context
,
"分享失败,未安装【微博】"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
3
->
{
if
(
CheckApkExistUtil
.
checkApkExist
(
YdBaseApplication
.
context
,
CheckApkExistUtil
.
mobileQQPkgName
))
{
shareAction
.
platform
=
SHARE_MEDIA
.
QQ
}
else
{
Toast
.
makeText
(
YdBaseApplication
.
context
,
"分享失败,未安装【QQ】"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
}
val
web
=
UMWeb
(
contentLink
)
web
.
title
=
title
if
(
imageUrl
!=
null
)
{
imageUrl
=
imageBaseUrl
+
imageUrl
+
imageParams
web
.
setThumb
(
UMImage
(
activity
,
imageUrl
))
}
else
{
web
.
setThumb
(
UMImage
(
activity
,
R
.
mipmap
.
ydlogo
))
}
web
.
description
=
description
shareAction
.
setCallback
(
object
:
UMShareListener
{
override
fun
onStart
(
platform
:
SHARE_MEDIA
?)
{
}
override
fun
onResult
(
platform
:
SHARE_MEDIA
?)
{
Toast
.
makeText
(
activity
,
"分享成功"
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
onError
(
platform
:
SHARE_MEDIA
?,
t
:
Throwable
?)
{
Log
.
e
(
"zhb-yd"
,
"失败"
+
t
?.
message
)
}
override
fun
onCancel
(
platform
:
SHARE_MEDIA
?)
{
Toast
.
makeText
(
activity
,
"分享取消"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}).
withMedia
(
web
).
share
()
dismiss
()
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
val
params
:
WindowManager
.
LayoutParams
?
=
window
?.
attributes
params
?.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
params
?.
height
=
WindowManager
.
LayoutParams
.
WRAP_CONTENT
window
?.
attributes
=
params
window
?.
attributes
?.
gravity
=
Gravity
.
BOTTOM
}
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/dialog/ShareImageDialog.kt
deleted
100644 → 0
View file @
0c301c6f
package
com.yidian.shenghuoquan.newscontent.ui.dialog
import
android.app.Activity
import
android.app.Dialog
import
android.content.ClipData
import
android.content.ClipboardManager
import
android.content.Context
import
android.os.Bundle
import
android.util.Log
import
android.view.Gravity
import
android.view.View
import
android.view.WindowManager
import
android.widget.Toast
import
androidx.recyclerview.widget.LinearLayoutManager
import
com.umeng.socialize.ShareAction
import
com.umeng.socialize.UMShareListener
import
com.umeng.socialize.bean.SHARE_MEDIA
import
com.umeng.socialize.media.UMImage
import
com.yidian.bcommon.app.YdBaseApplication
import
com.yidian.bcommon.cardutils.adapter.OnItemClickListener
import
com.yidian.bcommon.utils.CheckApkExistUtil
import
com.yidian.nightmode.widget.YdRecyclerView
import
com.yidian.nightmode.widget.YdTextView
import
com.yidian.shenghuoquan.newscontent.R
import
com.yidian.shenghuoquan.newscontent.adapter.ShareAdapter
import
com.yidian.shenghuoquan.newscontent.bean.SharePlatformBean
class
ShareImageDialog
(
private
val
activity
:
Activity
,
themeResId
:
Int
)
:
Dialog
(
activity
,
themeResId
)
{
private
lateinit
var
rvSharePlatform
:
YdRecyclerView
private
lateinit
var
tvCancel
:
YdTextView
private
lateinit
var
shareAdapter
:
ShareAdapter
private
lateinit
var
imageUrl
:
String
private
val
dataList
:
ArrayList
<
SharePlatformBean
>
by
lazy
{
ArrayList
<
SharePlatformBean
>()
}
private
lateinit
var
wechat
:
SharePlatformBean
private
lateinit
var
wechatMoments
:
SharePlatformBean
private
lateinit
var
qq
:
SharePlatformBean
private
lateinit
var
copyLink
:
SharePlatformBean
init
{
setDialog
()
}
private
fun
setDialog
()
{
this
.
setCanceledOnTouchOutside
(
true
)
this
.
setContentView
(
R
.
layout
.
share_dialog
)
this
.
setOwnerActivity
(
activity
)
window
?.
setWindowAnimations
(
R
.
style
.
PopupWindow_anim_style
)
rvSharePlatform
=
findViewById
(
R
.
id
.
rv_sharePlatform
)
tvCancel
=
findViewById
(
R
.
id
.
tv_cancel
)
shareAdapter
=
ShareAdapter
()
initPlatform
()
setClickListener
()
}
fun
setData
(
imageUrl
:
String
)
{
this
.
imageUrl
=
imageUrl
}
private
fun
setClickListener
()
{
tvCancel
.
setOnClickListener
{
dismiss
()
}
shareAdapter
.
setOnItemClickListener
(
object
:
OnItemClickListener
<
SharePlatformBean
>
{
override
fun
onClick
(
view
:
View
?,
position
:
Int
,
item
:
SharePlatformBean
?)
{
when
(
position
)
{
in
0
..
2
->
oneKeyShare
(
position
,
imageUrl
)
3
->
copyLink
(
imageUrl
)
}
}
})
}
private
fun
initPlatform
()
{
wechat
=
SharePlatformBean
(
R
.
mipmap
.
icon_share_wx
,
"微信好友"
,
ShareAdapter
.
normalType
)
wechatMoments
=
SharePlatformBean
(
R
.
mipmap
.
icon_share_pyq
,
"微信朋友圈"
,
ShareAdapter
.
normalType
)
qq
=
SharePlatformBean
(
R
.
mipmap
.
icon_share_qq
,
"手机QQ"
,
ShareAdapter
.
normalType
)
copyLink
=
SharePlatformBean
(
R
.
mipmap
.
icon_share_link
,
"复制链接"
,
ShareAdapter
.
footType
)
dataList
.
add
(
wechat
)
dataList
.
add
(
wechatMoments
)
dataList
.
add
(
qq
)
dataList
.
add
(
copyLink
)
val
layoutManager
=
LinearLayoutManager
(
activity
)
layoutManager
.
orientation
=
LinearLayoutManager
.
HORIZONTAL
rvSharePlatform
.
layoutManager
=
layoutManager
rvSharePlatform
.
adapter
=
shareAdapter
shareAdapter
.
update
(
dataList
)
}
private
fun
copyLink
(
text
:
String
)
{
val
cmb
=
activity
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
)
as
ClipboardManager
?
cmb
?.
setPrimaryClip
(
ClipData
.
newPlainText
(
null
,
text
))
Toast
.
makeText
(
activity
,
"复制成功"
,
Toast
.
LENGTH_SHORT
).
show
()
dismiss
()
}
private
fun
oneKeyShare
(
position
:
Int
,
imageUrl
:
String
)
{
val
shareAction
=
ShareAction
(
activity
)
when
(
position
)
{
0
->
{
if
(
CheckApkExistUtil
.
checkApkExist
(
YdBaseApplication
.
context
,
CheckApkExistUtil
.
weChatPkgName
))
{
shareAction
.
platform
=
SHARE_MEDIA
.
WEIXIN
}
else
{
Toast
.
makeText
(
YdBaseApplication
.
context
,
"分享失败,未安装【微信】"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
1
->
{
if
(
CheckApkExistUtil
.
checkApkExist
(
YdBaseApplication
.
context
,
CheckApkExistUtil
.
weChatPkgName
))
{
shareAction
.
platform
=
SHARE_MEDIA
.
WEIXIN_CIRCLE
}
else
{
Toast
.
makeText
(
YdBaseApplication
.
context
,
"分享失败,未安装【微信】"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
2
->
{
if
(
CheckApkExistUtil
.
checkApkExist
(
YdBaseApplication
.
context
,
CheckApkExistUtil
.
mobileQQPkgName
))
{
shareAction
.
platform
=
SHARE_MEDIA
.
QQ
}
else
{
Toast
.
makeText
(
YdBaseApplication
.
context
,
"分享失败,未安装【QQ】"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
}
val
image
=
UMImage
(
activity
,
imageUrl
)
val
thumb
=
UMImage
(
activity
,
imageUrl
)
image
.
setThumb
(
thumb
)
shareAction
.
setCallback
(
object
:
UMShareListener
{
override
fun
onStart
(
platform
:
SHARE_MEDIA
?)
{
}
override
fun
onResult
(
platform
:
SHARE_MEDIA
?)
{
Toast
.
makeText
(
activity
,
"分享成功"
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
onError
(
platform
:
SHARE_MEDIA
?,
t
:
Throwable
?)
{
Log
.
e
(
"zhb-yd"
,
"失败"
+
t
?.
message
)
}
override
fun
onCancel
(
platform
:
SHARE_MEDIA
?)
{
Toast
.
makeText
(
activity
,
"分享取消"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}).
withMedia
(
image
).
share
()
dismiss
()
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
val
params
:
WindowManager
.
LayoutParams
?
=
window
?.
attributes
params
?.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
params
?.
height
=
WindowManager
.
LayoutParams
.
WRAP_CONTENT
window
?.
attributes
=
params
window
?.
attributes
?.
gravity
=
Gravity
.
BOTTOM
}
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/dialog/SharePosterDialog.kt
deleted
100644 → 0
View file @
0c301c6f
package
com.yidian.shenghuoquan.newscontent.ui.dialog
import
android.app.Activity
import
android.app.Dialog
import
android.os.Bundle
import
android.text.TextUtils
import
android.util.Log
import
android.view.Gravity
import
android.view.View
import
android.view.WindowManager
import
android.widget.ImageView
import
android.widget.Toast
import
androidx.recyclerview.widget.GridLayoutManager
import
com.umeng.socialize.ShareAction
import
com.umeng.socialize.UMShareListener
import
com.umeng.socialize.bean.SHARE_MEDIA
import
com.umeng.socialize.media.UMImage
import
com.yidian.bcommon.app.YdBaseApplication
import
com.yidian.bcommon.cardutils.adapter.OnItemClickListener
import
com.yidian.bcommon.utils.CheckApkExistUtil
import
com.yidian.bcommon.utils.YdFileUtils
import
com.yidian.nightmode.widget.YdRecyclerView
import
com.yidian.nightmode.widget.YdRelativeLayout
import
com.yidian.nightmode.widget.YdTextView
import
com.yidian.shenghuoquan.newscontent.R
import
com.yidian.shenghuoquan.newscontent.adapter.ShareAdapter
import
com.yidian.shenghuoquan.newscontent.bean.SharePlatformBean
class
SharePosterDialog
(
private
val
activity
:
Activity
,
themeResId
:
Int
):
Dialog
(
activity
,
themeResId
)
{
private
lateinit
var
rvSharePlatform
:
YdRecyclerView
private
lateinit
var
tvCancel
:
YdTextView
private
lateinit
var
rlyRoot
:
YdRelativeLayout
private
lateinit
var
rlyPoster
:
YdRelativeLayout
private
lateinit
var
shareAdapter
:
ShareAdapter
private
lateinit
var
contentLink
:
String
private
lateinit
var
poster
:
View
private
val
dataList
:
ArrayList
<
SharePlatformBean
>
by
lazy
{
ArrayList
<
SharePlatformBean
>()
}
private
lateinit
var
saveImage
:
SharePlatformBean
private
lateinit
var
wechat
:
SharePlatformBean
private
lateinit
var
wechatMoments
:
SharePlatformBean
private
lateinit
var
qq
:
SharePlatformBean
init
{
setDialog
()
}
private
fun
setDialog
(){
this
.
setCanceledOnTouchOutside
(
true
)
this
.
setContentView
(
R
.
layout
.
share_image_dialog
)
this
.
setOwnerActivity
(
activity
)
window
?.
setWindowAnimations
(
R
.
style
.
PopupWindow_anim_style
)
rvSharePlatform
=
findViewById
(
R
.
id
.
rv_sharePlatform
)
tvCancel
=
findViewById
(
R
.
id
.
tv_cancel
)
rlyRoot
=
findViewById
(
R
.
id
.
rly_root
)
rlyPoster
=
findViewById
(
R
.
id
.
rly_poster
)
shareAdapter
=
ShareAdapter
()
initPlatform
()
setClickListener
()
}
fun
setData
(
contentLink
:
String
,
poster
:
View
,
ivQRCode
:
ImageView
){
this
.
contentLink
=
contentLink
this
.
poster
=
poster
initPoster
(
ivQRCode
)
}
private
fun
initPoster
(
ivQRCode
:
ImageView
){
val
qrCodeBitmap
=
YdFileUtils
.
createQRCodeBitmap
(
contentLink
,
200
,
200
)
if
(
qrCodeBitmap
!=
null
){
ivQRCode
.
setImageBitmap
(
qrCodeBitmap
)
}
rlyPoster
.
addView
(
poster
)
}
private
fun
initPlatform
(){
saveImage
=
SharePlatformBean
(
R
.
mipmap
.
icon_save_card
,
"保存图片"
,
ShareAdapter
.
headType
)
wechat
=
SharePlatformBean
(
R
.
mipmap
.
icon_share_wx
,
"微信好友"
,
ShareAdapter
.
normalType
)
wechatMoments
=
SharePlatformBean
(
R
.
mipmap
.
icon_share_pyq
,
"微信朋友圈"
,
ShareAdapter
.
normalType
)
qq
=
SharePlatformBean
(
R
.
mipmap
.
icon_share_qq
,
"手机QQ"
,
ShareAdapter
.
normalType
)
dataList
.
add
(
saveImage
)
dataList
.
add
(
wechat
)
dataList
.
add
(
wechatMoments
)
dataList
.
add
(
qq
)
rvSharePlatform
.
layoutManager
=
GridLayoutManager
(
activity
,
4
)
rvSharePlatform
.
adapter
=
shareAdapter
shareAdapter
.
update
(
dataList
)
}
private
fun
setClickListener
(){
tvCancel
.
setOnClickListener
{
dismiss
()
}
shareAdapter
.
setOnItemClickListener
(
object
:
OnItemClickListener
<
SharePlatformBean
>
{
override
fun
onClick
(
view
:
View
?,
position
:
Int
,
item
:
SharePlatformBean
?)
{
when
(
position
)
{
0
->
saveImage
()
in
1
..
3
->
oneKeyShare
(
position
)
}
}
})
rlyRoot
.
setOnClickListener
{
dismiss
()
}
}
private
fun
saveImage
(){
val
bitmap
=
YdFileUtils
.
createBitmap
(
poster
)
val
imagePath
=
YdFileUtils
.
saveImageFromView
(
activity
,
bitmap
)
if
(!
TextUtils
.
isEmpty
(
imagePath
)){
Toast
.
makeText
(
activity
,
"图片保存成功"
,
Toast
.
LENGTH_SHORT
).
show
()
}
dismiss
()
}
private
fun
oneKeyShare
(
position
:
Int
){
val
shareAction
=
ShareAction
(
activity
)
when
(
position
){
1
->
{
if
(
CheckApkExistUtil
.
checkApkExist
(
YdBaseApplication
.
context
,
CheckApkExistUtil
.
weChatPkgName
)){
shareAction
.
platform
=
SHARE_MEDIA
.
WEIXIN
}
else
{
Toast
.
makeText
(
YdBaseApplication
.
context
,
"分享失败,未安装【微信】"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
2
->
{
if
(
CheckApkExistUtil
.
checkApkExist
(
YdBaseApplication
.
context
,
CheckApkExistUtil
.
weChatPkgName
)){
shareAction
.
platform
=
SHARE_MEDIA
.
WEIXIN_CIRCLE
}
else
{
Toast
.
makeText
(
YdBaseApplication
.
context
,
"分享失败,未安装【微信】"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
3
->
{
if
(
CheckApkExistUtil
.
checkApkExist
(
YdBaseApplication
.
context
,
CheckApkExistUtil
.
mobileQQPkgName
)){
shareAction
.
platform
=
SHARE_MEDIA
.
QQ
}
else
{
Toast
.
makeText
(
YdBaseApplication
.
context
,
"分享失败,未安装【QQ】"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
}
val
bitmap
=
YdFileUtils
.
createBitmap
(
poster
)
if
(
bitmap
!=
null
){
val
image
=
UMImage
(
activity
,
bitmap
)
val
thumb
=
UMImage
(
activity
,
bitmap
)
image
.
setThumb
(
thumb
)
shareAction
.
setCallback
(
object
:
UMShareListener
{
override
fun
onStart
(
platform
:
SHARE_MEDIA
?)
{
}
override
fun
onResult
(
platform
:
SHARE_MEDIA
?)
{
Toast
.
makeText
(
activity
,
"分享成功"
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
onError
(
platform
:
SHARE_MEDIA
?,
t
:
Throwable
?)
{
Log
.
e
(
"zhb-yd"
,
"失败"
+
t
?.
message
)
}
override
fun
onCancel
(
platform
:
SHARE_MEDIA
?)
{
Toast
.
makeText
(
activity
,
"分享取消"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}).
withMedia
(
image
).
share
()
}
dismiss
()
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
val
params
:
WindowManager
.
LayoutParams
?
=
window
?.
attributes
params
?.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
params
?.
height
=
WindowManager
.
LayoutParams
.
WRAP_CONTENT
window
?.
attributes
=
params
window
?.
attributes
?.
gravity
=
Gravity
.
BOTTOM
}
}
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