Skip to content

Commit

Permalink
- added number of favorites
Browse files Browse the repository at this point in the history
  • Loading branch information
jakepurple13 committed Apr 5, 2021
1 parent b6d87fb commit ecbf31e
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,23 @@ class FavoriteFragment : BaseFragment() {
.distinctUntilChanged()
.subscribe {
adapter.setData(it.second.toList())
view.findViewById<TextInputLayout>(R.id.fav_search_layout)?.hint = resources.getQuantityString(R.plurals.numFavorites, it.first, it.first)
view.findViewById<TextInputLayout>(R.id.fav_search_layout)?.hint =
resources.getQuantityString(R.plurals.numFavorites, it.first, it.first)
favRv?.smoothScrollToPosition(0)
}
.addTo(disposable)

val sourceList = view.findViewById<ChipGroup>(R.id.sourceList)

dbFire
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.map { it.groupBy { s -> s.source } }
.subscribe { s ->
s.forEach { m -> sourceList.children.filterIsInstance<Chip>().find { it.text == m.key }?.text = "${m.key}: ${m.value.size}" }
}
.addTo(disposable)

}

private fun List<DbModel>.toGroup() = groupBy(DbModel::title)
Expand Down

0 comments on commit ecbf31e

Please sign in to comment.