Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #425: using setDefaultNightMode #428

Merged
merged 2 commits into from
May 3, 2021

Conversation

anandwana001
Copy link
Contributor

@anandwana001 anandwana001 commented May 1, 2021

Issue

Overview (Required)

  • Using of setDefaultNightMode

Links

Screenshot

Before After

This also solving #344

@anandwana001
Copy link
Contributor Author

@takahirom Please let me know, if this is a correct approach to fix this issue.

@takahirom
Copy link
Member

I think there are good and bad things, but since the ViewModel will be in the form of directly operating the View, how about doing the following?

class MainActivity : AppCompatActivity() {
    private val appViewModel by viewModels<RealAppViewModel>()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        WindowCompat.setDecorFitsSystemWindows(window, false)
        setup()
        appViewModel.state
            .onEach {
// ...
            }
            .launchIn(lifecycleScope)
    }

@github-actions github-actions bot temporarily deployed to deploygate-distribution May 1, 2021 10:29 Inactive
@anandwana001
Copy link
Contributor Author

anandwana001 commented May 1, 2021

Using setDefaultNightMode will lead into activity recreation - https://medium.com/androiddevelopers/appcompat-v23-2-daynight-d10f90c83e94

Twitter - https://twitter.com/Guardiola31337/status/1098938208954519554

@takahirom
Copy link
Member

I'll take a look tomorrow 👀

@github-actions github-actions bot temporarily deployed to deploygate-distribution May 1, 2021 10:56 Inactive
@takahirom
Copy link
Member

Now Activity is receated by config changes such as screen rotation. So that's fine.
Thank you for teaching me. 👍

Copy link
Member

@takahirom takahirom left a comment

Choose a reason for hiding this comment

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

Thank you for raising the issue and solving it! 👍

@takahirom takahirom merged commit b7a0a14 into DroidKaigi:main May 3, 2021
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.

Drawable-night is not accessible
2 participants