8000 [MBL-789] ProjectPageViewModel.kt to Jetpack ViewModel and RxJava2.2 by leighdouglas · Pull Request #1890 · kickstarter/android-oss · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[MBL-789] ProjectPageViewModel.kt to Jetpack ViewModel and RxJava2.2 #1890

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

Merged
merged 21 commits into from
Nov 6, 2023

Conversation

leighdouglas
Copy link
Contributor
@leighdouglas leighdouglas commented Oct 30, 2023

📲 What

Migrate project page viewmodel to rxjava 2.2 and jetpacks viewmodel

🤔 Why

Technical Details

👀 See

No user facing changes

📋 QA

Test project page loading correctly from all access points (discovery, search, profile, etc), all tabs, watching/unwatching project while logged in and out, and back a project. This will require additional QA time.

Story 📖

MBL-789: ProjectPageViewModel.kt to Jetpack ViewModel and RxJava2.2

@leighdouglas leighdouglas changed the title Leigh/mbl 789 pp rx2 [MBL-789] Project Oct 30, 2023
@leighdouglas leighdouglas changed the title [MBL-789] Project [MBL-789] ProjectPageViewModel migration to rxjava2 Oct 30, 2023
@codecov
Copy link
codecov bot commented Oct 31, 2023

Codecov Report

Merging #1890 (b9b465e) into master (27b590b) will decrease coverage by 0.04%.
The diff coverage is 91.16%.

@@             Coverage Diff              @@
##             master    #1890      +/-   ##
============================================
- Coverage     73.93%   73.89%   -0.04%     
- Complexity     1945     1950       +5     
============================================
  Files           339      339              
  Lines         19486    19501      +15     
  Branches       2698     2707       +9     
============================================
+ Hits          14407    14411       +4     
- Misses         3526     3528       +2     
- Partials       1553     1562       +9     
Files Coverage Δ
...rc/main/java/com/kickstarter/libs/CurrentUserV2.kt 70.45% <100.00%> (+0.68%) ⬆️
...main/java/com/kickstarter/libs/utils/KsOptional.kt 78.57% <100.00%> (+1.64%) ⬆️
...om/kickstarter/libs/utils/extensions/ProjectExt.kt 82.53% <100.00%> (ø)
...ickstarter/ui/intentmappers/ProjectIntentMapper.kt 79.31% <100.00%> (+4.59%) ⬆️
...a/com/kickstarter/viewmodels/DiscoveryViewModel.kt 92.93% <ø> (ø)
...ckstarter/viewmodels/ProjectCardHolderViewModel.kt 83.79% <100.00%> (+0.23%) ⬆️
...ls/projectpage/FrequentlyAskedQuestionViewModel.kt 85.00% <60.00%> (-1.67%) ⬇️
...ter/viewmodels/projectpage/ProjectRiskViewModel.kt 81.57% <60.00%> (-6.23%) ⬇️
...viewmodels/projectpage/ProjectOverviewViewModel.kt 89.25% <58.33%> (-2.02%) ⬇️
...ter/viewmodels/projectpage/ProjectPageViewModel.kt 91.68% <93.23%> (-0.72%) ⬇️

... and 1 file with indirect coverage changes

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

@leighdouglas leighdouglas changed the title [MBL-789] ProjectPageViewModel migration to rxjava2 [MBL-789] ProjectPageViewModel.kt to Jetpack ViewModel and RxJava2.2 Nov 1, 2023
@leighdouglas leighdouglas self-assigned this Nov 1, 2023
@leighdouglas leighdouglas marked this pull request as ready for review November 1, 2023 12:24

binding.backIcon.setOnClickListener {
(this as BaseActivity<*>).back()
onBackPressedDispatcher.onBackPressed()
Copy link
Contributor

Choose a reason for hiding this comment

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

💖

}

public override fun onPause() {
super.onPause()
binding.mediaHeader.inputs.releasePlayer()
}

override fun back() {
override fun onBackPressed() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be removed, is deprecated and the back navigation can be handled by adding:

 this.onBackPressedDispatcher.addCallback {
            finishWithAnimation()
        }


binding.backIcon.setOnClickListener {
(this as BaseActivity<*>).back()
onBackPressedDispatcher.onBackPressed()
finishWithAnimation()
Copy link
Contributor
@Arkariang Arkariang Nov 1, 2023

Choose a reason for hiding this comment

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

This finishWithAnimation() can be removed, on the previous line you are calling any of the callbacks registered for the back navigation.
Asumming of course that the callback is defined like:

 this.onBackPressedDispatcher.addCallback {
            finishWithAnimation()
        }

*/
fun refTag(intent: Intent): Observable<RefTag?> {
return Observable.just(intent.getParcelableExtra(IntentKey.REF_TAG))
fun refTag(intent: Intent): io.reactivex.Observable<KsOptional<RefTag?>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

love it!


intent()
Copy link
Contributor

Choose a reason for hiding this comment

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

just an fyi, your approach works perfectly, but in order reduce amount of code changes, take a look for example at MessagesActivity

The intent can be passed to the viewmodelProvider factory, and then have a private method
private fun intent() = intent?.let { Observable.just(it) } ?: Observable.empty()

in that way you don't need to create the new input fun configureWith(intent: Intent)

Copy link
Contributor
@Arkariang Arkariang left a comment

Choose a reason for hiding this comment

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

Wonderful job 💖

@leighdouglas leighdouglas merged commit 518fbb9 into master Nov 6, 2023
@leighdouglas leighdouglas deleted the leigh/mbl-789-pp-rx2 branch November 6, 2023 14:56
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
0