I am looking into extracting a string in a presenter class. There's a way to do it with context but it's not recommended to use context in presenter due to memory leaks and other issues. Is there a way I can do it without using context? Here's my code for example :
testLine = when {
sourceIds.isEmpty() -> ""
sourceIds.size > 1 -> String.format(Locale.getDefault(), "%d test", sourceIds.size)
else -> String.format(Locale.getDefault(), "%s", newMembers?.getNameForId(sourceIds[0]))
}
Best approach would be to drop context explicitly for example
Presenter
calling above from
takeContext->onViewCreated,dropContext->onDestroyViewSo that your context is only available when your view is drawed.