mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-25 10:28:23 +01:00
Fix activity leak
This commit is contained in:
parent
24a2d86f41
commit
9ee6262aed
@ -32,6 +32,7 @@ abstract class SettingsController : PreferenceController() {
|
|||||||
var preferenceKey: String? = null
|
var preferenceKey: String? = null
|
||||||
val preferences: PreferencesHelper = Injekt.get()
|
val preferences: PreferencesHelper = Injekt.get()
|
||||||
val viewScope = MainScope()
|
val viewScope = MainScope()
|
||||||
|
private var themedContext: Context? = null
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle?): View {
|
||||||
val view = super.onCreateView(inflater, container, savedInstanceState)
|
val view = super.onCreateView(inflater, container, savedInstanceState)
|
||||||
@ -76,20 +77,23 @@ abstract class SettingsController : PreferenceController() {
|
|||||||
super.onChangeStarted(handler, type)
|
super.onChangeStarted(handler, type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView(view: View) {
|
||||||
|
super.onDestroyView(view)
|
||||||
|
themedContext = null
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
val screen = preferenceManager.createPreferenceScreen(getThemedContext())
|
val tv = TypedValue()
|
||||||
|
activity!!.theme.resolveAttribute(R.attr.preferenceTheme, tv, true)
|
||||||
|
themedContext = ContextThemeWrapper(activity, tv.resourceId)
|
||||||
|
|
||||||
|
val screen = preferenceManager.createPreferenceScreen(themedContext)
|
||||||
preferenceScreen = screen
|
preferenceScreen = screen
|
||||||
setupPreferenceScreen(screen)
|
setupPreferenceScreen(screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun setupPreferenceScreen(screen: PreferenceScreen): PreferenceScreen
|
abstract fun setupPreferenceScreen(screen: PreferenceScreen): PreferenceScreen
|
||||||
|
|
||||||
private fun getThemedContext(): Context {
|
|
||||||
val tv = TypedValue()
|
|
||||||
activity!!.theme.resolveAttribute(R.attr.preferenceTheme, tv, true)
|
|
||||||
return ContextThemeWrapper(activity, tv.resourceId)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun animatePreferenceHighlight(view: View) {
|
private fun animatePreferenceHighlight(view: View) {
|
||||||
ValueAnimator
|
ValueAnimator
|
||||||
.ofObject(ArgbEvaluator(), Color.TRANSPARENT, view.context.getResourceColor(R.attr.rippleColor))
|
.ofObject(ArgbEvaluator(), Color.TRANSPARENT, view.context.getResourceColor(R.attr.rippleColor))
|
||||||
|
Loading…
Reference in New Issue
Block a user