This file contains 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 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 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 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 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 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 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 SwapiPeoplePagedListProvider(private val factory: DataSource.Factory<Int, Person?>) : PagedListProvider<Person?> { | |
override fun provide(): LiveData<PagedList<Person?>> { | |
return LivePagedListBuilder(factory, PagedList.Config.Builder() | |
.setEnablePlaceholders(false) | |
.setPageSize(20) | |
.setInitialLoadSizeHint(20) | |
.build() | |
).setFetchExecutor(createFetchExecutor()) |
This file contains 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 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 Foo { | |
public void showNotification(String _subText, | |
String _bigContentTitle, | |
String _bigText) { | |
String channelId = "channelId"; | |
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, channelId); | |
notificationBuilder.setAutoCancel(true); |
This file contains 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) |