Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
b28eaa1a
Commit
b28eaa1a
authored
Jan 23, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(gui): add synchronization to SimpleIndex class (#435)
parent
be509c71
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
SearchDialog.java
jadx-gui/src/main/java/jadx/gui/ui/SearchDialog.java
+1
-0
SimpleIndex.java
...-gui/src/main/java/jadx/gui/utils/search/SimpleIndex.java
+18
-10
No files found.
jadx-gui/src/main/java/jadx/gui/ui/SearchDialog.java
View file @
b28eaa1a
...
...
@@ -176,6 +176,7 @@ public class SearchDialog extends CommonSearchDialog {
.
subscribeOn
(
Schedulers
.
single
())
.
doOnNext
(
r
->
LOG
.
debug
(
"search event: {}"
,
r
))
.
switchMap
(
text
->
prepareSearch
(
text
)
.
doOnError
(
e
->
LOG
.
error
(
"Error prepare search: {}"
,
e
.
getMessage
(),
e
))
.
subscribeOn
(
Schedulers
.
single
())
.
toList
()
.
toFlowable
(),
1
)
...
...
jadx-gui/src/main/java/jadx/gui/utils/search/SimpleIndex.java
View file @
b28eaa1a
...
...
@@ -12,10 +12,14 @@ public class SimpleIndex<T> implements SearchIndex<T> {
private
final
List
<
String
>
keys
=
new
ArrayList
<>();
private
final
List
<
T
>
values
=
new
ArrayList
<>();
private
final
Object
syncData
=
new
Object
();
@Override
public
void
put
(
String
str
,
T
value
)
{
keys
.
add
(
str
);
values
.
add
(
value
);
synchronized
(
syncData
)
{
keys
.
add
(
str
);
values
.
add
(
value
);
}
}
@Override
...
...
@@ -39,13 +43,15 @@ public class SimpleIndex<T> implements SearchIndex<T> {
@Override
public
Flowable
<
T
>
search
(
final
String
searchStr
,
final
boolean
caseInsensitive
)
{
return
Flowable
.
create
(
emitter
->
{
int
size
=
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
if
(
isMatched
(
keys
.
get
(
i
),
searchStr
,
caseInsensitive
))
{
emitter
.
onNext
(
values
.
get
(
i
));
}
if
(
emitter
.
isCancelled
())
{
return
;
synchronized
(
syncData
)
{
int
size
=
keys
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
if
(
isMatched
(
keys
.
get
(
i
),
searchStr
,
caseInsensitive
))
{
emitter
.
onNext
(
values
.
get
(
i
));
}
if
(
emitter
.
isCancelled
())
{
return
;
}
}
}
emitter
.
onComplete
();
...
...
@@ -54,6 +60,8 @@ public class SimpleIndex<T> implements SearchIndex<T> {
@Override
public
int
size
()
{
return
keys
.
size
();
synchronized
(
syncData
)
{
return
keys
.
size
();
}
}
}
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