forked from upstream-mirrors/quik
Fix crash when returning to theme selector
This commit is contained in:
@@ -21,14 +21,19 @@ abstract class QkController<ViewContract : QkViewContract<State>, State, Present
|
||||
private val appCompatActivity: AppCompatActivity?
|
||||
get() = activity as? AppCompatActivity
|
||||
|
||||
override val containerView: View?
|
||||
get() = view
|
||||
override var containerView: View? = null
|
||||
|
||||
@LayoutRes
|
||||
var layoutRes: Int = 0
|
||||
|
||||
final override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
return inflater.inflate(layoutRes, container, false)
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
return inflater.inflate(layoutRes, container, false).also {
|
||||
containerView = it
|
||||
onViewCreated()
|
||||
}
|
||||
}
|
||||
|
||||
open fun onViewCreated() {
|
||||
}
|
||||
|
||||
fun setTitle(@StringRes titleId: Int) {
|
||||
@@ -45,7 +50,7 @@ abstract class QkController<ViewContract : QkViewContract<State>, State, Present
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
super.onDestroyView(view)
|
||||
containerView = null
|
||||
clearFindViewByIdCache()
|
||||
}
|
||||
|
||||
|
||||
@@ -67,12 +67,7 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
||||
.subscribe { activity?.recreate() }
|
||||
}
|
||||
|
||||
override fun onAttach(view: View) {
|
||||
super.onAttach(view)
|
||||
presenter.bindIntents(this)
|
||||
setTitle(R.string.title_settings)
|
||||
showBackButton(true)
|
||||
|
||||
override fun onViewCreated() {
|
||||
preferences.postDelayed({ preferences.animateLayoutChanges = true }, 100)
|
||||
|
||||
nightModeDialog.adapter.setData(R.array.night_modes)
|
||||
@@ -83,6 +78,13 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
||||
about.summary = context.getString(R.string.settings_version, BuildConfig.VERSION_NAME)
|
||||
}
|
||||
|
||||
override fun onAttach(view: View) {
|
||||
super.onAttach(view)
|
||||
presenter.bindIntents(this)
|
||||
setTitle(R.string.title_settings)
|
||||
showBackButton(true)
|
||||
}
|
||||
|
||||
override fun preferenceClicks(): Observable<PreferenceView> = (0 until preferences.childCount)
|
||||
.map { index -> preferences.getChildAt(index) }
|
||||
.mapNotNull { view -> view as? PreferenceView }
|
||||
|
||||
@@ -20,13 +20,15 @@ class AboutController : QkController<AboutView, Unit, AboutPresenter>(), AboutVi
|
||||
layoutRes = R.layout.about_controller
|
||||
}
|
||||
|
||||
override fun onViewCreated() {
|
||||
version.summary = BuildConfig.VERSION_NAME
|
||||
}
|
||||
|
||||
override fun onAttach(view: View) {
|
||||
super.onAttach(view)
|
||||
presenter.bindIntents(this)
|
||||
setTitle(R.string.about_title)
|
||||
showBackButton(true)
|
||||
|
||||
version.summary = BuildConfig.VERSION_NAME
|
||||
}
|
||||
|
||||
override fun preferenceClicks(): Observable<PreferenceView> = (0 until preferences.childCount)
|
||||
|
||||
+8
-6
@@ -54,12 +54,7 @@ class SwipeActionsController : QkController<SwipeActionsView, SwipeActionsState,
|
||||
actionsDialog.adapter.setData(R.array.settings_swipe_actions)
|
||||
}
|
||||
|
||||
override fun onAttach(view: View) {
|
||||
super.onAttach(view)
|
||||
presenter.bindIntents(this)
|
||||
setTitle(R.string.settings_swipe_actions)
|
||||
showBackButton(true)
|
||||
|
||||
override fun onViewCreated() {
|
||||
colors.theme().let { theme ->
|
||||
rightIcon.setBackgroundTint(theme.theme)
|
||||
rightIcon.setTint(theme.textPrimary)
|
||||
@@ -77,6 +72,13 @@ class SwipeActionsController : QkController<SwipeActionsView, SwipeActionsState,
|
||||
.subscribe(actionClicks)
|
||||
}
|
||||
|
||||
override fun onAttach(view: View) {
|
||||
super.onAttach(view)
|
||||
presenter.bindIntents(this)
|
||||
setTitle(R.string.settings_swipe_actions)
|
||||
showBackButton(true)
|
||||
}
|
||||
|
||||
override fun actionClicks(): Observable<SwipeActionsView.Action> = actionClicks
|
||||
|
||||
override fun actionSelected(): Observable<Int> = actionsDialog.adapter.menuItemClicks
|
||||
|
||||
@@ -45,6 +45,9 @@ class ThemePagerAdapter @Inject constructor(private val context: Context) : Page
|
||||
return view == `object`
|
||||
}
|
||||
|
||||
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
|
||||
}
|
||||
|
||||
override fun getCount(): Int {
|
||||
return 2
|
||||
}
|
||||
|
||||
+8
-6
@@ -56,12 +56,7 @@ class ThemePickerController(val threadId: Long = 0L) : QkController<ThemePickerV
|
||||
layoutRes = R.layout.theme_picker_controller
|
||||
}
|
||||
|
||||
override fun onAttach(view: View) {
|
||||
super.onAttach(view)
|
||||
presenter.bindIntents(this)
|
||||
setTitle(R.string.title_theme)
|
||||
showBackButton(true)
|
||||
|
||||
override fun onViewCreated() {
|
||||
pager.offscreenPageLimit = 1
|
||||
pager.adapter = themePagerAdapter
|
||||
tabs.pager = pager
|
||||
@@ -72,6 +67,13 @@ class ThemePickerController(val threadId: Long = 0L) : QkController<ThemePickerV
|
||||
materialColors.adapter = themeAdapter
|
||||
}
|
||||
|
||||
override fun onAttach(view: View) {
|
||||
super.onAttach(view)
|
||||
presenter.bindIntents(this)
|
||||
setTitle(R.string.title_theme)
|
||||
showBackButton(true)
|
||||
}
|
||||
|
||||
override fun showQksmsPlusSnackbar() {
|
||||
Snackbar.make(contentView, R.string.toast_qksms_plus, Snackbar.LENGTH_LONG).run {
|
||||
setAction(R.string.button_more) { viewQksmsPlusSubject.onNext(Unit) }
|
||||
|
||||
Reference in New Issue
Block a user