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

[#20] [Android] [Integrate] As a user, I can see the app cache and load survey list in Home screen #89

Merged

Conversation

luongvo
Copy link
Owner

@luongvo luongvo commented Mar 5, 2023

What happened 👀

  • Implement the local storage to cache the survey data.
  • Save & load the cache survey on the Home screen. The shimmer loading will display one time from both continuous steps: survey loading from the cache & survey loading from the remote API.
  • Clear cache when refreshing the Home screen.

Insight 📝

  • At first, I intended to use sqldelight but it seems to be too complicated & unfriendly. In the end, realm-kotlin is a better choice.
  • I created a new use case GetCachedSurveysUseCase to ease the shimmer loading logic control.

Proof Of Work 📹

  • First-time app open > no cache > the shimmer loading shows on the survey API call.
screen-20230306-022328.mp4
  • Next-times app open > pre-load survey list with cached survey > the shimmer loading does not show on the survey API call.
screen-20230306-022510.mp4

@luongvo luongvo added this to the 0.6.0 milestone Mar 5, 2023
@luongvo luongvo self-assigned this Mar 5, 2023
@luongvo luongvo force-pushed the feature/20-integrate-data-caching-on-the-home-screen branch 2 times, most recently from 808ef96 to 73fbaee Compare March 5, 2023 18:39
@luongvo luongvo force-pushed the feature/20-integrate-data-caching-on-the-home-screen branch from 73fbaee to 30ede0d Compare March 5, 2023 19:13
@luongvo luongvo force-pushed the feature/20-integrate-data-caching-on-the-home-screen branch from 30ede0d to b3ee93f Compare March 5, 2023 20:11
@github-actions
Copy link

github-actions bot commented Mar 5, 2023

23 Warnings
⚠️ Uh oh! AuthRemoteDataSource.kt is under 95% coverage!
⚠️ Uh oh! DateFormatter.kt is under 95% coverage!
⚠️ Uh oh! Realm.kt is under 95% coverage!
⚠️ Uh oh! SurveyLocalDataSource.kt is under 95% coverage!
⚠️ Uh oh! SurveyRealmObject.kt is under 95% coverage!
⚠️ Uh oh! SurveyRemoteDataSource.kt is under 95% coverage!
⚠️ Uh oh! UserRemoteDataSource.kt is under 95% coverage!
⚠️ Uh oh! Your project is under 80% coverage!
⚠️ android/src/main/java/vn/luongvo/kmm/survey/android/ui/screens/home/HomeScreen.kt#L78 - The function HomeScreenWithDrawer(appVersion: String, initialDrawerState: DrawerValue, scaffoldState: ScaffoldState, isLoading: Boolean, isRefreshing: Boolean, currentDate: String, user: UserUiModel?, surveys: List, onSurveyClick: (SurveyUiModel?) -> Unit, onRefresh: () -> Unit, onMenuLogoutClick: () -> Unit) has too many parameters. The current threshold is set to 8.
⚠️ android/src/main/java/vn/luongvo/kmm/survey/android/ui/screens/home/HomeScreen.kt#L126 - The function HomeScreenContent(scaffoldState: ScaffoldState, isLoading: Boolean, isRefreshing: Boolean, currentDate: String, user: UserUiModel?, surveys: List, onSurveyClick: (SurveyUiModel?) -> Unit, onUserAvatarClick: () -> Unit, onRefresh: () -> Unit) has too many parameters. The current threshold is set to 8.
⚠️ android/src/main/java/vn/luongvo/kmm/survey/android/ui/screens/home/HomeScreen.kt#L126 - The function HomeScreenContent is too long (63). The maximum length is 60.
⚠️ android/src/main/java/vn/luongvo/kmm/survey/android/ui/screens/login/LoginScreen.kt#L89 - The function LoginScreenContent is too long (77). The maximum length is 60.
⚠️ android/src/main/res/drawable/bg_login.jpg#L0 - Found bitmap drawable res/drawable/bg_login.jpg in densityless folder
⚠️ android/src/main/res/mipmap-hdpi/ic_launcher_round.png#L0 - Launcher icons should not fill every pixel of their square region; see the design guide for details
⚠️ android/src/main/res/mipmap-ldpi/ic_launcher.png#L0 - Launcher icons should not fill every pixel of their square region; see the design guide for details
⚠️ android/src/main/res/mipmap-mdpi/ic_launcher.png#L0 - Launcher icons should not fill every pixel of their square region; see the design guide for details
⚠️ android/src/main/res/mipmap-mdpi/ic_launcher_round.png#L0 - Launcher icons should not fill every pixel of their square region; see the design guide for details
⚠️ android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png#L0 - Launcher icon used as round icon did not have a circular shape
⚠️ android/src/staging/res/mipmap-hdpi/ic_launcher_round.png#L0 - Launcher icons should not fill every pixel of their square region; see the design guide for details
⚠️ android/src/staging/res/mipmap-ldpi/ic_launcher.png#L0 - Launcher icons should not fill every pixel of their square region; see the design guide for details
⚠️ android/src/staging/res/mipmap-mdpi/ic_launcher.png#L0 - Launcher icons should not fill every pixel of their square region; see the design guide for details
⚠️ android/src/staging/res/mipmap-mdpi/ic_launcher_round.png#L0 - Launcher icons should not fill every pixel of their square region; see the design guide for details
⚠️ android/src/staging/res/mipmap-xxxhdpi/ic_launcher_round.png#L0 - Launcher icon used as round icon did not have a circular shape

🧛 build Code Coverage: 71.52%

Coverage of Modified Files:

File Coverage
AuthRemoteDataSource.kt 0.00%
DateFormatter.kt 0.00%
GetCachedSurveysUseCase.kt 100.00%
GetSurveyDetailUseCase.kt 100.00%
GetSurveysUseCase.kt 100.00%
GetUserProfileUseCase.kt 100.00%
HomeViewModel.kt 100.00%
IsLoggedInUseCase.kt 100.00%
LogInUseCase.kt 100.00%
LogOutUseCase.kt 100.00%
Realm.kt 0.00%
RefreshTokenUseCase.kt 100.00%
SubmitSurveyUseCase.kt 100.00%
Survey.kt 100.00%
SurveyLocalDataSource.kt 0.00%
SurveyRealmObject.kt 84.31%
SurveyRemoteDataSource.kt 0.00%
SurveyRepositoryImpl.kt 100.00%
TokenLocalDataSource.kt 100.00%
UserRemoteDataSource.kt 0.00%

Modified Files Not Found In Coverage Report:

AuthRepository.kt
Configurations.kt
Dependencies.kt
Fake.kt
Fake.kt
GetCachedSurveysUseCaseTest.kt
HomeScreenTest.kt
HomeViewModelTest.kt
LocalModule.kt
SurveyRepository.kt
SurveyRepositoryTest.kt
UseCaseModule.kt
UserRepository.kt
build.gradle.kts
build.gradle.kts

Codebase cunningly covered by count Shroud 🧛

Generated by 🚫 Danger

@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2023

Codecov Report

Merging #89 (c9705db) into develop (f07cef6) will increase coverage by 0.18%.
The diff coverage is 72.58%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff             @@
##           develop      #89      +/-   ##
===========================================
+ Coverage    66.74%   66.92%   +0.18%     
===========================================
  Files           79       83       +4     
  Lines         1768     1826      +58     
  Branches       331      337       +6     
===========================================
+ Hits          1180     1222      +42     
- Misses         434      447      +13     
- Partials       154      157       +3     
Flag Coverage Δ
unittests 66.92% <72.58%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...vey/data/local/datasource/SurveyLocalDataSource.kt 0.00% <0.00%> (ø)
...in/vn/luongvo/kmm/survey/data/local/realm/Realm.kt 0.00% <0.00%> (ø)
...o/kmm/survey/data/local/model/SurveyRealmObject.kt 72.22% <72.22%> (ø)
...mm/survey/android/ui/screens/home/HomeViewModel.kt 100.00% <100.00%> (ø)
...kmm/survey/data/repository/SurveyRepositoryImpl.kt 100.00% <100.00%> (ø)
...otlin/vn/luongvo/kmm/survey/domain/model/Survey.kt 100.00% <100.00%> (ø)
...m/survey/domain/usecase/GetCachedSurveysUseCase.kt 100.00% <100.00%> (ø)
...uongvo/kmm/survey/android/ui/base/BaseViewModel.kt 94.11% <0.00%> (+5.88%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@luongvo luongvo marked this pull request as ready for review March 6, 2023 02:00
Base automatically changed from feature/37-home-pull-to-refresh to develop March 6, 2023 08:04
Copy link

@doannimble doannimble left a comment

Choose a reason for hiding this comment

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

rest lgtm

@luongvo luongvo requested a review from doannimble March 7, 2023 04:29
Copy link

@doannimble doannimble left a comment

Choose a reason for hiding this comment

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

LGTM now 🚀

@luongvo
Copy link
Owner Author

luongvo commented Mar 7, 2023

@blyscuit @suho 1 more review/approval please 👋

@luongvo luongvo requested a review from suho March 8, 2023 03:16
@luongvo luongvo merged commit d895ae0 into develop Mar 8, 2023
@luongvo luongvo deleted the feature/20-integrate-data-caching-on-the-home-screen branch March 8, 2023 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] [Integrate] As a user, I can see the app cache and load survey list in Home screen
4 participants