forked from sheepdestroyer/materialisheep
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcycle3_feedback.txt
More file actions
2363 lines (1979 loc) · 142 KB
/
cycle3_feedback.txt
File metadata and controls
2363 lines (1979 loc) · 142 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
author: sourcery-ai
association: none
edited: true
status: none
--
<!-- Generated by sourcery-ai[bot]: start review_guide -->
## Reviewer's Guide
Migrates core item and list screens from a custom ViewPager/FragmentStatePagerAdapter stack to ViewPager2/FragmentStateAdapter, replaces deprecated fragment lifecycle and menu APIs with onViewCreated and MenuProvider, and introduces a ViewModel-backed lazy loading mechanism for fragment state retention.
#### Sequence diagram for ViewPager2 page selection and lazy loading
```mermaid
sequenceDiagram
actor User
participant ItemActivity
participant ViewPager2
participant TabLayout
participant TabLayoutMediator
participant ItemPagerAdapter
participant Fragment as LazyLoadFragment
participant VM as LazyLoadViewModel
User->>ItemActivity: open item screen
ItemActivity->>ItemPagerAdapter: new ItemPagerAdapter(fragmentActivity, builder)
ItemActivity->>ViewPager2: setAdapter(mAdapter)
ItemActivity->>TabLayoutMediator: new TabLayoutMediator(TabLayout, ViewPager2, configureTab)
TabLayoutMediator-->>TabLayout: attach()
rect rgb(230,230,255)
User->>ViewPager2: swipe to page N
ViewPager2-->>ItemPagerAdapter: request fragment for position N
ItemPagerAdapter-->>Fragment: createFragment(N)
Fragment->>Fragment: onCreate()
Fragment->>Fragment: onViewCreated()
Fragment->>VM: obtain LazyLoadViewModel via ViewModelProvider
Fragment->>Fragment: eagerLoad() if isNewInstance()
Fragment->>VM: setLoaded(true)
end
rect rgb(230,255,230)
User->>TabLayout: tap tab N
TabLayout->>TabLayoutMediator: tab selected
TabLayoutMediator->>ViewPager2: setCurrentItem(N)
ViewPager2-->>ItemActivity: OnPageChangeCallback.onPageSelected(N)
ItemActivity->>ItemActivity: toggleFabs(isComments)
ItemActivity->>ItemActivity: getFragment(N)
ItemActivity->>Fragment: loadNow()
Fragment->>VM: setEagerLoad(true)
Fragment->>Fragment: eagerLoad()
Fragment->>VM: setLoaded(true)
end
```
#### Sequence diagram for fragment menu handling with MenuProvider
```mermaid
sequenceDiagram
participant Activity
participant BaseFragment
participant ViewLifecycleOwner
participant MenuProvider
participant Menu
participant MenuTintDelegate
BaseFragment->>Activity: onAttach(context)
BaseFragment->>BaseFragment: onCreateView(...)
BaseFragment->>BaseFragment: onViewCreated(view, savedInstanceState)
BaseFragment->>Activity: addMenuProvider(MenuProvider, ViewLifecycleOwner, RESUMED)
Activity-->>MenuProvider: registered for menu events
loop when menu is first shown
Activity->>MenuProvider: onCreateMenu(Menu, MenuInflater)
MenuProvider->>BaseFragment: createOptionsMenu(Menu, MenuInflater)
BaseFragment->>MenuTintDelegate: onOptionsMenuCreated(Menu)
end
loop before menu is displayed
Activity->>MenuProvider: onPrepareMenu(Menu)
MenuProvider->>BaseFragment: prepareOptionsMenu(Menu)
end
User->>Activity: selects menu item
Activity->>MenuProvider: onMenuItemSelected(MenuItem)
MenuProvider->>BaseFragment: onOptionsItemSelected(MenuItem)
BaseFragment-->>Activity: return handled or not
```
#### Class diagram for ViewPager2 paging and lazy loading stack
```mermaid
classDiagram
direction LR
class ItemActivity {
- ViewPager2 mViewPager
- TabLayout mTabLayout
- FloatingActionButton mReplyButton
- NavFloatingActionButton mNavButton
- ItemPagerAdapter mAdapter
- boolean mFullscreen
+ void bindData(WebItem story)
+ void setFullscreen()
+ <T> T getCurrent(Class clazz)
+ Fragment getFragment(int position)
+ void toggleFabs(boolean isComments, FloatingActionButton navigationFab, FloatingActionButton genericFab)
}
class BaseListActivity {
- ViewPager2 mViewPager
- TabLayout mTabLayout
- ItemPagerAdapter mAdapter
- TabLayoutMediator mTabLayoutMediator
- ViewPager2.OnPageChangeCallback mPageChangeCallback
- TabLayout.OnTabSelectedListener mTabSelectedListener
+ void bindViewPager()
+ void unbindViewPager()
+ void setFullscreen()
+ KeyDelegate.BackInterceptor getBackInterceptor()
+ Fragment getFragment(int position)
}
class ItemPagerAdapter {
- Context mContext
- WebItem mItem
- boolean mShowArticle
- int mCacheMode
- int mDefaultItem
- boolean mRetainInstance
+ ItemPagerAdapter(FragmentActivity fragmentActivity, Builder builder)
+ long getItemId(int position)
+ Fragment createFragment(int position)
+ int getItemCount()
+ CharSequence getPageTitle(int position)
}
class ItemPagerAdapter.Builder {
WebItem item
boolean showArticle
int cacheMode
boolean retainInstance
Preferences.StoryViewMode defaultViewMode
+ Builder setItem(WebItem item)
+ Builder setShowArticle(boolean showArticle)
+ Builder setCacheMode(int cacheMode)
+ Builder setRetainInstance(boolean retainInstance)
+ Builder setDefaultViewMode(Preferences.StoryViewMode defaultViewMode)
}
class BaseFragment {
- MenuTintDelegate mMenuTintDelegate
+ void onAttach(Context context)
+ void onViewCreated(View view, Bundle savedInstanceState)
+ void createOptionsMenu(Menu menu, MenuInflater menuInflater)
+ void prepareOptionsMenu(Menu menu)
+ boolean onOptionsItemSelected(MenuItem menuItem)
}
class LazyLoadFragment {
<<abstract>>
+ static String EXTRA_EAGER_LOAD
+ static String EXTRA_RETAIN_INSTANCE
- boolean mActivityCreated
- LazyLoadViewModel mViewModel
+ void onCreate(Bundle savedInstanceState)
+ void onViewCreated(View view, Bundle savedInstanceState)
+ void onSaveInstanceState(Bundle outState)
+ void onDetach()
+ void setUserVisibleHint(boolean isVisibleToUser)
+ void loadNow()
+ boolean isNewInstance()
+ void eagerLoad()
+ void load()
}
class LazyLoadViewModel {
- boolean mEagerLoad
- boolean mLoaded
- boolean mInitialized
+ boolean isEagerLoad()
+ void setEagerLoad(boolean eagerLoad)
+ boolean isLoaded()
+ void setLoaded(boolean loaded)
+ boolean isInitialized()
+ void setInitialized(boolean initialized)
}
class ListFragment {
+ void onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ void onViewCreated(View view, Bundle savedInstanceState)
}
class WebFragment {
+ void onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ void onViewCreated(View view, Bundle savedInstanceState)
}
ItemPagerAdapter --|> androidx.viewpager2.adapter.FragmentStateAdapter
LazyLoadFragment --|> BaseFragment
WebFragment --|> LazyLoadFragment
ListFragment --|> BaseListFragment
LazyLoadFragment --> LazyLoadViewModel
ItemActivity --> ItemPagerAdapter
ItemActivity --> ViewPager2
ItemActivity --> TabLayoutMediator
BaseListActivity --> ItemPagerAdapter
BaseListActivity --> ViewPager2
BaseListActivity --> TabLayoutMediator
ItemPagerAdapter o-- ItemPagerAdapter.Builder
```
### File-Level Changes
| Change | Details | Files |
| ------ | ------- | ----- |
| Migrate activities and layouts from custom ViewPager + FragmentStatePagerAdapter to ViewPager2 + FragmentStateAdapter with TabLayoutMediator and explicit callbacks. | <ul><li>Change BaseListActivity and ItemActivity to use ViewPager2 fields, userInputEnabled, and ViewPager2.OnPageChangeCallback instead of the custom ViewPager and its swipeEnabled API.</li><li>Replace the custom ViewPager widget in activity_list.xml and activity_item.xml with androidx.viewpager2.widget.ViewPager2.</li><li>Refactor ItemPagerAdapter to extend FragmentStateAdapter, implement createFragment/getItemCount, and remove custom bind/unbind methods and fragment caching array.</li><li>Introduce TabLayoutMediator wiring and explicit TabLayout.OnTabSelectedListener implementations in activities to manage tab titles, reselection scroll-to-top, and initial/current page selection.</li><li>Adjust navigation, back handling, and FAB visibility logic to work via Fragment lookups by tag ("f" + position) instead of adapter.getItem().</li></ul> | `app/src/main/java/io/github/sheepdestroyer/materialisheep/BaseListActivity.java`<br/>`app/src/main/java/io/github/sheepdestroyer/materialisheep/ItemActivity.java`<br/>`app/src/main/java/io/github/sheepdestroyer/materialisheep/widget/ItemPagerAdapter.java`<br/>`app/src/main/res/layout-w820dp-land/activity_list.xml`<br/>`app/src/main/res/layout/activity_item.xml`<br/>`app/src/main/java/io/github/sheepdestroyer/materialisheep/widget/ViewPager.java` |
| Replace deprecated fragment lifecycle/menu APIs with onViewCreated and MenuProvider-based handling and clean up obsolete overrides. | <ul><li>Update BaseFragment to perform menu setup in onViewCreated and register a MenuProvider tied to the view lifecycle owner for menu creation, preparation, and item selection.</li><li>Remove onActivityCreated overrides where they were no-ops or only used for adapter state restoration, moving that work into onViewCreated where needed (e.g., ListFragment).</li><li>Drop setHasOptionsMenu usage in BaseListFragment and WebFragment now that menu handling is centralized via MenuProvider.</li><li>Remove the now redundant onActivityCreated override from FavoriteFragment.</li></ul> | `app/src/main/java/io/github/sheepdestroyer/materialisheep/BaseFragment.java`<br/>`app/src/main/java/io/github/sheepdestroyer/materialisheep/BaseListFragment.java`<br/>`app/src/main/java/io/github/sheepdestroyer/materialisheep/FavoriteFragment.java`<br/>`app/src/main/java/io/github/sheepdestroyer/materialisheep/ListFragment.java`<br/>`app/src/main/java/io/github/sheepdestroyer/materialisheep/WebFragment.java` |
| Introduce LazyLoadViewModel and rework LazyLoadFragment to use ViewModel-backed state instead of setRetainInstance and manual flags. | <ul><li>Create LazyLoadViewModel to hold eagerLoad/loaded/initialized flags across configuration changes.</li><li>Refactor LazyLoadFragment to obtain a LazyLoadViewModel in onCreate, initialize eager-load state from arguments or savedInstanceState, and store/retrieve state via the ViewModel instead of local booleans and setRetainInstance/getRetainInstance.</li><li>Move lazy-load triggering from onActivityCreated to onViewCreated and base isNewInstance on ViewModel semantics rather than retain instance flags.</li><li>Update eagerLoad/loadNow logic to use the ViewModel flags, and ensure state is saved in onSaveInstanceState while allowing re-loading after restoration.</li></ul> | `app/src/main/java/io/github/sheepdestroyer/materialisheep/LazyLoadFragment.java`<br/>`app/src/main/java/io/github/sheepdestroyer/materialisheep/LazyLoadViewModel.java` |
### Possibly linked issues
- **#**: PR replaces deprecated menus, lifecycle, retainInstance, and ViewPager APIs exactly as outlined in the modernization issue.
---
<details>
<summary>Tips and commands</summary>
#### Interacting with Sourcery
- **Trigger a new review:** Comment `@sourcery-ai review` on the pull request.
- **Continue discussions:** Reply directly to Sourcery's review comments.
- **Generate a GitHub issue from a review comment:** Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with `@sourcery-ai issue` to create an issue from it.
- **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull
request title to generate a title at any time. You can also comment
`@sourcery-ai title` on the pull request to (re-)generate the title at any time.
- **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment `@sourcery-ai summary` on the pull request to
(re-)generate the summary at any time.
- **Generate reviewer's guide:** Comment `@sourcery-ai guide` on the pull
request to (re-)generate the reviewer's guide at any time.
- **Resolve all Sourcery comments:** Comment `@sourcery-ai resolve` on the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore.
- **Dismiss all Sourcery reviews:** Comment `@sourcery-ai dismiss` on the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
`@sourcery-ai review` to trigger a new review!
#### Customizing Your Experience
Access your [dashboard](https://app.sourcery.ai) to:
- Enable or disable review features such as the Sourcery-generated pull request
summary, the reviewer's guide, and others.
- Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
#### Getting Help
- [Contact our support team](mailto:support@sourcery.ai) for questions or feedback.
- Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information.
- Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
</details>
<!-- Generated by sourcery-ai[bot]: end review_guide -->
--
author: coderabbitai
association: none
edited: true
status: none
--
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- other_code_reviewer_warning_start -->
> [!NOTE]
> ## Other AI code review bot(s) detected
>
> CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.
<!-- other_code_reviewer_warning_end -->
<!-- walkthrough_start -->
<details>
<summary>📝 Walkthrough</summary>
## Walkthrough
The PR modernizes fragment lifecycle and menu handling (replacing deprecated methods with onViewCreated and MenuProvider), migrates ViewPager-based navigation to ViewPager2 with FragmentStateAdapter/TabLayoutMediator, introduces LazyLoadViewModel for fragment load state, and removes a custom ViewPager subclass and related layout usages.
## Changes
| Cohort / File(s) | Change Summary |
|---|---|
| **BaseFragment & menu handling** <br> `app/src/main/java/.../BaseFragment.java` | Removed onActivityCreated/onCreateOptionsMenu/onPrepareOptionsMenu; added onViewCreated registering a MenuProvider tied to getViewLifecycleOwner() delegating menu creation/selection/preparation. |
| **List & related fragments lifecycle** <br> `app/src/main/java/.../BaseListFragment.java`, `app/src/main/java/.../ListFragment.java`, `app/src/main/java/.../FavoriteFragment.java`, `app/src/main/java/.../WebFragment.java` | Replaced onActivityCreated with onViewCreated (or removed deprecated overrides); removed explicit setHasOptionsMenu(true) usages; preserved equivalent initialization in onViewCreated. |
| **ViewPager → ViewPager2 (activities & layouts)** <br> `app/src/main/java/.../BaseListActivity.java`, `app/src/main/java/.../ItemActivity.java`, `app/src/main/res/layout-w820dp-land/activity_list.xml`, `app/src/main/res/layout/activity_item.xml` | Replaced androidx.viewpager.widget.ViewPager with androidx.viewpager2.widget.ViewPager2; integrated TabLayoutMediator, updated adapter binding, page change callbacks, setUserInputEnabled for swipe control, and layout tag updates. |
| **Pager adapter migration** <br> `app/src/main/java/.../widget/ItemPagerAdapter.java` | Migrated from FragmentStatePagerAdapter to FragmentStateAdapter: constructor now accepts FragmentActivity; implemented createFragment/getItemCount/getItemId; removed old instantiateItem/getItem/getCount and internal fragment cache. |
| **Lazy load ViewModel & fragment** <br> `app/src/main/java/.../LazyLoadViewModel.java`, `app/src/main/java/.../LazyLoadFragment.java` | Added LazyLoadViewModel (eager/load/initialized flags with getters/setters); LazyLoadFragment now uses ViewModelProvider, moves init from onActivityCreated to onViewCreated, adds setUserVisibleHint, and defers load decisions to ViewModel. |
| **Removed custom ViewPager widget** <br> `app/src/main/java/.../widget/ViewPager.java` | Deleted custom ViewPager subclass (swipe toggle logic and setSwipeEnabled API); codebase now relies on ViewPager2. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant Fragment as BaseFragment
participant View as ViewLifecycle
participant MenuProv as MenuProvider
participant Activity as Activity
participant Menu as Menu
Fragment->>View: onViewCreated(view, bundle)
View->>MenuProv: register MenuProvider (getViewLifecycleOwner(), RESUMED)
MenuProv->>Fragment: onCreateMenu(menu, inflater)
Fragment->>Menu: inflate/delegate to mMenuTintDelegate
Menu->>MenuProv: onMenuItemSelected(item)
MenuProv->>Fragment: onOptionsItemSelected(item)
```
```mermaid
sequenceDiagram
participant Activity as ItemActivity
participant VP2 as ViewPager2
participant TLM as TabLayoutMediator
participant Adapter as ItemPagerAdapter
participant Fragment as PageFragment
Activity->>Adapter: new ItemPagerAdapter(activity, builder)
Activity->>VP2: setAdapter(adapter)
Activity->>TLM: new TabLayoutMediator(tabLayout, VP2).attach()
VP2->>Adapter: createFragment(position)
Adapter->>Fragment: instantiate page fragment
VP2->>Activity: onPageSelected(position)
Activity->>Activity: toggle FABs / trigger lazy load via fragment tag
```
## Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
## Possibly related issues
- **sheepdestroyer/materialisheep#52**: Implements the fragment API modernization, ViewModel lazy-load approach, and ViewPager → ViewPager2 migration described in the issue.
## Possibly related PRs
- **sheepdestroyer/materialisheep#51**: Touches the same deprecated fragment lifecycle/menu methods in BaseFragment; changes may conflict or overlap with this PR's removals.
## Suggested labels
`Review effort 3/5`
## Poem
> 🐰 Hopping from old hooks to newer light,
> > Menus find providers, tabs align just right,
> > ViewModels remember what the rabbit forgot,
> > ViewPager2 hops in—no custom swipe to plot,
> > A joyful thump for code made bright!
</details>
<!-- walkthrough_end -->
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary>🚥 Pre-merge checks | ✅ 2 | ❌ 1</summary>
<details>
<summary>❌ Failed checks (1 warning)</summary>
| Check name | Status | Explanation | Resolution |
| :----------------: | :--------- | :------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- |
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 21.28% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
</details>
<details>
<summary>✅ Passed checks (2 passed)</summary>
| Check name | Status | Explanation |
| :---------------: | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
| Title check | ✅ Passed | The title accurately summarizes the two main changes: ViewPager2 migration and Fragment API modernization to replace deprecated lifecycle methods. |
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
</details>
<sub>✏️ Tip: You can configure your own custom pre-merge checks in the settings.</sub>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary>✨ Finishing touches</summary>
- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate docstrings
</details>
<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->
---
Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=sheepdestroyer/materialisheep&utm_content=56)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
<details>
<summary>❤️ Share</summary>
- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
</details>
<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>
<!-- tips_end -->
<!-- internal state start -->
<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKPR1AGxJcbJAGZoYvgUXABq8CQA7lZopBQATJAAsvBEVOL4WJj0AGJURGwYuJAAglYAksmKlBjwAF7U8JmQkAYAco4ClFwArABskIAoBJCwuLjciBwA9FNE6rDYAhpMzFOIsCQk3EqIuBT4spRTzNSU8GgeSBtbU9zYHh5T/S0GAKqI3fbX29J7B5RDSAAZXw2AoDG8kAo/kCBAoUwkEUi3FilHiYGYqXSTSwgCTCGDOUicSAnXYA1oAYWhp1oXHiAAZ4n0wPSAIxgVkATmg9PpHDZHAAzIKAFqAoG4ajYSb8bhkNwIZC2ElY07IXAbdDcbiQPz7ZiQDUkSBeIiBeThKIxOKQKaQPKxQq4CWna2UEq0NDcGh8D64bA6giQS3RVEJSCReb2/JOl00D1en3oDD0ZjVCi1OrSaOO9ilCrIbIksjYEbZS4YIgaSAU2CYUjIeAYBgebBKDgGKApNKnSDlGjMEpiSTqeRFgBCaA+ABkkLgh+JEbh5EHpcaQ27w0XoCpp2hZKDcEk6Oc4ZAABTcVvIFGkRh1yvGhgXDwCQIAa0QAEoNJ3IL4r0CJ9pQIA0NzDSBpVRFAsA8fdD2Qc9YRHZcAH1Ll2DQAA9mA8AAadBhyXWRUPUEhmGw3CvwjKNwLiRIiyULwaENTUGBAlhgyRTdGDgxBEF/KBXm2Xt+3IzcE29AEgxILCaBTHMCnYOMSEkn1BKqKRdRjPMPHwOYGG0zilF4UQa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ZtI2GLl0UW3zc1t6pBbsAYW79G5uuiSbq58m/YYhl1rQxLWv/idSLw1V0kzFFW1wEBupn1bHN3W35CJvxAdb2NvW3jeosE3ubxNyM6TZzOS2gR1toPbbZ77b0nbcOVWzmfduc3UbXAQWL7YFsB3rzQdom+LfDsW3a1EkqOzTcbVd6bgLaxGYBzYbIyE7Lt+G8nc9vc2egGdqVPrcNsYVuTJt0O2bYjuQzqbstiG2XeMGmSnQztyAK7f5MN2/bXttOy3ZxtZ2lLudkm74mFYGBV7aycoxiaxMkAcTGl+Eyif0BAA== -->
<!-- internal state end -->
--
author: gemini-code-assist
association: none
edited: false
status: none
--
## Summary of Changes
Hello @sheepdestroyer, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly modernizes the application's UI and Fragment management by adopting contemporary AndroidX components and lifecycle practices. The core changes involve upgrading the paging mechanism from the legacy ViewPager to ViewPager2, streamlining Fragment lifecycle callbacks, and introducing ViewModel for robust state retention. These updates enhance maintainability, improve performance, and ensure compatibility with the latest Android development standards.
### Highlights
* **ViewPager2 Migration**: The application has been migrated from the deprecated `ViewPager` and `FragmentStatePagerAdapter` to the modern `ViewPager2` and `FragmentStateAdapter` for improved performance and integration with AndroidX.
* **Fragment Lifecycle Modernization**: Deprecated Fragment lifecycle methods like `onActivityCreated` have been replaced with `onViewCreated` across several fragments (`BaseFragment`, `BaseListFragment`, `FavoriteFragment`, `LazyLoadFragment`, `ListFragment`) to align with current Android development best practices.
* **State Retention with ViewModel**: The `setRetainInstance` method, which is now deprecated, has been replaced by a new `LazyLoadViewModel` to manage the state of `LazyLoadFragment` instances, ensuring proper data retention across configuration changes.
* **Modern Menu Handling**: Menu creation and preparation in `BaseFragment` have been updated to use the `androidx.core.view.MenuProvider` API, replacing the older, deprecated Fragment menu callbacks.
* **Custom ViewPager Removal**: The custom `io.github.sheepdestroyer.materialisheep.widget.ViewPager` class has been removed, as its functionality (swipe enabling) is now handled directly by `ViewPager2`'s `setUserInputEnabled` method.
<details>
<summary><b>Using Gemini Code Assist</b></summary>
<br>
The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.
<b>Invoking Gemini</b>
You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page.
Feature | Command | Description
--- | --- | ---
Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help | `/gemini help` | Displays a list of available commands.
<b>Customization</b>
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
<b>Limitations & Feedback</b>
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
<b>You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the [Gemini Code Assist IDE Extension](https://cloud.google.com/products/gemini/code-assist).</b>
</details>
[^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
--
author: qodo-code-review
association: none
edited: true
status: none
--
## PR Compliance Guide 🔍
<!-- https://github.com/sheepdestroyer/materialisheep/commit/4f73c22bf8e4d1a3ce2692db6e9365847ef18557 -->
Below is a summary of compliance checks for this PR:<br>
<table><tbody><tr><td colspan='2'><strong>Security Compliance</strong></td></tr>
<tr><td>🟢</td><td><details><summary><strong>No security concerns identified</strong></summary>
No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
</details></td></tr>
<tr><td colspan='2'><strong>Ticket Compliance</strong></td></tr>
<tr><td>⚪</td><td><details><summary>🎫 <strong>No ticket provided </strong></summary>
- [ ] Create ticket/issue <!-- /create_ticket --create_ticket=true -->
</details></td></tr>
<tr><td colspan='2'><strong>Codebase Duplication Compliance</strong></td></tr>
<tr><td>⚪</td><td><details><summary><strong>Codebase context is not defined </strong></summary>
Follow the <a href='https://qodo-merge-docs.qodo.ai/core-abilities/rag_context_enrichment/'>guide</a> to enable codebase context checks.
</details></td></tr>
<tr><td colspan='2'><strong>Custom Compliance</strong></td></tr>
<tr><td rowspan=2>🟢</td><td>
<details><summary><strong>Generic: Secure Error Handling</strong></summary><br>
**Objective:** To prevent the leakage of sensitive system information through error messages while <br>providing sufficient detail for internal debugging.<br>
**Status:** Passed<br>
> Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a>
</details></td></tr>
<tr><td>
<details><summary><strong>Generic: Secure Logging Practices</strong></summary><br>
**Objective:** To ensure logs are useful for debugging and auditing without exposing sensitive <br>information like PII, PHI, or cardholder data.<br>
**Status:** Passed<br>
> Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a>
</details></td></tr>
<tr><td rowspan=2>🔴</td>
<td><details>
<summary><strong>Generic: Meaningful Naming and Self-Documenting Code</strong></summary><br>
**Objective:** Ensure all identifiers clearly express their purpose and intent, making code <br>self-documenting<br>
**Status:** <br><a href='https://github.com/sheepdestroyer/materialisheep/pull/56/files#diff-a3f58229f06c2b8191eba660862f766fa28dd77ddd1acc12a3feebe4b7f1dfa0R125-R132'><strong>Misleading method name</strong></a>: The method <code>isNewInstance()</code> is now implemented as an unconditional <code>true</code>, making the name <br>misleading relative to its stated intent and documentation.<br>
<details open><summary>Referred Code</summary>
```java
/**
* Checks if the fragment is a new instance.
*
* @return True if the fragment is a new instance, false otherwise.
*/
protected boolean isNewInstance() {
return true;
}
```
</details>
> Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a>
</details></td></tr>
<tr><td><details>
<summary><strong>Generic: Robust Error Handling and Edge Case Management</strong></summary><br>
**Objective:** Ensure comprehensive error handling that provides meaningful context and graceful <br>degradation<br>
**Status:** <br><a href='https://github.com/sheepdestroyer/materialisheep/pull/56/files#diff-541bfd1c727ef903fd6bb20ddb37eb4d1dbd94a80a601db8b7804f8b61d358c2R146-R153'><strong>Unsafe fragment cast</strong></a>: The code casts the result of <code>getFragment(0)</code> to <code>Navigable</code> without null/type checks, which <br>can crash if the fragment is not yet created or is not <code>Navigable</code>.<br>
<details open><summary>Referred Code</summary>
```java
mViewPager = (ViewPager2) findViewById(R.id.content);
mViewPager.setVisibility(View.GONE);
mReplyButton = (FloatingActionButton) findViewById(R.id.reply_button);
mNavButton = (NavFloatingActionButton) findViewById(R.id.navigation_button);
mNavButton.setNavigable(direction ->
// if callback is fired navigable should not be null
((Navigable) getFragment(0)).onNavigate(direction));
AppUtils.toggleFab(mNavButton, false);
```
</details>
> Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a>
</details></td></tr>
<tr><td rowspan=2>⚪</td>
<td><details>
<summary><strong>Generic: Comprehensive Audit Trails</strong></summary><br>
**Objective:** To create a detailed and reliable record of critical system actions for security analysis <br>and compliance.<br>
**Status:** <br><a href='https://github.com/sheepdestroyer/materialisheep/pull/56/files#diff-541bfd1c727ef903fd6bb20ddb37eb4d1dbd94a80a601db8b7804f8b61d358c2R516-R548'><strong>No audit logging</strong></a>: The diff introduces new user-triggered state changes and navigation flows without any <br>audit logging, but it is unclear from the diff whether these actions are considered <br>"critical" or are logged elsewhere.<br>
<details open><summary>Referred Code</summary>
```java
mViewPager.setVisibility(View.VISIBLE);
bindViewPager();
mSessionManager.view(mSelectedItem.getId());
}
}
private void bindViewPager() {
if (mAdapter != null) {
// No custom unbind needed for Adapter anymore
}
mAdapter = new ItemPagerAdapter(this, new ItemPagerAdapter.Builder()
.setItem(mSelectedItem)
.setCacheMode(getItemCacheMode())
.setShowArticle(true)
.setDefaultViewMode(mStoryViewMode));
mViewPager.setAdapter(mAdapter);
new TabLayoutMediator(mTabLayout, mViewPager,
(tab, position) -> tab.setText(mAdapter.getPageTitle(position))).attach();
mViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@Override
public void onPageSelected(int position) {
... (clipped 12 lines)
```
</details>
> Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a>
</details></td></tr>
<tr><td><details>
<summary><strong>Generic: Security-First Input Validation and Data Handling</strong></summary><br>
**Objective:** Ensure all data inputs are validated, sanitized, and handled securely to prevent <br>vulnerabilities<br>
**Status:** <br><a href='https://github.com/sheepdestroyer/materialisheep/pull/56/files#diff-cd1bd6c16056eabdbb05b9b46cd4f05e46572722c428ea2fa7bb3250beeb6545R186-R192'><strong>Unvalidated runtime type</strong></a>: The code casts <code>getFragment(0)</code> to <code>Navigable</code> without validating existence/type, which can be <br>influenced by lifecycle/state and lead to crashes rather than a controlled failure path.<br>
<details open><summary>Referred Code</summary>
```java
mReplyButton = findViewById(R.id.reply_button);
mNavButton = findViewById(R.id.navigation_button);
mNavButton = findViewById(R.id.navigation_button);
mNavButton.setNavigable(direction ->
// if callback is fired navigable should not be null
AppUtils.navigate(direction, mAppBar, (Navigable) getFragment(0)));
mVoteButton = findViewById(R.id.vote_button);
```
</details>
> Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a>
</details></td></tr>
<tr><td align="center" colspan="2">
- [ ] Update <!-- /compliance --update_compliance=true -->
</td></tr></tbody></table>
<details><summary>Compliance status legend</summary>
🟢 - Fully Compliant<br>
🟡 - Partial Compliant<br>
🔴 - Not Compliant<br>
⚪ - Requires Further Human Verification<br>
🏷️ - Compliance label<br>
</details>
--
author: sourcery-ai
association: none
edited: false
status: commented
--
Hey - I've found 2 issues, and left some high level feedback:
- In LazyLoadFragment, the new eagerLoad() implementation only checks isEagerLoad() and no longer guards on an unloaded state, so load() can now be invoked multiple times; consider tracking and checking an isLoaded flag (from LazyLoadViewModel) before calling load(), and revisiting isNewInstance() now that it always returns true.
- The new getFragment/unbindViewPager logic in BaseListActivity and ItemActivity relies on hardcoded ViewPager2 fragment tags ("f0", "f1"); this is brittle if itemIds or page count change—consider deriving tags from adapter itemIds or resolving current fragments via FragmentManager and container id rather than fixed tag strings.
- In ItemActivity.onCreate, mNavButton is assigned twice consecutively from findViewById(R.id.navigation_button); the second assignment is redundant and can be removed.
<details>
<summary>Prompt for AI Agents</summary>
~~~markdown
Please address the comments from this code review:
## Overall Comments
- In LazyLoadFragment, the new eagerLoad() implementation only checks isEagerLoad() and no longer guards on an unloaded state, so load() can now be invoked multiple times; consider tracking and checking an isLoaded flag (from LazyLoadViewModel) before calling load(), and revisiting isNewInstance() now that it always returns true.
- The new getFragment/unbindViewPager logic in BaseListActivity and ItemActivity relies on hardcoded ViewPager2 fragment tags ("f0", "f1"); this is brittle if itemIds or page count change—consider deriving tags from adapter itemIds or resolving current fragments via FragmentManager and container id rather than fixed tag strings.
- In ItemActivity.onCreate, mNavButton is assigned twice consecutively from findViewById(R.id.navigation_button); the second assignment is redundant and can be removed.
## Individual Comments
### Comment 1
<location> `app/src/main/java/io/github/sheepdestroyer/materialisheep/LazyLoadFragment.java:135-136` </location>
<code_context>
final void eagerLoad() {
- if (mEagerLoad && !mLoaded) {
- mLoaded = true;
+ if (mViewModel.isEagerLoad()) {
+ mViewModel.setLoaded(true);
load();
}
</code_context>
<issue_to_address>
**issue (bug_risk):** Guard `load()` with the `loaded` flag to avoid repeated loading.
Before the refactor, `eagerLoad()` guarded `load()` with `!mLoaded`, so it ran at most once per instance even if `loadNow()` or lifecycle events fired multiple times. Now `eagerLoad()` only checks `isEagerLoad()` and always calls `load()`, so multiple invocations (e.g., repeated `loadNow()` or visibility changes) can trigger repeated loads. Please reintroduce the `!isLoaded()` check:
```java
final void eagerLoad() {
if (mViewModel.isEagerLoad() && !mViewModel.isLoaded()) {
mViewModel.setLoaded(true);
load();
}
}
```
and ensure `STATE_LOADED` is restored from the ViewModel if that flag must be persisted.
</issue_to_address>
### Comment 2
<location> `app/src/main/java/io/github/sheepdestroyer/materialisheep/LazyLoadFragment.java:39-48` </location>
<code_context>
*/
- @SuppressWarnings("deprecation") // Using deprecated onActivityCreated; migration to onViewCreated requires
- // refactoring
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
</code_context>
<issue_to_address>
**suggestion:** Using `setUserVisibleHint` is deprecated and won’t be triggered by ViewPager2.
With ViewPager2 + FragmentStateAdapter, `setUserVisibleHint` is never invoked because visibility is controlled via `setMaxLifecycle`, so this method is effectively dead code and can mislead future maintenance around lazy loading.
Given that `loadNow()` is already triggered from the ViewPager2 `OnPageChangeCallback`, you can remove this override. If you still need lifecycle-driven loading, tie it to fragment lifecycle callbacks (e.g., `onResume` with the adapter’s current item) instead of `setUserVisibleHint`.
</issue_to_address>
~~~
</details>
***
<details>
<summary>Sourcery is free for open source - if you like our reviews please consider sharing them ✨</summary>
- [X](https://twitter.com/intent/tweet?text=I%20just%20got%20an%20instant%20code%20review%20from%20%40SourceryAI%2C%20and%20it%20was%20brilliant%21%20It%27s%20free%20for%20open%20source%20and%20has%20a%20free%20trial%20for%20private%20code.%20Check%20it%20out%20https%3A//sourcery.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20got%20an%20instant%20code%20review%20from%20%40SourceryAI%2C%20and%20it%20was%20brilliant%21%20It%27s%20free%20for%20open%20source%20and%20has%20a%20free%20trial%20for%20private%20code.%20Check%20it%20out%20https%3A//sourcery.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https://sourcery.ai)
- [Facebook](https://www.facebook.com/sharer/sharer.php?u=https://sourcery.ai)
</details>
<sub>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
</sub>
--
author: qodo-code-review
association: none
edited: true
status: none
--
## PR Code Suggestions ✨
<!-- 4f73c22 -->
Explore these optional code suggestions:
<table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=1>Possible issue</td>
<td>
<details><summary>✅ <s>Use onResume for fragment visibility detection</s></summary>
___
<details><summary><b>Suggestion Impact:</b></summary>The commit removed the setUserVisibleHint override (the method called out as deprecated/non-functional with ViewPager2), and adjusted loading logic to avoid re-loading (added !isLoaded check) while triggering eagerLoad from onViewCreated instead. However, it did not implement the suggested onResume-based visibility detection.
code diff:
```diff
public void onViewCreated(android.view.View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mActivityCreated = true;
- if (isNewInstance()) {
+ if (true) {
eagerLoad();
}
}
@@ -98,15 +91,6 @@
mActivityCreated = false;
}
- @Override
- public void setUserVisibleHint(boolean isVisibleToUser) {
- super.setUserVisibleHint(isVisibleToUser);
- if (isVisibleToUser && !mViewModel.isLoaded()) {
- mViewModel.setEagerLoad(true);
- eagerLoad();
- }
- }
-
/**
* Loads the data immediately.
*/
@@ -122,17 +106,8 @@
*/
protected abstract void load();
- /**
- * Checks if the fragment is a new instance.
- *
- * @return True if the fragment is a new instance, false otherwise.
- */
- protected boolean isNewInstance() {
- return true;
- }
-
final void eagerLoad() {
- if (mViewModel.isEagerLoad()) {
+ if (mViewModel.isEagerLoad() && !mViewModel.isLoaded()) {
mViewModel.setLoaded(true);
load();
}
```
</details>
___
**Replace the deprecated <code>setUserVisibleHint</code> method with <code>onResume</code> for detecting <br>fragment visibility. This is necessary because <code>ViewPager2</code> does not call <br><code>setUserVisibleHint</code>, which would prevent lazy-loaded fragments from ever loading <br>their data.**
[app/src/main/java/io/github/sheepdestroyer/materialisheep/LazyLoadFragment.java [101-108]](https://github.com/sheepdestroyer/materialisheep/pull/56/files#diff-a3f58229f06c2b8191eba660862f766fa28dd77ddd1acc12a3feebe4b7f1dfa0R101-R108)
```diff
@Override
-public void setUserVisibleHint(boolean isVisibleToUser) {
- super.setUserVisibleHint(isVisibleToUser);
- if (isVisibleToUser && !mViewModel.isLoaded()) {
+public void onResume() {
+ super.onResume();
+ // onResume is called when the fragment becomes the primary navigation fragment in ViewPager2
+ if (getUserVisibleHint() && !mViewModel.isLoaded()) { // Maintain compatibility with old ViewPager if needed
mViewModel.setEagerLoad(true);
eagerLoad();
}
}
```
`[Suggestion processed]`
<details><summary>Suggestion importance[1-10]: 9</summary>
__
Why: This suggestion correctly identifies a critical bug where lazy-loaded fragments would not load due to the deprecation of `setUserVisibleHint` in `ViewPager2`, and it provides the correct fix using `onResume`.
</details></details></td><td align=center>High
</td></tr><tr><td rowspan=1>General</td>
<td>
<details><summary>✅ <s>Unregister callbacks to prevent leaks</s></summary>
___
<details><summary><b>Suggestion Impact:</b></summary>The commit introduces member fields for TabLayoutMediator and the ViewPager2.OnPageChangeCallback, uses them when binding the ViewPager, and properly detaches/unregisters them in unbindViewPager(). It also additionally stores/removes a TabLayout.OnTabSelectedListener for cleanup.
code diff:
```diff
+ private TabLayoutMediator mTabLayoutMediator;
+ private ViewPager2.OnPageChangeCallback mPageChangeCallback;
+ private TabLayout.OnTabSelectedListener mTabSelectedListener;
/**
* Called when the activity is first created.
@@ -529,9 +532,11 @@
.setShowArticle(true)
.setDefaultViewMode(mStoryViewMode));
mViewPager.setAdapter(mAdapter);
- new TabLayoutMediator(mTabLayout, mViewPager,
- (tab, position) -> tab.setText(mAdapter.getPageTitle(position))).attach();
- mViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
+ mTabLayoutMediator = new TabLayoutMediator(mTabLayout, mViewPager,
+ (tab, position) -> tab.setText(mAdapter.getPageTitle(position)));
+ mTabLayoutMediator.attach();
+
+ mPageChangeCallback = new ViewPager2.OnPageChangeCallback() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
@@ -544,8 +549,10 @@
((LazyLoadFragment) fragment).loadNow();
}
}
- });
- mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
+ };
+ mViewPager.registerOnPageChangeCallback(mPageChangeCallback);
+
+ mTabSelectedListener = new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
}
@@ -561,7 +568,8 @@
((Scrollable) fragment).scrollToTop();
}
}
- });
+ };
+ mTabLayout.addOnTabSelectedListener(mTabSelectedListener);
// Initial FAB state
int current = mViewPager.getCurrentItem();
@@ -575,6 +583,20 @@
@SuppressLint("RestrictedApi")
private void unbindViewPager() {
+ if (mTabLayoutMediator != null) {
+ mTabLayoutMediator.detach();
+ mTabLayoutMediator = null;
+ }
+
+ if (mPageChangeCallback != null) {
+ mViewPager.unregisterOnPageChangeCallback(mPageChangeCallback);
+ mPageChangeCallback = null;
+ }
+ if (mTabSelectedListener != null) {
+ mTabLayout.removeOnTabSelectedListener(mTabSelectedListener);
+ mTabSelectedListener = null;
+ }
```
</details>
___
**To prevent memory leaks, store the <code>OnPageChangeCallback</code> and <code>TabLayoutMediator</code> <br>instances as member fields. Unregister the callback and detach the mediator in <br>the <code>unbindViewPager()</code> method to ensure they are properly cleaned up.**
[app/src/main/java/io/github/sheepdestroyer/materialisheep/BaseListActivity.java [534-547]](https://github.com/sheepdestroyer/materialisheep/pull/56/files#diff-541bfd1c727ef903fd6bb20ddb37eb4d1dbd94a80a601db8b7804f8b61d358c2R534-R547)
```diff
-mViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
+// declare fields
+private ViewPager2.OnPageChangeCallback mPageCallback;
+private TabLayoutMediator mTabMediator;
+
+// in bindViewPager():
+mPageCallback = new ViewPager2.OnPageChangeCallback() {
@Override
- public void onPageSelected(int position) {
- super.onPageSelected(position);
- AppUtils.toggleFab(mNavButton, position == 0 && Preferences.navigationEnabled(BaseListActivity.this));
- AppUtils.toggleFab(mReplyButton, true);
- AppUtils.toggleFabAction(mReplyButton, mSelectedItem, position == 0);
+ public void onPageSelected(int position) { /* ... */ }
+};
+mViewPager.registerOnPageChangeCallback(mPageCallback);
+mTabMediator = new TabLayoutMediator(mTabLayout, mViewPager,
+ (tab, pos) -> tab.setText(mAdapter.getPageTitle(pos)));
+mTabMediator.attach();
- Fragment fragment = getFragment(position);
- if (fragment instanceof LazyLoadFragment) {
- ((LazyLoadFragment) fragment).loadNow();
- }
- }
-});
+// in unbindViewPager():
+if (mPageCallback != null) {
+ mViewPager.unregisterOnPageChangeCallback(mPageCallback);
+ mPageCallback = null;
+}
+if (mTabMediator != null) {
+ mTabMediator.detach();
+ mTabMediator = null;
+}
+FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+// ...
+transaction.commitAllowingStateLoss();
```