From ee44d8aa89b355d16aeddc2805f9f60bfd0a9b69 Mon Sep 17 00:00:00 2001 From: KirillKhoroshkov Date: Wed, 27 Dec 2023 20:35:48 +0300 Subject: [PATCH 1/3] Replaced 'fun getLifecycle' with 'val lifecycle' --- navigation-viewcontroller/build.gradle | 2 +- .../viewcontrollers/ViewController.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/navigation-viewcontroller/build.gradle b/navigation-viewcontroller/build.gradle index 6714ab8..5b5d19c 100644 --- a/navigation-viewcontroller/build.gradle +++ b/navigation-viewcontroller/build.gradle @@ -12,7 +12,7 @@ dependencies { constraints { implementation("androidx.appcompat:appcompat") { version { - require '1.0.2' + require '2.6.0' } } } diff --git a/navigation-viewcontroller/src/main/java/ru/touchin/roboswag/navigation_viewcontroller/viewcontrollers/ViewController.kt b/navigation-viewcontroller/src/main/java/ru/touchin/roboswag/navigation_viewcontroller/viewcontrollers/ViewController.kt index f205033..ba451c4 100644 --- a/navigation-viewcontroller/src/main/java/ru/touchin/roboswag/navigation_viewcontroller/viewcontrollers/ViewController.kt +++ b/navigation-viewcontroller/src/main/java/ru/touchin/roboswag/navigation_viewcontroller/viewcontrollers/ViewController.kt @@ -69,12 +69,13 @@ open class ViewController( val view: View = creationContext.inflater.inflate(layoutRes, creationContext.container, false) + override val lifecycle: Lifecycle + get() = fragment.viewLifecycleOwner.lifecycle + init { lifecycle.addObserver(LifecycleLoggingObserver(this)) } - override fun getLifecycle(): Lifecycle = fragment.viewLifecycleOwner.lifecycle - /** * Look for a child view with the given id. If this view has the given id, return this view. * From b0c818aadd6c72eda3d1fd7b9963aa1ae021cb80 Mon Sep 17 00:00:00 2001 From: KirillKhoroshkov Date: Wed, 27 Dec 2023 21:10:17 +0300 Subject: [PATCH 2/3] Replaced 'fun getLifecycle' with 'val lifecycle' --- navigation-viewcontroller/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/navigation-viewcontroller/build.gradle b/navigation-viewcontroller/build.gradle index 5b5d19c..99f3641 100644 --- a/navigation-viewcontroller/build.gradle +++ b/navigation-viewcontroller/build.gradle @@ -12,7 +12,7 @@ dependencies { constraints { implementation("androidx.appcompat:appcompat") { version { - require '2.6.0' + require '1.7.0-alpha03' } } } From 89d8bfdff5509701c8ddc400490e60c519758d62 Mon Sep 17 00:00:00 2001 From: KirillKhoroshkov Date: Wed, 27 Dec 2023 21:41:05 +0300 Subject: [PATCH 3/3] Fixed KeyboardResizeableViewController, DelegationListAdapter and LoadingContentView --- .../KeyboardResizeableViewController.kt | 49 ++++++++++--------- .../adapters/DelegationListAdapter.kt | 13 +++++ .../views/widget/LoadingContentView.kt | 38 +++++++------- 3 files changed, 59 insertions(+), 41 deletions(-) diff --git a/navigation-viewcontroller/src/main/java/ru/touchin/roboswag/navigation_viewcontroller/keyboard_resizeable/KeyboardResizeableViewController.kt b/navigation-viewcontroller/src/main/java/ru/touchin/roboswag/navigation_viewcontroller/keyboard_resizeable/KeyboardResizeableViewController.kt index bd7f7c8..54d8188 100644 --- a/navigation-viewcontroller/src/main/java/ru/touchin/roboswag/navigation_viewcontroller/keyboard_resizeable/KeyboardResizeableViewController.kt +++ b/navigation-viewcontroller/src/main/java/ru/touchin/roboswag/navigation_viewcontroller/keyboard_resizeable/KeyboardResizeableViewController.kt @@ -25,9 +25,21 @@ abstract class KeyboardResizeableViewController + onKeyboardShow(diff) + isKeyboardVisible = true + } + private var isKeyboardVisible: Boolean = false - private val keyboardHideListener = OnBackPressedListener { + private val keyboardHidingOnBackPressedListener = OnBackPressedListener { if (isKeyboardVisible) { UiUtils.OfViews.hideSoftInput(activity) true @@ -46,39 +58,31 @@ abstract class KeyboardResizeableViewController - onKeyboardShow(diff) - isKeyboardVisible = true - } - } + if (isHideKeyboardOnBackEnabled) activity.removeOnBackPressedListener(keyboardHidingOnBackPressedListener) } override fun onStop() { super.onStop() activity.keyboardBehaviorDetector?.apply { - keyboardHideListener = null - keyboardShowListener = null + removeOnHideListener(onKeyboardHideListener) + removeOnShowListener(onKeyboardShowListener) } } @@ -86,5 +90,4 @@ abstract class KeyboardResizeableViewController(config: AsyncDifferConfig) : Recy */ fun submitList(list: List) = differ.submitList(list) + /** + * Submits a new list to be diffed, and displayed. + * + * The commit callback can be used to know when the List is committed, but note that it + * may not be executed. If List B is submitted immediately after List A, and is + * committed directly, the callback associated with List A will not be run. + * + * @param newList The new List. + * @param commitCallback Optional runnable that is executed when the List is committed, if + * it is committed. + */ + fun submitList(list: List?, commitCallback: (() -> Unit)?) = differ.submitList(list, commitCallback) + /** * Get the current List - any diffing to present this list has already been computed and * dispatched via the ListUpdateCallback. diff --git a/views/src/main/java/ru/touchin/roboswag/views/widget/LoadingContentView.kt b/views/src/main/java/ru/touchin/roboswag/views/widget/LoadingContentView.kt index 72c5f71..5a6bfae 100644 --- a/views/src/main/java/ru/touchin/roboswag/views/widget/LoadingContentView.kt +++ b/views/src/main/java/ru/touchin/roboswag/views/widget/LoadingContentView.kt @@ -36,24 +36,26 @@ class LoadingContentView @JvmOverloads constructor( } private fun updateView(state: State) { - if (state == State.ShowContent) { - getChildAt(childCount - 1)?.let { showChild(it.id) } - } else { - when (state) { - is State.Stub -> { - setStubText(state.stubText) - showChild(R.id.text_stub) - } - is State.Loading -> { - showChild(R.id.progress_bar) - } - is State.Error -> { - binding.apply { - errorText.text = state.errorText - errorRepeatButton.setOnRippleClickListener { state.action.invoke() } - errorRepeatButton.text = state.repeatButtonText - showChild(R.id.error_with_repeat) - } + when (state) { + State.ShowContent -> { + getChildAt(childCount - 1)?.let { showChild(it.id) } + } + + is State.Stub -> { + setStubText(state.stubText) + showChild(R.id.text_stub) + } + + State.Loading -> { + showChild(R.id.progress_bar) + } + + is State.Error -> { + binding.apply { + errorText.text = state.errorText + errorRepeatButton.setOnRippleClickListener { state.action.invoke() } + errorRepeatButton.text = state.repeatButtonText + showChild(R.id.error_with_repeat) } } }