Skip to content

Instantly share code, notes, and snippets.

View Diolor's full-sized avatar

Dionysis Lorentzos Diolor

View GitHub Profile
fun printCurrentThread(tag: String) = println("$tag: ${Thread.currentThread().name.substringBefore("-")}")
fun main(args: Array<String>) {
printCurrentThread("main thread name")
val connectable = just(Unit)
.replay().refCount()
connectable
.subscribeOn(newThread())
fun printCurrentThread(tag: String) = println("$tag: ${Thread.currentThread().name.substringBefore("-")}")
fun main(args: Array<String>) {
printCurrentThread("main thread name")
val subject = BehaviorSubject.create(Unit)
val connectable = subject
.observeOn(io())
.replay().refCount()
/**
* ListAdapter is a superclass of RecyclerView.Adapter.
* Check the d.android.com for more.
*/
class JobsAdapter : ListAdapter<JobListItem, JobViewHolder>() {
}
// items of 2 types
sealed class JobListItem {
class JobsListAdapter : ListAdapter<JobListItem, JobViewHolder>() {
override fun getItemViewType(position: Int): Int {
return getItem(position).ordinal()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): JobViewHolder {
return when (viewType) {
Header.ordinal() -> HeaderViewHolder(...)
JobItem.ordinal() -> JobViewHolder(...)