This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onResume() { | |
super.onResume() | |
mainViewModel.showSearchView() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val mainViewModel: MainViewModel by activityViewModels() | |
override fun onResume() { | |
super.onResume() | |
mainViewModel.hideSearchView() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val _searchView = MutableLiveData(true) | |
val searchViewVisibility: LiveData<Boolean> = _searchView | |
fun showSearchView() { | |
_searchView.value = true | |
} | |
fun hideSearchView() { | |
_searchView.value = false | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
viewModel.searchViewVisibility.observe(this) { item.isVisible = it } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/characters_rv" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:nestedScrollingEnabled="false" | |
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" | |
app:spanCount="@integer/rows_recycler" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<data> | |
<variable | |
name="character" | |
type="br.com.samuelnunes.rickandmortyapp.data.entities.Character" /> | |
</data> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<string name="character_status">Status: %1$s</string> | |
<string name="character_species">Specie: %1$s</string> | |
<string name="character_gender">Gender: %1$s</string> | |
<string name="character_type">Type: %1$s</string> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BindingAdapter("visibleIf") | |
fun View.visibleIf(condition: Boolean) { | |
visibility = if (condition) { | |
VISIBLE | |
} else { | |
GONE | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<data> | |
<variable | |
name="character" | |
type="br.com.samuelnunes.rickandmortyapp.data.entities.Character" /> | |
</data> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.samuelnunes.rickandmorty.ui.characters | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import androidx.paging.PagingDataAdapter | |
import androidx.recyclerview.widget.DiffUtil | |
import androidx.recyclerview.widget.RecyclerView | |
import br.com.samuelnunes.rickandmortyapp.data.entities.Character | |
import br.com.samuelnunes.rickandmortyapp.databinding.ItemCharacterBinding |