mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-12-25 22:26:59 +00:00
fix follower comparison issues
This commit is contained in:
parent
52d53c5ad1
commit
9358309c89
@ -153,14 +153,18 @@ class FollowViewerFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener {
|
||||
override fun onQueryTextChange(query: String): Boolean {
|
||||
if (query.isEmpty()) {
|
||||
if (!isCompare && searching) {
|
||||
searching = false
|
||||
viewModel.setQuery(null, isFollowersList)
|
||||
viewModel.getSearch().removeObservers(viewLifecycleOwner)
|
||||
viewModel.getList(isFollowersList).observe(viewLifecycleOwner) {
|
||||
refreshAdapter(it, null, null, null)
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (isCompare && searching) {
|
||||
adapter!!.filter.filter("")
|
||||
return true
|
||||
}
|
||||
searching = false
|
||||
return true
|
||||
}
|
||||
searching = true
|
||||
if (isCompare && adapter != null) {
|
||||
|
@ -45,21 +45,15 @@ class FollowViewModel : ViewModel() {
|
||||
if (it.first && it.second) {
|
||||
val followersList = followers.value!!
|
||||
val followingList = followings.value!!
|
||||
val allUsers: MutableList<User> = mutableListOf()
|
||||
allUsers.addAll(followersList)
|
||||
allUsers.addAll(followingList)
|
||||
val followersMap = followersList.groupBy { it.pk }
|
||||
val followingMap = followingList.groupBy { it.pk }
|
||||
val mutual: MutableList<User> = mutableListOf()
|
||||
val onlyFollowing: MutableList<User> = mutableListOf()
|
||||
val onlyFollowers: MutableList<User> = mutableListOf()
|
||||
allUsers.forEach {
|
||||
val isFollowing = followingMap.get(it.pk) != null
|
||||
val isFollower = followersMap.get(it.pk) != null
|
||||
if (isFollowing && isFollower) mutual.add(it)
|
||||
else if (isFollowing) onlyFollowing.add(it)
|
||||
else if (isFollower) onlyFollowers.add(it)
|
||||
followersList.forEach {
|
||||
if (followingMap.get(it.pk) != null) mutual.add(it)
|
||||
else onlyFollowers.add(it)
|
||||
}
|
||||
val mutualMap = mutual.groupBy { it.pk }
|
||||
val onlyFollowing = followingList.filter { mutualMap.get(it.pk) == null }
|
||||
postValue(Triple(mutual, onlyFollowing, onlyFollowers))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user