feat(social): only save last 100 activity ids
This commit is contained in:
parent
90b9b7bef3
commit
c947dbdb70
3 changed files with 7 additions and 7 deletions
|
@ -42,7 +42,7 @@ class StatusActivity : AppCompatActivity(), StoriesCallback {
|
||||||
slideOutLeft = AnimationUtils.loadAnimation(this, R.anim.slide_out_left)
|
slideOutLeft = AnimationUtils.loadAnimation(this, R.anim.slide_out_left)
|
||||||
slideInRight = AnimationUtils.loadAnimation(this, R.anim.slide_in_right)
|
slideInRight = AnimationUtils.loadAnimation(this, R.anim.slide_in_right)
|
||||||
|
|
||||||
val watchedActivity = PrefManager.getCustomVal<Set<Int>>("${activity[position].id}_activities", setOf())
|
val watchedActivity = PrefManager.getCustomVal<Set<Int>>("activities", setOf())
|
||||||
val startFrom = findFirstNonMatch(watchedActivity, activity[position].activity )
|
val startFrom = findFirstNonMatch(watchedActivity, activity[position].activity )
|
||||||
val startIndex = if ( startFrom > 0) startFrom else 0
|
val startIndex = if ( startFrom > 0) startFrom else 0
|
||||||
binding.stories.setStoriesList(activity[position].activity, this, startIndex + 1)
|
binding.stories.setStoriesList(activity[position].activity, this, startIndex + 1)
|
||||||
|
@ -77,7 +77,7 @@ class StatusActivity : AppCompatActivity(), StoriesCallback {
|
||||||
override fun onStoriesEnd() {
|
override fun onStoriesEnd() {
|
||||||
position += 1
|
position += 1
|
||||||
if (position < activity.size - 1) {
|
if (position < activity.size - 1) {
|
||||||
val watchedActivity = PrefManager.getCustomVal<Set<Int>>("${activity[position].id}_activities", setOf())
|
val watchedActivity = PrefManager.getCustomVal<Set<Int>>("activities", setOf())
|
||||||
val startFrom = findFirstNonMatch(watchedActivity, activity[position].activity )
|
val startFrom = findFirstNonMatch(watchedActivity, activity[position].activity )
|
||||||
val startIndex= if ( startFrom > 0) startFrom else 0
|
val startIndex= if ( startFrom > 0) startFrom else 0
|
||||||
binding.stories.startAnimation(slideOutLeft)
|
binding.stories.startAnimation(slideOutLeft)
|
||||||
|
@ -91,7 +91,7 @@ class StatusActivity : AppCompatActivity(), StoriesCallback {
|
||||||
override fun onStoriesStart() {
|
override fun onStoriesStart() {
|
||||||
position -= 1
|
position -= 1
|
||||||
if (position >= 0) {
|
if (position >= 0) {
|
||||||
val watchedActivity = PrefManager.getCustomVal<Set<Int>>("${activity[position].id}_activities", setOf())
|
val watchedActivity = PrefManager.getCustomVal<Set<Int>>("activities", setOf())
|
||||||
val startFrom = findFirstNonMatch(watchedActivity, activity[position].activity )
|
val startFrom = findFirstNonMatch(watchedActivity, activity[position].activity )
|
||||||
val startIndex = if ( startFrom > 0) startFrom else 0
|
val startIndex = if ( startFrom > 0) startFrom else 0
|
||||||
binding.stories.startAnimation(slideOutRight)
|
binding.stories.startAnimation(slideOutRight)
|
||||||
|
|
|
@ -384,7 +384,7 @@ constructor(
|
||||||
loadingView.visibility = View.GONE
|
loadingView.visibility = View.GONE
|
||||||
animation.start()
|
animation.start()
|
||||||
|
|
||||||
val key = "${story.user?.id}_activities"
|
val key = "activities"
|
||||||
val set = PrefManager.getCustomVal<Set<Int>>(key, setOf()).plus((story.id))
|
val set = PrefManager.getCustomVal<Set<Int>>(key, setOf()).plus((story.id))
|
||||||
PrefManager.setCustomVal(key, set)
|
PrefManager.setCustomVal(key, set)
|
||||||
|
|
||||||
|
|
|
@ -63,11 +63,11 @@ class UserStatusAdapter(private val user: ArrayList<User>) :
|
||||||
b.profileUserAvatar.loadImage(user.pfp)
|
b.profileUserAvatar.loadImage(user.pfp)
|
||||||
b.profileUserName.text = if (Anilist.userid == user.id) getAppString(R.string.your_story) else user.name
|
b.profileUserName.text = if (Anilist.userid == user.id) getAppString(R.string.your_story) else user.name
|
||||||
|
|
||||||
val watchedActivity =
|
val watchedActivity = PrefManager.getCustomVal<Set<Int>>("activities", setOf())
|
||||||
PrefManager.getCustomVal<Set<Int>>("${user.id}_activities", setOf())
|
|
||||||
val booleanList = user.activity.map { watchedActivity.contains(it.id) }
|
val booleanList = user.activity.map { watchedActivity.contains(it.id) }
|
||||||
b.profileUserStatusIndicator.setParts(user.activity.size, booleanList, user.id == Anilist.userid)
|
b.profileUserStatusIndicator.setParts(user.activity.size, booleanList, user.id == Anilist.userid)
|
||||||
|
val newList = watchedActivity.sorted().takeLast(100)
|
||||||
|
PrefManager.setCustomVal("activities",newList.toSet())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int = user.size
|
override fun getItemCount(): Int = user.size
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue