Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
IBMS
/
nativeview
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9072aa05
authored
Feb 23, 2022
by
huangzhicong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去掉singleOptions,jssdk定义只有一个参数时args即为参数
parent
6d73cc3c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
20 deletions
+9
-20
app/src/main/java/com/maxrocky/nativeview/fragment/MainFragment.kt
+9
-18
app/src/main/java/com/maxrocky/nativeview/model/Options.kt
+0
-2
No files found.
app/src/main/java/com/maxrocky/nativeview/fragment/MainFragment.kt
View file @
9072aa05
...
@@ -18,7 +18,6 @@ import com.maxrocky.nativeview.R
...
@@ -18,7 +18,6 @@ import com.maxrocky.nativeview.R
import
com.maxrocky.nativeview.WebViewProxy
import
com.maxrocky.nativeview.WebViewProxy
import
com.maxrocky.nativeview.contract.*
import
com.maxrocky.nativeview.contract.*
import
com.maxrocky.nativeview.model.StorageOptions
import
com.maxrocky.nativeview.model.StorageOptions
import
com.maxrocky.nativeview.model.SingleOptions
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
...
@@ -152,28 +151,20 @@ class MainFragment : Fragment() {
...
@@ -152,28 +151,20 @@ class MainFragment : Fragment() {
@JavascriptInterface
@JavascriptInterface
fun
execute
(
sessionId
:
Int
,
method
:
String
,
args
:
String
)
{
fun
execute
(
sessionId
:
Int
,
method
:
String
,
args
:
String
)
{
when
(
method
)
{
when
(
method
)
{
"selectFile"
->
{
"selectFile"
->
selectFileContract
.
selectFile
(
sessionId
,
args
)
val
options
=
gson
.
fromJson
<
SingleOptions
<
String
>>(
args
,
SingleOptions
::
class
.
java
)
selectFileContract
.
selectFile
(
sessionId
,
options
.
data1
)
}
"selectPhoto"
->
selectPhotoContract
.
selectPhoto
(
sessionId
)
"selectPhoto"
->
selectPhotoContract
.
selectPhoto
(
sessionId
)
"openCamera"
->
cameraContract
.
openCamera
(
sessionId
)
"openCamera"
->
cameraContract
.
openCamera
(
sessionId
)
"recordAudio"
->
{
"recordAudio"
->
if
(
args
.
isNotEmpty
())
{
recordAudioContract
.
recordAudio
(
sessionId
,
args
.
toIntOrNull
())
val
options
=
gson
.
fromJson
<
SingleOptions
<
Int
>>(
args
,
SingleOptions
::
class
.
java
)
"cropPhoto"
->
recordAudioContract
.
recordAudio
(
sessionId
,
options
.
data1
)
cropContract
.
cropPhoto
(
sessionId
,
Uri
.
parse
(
args
))
}
else
{
recordAudioContract
.
recordAudio
(
sessionId
)
}
}
"cropPhoto"
->
{
val
options
=
gson
.
fromJson
<
SingleOptions
<
String
>>(
args
,
SingleOptions
::
class
.
java
)
cropContract
.
cropPhoto
(
sessionId
,
Uri
.
parse
(
options
.
data1
))
}
"captureVideo"
->
videoContract
.
captureVideo
(
sessionId
)
"captureVideo"
->
videoContract
.
captureVideo
(
sessionId
)
"qrcode"
->
qrCodeContract
.
qrcode
(
sessionId
)
"qrcode"
->
qrCodeContract
.
qrcode
(
sessionId
)
"storageValue"
->
{
"storageValue"
->
{
val
options
=
gson
.
fromJson
<
StorageOptions
<
String
,
String
>>(
args
,
StorageOptions
::
class
.
java
)
val
options
=
gson
.
fromJson
<
StorageOptions
<
String
,
String
>>(
args
,
StorageOptions
::
class
.
java
)
storageContract
.
storageValue
(
sessionId
,
options
.
key
,
options
.
value
)
storageContract
.
storageValue
(
sessionId
,
options
.
key
,
options
.
value
)
}
}
"acquireValue"
->
storageContract
.
acquireValue
(
sessionId
,
args
)
"acquireValue"
->
storageContract
.
acquireValue
(
sessionId
,
args
)
...
...
app/src/main/java/com/maxrocky/nativeview/model/Options.kt
View file @
9072aa05
package
com.maxrocky.nativeview.model
package
com.maxrocky.nativeview.model
data class
SingleOptions
<
T
>(
val
data1
:
T
)
data class
StorageOptions
<
T
,
U
>(
val
key
:
T
,
val
value
:
U
)
data class
StorageOptions
<
T
,
U
>(
val
key
:
T
,
val
value
:
U
)
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