Skip to content

Commit

Permalink
Remove SignatureAdapter memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed May 1, 2024
1 parent 56865cc commit 155beef
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class NewMessageFragment : Fragment() {
private var quoteWebView: WebView? = null
private var signatureWebView: WebView? = null

private val signatureAdapter = SignatureAdapter(::onSignatureClicked)
private var signatureAdapter: SignatureAdapter? = SignatureAdapter(::onSignatureClicked)
private val attachmentAdapter inline get() = binding.attachmentsRecyclerView.adapter as AttachmentAdapter

private val newMessageActivity by lazy { requireActivity() as NewMessageActivity }
Expand Down Expand Up @@ -232,6 +232,7 @@ class NewMessageFragment : Fragment() {
}

override fun onDestroyView() {
signatureAdapter = null
addressListPopupWindow = null
quoteWebView?.destroyAndClearHistory()
quoteWebView = null
Expand Down Expand Up @@ -375,7 +376,7 @@ class NewMessageFragment : Fragment() {

private fun setupFromField(signatures: List<Signature>) = with(binding) {

signatureAdapter.setList(signatures)
signatureAdapter?.setList(signatures)

fromMailAddress.post {
runCatching {
Expand Down Expand Up @@ -429,7 +430,7 @@ class NewMessageFragment : Fragment() {
fromLiveData.observe(viewLifecycleOwner) { (signature, shouldUpdateBodySignature) ->
updateSelectedSignatureInFromField(signature)
if (shouldUpdateBodySignature) updateBodySignature(signature)
signatureAdapter.updateSelectedSignature(signature.id)
signatureAdapter?.updateSelectedSignature(signature.id)
}
}

Expand Down

0 comments on commit 155beef

Please sign in to comment.