Created
June 28, 2018 14:30
-
-
Save EfeBudak/73ff2762fe5a47069e9ca74fc65c90b0 to your computer and use it in GitHub Desktop.
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 start() { | |
itemDBObservable = itemDao.getAllItems() | |
compositeDisposable.clear() | |
compositeDisposable += itemDBObservable | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.scan { previousList: List<Item>, newList: List<Item> -> | |
val newItems = newList - previousList | |
if (previousList.isNotEmpty() && newItems.isNotEmpty()) { | |
showReturnToTopButton() | |
} | |
newList | |
} | |
.subscribeBy { | |
updateItemList(it) | |
} | |
} | |
fun updateItemList(itemList: List<Item>) = itemAdapter.submitList(itemList) | |
fun showReturnToTopButton() { | |
showReturnToTopButton = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment