-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
Change-Id: Ieb43b88302a449778828da81e8bee64d4652d480
Change-Id: I01a68c0c100138b91f4a7cafa9c84b9e1978c8ec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
SplashScreen/app/build.gradle
Outdated
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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need constraintlayout?
There was a problem hiding this comment.
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 - |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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?
Yes, it was 172330 internally. |
Change-Id: Ieb43b88302a449778828da81e8bee64d4652d480