fix: what does the fix say? 🦊

This commit is contained in:
rebelonion 2024-05-25 08:37:16 -05:00
parent 37949c7e8e
commit 7717974b9e
8 changed files with 436 additions and 15 deletions

View file

@ -16,6 +16,8 @@ import ani.dantotsu.navBarHeight
import ani.dantotsu.profile.User
import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.statusBarHeight
import ani.dantotsu.toast
import ani.dantotsu.util.Logger
class StatusActivity : AppCompatActivity(), StoriesCallback {
private lateinit var activity: ArrayList<User>
@ -44,10 +46,14 @@ class StatusActivity : AppCompatActivity(), StoriesCallback {
val key = "activities"
val watchedActivity = PrefManager.getCustomVal<Set<Int>>(key, setOf())
val startFrom = findFirstNonMatch(watchedActivity, activity[position].activity )
val startIndex = if ( startFrom > 0) startFrom else 0
binding.stories.setStoriesList(activity[position].activity, this, startIndex + 1)
if (activity.getOrNull(position) != null) {
val startFrom = findFirstNonMatch(watchedActivity, activity[position].activity )
val startIndex = if ( startFrom > 0) startFrom else 0
binding.stories.setStoriesList(activity[position].activity, this, startIndex + 1)
} else {
Logger.log("index out of bounds for position $position of size ${activity.size}")
finish()
}
}
private fun findFirstNonMatch(watchedActivity: Set<Int>, activity: List<Activity>): Int {
@ -58,13 +64,16 @@ class StatusActivity : AppCompatActivity(), StoriesCallback {
}
return -1
}
override fun onPause() {
super.onPause()
binding.stories.pause()
}
override fun onResume() {
super.onResume()
binding.stories.resume()
if (hasWindowFocus())
binding.stories.resume()
}
override fun onWindowFocusChanged(hasFocus: Boolean) {