Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
7895e1e5
Commit
7895e1e5
authored
Jul 20, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify RemoteConfig
parent
8b29b1bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
14 deletions
+11
-14
core/build.gradle
core/build.gradle
+4
-2
core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt
core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt
+7
-12
No files found.
core/build.gradle
View file @
7895e1e5
...
@@ -49,9 +49,10 @@ androidExtensions {
...
@@ -49,9 +49,10 @@ androidExtensions {
experimental
=
true
experimental
=
true
}
}
def
coroutinesVersion
=
'1.3.0-RC'
def
lifecycleVersion
=
'2.1.0-rc01'
def
lifecycleVersion
=
'2.1.0-rc01'
def
roomVersion
=
'2.1.0'
def
roomVersion
=
'2.1.0'
def
workVersion
=
'2.2.0-beta0
1
'
def
workVersion
=
'2.2.0-beta0
2
'
dependencies
{
dependencies
{
api
project
(
':plugin'
)
api
project
(
':plugin'
)
api
"androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
api
"androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
...
@@ -66,7 +67,8 @@ dependencies {
...
@@ -66,7 +67,8 @@ dependencies {
api
'com.google.firebase:firebase-config:18.0.0'
api
'com.google.firebase:firebase-config:18.0.0'
api
'com.google.firebase:firebase-core:17.0.1'
api
'com.google.firebase:firebase-core:17.0.1'
api
'dnsjava:dnsjava:2.1.9'
api
'dnsjava:dnsjava:2.1.9'
api
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0-M2'
api
"org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
api
"org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion"
api
'org.connectbot.jsocks:jsocks:1.0.0'
api
'org.connectbot.jsocks:jsocks:1.0.0'
kapt
"androidx.room:room-compiler:$roomVersion"
kapt
"androidx.room:room-compiler:$roomVersion"
testImplementation
"junit:junit:$junitVersion"
testImplementation
"junit:junit:$junitVersion"
...
...
core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt
View file @
7895e1e5
...
@@ -25,8 +25,7 @@ import androidx.core.os.bundleOf
...
@@ -25,8 +25,7 @@ import androidx.core.os.bundleOf
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.core.R
import
com.github.shadowsocks.core.R
import
com.google.firebase.remoteconfig.FirebaseRemoteConfig
import
com.google.firebase.remoteconfig.FirebaseRemoteConfig
import
kotlinx.coroutines.suspendCancellableCoroutine
import
kotlinx.coroutines.tasks.await
import
kotlin.coroutines.resume
object
RemoteConfig
{
object
RemoteConfig
{
private
val
config
by
lazy
{
FirebaseRemoteConfig
.
getInstance
().
apply
{
setDefaults
(
R
.
xml
.
default_configs
)
}
}
private
val
config
by
lazy
{
FirebaseRemoteConfig
.
getInstance
().
apply
{
setDefaults
(
R
.
xml
.
default_configs
)
}
}
...
@@ -40,15 +39,11 @@ object RemoteConfig {
...
@@ -40,15 +39,11 @@ object RemoteConfig {
if
(
it
.
isSuccessful
)
config
.
activate
()
else
it
.
exception
?.
log
()
if
(
it
.
isSuccessful
)
config
.
activate
()
else
it
.
exception
?.
log
()
}
}
suspend
fun
fetch
()
=
suspendCancellableCoroutine
<
Pair
<
FirebaseRemoteConfig
,
Boolean
>>
{
cont
->
suspend
fun
fetch
()
=
try
{
config
.
fetch
().
addOnCompleteListener
{
config
.
fetch
().
await
()
if
(
it
.
isSuccessful
)
{
config
to
true
config
.
activate
()
}
catch
(
e
:
Exception
)
{
cont
.
resume
(
config
to
true
)
e
.
log
()
}
else
{
config
to
false
it
.
exception
?.
log
()
cont
.
resume
(
config
to
false
)
}
}
}
}
}
}
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