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

[SplashScreen] Add a new sample #234

Merged
merged 3 commits into from
Apr 22, 2021
Merged

[SplashScreen] Add a new sample #234

merged 3 commits into from
Apr 22, 2021

Conversation

yaraki
Copy link
Contributor

@yaraki yaraki commented Apr 22, 2021

Change-Id: Ieb43b88302a449778828da81e8bee64d4652d480

Change-Id: Ieb43b88302a449778828da81e8bee64d4652d480
@yaraki yaraki requested a review from chrisbanes April 22, 2021 06:31
Change-Id: I01a68c0c100138b91f4a7cafa9c84b9e1978c8ec
Copy link
Contributor

@chrisbanes chrisbanes left a comment

Choose a reason for hiding this comment

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

LGTM

implementation 'androidx.activity:activity-ktx:1.3.0-alpha05'
implementation 'androidx.appcompat:appcompat:1.3.0-beta01'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
Copy link
Contributor

Choose a reason for hiding this comment

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

Need constraintlayout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. Removed.

// duration of the app launch, the animation might not have finished yet. We can
// calculate the remaining duration of the icon animation as follows.
val remainingDuration = (
splashScreenView.iconAnimationDurationMillis -
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks a bit weird to me. Can this be extracted to an ext-val?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted the calculation and added comments about each of the involved values.

setContentView(binding.root)
setSupportActionBar(binding.toolbar)
// Suspend drawing the app content until the initial data is ready.
suspendDraw()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd call this suppressDraw() instead. suspend makes me think of coroutines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed.

init {
viewModelScope.launch {
val nightMode = withContext(Dispatchers.IO) {
prefs.getInt(PREF_NIGHT_MODE, UiModeManager.MODE_NIGHT_AUTO)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think getSharedPreferences() should probably be done in the bg too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. It is now in a background thread.

- Remove an unnecessary dependency of ConstraintLayout.
- Improve handling of SharedPreferences.
- suspendDraw is now supressDraw
- Extract calculation of remaining duration of animation.

Change-Id: I006f9fc1f930f85fee46d4e3e3dbaf03cbe63d59
Copy link
Contributor

@chrisbanes chrisbanes left a comment

Choose a reason for hiding this comment

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

LGTM. I assume that Vadim has already taken a look?

@yaraki
Copy link
Contributor Author

yaraki commented Apr 22, 2021

Yes, it was 172330 internally.

@yaraki yaraki merged commit 27aadcc into dev-androidS Apr 22, 2021
@yaraki yaraki deleted the ya/dp3-SplashScreen branch April 22, 2021 08:51
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.

2 participants