Skip to content

Commit 4fbb7b1

Browse files
committed
hide some classes
1 parent e3e1731 commit 4fbb7b1

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

example/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ android {
3232
}
3333

3434
dependencies {
35-
// implementation project(path: ':fcl-android')
35+
implementation project(path: ':fcl-android')
3636

3737
implementation 'androidx.core:core-ktx:1.7.0'
3838
implementation 'androidx.appcompat:appcompat:1.4.1'
@@ -42,7 +42,7 @@ dependencies {
4242

4343
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
4444

45-
implementation 'com.github.Outblock:fcl-android:0.03'
45+
// implementation 'com.github.Outblock:fcl-android:0.03'
4646

4747
testImplementation 'junit:junit:4.13.2'
4848
androidTestImplementation 'androidx.test.ext:junit:1.1.3'

example/src/main/java/io/outblock/fcl/example/MainActivity.kt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ import androidx.core.content.ContextCompat
1515
import com.google.android.material.tabs.TabLayout
1616
import io.outblock.fcl.Fcl
1717
import io.outblock.fcl.provider.WalletProvider
18-
import io.outblock.fcl.utils.ioScope
19-
import io.outblock.fcl.utils.uiScope
18+
import kotlinx.coroutines.CoroutineScope
19+
import kotlinx.coroutines.Dispatchers
20+
import kotlinx.coroutines.launch
2021

2122
class MainActivity : AppCompatActivity() {
2223
override fun onCreate(savedInstanceState: Bundle?) {
@@ -46,25 +47,25 @@ class MainActivity : AppCompatActivity() {
4647
""".trimIndent()
4748
)
4849
findViewById<View>(R.id.button_query).setOnClickListener {
49-
ioScope {
50+
CoroutineScope(Dispatchers.IO).launch {
5051
val cadence = edittext.text.toString()
5152
val result = Fcl.query {
5253
cadence(cadence)
5354
arg { int(7) }
5455
arg { int(3) }
5556
arg { address("0xba1132bc08f82fe2") }
5657
}
57-
uiScope { findViewById<TextView>(R.id.query_result_view).text = result }
58+
CoroutineScope(Dispatchers.Main).launch { findViewById<TextView>(R.id.query_result_view).text = result }
5859
}
5960
}
6061
}
6162

6263
private fun setupSignMessage() {
6364
findViewById<View>(R.id.button_sign_message).setOnClickListener {
64-
ioScope {
65+
CoroutineScope(Dispatchers.IO).launch {
6566
val message = findViewById<EditText>(R.id.sign_message_edittext).text.toString()
6667
val signature = Fcl.signMessage(message)
67-
uiScope { findViewById<TextView>(R.id.signed_message_view).text = signature }
68+
CoroutineScope(Dispatchers.Main).launch { findViewById<TextView>(R.id.signed_message_view).text = signature }
6869
}
6970
}
7071
}
@@ -91,11 +92,11 @@ class MainActivity : AppCompatActivity() {
9192

9293
findViewById<View>(R.id.auth_button).setOnClickListener {
9394
val provider = if (tabLayout.selectedTabPosition == 0) WalletProvider.DAPPER else WalletProvider.BLOCTO
94-
ioScope {
95+
CoroutineScope(Dispatchers.IO).launch {
9596
val auth = Fcl.authenticate(provider)
9697
Log.d(TAG, "authenticate complete:$auth")
97-
uiScope {
98-
Toast.makeText(this, "authenticate complete", Toast.LENGTH_SHORT).show()
98+
CoroutineScope(Dispatchers.Main).launch {
99+
Toast.makeText(this@MainActivity, "authenticate complete", Toast.LENGTH_SHORT).show()
99100
findViewById<TextView>(R.id.address).text = auth.address
100101
}
101102
}
@@ -123,15 +124,15 @@ class MainActivity : AppCompatActivity() {
123124
)
124125

125126
button.setOnClickListener {
126-
ioScope {
127+
CoroutineScope(Dispatchers.IO).launch {
127128
val tid = Fcl.mutate {
128129
cadence(editText.text.toString())
129130
arg { string("Test2") }
130131
arg { int(1) }
131132
gaslimit(1000)
132133
}
133134
Log.d(TAG, "tid:$tid")
134-
uiScope {
135+
CoroutineScope(Dispatchers.Main).launch {
135136
txidView.text = tid
136137
txidLayout.visibility = View.VISIBLE
137138
viewOnFlowScanView.setOnClickListener {
@@ -144,7 +145,7 @@ class MainActivity : AppCompatActivity() {
144145
}
145146
}
146147

147-
fun String.openInSystemBrowser(context: Context) {
148+
private fun String.openInSystemBrowser(context: Context) {
148149
ContextCompat.startActivity(context, Intent(Intent.ACTION_VIEW, Uri.parse(this)), null)
149150
}
150151

fcl-android/src/main/java/io/outblock/fcl/utils/CoroutineUtils.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ package io.outblock.fcl.utils
33
import io.outblock.fcl.BuildConfig
44
import kotlinx.coroutines.*
55

6-
fun ioScope(unit: suspend () -> Unit) = CoroutineScope(Dispatchers.IO).launch { execute(unit) }
6+
internal fun ioScope(unit: suspend () -> Unit) = CoroutineScope(Dispatchers.IO).launch { execute(unit) }
77

8-
suspend fun contextScope(unit: suspend () -> Unit) = withContext(Dispatchers.Main) { execute(unit) }
8+
internal suspend fun contextScope(unit: suspend () -> Unit) = withContext(Dispatchers.Main) { execute(unit) }
99

10-
fun uiScope(unit: suspend () -> Unit) = CoroutineScope(Dispatchers.Main).launch { execute(unit) }
10+
internal fun uiScope(unit: suspend () -> Unit) = CoroutineScope(Dispatchers.Main).launch { execute(unit) }
1111

12-
fun uiDelay(delayMs: Long, unit: suspend () -> Unit) = CoroutineScope(Dispatchers.Main).launch {
12+
internal fun uiDelay(delayMs: Long, unit: suspend () -> Unit) = CoroutineScope(Dispatchers.Main).launch {
1313
delay(delayMs)
1414
execute(unit)
1515
}
1616

17-
fun cpuScope(unit: suspend () -> Unit) = CoroutineScope(Dispatchers.Default).launch { execute(unit) }
17+
internal fun cpuScope(unit: suspend () -> Unit) = CoroutineScope(Dispatchers.Default).launch { execute(unit) }
1818

19-
suspend fun repeatWhen(
19+
internal suspend fun repeatWhen(
2020
predicate: suspend () -> Boolean,
2121
block: suspend () -> Unit,
2222
) {
@@ -25,7 +25,7 @@ suspend fun repeatWhen(
2525
}
2626
}
2727

28-
suspend fun runBlockDelay(timeMillis: Long, block: suspend () -> Unit) {
28+
internal suspend fun runBlockDelay(timeMillis: Long, block: suspend () -> Unit) {
2929
val startTime = System.currentTimeMillis()
3030
block.invoke()
3131
val elapsedTime = System.currentTimeMillis() - startTime

fcl-android/src/main/java/io/outblock/fcl/utils/Log.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ import io.outblock.fcl.BuildConfig
55

66
private val PRINT_LOG = BuildConfig.DEBUG
77

8-
fun logv(tag: String?, msg: Any?) {
8+
internal fun logv(tag: String?, msg: Any?) {
99
log(tag, msg, Log.VERBOSE)
1010
}
1111

12-
fun logd(tag: String?, msg: Any?) {
12+
internal fun logd(tag: String?, msg: Any?) {
1313
log(tag, msg, Log.DEBUG)
1414
}
1515

16-
fun logi(tag: String?, msg: Any?) {
16+
internal fun logi(tag: String?, msg: Any?) {
1717
log(tag, msg, Log.INFO)
1818
}
1919

20-
fun logw(tag: String?, msg: Any?) {
20+
internal fun logw(tag: String?, msg: Any?) {
2121
log(tag, msg, Log.WARN)
2222
}
2323

24-
fun loge(tag: String?, msg: Any?) {
24+
internal fun loge(tag: String?, msg: Any?) {
2525
log(tag, msg, Log.ERROR)
2626
}
2727

28-
fun loge(msg: Throwable?, printStackTrace: Boolean = true) {
28+
internal fun loge(msg: Throwable?, printStackTrace: Boolean = true) {
2929
log("Exception", msg?.message ?: "", Log.ERROR)
3030
if (PRINT_LOG && printStackTrace) {
3131
msg?.printStackTrace()

0 commit comments

Comments
 (0)