mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-08-01 11:40:34 +00:00
fix memory leak
This commit is contained in:
parent
c09a1c6e70
commit
6068da2f91
5 changed files with 46 additions and 44 deletions
|
|
@ -150,7 +150,7 @@ android {
|
|||
buildConfigField "String", "TESTING_LEVEL", "\"production\""
|
||||
multiDexEnabled true
|
||||
|
||||
versionCode 2153
|
||||
versionCode 2157
|
||||
versionName "1.10"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -226,31 +226,30 @@ class AuthenticationPreferenceFragment: BasePreferencesFragment() {
|
|||
}
|
||||
|
||||
private fun showAccountResetConfirmation() {
|
||||
context?.let { context ->
|
||||
val dialog = HabiticaAlertDialog(context)
|
||||
dialog.setTitle(R.string.reset_account)
|
||||
dialog.setMessage(R.string.reset_account_description)
|
||||
dialog.addButton(R.string.reset_account_confirmation, true, true) { _, _ ->
|
||||
resetAccount()
|
||||
}
|
||||
dialog.addCancelButton()
|
||||
dialog.setAdditionalContentSidePadding(12.dpToPx(context))
|
||||
dialog.show()
|
||||
val context = context ?: return
|
||||
|
||||
val dialog = HabiticaAlertDialog(context)
|
||||
dialog.setTitle(R.string.reset_account)
|
||||
dialog.setMessage(R.string.reset_account_description)
|
||||
dialog.addButton(R.string.reset_account_confirmation, true, true) { _, _ ->
|
||||
resetAccount()
|
||||
}
|
||||
dialog.addCancelButton()
|
||||
dialog.setAdditionalContentSidePadding(12.dpToPx(context))
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun showConfirmUsernameDialog() {
|
||||
context?.let { context ->
|
||||
val dialog = HabiticaAlertDialog(context)
|
||||
dialog.setTitle(R.string.confirm_username_title)
|
||||
dialog.setMessage(R.string.confirm_username_description)
|
||||
dialog.addButton(R.string.confirm, true) { _, _ ->
|
||||
userRepository.updateLoginName(user?.authentication?.localAuthentication?.username ?: "")
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
dialog.addCancelButton()
|
||||
dialog.show()
|
||||
val context = context ?: return
|
||||
val dialog = HabiticaAlertDialog(context)
|
||||
dialog.setTitle(R.string.confirm_username_title)
|
||||
dialog.setMessage(R.string.confirm_username_description)
|
||||
dialog.addButton(R.string.confirm, true) { _, _ ->
|
||||
userRepository.updateLoginName(user?.authentication?.localAuthentication?.username ?: "")
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
dialog.addCancelButton()
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun resetAccount() {
|
||||
|
|
|
|||
|
|
@ -350,23 +350,21 @@ class ChallengeDetailFragment: BaseMainFragment() {
|
|||
}
|
||||
|
||||
private fun showChallengeLeaveDialog() {
|
||||
context?.let { context ->
|
||||
val alert = HabiticaAlertDialog(context)
|
||||
alert.setTitle(this.getString(R.string.challenge_leave_title))
|
||||
alert.setMessage(this.getString(R.string.challenge_leave_text, challenge?.name ?: ""))
|
||||
alert.addButton(R.string.yes, true) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
challenge?.let { challenge ->
|
||||
showRemoveTasksDialog(Consumer { keepTasks ->
|
||||
challengeRepository.leaveChallenge(challenge, keepTasks).subscribe(Consumer {}, RxErrorHandler.handleEmptyError())
|
||||
})
|
||||
}
|
||||
}
|
||||
alert.addButton(R.string.no, false) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
alert.show()
|
||||
val context = context ?: return
|
||||
val alert = HabiticaAlertDialog(context)
|
||||
alert.setTitle(this.getString(R.string.challenge_leave_title))
|
||||
alert.setMessage(this.getString(R.string.challenge_leave_text, challenge?.name ?: ""))
|
||||
alert.addButton(R.string.yes, true) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
showRemoveTasksDialog(Consumer { keepTasks ->
|
||||
val challenge = challenge ?: return@Consumer
|
||||
challengeRepository.leaveChallenge(challenge, keepTasks).subscribe(Consumer {}, RxErrorHandler.handleEmptyError())
|
||||
})
|
||||
}
|
||||
alert.addButton(R.string.no, false) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
alert.show()
|
||||
}
|
||||
|
||||
private fun showRemoveTasksDialog(callback: Consumer<String>) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import com.habitrpg.android.habitica.ui.activities.TaskFormActivity
|
|||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
||||
import com.habitrpg.android.habitica.ui.views.tasks.TaskFilterDialog
|
||||
import io.reactivex.functions.Consumer
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -65,12 +64,19 @@ class TasksFragment : BaseMainFragment() {
|
|||
}
|
||||
updateBottomBarBadges()
|
||||
}
|
||||
bottomNavigation?.onAddListener = WeakReference { type ->
|
||||
bottomNavigation?.onAddListener = { type ->
|
||||
openNewTaskActivity(type)
|
||||
}
|
||||
bottomNavigation?.flipAddBehaviour = appConfigManager.flipAddTaskBehaviour()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
bottomNavigation?.onTabSelectedListener = null
|
||||
bottomNavigation?.onAddListener = null
|
||||
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
tagRepository.close()
|
||||
super.onDestroy()
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import com.habitrpg.android.habitica.R
|
|||
import com.habitrpg.android.habitica.extensions.inflate
|
||||
import com.habitrpg.android.habitica.models.tasks.Task
|
||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
|
||||
class HabiticaBottomNavigationView @JvmOverloads constructor(
|
||||
|
|
@ -45,7 +44,7 @@ class HabiticaBottomNavigationView @JvmOverloads constructor(
|
|||
}
|
||||
}
|
||||
var onTabSelectedListener: ((String) -> Unit)? = null
|
||||
var onAddListener: WeakReference<((String) -> Unit)>? = null
|
||||
var onAddListener: ((String) -> Unit)? = null
|
||||
var activeTaskType: String = Task.TYPE_HABIT
|
||||
set(value) {
|
||||
field = value
|
||||
|
|
@ -72,7 +71,7 @@ class HabiticaBottomNavigationView @JvmOverloads constructor(
|
|||
if (isShowingSubmenu) {
|
||||
hideSubmenu()
|
||||
} else {
|
||||
onAddListener?.get()?.invoke(activeTaskType)
|
||||
onAddListener?.invoke(activeTaskType)
|
||||
}
|
||||
} else {
|
||||
showSubmenu()
|
||||
|
|
@ -83,7 +82,7 @@ class HabiticaBottomNavigationView @JvmOverloads constructor(
|
|||
if (flipAddBehaviour) {
|
||||
showSubmenu()
|
||||
} else {
|
||||
onAddListener?.get()?.invoke(activeTaskType)
|
||||
onAddListener?.invoke(activeTaskType)
|
||||
}
|
||||
animateButtonTap()
|
||||
true
|
||||
|
|
@ -165,7 +164,7 @@ class HabiticaBottomNavigationView @JvmOverloads constructor(
|
|||
}
|
||||
}
|
||||
view.onAddListener = {
|
||||
onAddListener?.get()?.invoke(taskType)
|
||||
onAddListener?.invoke(taskType)
|
||||
hideSubmenu()
|
||||
}
|
||||
submenuWrapper.addView(view)
|
||||
|
|
|
|||
Loading…
Reference in a new issue