fix: add onDestroyView() to release fragment resources

This commit is contained in:
andrekir
2023-04-03 18:03:55 -03:00
parent 4dec73ea76
commit b3d581486a
7 changed files with 40 additions and 0 deletions

View File

@@ -363,6 +363,11 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
private fun getModemPreset(selectedChannelOptionString: String): ConfigProtos.Config.LoRaConfig.ModemPreset {
for (item in ChannelOption.values()) {
if (getString(item.configRes) == selectedChannelOptionString)

View File

@@ -222,6 +222,13 @@ class ContactsFragment : ScreenFragment("Messages"), Logging {
}
}
override fun onDestroyView() {
super.onDestroyView()
actionMode?.finish()
actionMode = null
_binding = null
}
private inner class ActionModeCallback : ActionMode.Callback {
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
mode.menuInflater.inflate(R.menu.menu_messages, menu)

View File

@@ -51,4 +51,9 @@ class DebugFragment : Fragment() {
logs?.let { adapter.setLogs(it) }
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}

View File

@@ -320,6 +320,13 @@ class MessagesFragment : Fragment(), Logging {
}
}
override fun onDestroyView() {
super.onDestroyView()
actionMode?.finish()
actionMode = null
_binding = null
}
private inner class ActionModeCallback : ActionMode.Callback {
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
mode.menuInflater.inflate(R.menu.menu_messages, menu)

View File

@@ -109,6 +109,11 @@ class QuickChatSettingsFragment : ScreenFragment("Quick Chat Settings"), Logging
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
data class DialogBuilder(
val builder: MaterialAlertDialogBuilder,
val nameInput: EditText,

View File

@@ -618,6 +618,12 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
if (binding.provideLocationCheckbox.isChecked)
checkLocationEnabled(getString(R.string.location_disabled))
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
companion object {
const val SCAN_PERIOD: Long = 10000 // Stops scanning after 10 seconds
}

View File

@@ -318,4 +318,9 @@ class UsersFragment : ScreenFragment("Users"), Logging {
nodesAdapter.onNodesChanged(it.values.toTypedArray())
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}