Commit 4f43dcb 1 parent 8a019c7 commit 4f43dcb Copy full SHA for 4f43dcb
File tree 3 files changed +22
-6
lines changed
library/src/main/java/org/xmtp/android/library
3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ data class GRPCApiClient(
90
90
91
91
private val channel: ManagedChannel =
92
92
Grpc .newChannelBuilderForAddress(
93
- environment.rawValue ,
93
+ environment.getValue() ,
94
94
5556 ,
95
95
if (secure) {
96
96
TlsChannelCredentials .create()
Original file line number Diff line number Diff line change @@ -324,7 +324,7 @@ class Client() {
324
324
325
325
createClient(
326
326
logger = logger,
327
- host = " http://10.0.2.2 :5556" ,
327
+ host = " http://${options.api.env.getValue()} :5556" ,
328
328
isSecure = false ,
329
329
db = dbPath,
330
330
encryptionKey = retrievedKey.encoded,
Original file line number Diff line number Diff line change @@ -3,11 +3,27 @@ package org.xmtp.android.library
3
3
enum class XMTPEnvironment (val rawValue : String ) {
4
4
DEV (" dev.xmtp.network" ),
5
5
PRODUCTION (" production.xmtp.network" ),
6
- LOCAL (" 10.0.2.2" ),
7
- ;
6
+ LOCAL (" 10.0.2.2" ) {
7
+ override fun withValue (value : String ): XMTPEnvironment {
8
+ return LOCAL .apply { customValue = value }
9
+ }
10
+ };
11
+
12
+ private var customValue: String = " "
13
+
14
+ open fun withValue (value : String ): XMTPEnvironment {
15
+ return this
16
+ }
8
17
9
18
companion object {
10
- operator fun invoke (rawValue : String ) =
11
- XMTPEnvironment .values().firstOrNull { it.rawValue == rawValue }
19
+ operator fun invoke (rawValue : String ): XMTPEnvironment {
20
+ return XMTPEnvironment .values().firstOrNull { it.rawValue == rawValue }
21
+ ? : LOCAL .withValue(rawValue)
22
+ }
23
+ }
24
+
25
+ // This function returns the actual raw value for the enum, handling the CUSTOM case.
26
+ fun getValue (): String {
27
+ return if (this == LOCAL && customValue.isNotEmpty()) customValue else rawValue
12
28
}
13
29
}
You can’t perform that action at this time.
0 commit comments