-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: address pre-existing StrictMode violations
- Loading branch information
1 parent
b460150
commit 4791839
Showing
28 changed files
with
476 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,7 @@ class ClientUserTest { | |
client.setUser(USER_ID, USER_EMAIL, USER_NAME) | ||
|
||
// Check that the user was persisted | ||
val file = File(config.persistenceDirectory, "user-info") | ||
val file = File(client.config.persistenceDirectory.value, "user-info") | ||
val expected = "{\"id\":\"123456\",\"email\":\"[email protected]\",\"name\":\"Mr Test\"}" | ||
assertEquals(expected, file.readText()) | ||
} | ||
|
@@ -89,7 +89,7 @@ class ClientUserTest { | |
client = Client(context, config) | ||
|
||
// Check that the user was not persisted | ||
val file = File(config.persistenceDirectory, "user-info") | ||
val file = File(client.config.persistenceDirectory.value, "user-info") | ||
assertEquals("", file.readText()) | ||
client.setUser(USER_ID, USER_EMAIL, USER_NAME) | ||
assertEquals("", file.readText()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
bugsnag-android-core/src/main/java/com/bugsnag/android/BugsnagStateModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.bugsnag.android | ||
|
||
import com.bugsnag.android.internal.dag.ConfigModule | ||
import com.bugsnag.android.internal.dag.DependencyModule | ||
|
||
/** | ||
* A dependency module which constructs the objects that track state in Bugsnag. For example, this | ||
* class is responsible for creating classes which track the current breadcrumb/metadata state. | ||
*/ | ||
internal class BugsnagStateModule( | ||
configModule: ConfigModule, | ||
configuration: Configuration | ||
) : DependencyModule { | ||
|
||
private val cfg = configModule.config | ||
|
||
val clientObservable = ClientObservable() | ||
|
||
val callbackState = configuration.impl.callbackState.copy() | ||
|
||
val contextState = ContextState().apply { | ||
if (configuration.context != null) { | ||
setManualContext(configuration.context) | ||
} | ||
} | ||
|
||
val breadcrumbState = BreadcrumbState(cfg.maxBreadcrumbs, callbackState, cfg.logger) | ||
|
||
val metadataState = copyMetadataState(configuration) | ||
|
||
private fun copyMetadataState(configuration: Configuration): MetadataState { | ||
// performs deep copy of metadata to preserve immutability of Configuration interface | ||
val orig = configuration.impl.metadataState.metadata | ||
val copy = orig.copy() | ||
return configuration.impl.metadataState.copy(metadata = copy) | ||
} | ||
} |
Oops, something went wrong.