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
9815d536
Commit
9815d536
authored
May 24, 2021
by
yinjiacheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 金山云存储逻辑
parent
bfd5e754
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
260 additions
and
80 deletions
+260
-80
XRouterPathConstants.kt
...n/src/main/java/com/yidian/common/XRouterPathConstants.kt
+1
-0
NewsContentApplication.kt
...an/shenghuoquan/newscontent/app/NewsContentApplication.kt
+14
-1
ApiService.kt
...va/com/yidian/shenghuoquan/newscontent/http/ApiService.kt
+6
-6
CommonService.kt
...com/yidian/shenghuoquan/newscontent/http/CommonService.kt
+2
-2
GetIDCardOCRBean.kt
...henghuoquan/newscontent/http/httpbean/GetIDCardOCRBean.kt
+7
-3
GetKSYunObjectIdBean.kt
...huoquan/newscontent/http/httpbean/GetKSYunObjectIdBean.kt
+1
-1
IGetIDCardOCRCallback.kt
...uoquan/newscontent/http/httpbean/IGetIDCardOCRCallback.kt
+7
-3
IDCardTestActivity.kt
.../shenghuoquan/newscontent/ui/idcard/IDCardTestActivity.kt
+103
-7
KS3Core.kt
...java/com/yidian/shenghuoquan/newscontent/utils/KS3Core.kt
+93
-57
activity_idcard.xml
...nents/newscontent/src/main/res/layout/activity_idcard.xml
+26
-0
No files found.
CommonLib/Common/src/main/java/com/yidian/common/XRouterPathConstants.kt
View file @
9815d536
...
...
@@ -31,5 +31,6 @@ class XRouterPathConstants {
const
val
MINE
=
"/mine"
const
val
LIFE_ACCOUNT_IDENTITY
=
"/lifeAccountIdentity"
const
val
LIFE_ACCOUNT_AUTH
=
"/lifeAccountAuth"
const
val
ID_CARD_TEST
=
"/idCardTest"
}
}
\ No newline at end of file
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/app/NewsContentApplication.kt
View file @
9815d536
...
...
@@ -18,6 +18,7 @@ import com.yidian.common.XRouterPathConstants.Companion.COLLECTION
import
com.yidian.common.XRouterPathConstants.Companion.FLASH
import
com.yidian.common.XRouterPathConstants.Companion.GALLERY
import
com.yidian.common.XRouterPathConstants.Companion.HOME
import
com.yidian.common.XRouterPathConstants.Companion.ID_CARD_TEST
import
com.yidian.common.XRouterPathConstants.Companion.LIFE_ACCOUNT_AUTH
import
com.yidian.common.XRouterPathConstants.Companion.LIFE_ACCOUNT_IDENTITY
import
com.yidian.common.XRouterPathConstants.Companion.LOGIN_LIFE_CIRCLE
...
...
@@ -42,13 +43,13 @@ import com.yidian.shenghuoquan.newscontent.action.ChameleonActionExecutor
import
com.yidian.shenghuoquan.newscontent.service.*
import
com.yidian.shenghuoquan.newscontent.ui.*
import
com.yidian.shenghuoquan.newscontent.ui.author.AuthorHomePageActivity
import
com.yidian.shenghuoquan.newscontent.ui.idcard.IDCardTestActivity
import
com.yidian.shenghuoquan.newscontent.ui.mine.BrowsingHistoryActivity
import
com.yidian.shenghuoquan.newscontent.ui.mine.CollectionActivity
import
com.yidian.shenghuoquan.newscontent.ui.mine.MineActivity
import
com.yidian.shenghuoquan.newscontent.ui.mine.SubscriptionActivity
import
com.yidian.shenghuoquan.newscontent.ui.search.SearchChannelActivity
import
com.yidian.shenghuoquan.newscontent.ui.search.SearchResultPageActivity
import
com.yidian.shenghuoquan.newscontent.utils.Ks3Core
import
com.yidian.xpage.XPageManager
import
com.yidian.xpage.node.XPageHandler
import
com.yidian.xpage.node.XPageNode
...
...
@@ -144,6 +145,18 @@ class NewsContentApplication : YdBaseApplication() {
}
}),
XPageNode
(
ID_CARD_TEST
,
XPageNodePageType
.
NATIVE
,
object
:
XPageHandler
{
override
fun
handler
(
params
:
Map
<
String
,
Any
?
>?)
{
val
intent
=
Intent
()
if
(
params
!=
null
)
{
intent
.
putExtra
(
XRouterPathConstants
.
ParamsKey
,
params
as
HashMap
)
}
intent
.
setClass
(
context
,
IDCardTestActivity
::
class
.
java
)
intent
.
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
context
.
startActivity
(
intent
)
}
}),
XPageNode
(
NEWS_CONTENT
,
XPageNodePageType
.
NATIVE
,
object
:
XPageHandler
{
override
fun
handler
(
params
:
Map
<
String
,
Any
?
>?)
{
val
intent
=
Intent
()
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/http/ApiService.kt
View file @
9815d536
...
...
@@ -55,7 +55,7 @@ class ApiService {
}
//获取金山云token接口
fun
getKSYunToken
(
requestParams
:
GetKSYunTokenBean
.
Request
):
HttpResult
<
GetKSYunTokenBean
.
Response
?
>?
{
fun
getKSYunToken
(
requestParams
:
GetKSYunTokenBean
.
Request
):
HttpResult
<
GetKSYunTokenBean
.
Response
>?
{
val
paramsMap
=
HttpParamsUtils
.
getParamsMap
()
return
ServiceFactory
.
getInstance
().
createService
(
CommonService
::
class
.
java
)
.
getKSYunToken
(
paramsMap
,
requestParams
)
...
...
@@ -68,13 +68,13 @@ class ApiService {
ServiceFactory
.
getInstance
().
createService
(
CommonService
::
class
.
java
)
.
getIDCardOCR
(
paramsMap
,
requestParams
)
.
compose
(
TransformUtil
.
defaultSchedulers
())
.
subscribe
(
object
:
HttpResultSubscriber
<
GetIDCardOCRBean
.
Response
?
>()
{
override
fun
onSuccess
(
result
:
HttpResult
<
GetIDCardOCRBean
.
Response
?
>?)
{
apiCallback
.
getIDCardOCR
(
result
)
.
subscribe
(
object
:
HttpResultSubscriber
<
GetIDCardOCRBean
.
Response
>()
{
override
fun
onSuccess
(
result
:
HttpResult
<
GetIDCardOCRBean
.
Response
>?)
{
apiCallback
.
getIDCardOCR
Success
(
result
?.
result
)
}
override
fun
onFailer
(
result
:
HttpResult
<
GetIDCardOCRBean
.
Response
?
>?)
{
apiCallback
.
getIDCardOCR
(
result
)
override
fun
onFailer
(
result
:
HttpResult
<
GetIDCardOCRBean
.
Response
>?)
{
apiCallback
.
getIDCardOCR
Failure
(
result
?.
status
)
}
})
}
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/http/CommonService.kt
View file @
9815d536
...
...
@@ -111,11 +111,11 @@ interface CommonService {
@Headers
(
"Content-Type: application/json"
)
@POST
(
URLs
.
getKSYunToken
)
fun
getKSYunToken
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@Body
requestParams
:
GetKSYunTokenBean
.
Request
):
Call
<
HttpResult
<
GetKSYunTokenBean
.
Response
?
>>
fun
getKSYunToken
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@Body
requestParams
:
GetKSYunTokenBean
.
Request
):
Call
<
HttpResult
<
GetKSYunTokenBean
.
Response
>>
@Headers
(
"Content-Type: application/json"
)
@POST
(
URLs
.
getIDCardOCR
)
fun
getIDCardOCR
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@Body
requestParams
:
GetIDCardOCRBean
.
Request
):
Observable
<
HttpResult
<
GetIDCardOCRBean
.
Response
?
>>
fun
getIDCardOCR
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@Body
requestParams
:
GetIDCardOCRBean
.
Request
):
Observable
<
HttpResult
<
GetIDCardOCRBean
.
Response
>>
@Headers
(
"Content-Type: application/json"
)
@POST
(
URLs
.
identifyIdOcrVerify
)
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/http/httpbean/GetIDCardOCRBean.kt
View file @
9815d536
package
com.yidian.shenghuoquan.newscontent.http.httpbean
/**
* author: yinjiacheng
* date: 5/23/21 12:13 PM
* description: 获取身份证OCR
*/
class
GetIDCardOCRBean
(
val
request
:
Request
,
val
response
:
Response
)
{
data class
Request
(
val
posit_image_objectid
:
String
,
val
back_image_objectid
:
String
,
val
bucket
:
String
val
posit_image_objectid
:
String
?,
val
back_image_objectid
:
String
?
)
data class
Response
(
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/http/httpbean/GetKSYunObjectIdBean.kt
View file @
9815d536
...
...
@@ -6,5 +6,5 @@ package com.yidian.shenghuoquan.newscontent.http.httpbean
* description: 获取金山云ObjectId
*/
class
GetKSYunObjectIdBean
{
data class
Response
(
val
bucket
:
String
,
val
object
i
d
:
String
)
data class
Response
(
val
bucket
:
String
,
val
object
I
d
:
String
)
}
\ No newline at end of file
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/http/httpbean/IGetIDCardOCRCallback.kt
View file @
9815d536
package
com.yidian.shenghuoquan.newscontent.http.httpbean
import
com.yidian.common.http.HttpResult
/**
* author: yinjiacheng
* date: 5/23/21 12:18 PM
* description: 获取身份证OCR
*/
interface
IGetIDCardOCRCallback
{
fun
getIDCardOCR
(
t
:
HttpResult
<
GetIDCardOCRBean
.
Response
?
>?)
fun
getIDCardOCRSuccess
(
result
:
GetIDCardOCRBean
.
Response
?)
fun
getIDCardOCRFailure
(
message
:
String
?)
}
\ No newline at end of file
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/idcard/IDCardTestActivity.kt
View file @
9815d536
...
...
@@ -4,8 +4,11 @@ import android.Manifest
import
android.app.Activity
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.graphics.Bitmap
import
android.graphics.BitmapFactory
import
android.os.Build
import
android.os.Bundle
import
android.util.Log
import
android.widget.Toast
import
com.megvii.demo.activity.IDCardDetectActivity
import
com.megvii.demo.utils.Configuration
...
...
@@ -13,6 +16,12 @@ import com.megvii.idcardquality.IDCardQualityLicenseManager
import
com.megvii.licensemanager.Manager
import
com.yidian.common.base.BaseActivity
import
com.yidian.shenghuoquan.newscontent.databinding.ActivityIdcardBinding
import
com.yidian.shenghuoquan.newscontent.http.ApiService
import
com.yidian.shenghuoquan.newscontent.http.httpbean.GetIDCardOCRBean
import
com.yidian.shenghuoquan.newscontent.http.httpbean.IGetIDCardOCRCallback
import
com.yidian.shenghuoquan.newscontent.utils.KS3Core
import
java.io.File
import
java.io.FileOutputStream
/**
...
...
@@ -24,6 +33,11 @@ class IDCardTestActivity : BaseActivity<ActivityIdcardBinding>() {
private
lateinit
var
mIdCardLicenseManager
:
IDCardQualityLicenseManager
private
val
INTO_IDCARDSCAN_PAGE
=
100
private
lateinit
var
idCardFront
:
Bitmap
private
lateinit
var
idCardBack
:
Bitmap
private
lateinit
var
idCardFrontObjectKey
:
String
private
lateinit
var
idCardBackObjectKey
:
String
override
fun
createViewBinding
():
ActivityIdcardBinding
{
return
ActivityIdcardBinding
.
inflate
(
layoutInflater
)
}
...
...
@@ -40,6 +54,82 @@ class IDCardTestActivity : BaseActivity<ActivityIdcardBinding>() {
//2、请求授权信息
startGetLicense
()
}
viewBind
.
btnOcr
.
setOnClickListener
{
val
frontFile
=
File
(
externalCacheDir
?.
absolutePath
+
"/front.jpg"
)
if
(
frontFile
.
exists
())
frontFile
.
delete
()
else
frontFile
.
createNewFile
()
val
backFile
=
File
(
externalCacheDir
?.
absolutePath
+
"/back.jpg"
)
if
(
backFile
.
exists
())
backFile
.
delete
()
else
backFile
.
createNewFile
()
idCardFront
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
FileOutputStream
(
frontFile
))
idCardBack
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
FileOutputStream
(
backFile
))
KS3Core
.
INSTANCE
.
uploadObject
(
frontFile
,
object
:
KS3Core
.
OnKS3TaskListener
{
override
fun
onTaskStart
()
{
}
override
fun
onTaskProgress
(
progress
:
Double
)
{
}
override
fun
onTaskFinish
()
{
}
override
fun
onTaskCancel
()
{
}
override
fun
onTaskSuccess
(
bucket
:
String
?,
objectKey
:
String
?)
{
if
(
objectKey
!=
null
)
{
idCardFrontObjectKey
=
objectKey
}
KS3Core
.
INSTANCE
.
uploadObject
(
backFile
,
object
:
KS3Core
.
OnKS3TaskListener
{
override
fun
onTaskStart
()
{
}
override
fun
onTaskProgress
(
progress
:
Double
)
{
}
override
fun
onTaskFinish
()
{
}
override
fun
onTaskCancel
()
{
}
override
fun
onTaskSuccess
(
bucket
:
String
?,
objectKey
:
String
?)
{
if
(
objectKey
!=
null
)
{
idCardBackObjectKey
=
objectKey
}
val
request
=
GetIDCardOCRBean
.
Request
(
idCardFrontObjectKey
,
idCardBackObjectKey
)
ApiService
.
getIDCardOCR
(
object
:
IGetIDCardOCRCallback
{
override
fun
getIDCardOCRSuccess
(
result
:
GetIDCardOCRBean
.
Response
?)
{
Log
.
d
(
KS3Core
.
TAG
,
"name: ${result?.posit?.name}, id num: ${result?.posit?.idcard_number}"
)
}
override
fun
getIDCardOCRFailure
(
message
:
String
?)
{
}
},
request
)
}
override
fun
onTaskFailure
(
statesCode
:
Int
,
message
:
String
?)
{
}
})
}
override
fun
onTaskFailure
(
statesCode
:
Int
,
message
:
String
?)
{
}
})
}
requestCameraPerm
()
...
...
@@ -91,7 +181,11 @@ class IDCardTestActivity : BaseActivity<ActivityIdcardBinding>() {
}
}
override
fun
onRequestPermissionsResult
(
requestCode
:
Int
,
permissions
:
Array
<
out
String
>,
grantResults
:
IntArray
)
{
override
fun
onRequestPermissionsResult
(
requestCode
:
Int
,
permissions
:
Array
<
out
String
>,
grantResults
:
IntArray
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
)
//@TODO 权限通过后的回调
...
...
@@ -128,14 +222,16 @@ class IDCardTestActivity : BaseActivity<ActivityIdcardBinding>() {
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
requestCode
==
INTO_IDCARDSCAN_PAGE
&&
resultCode
==
Activity
.
RESULT_OK
)
{
val
intent
:
Intent
=
Intent
(
this
,
IDCardResultActivity
::
class
.
java
)
if
(
data
!=
null
)
{
intent
.
putExtra
(
"portraitimg_bitmap"
,
data
.
getByteArrayExtra
(
"portraitimg_bitmap"
))
}
if
(
data
!=
null
)
{
intent
.
putExtra
(
"idcardimg_bitmap"
,
data
.
getByteArrayExtra
(
"idcardimg_bitmap"
))
val
bytes
=
data
.
getByteArrayExtra
(
"idcardimg_bitmap"
)
if
(
Configuration
.
getCardType
(
this
)
==
1
)
{
idCardFront
=
BitmapFactory
.
decodeByteArray
(
bytes
,
0
,
bytes
.
size
)
viewBind
.
resultIdcardImageFront
.
setImageBitmap
(
idCardFront
)
}
else
{
idCardBack
=
BitmapFactory
.
decodeByteArray
(
bytes
,
0
,
bytes
.
size
)
viewBind
.
resultIdcardImageBack
.
setImageBitmap
(
idCardBack
)
}
}
startActivity
(
intent
)
}
}
}
\ No newline at end of file
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/utils/K
s
3Core.kt
→
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/utils/K
S
3Core.kt
View file @
9815d536
...
...
@@ -26,20 +26,14 @@ import java.io.File
* date: 5/20/21 11:08 AM
* description: 金山云存储
*/
class
K
s
3Core
private
constructor
(
val
context
:
Context
)
:
AuthListener
{
class
K
S
3Core
private
constructor
(
val
context
:
Context
)
:
AuthListener
{
private
val
client
by
lazy
{
Ks3Client
(
this
,
context
)
}
private
val
gson
by
lazy
{
Gson
()
}
private
val
onKs3UploadListenerList
:
ArrayList
<
OnKs3UploadListener
>
by
lazy
{
ArrayList
<
OnKs3UploadListener
>()
}
private
val
putObjectResponseHandler
by
lazy
{
object
:
PutObjectResponseHandler
()
{
override
fun
onTaskProgress
(
progress
:
Double
)
{
// work thread
if
(
onKs3UploadListenerList
.
size
>
0
)
{
for
(
listener
in
onKs3UploadListenerList
)
{
listener
.
onUploadProgress
(
progress
)
}
}
}
override
fun
onTaskFailure
(
...
...
@@ -53,44 +47,22 @@ class Ks3Core private constructor(val context: Context) : AuthListener {
TAG
,
"put object fail:, errorMsg: ${error?.errorMessage}"
)
if
(
onKs3UploadListenerList
.
size
>
0
)
{
for
(
listener
in
onKs3UploadListenerList
)
{
listener
.
onUploadFailure
(
error
?.
errorMessage
)
}
}
}
override
fun
onTaskSuccess
(
statesCode
:
Int
,
responceHeaders
:
Array
<
out
Header
>?)
{
Log
.
d
(
TAG
,
"put object success."
)
if
(
onKs3UploadListenerList
.
size
>
0
)
{
for
(
listener
in
onKs3UploadListenerList
)
{
listener
.
onUploadSuccess
()
}
}
}
override
fun
onTaskStart
()
{
if
(
onKs3UploadListenerList
.
size
>
0
)
{
for
(
listener
in
onKs3UploadListenerList
)
{
listener
.
onUploadStart
()
}
}
}
override
fun
onTaskFinish
()
{
if
(
onKs3UploadListenerList
.
size
>
0
)
{
for
(
listener
in
onKs3UploadListenerList
)
{
listener
.
onUploadFinish
()
}
}
}
override
fun
onTaskCancel
()
{
if
(
onKs3UploadListenerList
.
size
>
0
)
{
for
(
listener
in
onKs3UploadListenerList
)
{
listener
.
onUploadCancel
()
}
}
}
}
}
...
...
@@ -114,13 +86,13 @@ class Ks3Core private constructor(val context: Context) : AuthListener {
}
companion
object
{
const
val
TAG
=
"K
s
3Core"
const
val
TAG
=
"K
S
3Core"
const
val
DEFAULT_BUCKET_NAME
=
"bp-yidian"
const
val
DEFAULT_END_POINT
=
"ks3-cn-beijing.ksyun.com"
const
val
VIDEO_SUFFIX
=
".mp4"
const
val
IMAGE_SUFFIX
=
".png"
val
instance
:
Ks
3Core
by
lazy
(
mode
=
LazyThreadSafetyMode
.
SYNCHRONIZED
)
{
K
s
3Core
(
context
=
YdBaseApplication
.
context
)
val
INSTANCE
:
KS
3Core
by
lazy
(
mode
=
LazyThreadSafetyMode
.
SYNCHRONIZED
)
{
K
S
3Core
(
context
=
YdBaseApplication
.
context
)
}
}
...
...
@@ -140,18 +112,46 @@ class Ks3Core private constructor(val context: Context) : AuthListener {
* 文件上传
* @param path 本地文件全路径
*/
fun
uploadObject
(
path
:
String
)
{
fun
uploadObject
(
path
:
String
,
listener
:
OnKS3TaskListener
)
{
ApiService
.
getKSYunObjectId
(
object
:
IGetKSYunObjectIdCallback
{
override
fun
getKSYunObjectIdSuccess
(
result
:
GetKSYunObjectIdBean
.
Response
?)
{
Log
.
d
(
TAG
,
"request getKSYun objectId success, objectId: ${result?.object
i
d}, bucket: ${result?.bucket}"
"request getKSYun objectId success, objectId: ${result?.object
I
d}, bucket: ${result?.bucket}"
)
// 执行金山云上传
// val request = PutObjectRequest(result?.bucket, result?.objectid, File(path))
val
request
=
PutObjectRequest
(
DEFAULT_BUCKET_NAME
,
result
?.
objectid
,
File
(
path
))
val
request
=
PutObjectRequest
(
result
?.
bucket
,
result
?.
objectId
,
File
(
path
))
request
.
cannedAcl
=
CannedAccessControlList
.
PublicRead
client
.
putObject
(
request
,
putObjectResponseHandler
)
client
.
putObject
(
request
,
KS3CorePutObjectResponseHandler
(
result
?.
bucket
,
result
?.
objectId
,
listener
)
)
}
override
fun
getKSYunObjectIdFailure
(
message
:
String
?)
{
Log
.
e
(
TAG
,
"request get KSYun objectId fail, message: $message"
)
}
})
}
/**
* 文件上传
* @param file 文件实体
*/
fun
uploadObject
(
file
:
File
,
listener
:
OnKS3TaskListener
)
{
ApiService
.
getKSYunObjectId
(
object
:
IGetKSYunObjectIdCallback
{
override
fun
getKSYunObjectIdSuccess
(
result
:
GetKSYunObjectIdBean
.
Response
?)
{
Log
.
d
(
TAG
,
"request getKSYun objectId success, objectId: ${result?.objectId}, bucket: ${result?.bucket}"
)
// 执行金山云上传
val
request
=
PutObjectRequest
(
result
?.
bucket
,
result
?.
objectId
,
file
)
request
.
cannedAcl
=
CannedAccessControlList
.
PublicRead
client
.
putObject
(
request
,
KS3CorePutObjectResponseHandler
(
result
?.
bucket
,
result
?.
objectId
,
listener
)
)
}
override
fun
getKSYunObjectIdFailure
(
message
:
String
?)
{
...
...
@@ -202,26 +202,16 @@ class Ks3Core private constructor(val context: Context) : AuthListener {
return
ApiService
.
getKSYunToken
(
GetKSYunTokenBean
.
Request
(
tok
))
?.
result
?.
token
}
fun
addOnKs3UploadListener
(
listener
:
OnKs3UploadListener
)
{
if
(!
onKs3UploadListenerList
.
contains
(
listener
))
{
onKs3UploadListenerList
.
add
(
listener
)
}
}
fun
removeOnKs3UploadListener
(
listener
:
OnKs3UploadListener
)
{
onKs3UploadListenerList
.
remove
(
listener
)
}
/**
* 业务监听
*/
interface
OnK
s3Upload
Listener
{
fun
on
Upload
Start
()
fun
on
Upload
Progress
(
progress
:
Double
)
fun
on
Upload
Finish
()
fun
on
Upload
Cancel
()
fun
on
UploadSuccess
(
)
fun
on
UploadFailure
(
message
:
String
?)
interface
OnK
S3Task
Listener
{
fun
on
Task
Start
()
fun
on
Task
Progress
(
progress
:
Double
)
fun
on
Task
Finish
()
fun
on
Task
Cancel
()
fun
on
TaskSuccess
(
bucket
:
String
?,
objectKey
:
String
?
)
fun
on
TaskFailure
(
statesCode
:
Int
,
message
:
String
?)
}
/**
...
...
@@ -231,4 +221,50 @@ class Ks3Core private constructor(val context: Context) : AuthListener {
VIDEO
,
IMAGE
}
/**
* 金山云object上传handler
*/
class
KS3CorePutObjectResponseHandler
(
private
val
bucket
:
String
?,
private
val
objectKey
:
String
?,
val
listener
:
OnKS3TaskListener
)
:
PutObjectResponseHandler
()
{
override
fun
onTaskProgress
(
progress
:
Double
)
{
// work thread
listener
.
onTaskProgress
(
progress
)
}
override
fun
onTaskFailure
(
statesCode
:
Int
,
error
:
Ks3Error
?,
responceHeaders
:
Array
<
out
Header
>?,
response
:
String
?,
throwable
:
Throwable
?
)
{
Log
.
e
(
TAG
,
"put object fail:, errorMsg: ${error?.errorMessage}"
)
listener
.
onTaskFailure
(
statesCode
,
error
?.
errorMessage
)
}
override
fun
onTaskSuccess
(
statesCode
:
Int
,
responceHeaders
:
Array
<
out
Header
>?)
{
Log
.
d
(
TAG
,
"put object success."
)
listener
.
onTaskSuccess
(
bucket
,
objectKey
)
}
override
fun
onTaskStart
()
{
listener
.
onTaskStart
()
}
override
fun
onTaskFinish
()
{
listener
.
onTaskFinish
()
}
override
fun
onTaskCancel
()
{
listener
.
onTaskCancel
()
}
}
}
\ No newline at end of file
Components/newscontent/src/main/res/layout/activity_idcard.xml
View file @
9815d536
...
...
@@ -82,4 +82,30 @@
android:textColor=
"@android:color/white"
android:textSize=
"22sp"
/>
<ImageView
android:id=
"@+id/result_idcard_image_front"
android:layout_width=
"300dp"
android:layout_height=
"200dp"
android:scaleType=
"fitCenter"
android:layout_centerInParent=
"true"
/>
<ImageView
android:id=
"@+id/result_idcard_image_back"
android:layout_width=
"300dp"
android:layout_height=
"200dp"
android:layout_marginTop=
"10dp"
android:scaleType=
"fitCenter"
android:layout_centerHorizontal=
"true"
android:layout_below=
"@id/result_idcard_image_front"
/>
<Button
android:id=
"@+id/btn_ocr"
android:layout_width=
"300dp"
android:layout_height=
"50dp"
android:layout_alignParentBottom=
"true"
android:layout_centerHorizontal=
"true"
android:text=
"开始OCR识别"
android:textColor=
"@android:color/white"
android:textSize=
"22sp"
/>
</RelativeLayout>
\ No newline at end of file
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