Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
Scan QR Code Barcode Reader
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
Scan QR Code Barcode Reader
Commits
b78e096b
Commit
b78e096b
authored
Dec 26, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
73d13962
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
10 deletions
+40
-10
HistoryViewModel.kt
...src/main/java/com/base/scanqr/ui/main/HistoryViewModel.kt
+37
-10
SpJsonUtils.kt
app/src/main/java/com/base/scanqr/utils/SpJsonUtils.kt
+3
-0
No files found.
app/src/main/java/com/base/scanqr/ui/main/HistoryViewModel.kt
View file @
b78e096b
...
...
@@ -56,18 +56,45 @@ class HistoryViewModel() : ViewModel() {
}
fun
removeBean
(
bean
:
ScanBean
)
{
val
scanBean
=
when
(
bean
.
scanType
)
{
FunctionUIBean
.
KEY_WIFI
->
bean
as
WifiUIBean
FunctionUIBean
.
KEY_TEXT
->
bean
as
TextUIBean
FunctionUIBean
.
KEY_EMAIL
->
bean
as
EmailUIBean
else
->
bean
when
(
bean
.
scanType
)
{
FunctionUIBean
.
KEY_WIFI
->
{
SpJsonUtils
.
removeJsonBean
<
WifiUIBean
>(
bean
.
scanType
,
bean
as
WifiUIBean
,
removeIf
=
{
it1
,
it2
->
it1
.
createTime
==
it2
.
createTime
})
}
SpJsonUtils
.
removeJsonBean
(
bean
.
scanType
,
scanBean
,
removeIf
=
{
it1
,
it2
->
FunctionUIBean
.
KEY_TEXT
->
{
SpJsonUtils
.
removeJsonBean
<
TextUIBean
>(
bean
.
scanType
,
bean
as
TextUIBean
,
removeIf
=
{
it1
,
it2
->
it1
.
createTime
==
it2
.
createTime
})
}
FunctionUIBean
.
KEY_EMAIL
->
{
SpJsonUtils
.
removeJsonBean
<
EmailUIBean
>(
bean
.
scanType
,
bean
as
EmailUIBean
,
removeIf
=
{
it1
,
it2
->
it1
.
createTime
==
it2
.
createTime
})
}
FunctionUIBean
.
KEY_CONTACT
->
{
}
FunctionUIBean
.
KEY_WEBSITE
->
{
SpJsonUtils
.
removeJsonBean
<
WebsiteUIBean
>(
bean
.
scanType
,
bean
as
WebsiteUIBean
,
removeIf
=
{
it1
,
it2
->
it1
.
createTime
==
it2
.
createTime
})
}
FunctionUIBean
.
KEY_PRODUCT
->
{
SpJsonUtils
.
removeJsonBean
<
ProductUIBean
>(
bean
.
scanType
,
bean
as
ProductUIBean
,
removeIf
=
{
it1
,
it2
->
it1
.
createTime
==
it2
.
createTime
})
}
}
historyList
.
remove
If
{
it
.
createTime
==
bean
.
createTime
}
historyList
.
remove
(
bean
)
}
...
...
app/src/main/java/com/base/scanqr/utils/SpJsonUtils.kt
View file @
b78e096b
...
...
@@ -33,6 +33,9 @@ object SpJsonUtils {
saveJsonBeanList
(
key
,
arrayList
.
toList
())
}
/**
* 这里保存一定要找到具体的类型,不能用父类
*/
inline
fun
<
reified
T
>
removeJsonBean
(
key
:
String
,
bean
:
T
,
crossinline
removeIf
:
(
it1
:
T
,
it2
:
T
)
->
Boolean
)
{
val
list
=
getSpJsonList
<
T
>(
key
).
toMutableList
()
list
.
removeIf
{
removeIf
(
it
,
bean
)
}
...
...
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