Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Projects
Groups
Snippets
Sign up now
Login
Sign in / Register
Toggle navigation
Menu
Open sidebar
PublicAndroidApps
Nebulo
Commits
92e1a3f9
Commit
92e1a3f9
authored
Sep 05, 2020
by
Daniel Wolf
Browse files
Refactor logic
parent
e646f26c
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/com/frostnerd/smokescreen/database/repository/DnsQueryRepository.kt
View file @
92e1a3f9
...
...
@@ -50,29 +50,19 @@ class DnsQueryRepository(private val dnsQueryDao: DnsQueryDao) {
}
private
fun
filterDnsQuery
(
filterConfig
:
QueryLogFilterDialog
.
FilterConfig
,
liveData
:
LiveData
<
List
<
DnsQuery
>>):
LiveData
<
List
<
DnsQuery
>>
{
if
(
filterConfig
.
showForwarded
&&
filterConfig
.
showBlockedByDns
)
{
return
liveData
}
else
{
val
holdsAllData
=
liveData
.
value
?.
let
{
dnsQueryDao
.
getCount
()
==
it
.
size
}
?:
false
return
when
{
holdsAllData
->
{
liveData
}
filterConfig
.
showForwarded
->
{
Transformations
.
map
(
liveData
)
{
it
.
filter
{
!
it
.
isHostBlockedByDnsServer
}
return
if
(
filterConfig
.
showForwarded
==
filterConfig
.
showBlockedByDns
)
{
liveData
}
else
{
if
(
filterConfig
.
showForwarded
&&
!
filterConfig
.
showBlockedByDns
)
{
Transformations
.
map
(
liveData
)
{
it
.
filterNot
{
query
->
query
.
isHostBlockedByDnsServer
}
}
else
->
{
// showForwarded = false, showBlockedByDns = true
Transformations
.
map
(
liveData
)
{
it
.
filter
{
it
.
isHostBlockedByDnsServer
}
}
else
{
Transformations
.
map
(
liveData
)
{
it
.
filter
{
query
->
query
.
isHostBlockedByDnsServer
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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