refactor(card-browser): Convert to fragment (and fix a few issues)#18463
refactor(card-browser): Convert to fragment (and fix a few issues)#18463BrayanDSO merged 11 commits intoankidroid:mainfrom
Conversation
AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserFragment.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserFragment.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserFragment.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserFragment.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserFragment.kt
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
9772399 to
10234e6
Compare
10234e6 to
41e4ff3
Compare
8741967 to
a0fd651
Compare
mikehardy
left a comment
There was a problem hiding this comment.
LGTM and I'd prefer to get this in ASAP so it receives quickest wide testing as possible
One thought regarding possible memory leak - I'll trust your analysis and any possible changes
| setDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.browser_divider)!!) | ||
| cardsListView.addItemDecoration(this) | ||
| } | ||
| cardsAdapter = |
There was a problem hiding this comment.
interesting - while doing the review on #18467 I saw a lot of chatter on memory leaks related to the combination of Fragment + RecyclerView + Adapter, and it looks like this may suffer from the leak described
https://stackoverflow.com/a/46957469/9910298
the adapter will continue to live on in the fragment after the RecyclerView goes away, which will leak perhaps?
during the fragment lifecycle (ie. in onDestroyView) the adapter may be set to null and cleared out of the recyclerview to allow it to GC
there's an interaction with the var declaration as lateinit vs nullable though - and maybe I'm mis-reading it and this doesn't apply ? fine with being wrong and this being comment being closeable
There was a problem hiding this comment.
Not enough motivation to deep dive today. May not have been a problem due to the lifecycles of the activity and fragment being equal.
Fixed:
override fun onDestroyView() {
super.onDestroyView()
if (::cardsListView.isInitialized) {
cardsListView.adapter = null
}
}* move flows to fragment Flows needed to go together to handle lifecycle changes: LinearProgressIndicator Issue 17901
* & remove extra parens
Removed another reference to cardsAdapter Issue 17901
Issue 17901
Only used in tests Issue 17901
a0fd651 to
b82e3fc
Compare
BrayanDSO
left a comment
There was a problem hiding this comment.
Mike's comment was addressed, and we can keep looking if it causes other leaks after the merge
Purpose / Description
Requested by @BrayanDSO
Fixes
Approach
See commits:
cardBrowserFragmentcardBrowserFragment, it became test onlyHow Has This Been Tested?
main: Browse (split screen): changing deck in note editor updates the browser instead #18462Learning (optional, can help others)
Easier than expected. There's more rounds if we want to tackle the menu
I feel I did something wrong....
Checklist