Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
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
Administrator
Magisk
Commits
a181fa06
Commit
a181fa06
authored
Apr 22, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed updating lists being to heavy for the UI thread
Moved list diff recalculation to the computing thread instead
parent
3f748b4d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
36 deletions
+47
-36
HideViewModel.kt
...c/main/java/com/topjohnwu/magisk/ui/hide/HideViewModel.kt
+22
-18
ModuleViewModel.kt
...in/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt
+19
-18
XList.kt
app/src/main/java/com/topjohnwu/magisk/utils/XList.kt
+6
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/ui/hide/HideViewModel.kt
View file @
a181fa06
...
...
@@ -18,6 +18,7 @@ import com.topjohnwu.magisk.model.events.HideProcessEvent
import
com.topjohnwu.magisk.ui.base.MagiskViewModel
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.toSingle
import
com.topjohnwu.magisk.utils.update
import
com.topjohnwu.superuser.Shell
import
io.reactivex.Single
import
me.tatarka.bindingcollectionadapter2.OnItemBind
...
...
@@ -31,7 +32,7 @@ class HideViewModel(
val
query
=
KObservableField
(
""
)
val
isShowSystem
=
KObservableField
(
false
)
private
val
allItems
=
DiffObservableList
(
ComparableRvItem
.
callback
)
private
val
allItems
=
mutableListOf
<
ComparableRvItem
<*>>(
)
val
items
=
DiffObservableList
(
ComparableRvItem
.
callback
)
val
itemBinding
=
OnItemBind
<
ComparableRvItem
<*>>
{
itemBinding
,
_
,
item
->
item
.
bind
(
itemBinding
)
...
...
@@ -72,27 +73,30 @@ class HideViewModel(
.
map
{
HideRvItem
(
it
,
hideTargets
.
blockingGet
())
}
.
toList
()
.
map
{
it
.
sortBy
{
it
.
item
.
info
.
name
};
it
}
.
doOnSuccess
{
allItems
.
update
(
it
)
}
.
flatMap
{
queryRaw
()
}
.
applyViewModel
(
this
)
.
subscribeK
(
onError
=
Timber
::
e
)
{
allItems
.
update
(
it
)
query
()
}
.
subscribeK
(
onError
=
Timber
::
e
)
{
items
.
update
(
it
.
first
,
it
.
second
)
}
.
add
()
}
private
fun
query
(
showSystem
:
Boolean
=
isShowSystem
.
value
,
query
:
String
=
this
.
query
.
value
)
{
allItems
.
toSingle
()
.
map
{
it
.
filterIsInstance
<
HideRvItem
>()
}
.
flattenAsFlowable
{
it
}
.
filter
{
it
.
item
.
name
.
contains
(
query
,
ignoreCase
=
true
)
||
it
.
item
.
processes
.
any
{
it
.
contains
(
query
,
ignoreCase
=
true
)
}
}
.
filter
{
if
(
showSystem
)
true
else
it
.
item
.
info
.
flags
and
ApplicationInfo
.
FLAG_SYSTEM
==
0
}
.
toList
()
.
subscribeK
{
items
.
update
(
it
)
}
.
add
()
}
private
fun
query
()
=
queryRaw
()
.
subscribeK
{
items
.
update
(
it
.
first
,
it
.
second
)
}
.
add
()
private
fun
queryRaw
(
showSystem
:
Boolean
=
isShowSystem
.
value
,
query
:
String
=
this
.
query
.
value
)
=
allItems
.
toSingle
()
.
map
{
it
.
filterIsInstance
<
HideRvItem
>()
}
.
flattenAsFlowable
{
it
}
.
filter
{
it
.
item
.
name
.
contains
(
query
,
ignoreCase
=
true
)
||
it
.
item
.
processes
.
any
{
it
.
contains
(
query
,
ignoreCase
=
true
)
}
}
.
filter
{
if
(
showSystem
)
true
else
it
.
item
.
info
.
flags
and
ApplicationInfo
.
FLAG_SYSTEM
==
0
}
.
toList
()
.
map
{
it
to
items
.
calculateDiff
(
it
)
}
private
fun
toggleItem
(
item
:
HideProcessRvItem
)
{
val
state
=
if
(
item
.
isHidden
.
value
)
"add"
else
"rm"
...
...
app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt
View file @
a181fa06
...
...
@@ -20,6 +20,7 @@ import com.topjohnwu.magisk.ui.base.MagiskViewModel
import
com.topjohnwu.magisk.utils.Event
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.toSingle
import
com.topjohnwu.magisk.utils.update
import
io.reactivex.Single
import
me.tatarka.bindingcollectionadapter2.OnItemBind
...
...
@@ -29,7 +30,7 @@ class ModuleViewModel(
val
query
=
KObservableField
(
""
)
private
val
allItems
=
DiffObservableList
(
ComparableRvItem
.
callback
)
private
val
allItems
=
mutableListOf
<
ComparableRvItem
<*>>(
)
val
itemsInstalled
=
DiffObservableList
(
ComparableRvItem
.
callback
)
val
itemsRemote
=
DiffObservableList
(
ComparableRvItem
.
callback
)
...
...
@@ -73,27 +74,27 @@ class ModuleViewModel(
.
flattenAsFlowable
{
it
}
.
map
{
RepoRvItem
(
it
)
}
.
toList
()
.
doOnSuccess
{
allItems
.
update
(
it
)
}
.
flatMap
{
queryRaw
()
}
.
applyViewModel
(
this
)
.
subscribeK
{
allItems
.
update
(
it
)
query
()
}
.
subscribeK
{
itemsRemote
.
update
(
it
.
first
,
it
.
second
)
}
.
add
()
}
private
fun
query
(
query
:
String
=
this
.
query
.
value
)
{
allItems
.
toSingle
()
.
map
{
it
.
filterIsInstance
<
RepoRvItem
>()
}
.
flattenAsFlowable
{
it
}
.
filter
{
it
.
item
.
name
.
contains
(
query
,
ignoreCase
=
true
)
||
it
.
item
.
author
.
contains
(
query
,
ignoreCase
=
true
)
||
it
.
item
.
description
.
contains
(
query
,
ignoreCase
=
true
)
}
.
toList
()
.
subscribeK
{
itemsRemote
.
update
(
it
)
}
.
add
()
}
private
fun
query
()
=
queryRaw
()
.
subscribeK
{
itemsRemote
.
update
(
it
.
first
,
it
.
second
)
}
.
add
()
private
fun
queryRaw
(
query
:
String
=
this
.
query
.
value
)
=
allItems
.
toSingle
()
.
map
{
it
.
filterIsInstance
<
RepoRvItem
>()
}
.
flattenAsFlowable
{
it
}
.
filter
{
it
.
item
.
name
.
contains
(
query
,
ignoreCase
=
true
)
||
it
.
item
.
author
.
contains
(
query
,
ignoreCase
=
true
)
||
it
.
item
.
description
.
contains
(
query
,
ignoreCase
=
true
)
}
.
toList
()
.
map
{
it
to
itemsRemote
.
calculateDiff
(
it
)
}
private
fun
<
Result
>
Cursor
.
toList
(
transformer
:
(
Cursor
)
->
Result
):
List
<
Result
>
{
val
out
=
mutableListOf
<
Result
>()
...
...
app/src/main/java/com/topjohnwu/magisk/utils/XList.kt
0 → 100644
View file @
a181fa06
package
com.topjohnwu.magisk.utils
fun
<
T
>
MutableList
<
T
>.
update
(
newList
:
List
<
T
>)
{
clear
()
addAll
(
newList
)
}
\ 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