Skip to content

Conversation

@jkmassel
Copy link
Contributor

What?

Why?

How?

Testing Instructions

Accessibility Testing Instructions

Screenshots or screencast

@jkmassel jkmassel changed the base branch from trunk to add/preload-list-tests December 16, 2025 16:14
Comment on lines +128 to +131
val viewModel = ViewModelProvider(
this,
SitePreparationViewModelFactory(application, configurationItem)
)[SitePreparationViewModel::class.java]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️Aren't we using injection in the example project? ViewModels can be simply injected.

* @param filePath The absolute path to the serialized dependencies file.
* @return The deserialized dependencies, or `null` if the file doesn't exist or is invalid.
*/
fun readFromDisk(filePath: String?): EditorDependencies? {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ kotlin nitpick: Do we need to accept null for filePath? I would avoid nullability when possible.

null
}

val stringValue = jsonValue?.toString() ?: ""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val stringValue = jsonValue?.toString() ?: ""
val stringValue = jsonValue?.toString().orEmpty()

/**
* Shuts down background operations.
*/
fun shutdown() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this function being called. So, creating a CoroutineScope as a variable could cause leaks because of no lifecycle awareness..
❓ What about using the ´ApplicationScope´, ´ViewModelScope´, or similar?

responseHeaders = EditorHTTPHeaders(entry.headers)
)
} catch (e: Exception) {
null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to track the exception here?


override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
coroutineScope.cancel()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Good approach since we are cancelling the scope when detached from Windows. But if the view is reattached again because of other scenarios (I'm not aware about all the scenarios), the coroutineScope is dead forever.
There are a few lifecycle aware CoroutineScopes we can use on Android. This class is a tricky one, but maybe you could try using:

findViewTreeLifecycleOwner()?.lifecycleScope.run {
    ...
}

@dcalhoun dcalhoun force-pushed the add/preload-list-tests branch from 209696f to f59acb1 Compare December 17, 2025 19:26
@jkmassel jkmassel force-pushed the add/preload-list-tests branch from f59acb1 to c82027d Compare December 17, 2025 20:17
Base automatically changed from add/preload-list-tests to trunk December 17, 2025 20:50
@jkmassel jkmassel force-pushed the add/android-preload-list branch 2 times, most recently from a8fb889 to d33bb53 Compare December 17, 2025 20:57
@jkmassel jkmassel force-pushed the add/android-preload-list branch from d33bb53 to 0e760f1 Compare December 18, 2025 17:31
@jkmassel jkmassel force-pushed the add/android-preload-list branch from 0e760f1 to 8060669 Compare December 18, 2025 21:11
Full warning:

> Redundant creation of Json format. Creating instances for each usage can be slow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants