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
| object PaginationItemCallback : DiffUtil.ItemCallback<Person?>() { | |
| override fun areItemsTheSame(oldItem: Person?, newItem: Person?): Boolean { | |
| if (oldItem == null || newItem == null) return false | |
| return oldItem == newItem | |
| } | |
| override fun areContentsTheSame(oldItem: Person?, newItem: Person?): Boolean { | |
| if (oldItem == null || newItem == null) return false | |
| return oldItem.name == newItem.name |
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"> | |
| <data> | |
| <variable | |
| name="viewModel" | |
| type="pl.marchuck.pagingexample.pagination.PaginationViewModel" /> | |
| </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
| @BindingAdapter("android:adapterSetup") | |
| fun setupRecyclerViewAdapter(view: RecyclerView, viewModel: PaginationViewModel) { | |
| view.layoutManager = LinearLayoutManager(view.context) | |
| view.adapter = viewModel.adapter | |
| } |
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
| class PaginationViewModel(pagedListProvider: PagedListProvider<Person?>) : ViewModel() { | |
| val pagedListData = pagedListProvider.provide() | |
| val adapter = SwapiAdapter() | |
| } |
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
| class SwapiAdapter(diffCallback: DiffUtil.ItemCallback<Person?>) | |
| : PagedListAdapter<Person, SwapiPersonViewHolder>(diffCallback) { | |
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SwapiPersonViewHolder { | |
| val inflater = LayoutInflater.from(parent.context) | |
| val binding = DataBindingUtil.inflate<ItemSwapiPersonBinding>( | |
| inflater, R.layout.item_swapi_person, parent, false) | |
| return SwapiPersonViewHolder(binding) | |
| } |
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
| class SwapiPersonViewHolder(private val binding: ItemSwapiPersonBinding) : RecyclerView.ViewHolder(binding.root) { | |
| fun bind(item: Person?) { | |
| binding.personModel = SwapiPersonViewModel(item) | |
| binding.executePendingBindings() | |
| } | |
| } |
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="personModel" | |
| type="pl.marchuck.pagingexample.pagination.adapter.SwapiPersonViewModel" /> | |
| </data> | |
| <android.support.v7.widget.CardView ...> |
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
| #!/bin/bash | |
| for i in "${@:3}" | |
| do | |
| echo "generating $i x $i icon..." | |
| sips -z $i $i $1 --out $2_$i.png | |
| done | |
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
| class LoginViewController { | |
| var userName: String = "joe@doe.com" | |
| let HOME_SEGUE = "HOME_SEGUE" | |
| let FORGOT_PASSWORD_SEGUE = "FORGOT_PASSWORD_SEGUE" | |
| func startHomeScreen(){ | |
| self.performSegue(withIdentifier: HOME_SEGUE, sender: self) |