Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
PublicAndroidApps
Nebulo
Commits
c79568a5
Commit
c79568a5
authored
Jun 25, 2019
by
Daniel Wolf
Browse files
Persist the edit of a dns rule to the database
parent
2ae8425d
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/com/frostnerd/smokescreen/activity/DnsRuleActivity.kt
View file @
c79568a5
...
...
@@ -173,6 +173,7 @@ class DnsRuleActivity : BaseActivity() {
sourceAdapter
.
notifyItemRemoved
(
sourceAdapterList
.
size
+
1
+
index
)
},
editRule
=
{
DnsRuleDialog
(
this
,
it
)
{
newRule
->
getDatabase
().
dnsRuleRepository
().
updateAsync
(
newRule
)
val
index
=
userDnsRules
.
indexOf
(
it
)
userDnsRules
[
index
]
=
newRule
sourceAdapter
.
notifyItemChanged
(
sourceAdapterList
.
size
+
1
+
index
)
...
...
app/src/main/java/com/frostnerd/smokescreen/database/dao/DnsRuleDao.kt
View file @
c79568a5
...
...
@@ -27,6 +27,9 @@ import org.minidns.record.Record
@TypeConverters
(
DnsTypeConverter
::
class
)
interface
DnsRuleDao
{
@Update
fun
update
(
dnsRule
:
DnsRule
)
@Insert
fun
insert
(
dnsRule
:
DnsRule
)
...
...
app/src/main/java/com/frostnerd/smokescreen/database/repository/DnsRuleRepository.kt
View file @
c79568a5
...
...
@@ -28,6 +28,12 @@ import kotlinx.coroutines.launch
*/
class
DnsRuleRepository
(
val
dnsRuleDao
:
DnsRuleDao
)
{
fun
updateAsync
(
dnsRule
:
DnsRule
,
coroutineScope
:
CoroutineScope
=
GlobalScope
)
{
coroutineScope
.
launch
{
dnsRuleDao
.
update
(
dnsRule
)
}
}
fun
insertAsync
(
dnsRule
:
DnsRule
,
coroutineScope
:
CoroutineScope
=
GlobalScope
)
{
coroutineScope
.
launch
{
dnsRuleDao
.
insert
(
dnsRule
)
...
...
Write
Preview
Supports
Markdown
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