Skip to content

Commit

Permalink
[Search] Private screen implementation in activity
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercandj committed Apr 24, 2019
1 parent 29ae8aa commit 5e5f3cd
Showing 1 changed file with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -53,23 +52,6 @@ class SearchActivity : Activity(),
super.onDestroy()
}

override fun populate(list: List<File>) {
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())
Expand All @@ -93,10 +75,31 @@ class SearchActivity : Activity(),
}
}

private fun createScreen() = object : SearchActivityContract.Screen {

override fun populate(list: List<File>) {
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
)
}
Expand Down

0 comments on commit 5e5f3cd

Please sign in to comment.