From 5e5f3cdb2cc03786b823aeef2b433a3cb1ebae14 Mon Sep 17 00:00:00 2001 From: Mercandj Date: Wed, 24 Apr 2019 20:43:20 +0200 Subject: [PATCH] [Search] Private screen implementation in activity --- .../search_dynamic/activity/SearchActivity.kt | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/feature_search_dynamic/src/main/java/com/mercandalli/android/apps/search_dynamic/activity/SearchActivity.kt b/feature_search_dynamic/src/main/java/com/mercandalli/android/apps/search_dynamic/activity/SearchActivity.kt index a0fd255..b23edfa 100644 --- a/feature_search_dynamic/src/main/java/com/mercandalli/android/apps/search_dynamic/activity/SearchActivity.kt +++ b/feature_search_dynamic/src/main/java/com/mercandalli/android/apps/search_dynamic/activity/SearchActivity.kt @@ -19,8 +19,7 @@ import com.mercandalli.android.apps.search_dynamic.SearchGraph import com.mercandalli.android.apps.search_dynamic.list.SearchListView import com.mercandalli.sdk.files.api.File -class SearchActivity : Activity(), - SearchActivityContract.Screen { +class SearchActivity : Activity() { private val back: View by bind(R.id.activity_search_toolbar_back) private val input: EditText by bind(R.id.activity_search_input) @@ -53,23 +52,6 @@ class SearchActivity : Activity(), super.onDestroy() } - override fun populate(list: List) { - searchListView.populate(list) - } - - override fun showKeyboard() { - input.requestFocus() - KeyboardUtils.showSoftInput(input) - } - - override fun hideKeyBoard() { - KeyboardUtils.hideSoftInput(input) - } - - override fun quit() { - finish() - } - private fun onEditorAction(actionId: Int) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { userAction.onSearchPerformed(input.text.toString()) @@ -93,10 +75,31 @@ class SearchActivity : Activity(), } } + private fun createScreen() = object : SearchActivityContract.Screen { + + override fun populate(list: List) { + searchListView.populate(list) + } + + override fun showKeyboard() { + input.requestFocus() + KeyboardUtils.showSoftInput(input) + } + + override fun hideKeyBoard() { + KeyboardUtils.hideSoftInput(input) + } + + override fun quit() { + finish() + } + } + private fun createUserAction(): SearchActivityContract.UserAction { + val screen = createScreen() val fileSearchManager = SearchGraph.getFileSearchManager() return SearchActivityPresenter( - this, + screen, fileSearchManager ) }