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