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