Skip to content

Commit

Permalink
Merge pull request #15 from googlecodelabs/fm/upgrade_dep_lambda
Browse files Browse the repository at this point in the history
Upgrading dependencies and moving lambda code to blocks
  • Loading branch information
florina-muntenescu committed Sep 24, 2018
2 parents 8ba0fe3 + d305f7c commit c83d667
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class GithubRepository(

isRequestInProgress = true
searchRepos(service, query, lastRequestedPage, NETWORK_PAGE_SIZE, { repos ->
cache.insert(repos, {
cache.insert(repos) {
lastRequestedPage++
isRequestInProgress = false
})
}
}, { error ->
networkErrors.postValue(error)
isRequestInProgress = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@ class SearchRepositoriesActivity : AppCompatActivity() {
private fun initSearch(query: String) {
search_repo.setText(query)

search_repo.setOnEditorActionListener({ _, actionId, _ ->
search_repo.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_GO) {
updateRepoListFromInput()
true
} else {
false
}
})
search_repo.setOnKeyListener({ _, keyCode, event ->
}
search_repo.setOnKeyListener { _, keyCode, event ->
if (event.action == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) {
updateRepoListFromInput()
true
} else {
false
}
})
}
}

private fun updateRepoListFromInput() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class SearchRepositoriesViewModel(private val repository: GithubRepository) : Vi
}

private val queryLiveData = MutableLiveData<String>()
private val repoResult: LiveData<RepoSearchResult> = Transformations.map(queryLiveData, {
private val repoResult: LiveData<RepoSearchResult> = Transformations.map(queryLiveData) {
repository.search(it)
})
}

val repos: LiveData<List<Repo>> = Transformations.switchMap(repoResult,
{ it -> it.data })
val networkErrors: LiveData<String> = Transformations.switchMap(repoResult,
{ it -> it.networkErrors })
val repos: LiveData<List<Repo>> = Transformations.switchMap(repoResult) { it -> it.data }
val networkErrors: LiveData<String> = Transformations.switchMap(repoResult) { it ->
it.networkErrors
}

/**
* Search a repository based on a query string.
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.21'
ext.kotlin_version = '1.2.70'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-alpha09'
classpath 'com.android.tools.build:gradle:3.2.0-beta04'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -49,8 +49,8 @@ ext {
supportLibVersion = "27.1.0"
constraintLayoutVersion = "1.0.2"
archComponentsVersion = "1.1.1"
roomVersion = "1.1.0-beta1"
pagingVersion = "1.0.0-beta1"
roomVersion = "1.1.1"
pagingVersion = "1.0.1"
retrofitVersion = "2.3.0"
okhttpLoggingInterceptorVersion = "3.9.0"

Expand Down

0 comments on commit c83d667

Please sign in to comment.