Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Simple-Sms
Project
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
zhangchengbo
Simple-Sms
Commits
66ddf21e
Commit
66ddf21e
authored
Mar 04, 2026
by
zhangchengbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:优化foreach,list集合效率
parent
56263fa2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
MainActivity.kt
...c/main/kotlin/com/secspace/sms/activities/MainActivity.kt
+7
-3
No files found.
app/src/main/kotlin/com/secspace/sms/activities/MainActivity.kt
View file @
66ddf21e
...
@@ -38,6 +38,8 @@ import kotlinx.coroutines.launch
...
@@ -38,6 +38,8 @@ import kotlinx.coroutines.launch
import
org.greenrobot.eventbus.EventBus
import
org.greenrobot.eventbus.EventBus
import
org.greenrobot.eventbus.Subscribe
import
org.greenrobot.eventbus.Subscribe
import
org.greenrobot.eventbus.ThreadMode
import
org.greenrobot.eventbus.ThreadMode
import
java.util.Collections
import
java.util.WeakHashMap
class
MainActivity
:
SimpleActivity
()
{
class
MainActivity
:
SimpleActivity
()
{
...
@@ -49,7 +51,8 @@ class MainActivity : SimpleActivity() {
...
@@ -49,7 +51,8 @@ class MainActivity : SimpleActivity() {
private
var
lastSearchedText
=
""
private
var
lastSearchedText
=
""
private
var
bus
:
EventBus
?
=
null
private
var
bus
:
EventBus
?
=
null
private
var
wasProtectionHandled
=
false
private
var
wasProtectionHandled
=
false
private
val
listMessageId
=
arrayListOf
<
Long
>()
// private val listMessageId = arrayListOf<Long>()
private
val
listMessageId
=
Collections
.
newSetFromMap
(
WeakHashMap
<
Long
,
Boolean
>())
private
val
binding
by
viewBinding
(
ActivityMainBinding
::
inflate
)
private
val
binding
by
viewBinding
(
ActivityMainBinding
::
inflate
)
...
@@ -361,14 +364,15 @@ class MainActivity : SimpleActivity() {
...
@@ -361,14 +364,15 @@ class MainActivity : SimpleActivity() {
Log
.
d
(
TAG
,
" getNewConversations 获取系统SMS DB短信列表(脏数据) conversations:${GsonUtil.parseListToJson(conversations)}"
)
Log
.
d
(
TAG
,
" getNewConversations 获取系统SMS DB短信列表(脏数据) conversations:${GsonUtil.parseListToJson(conversations)}"
)
//通过DB数据与cache对比threadID
//通过DB数据与cache对比threadID
val
threadIdSet
=
cachedConversations
.
map
{
it
.
threadId
}.
toSet
()
conversations
.
forEach
{
clonedConversation
->
conversations
.
forEach
{
clonedConversation
->
val
threadIds
=
cachedConversations
.
map
{
it
.
threadId
}
if
(!
threadIdSet
.
contains
(
clonedConversation
.
threadId
))
{
// O(1) 查找
if
(!
threadIds
.
contains
(
clonedConversation
.
threadId
))
{
conversationsDB
.
insertOrUpdate
(
clonedConversation
)
conversationsDB
.
insertOrUpdate
(
clonedConversation
)
cachedConversations
.
add
(
clonedConversation
)
cachedConversations
.
add
(
clonedConversation
)
}
}
}
}
cachedConversations
.
forEach
{
cachedConversation
->
cachedConversations
.
forEach
{
cachedConversation
->
val
threadId
=
cachedConversation
.
threadId
val
threadId
=
cachedConversation
.
threadId
...
...
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