mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-18 03:23:55 +00:00
check for activity context
This commit is contained in:
@@ -268,14 +268,19 @@ class AnimeFragment : Fragment() {
|
||||
model.loaded = true
|
||||
model.loadTrending(1)
|
||||
model.loadUpdated()
|
||||
model.loadPopular("ANIME", sort = Anilist.sortBy[1], onList = requireContext().getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
||||
.getBoolean("popular_list", false))
|
||||
}
|
||||
live.postValue(false)
|
||||
_binding?.animeRefresh?.isRefreshing = false
|
||||
withContext(Dispatchers.Main) {
|
||||
if (isAdded) { // Check if the fragment is still attached
|
||||
model.loadPopular("ANIME", sort = Anilist.sortBy[1], onList = requireContext().getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
||||
.getBoolean("popular_list", false))
|
||||
}
|
||||
live.postValue(false)
|
||||
_binding?.animeRefresh?.isRefreshing = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
||||
@@ -242,11 +242,16 @@ class MangaFragment : Fragment() {
|
||||
model.loaded = true
|
||||
model.loadTrending()
|
||||
model.loadTrendingNovel()
|
||||
model.loadPopular("MANGA", sort = Anilist.sortBy[1], onList = requireContext().getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
||||
.getBoolean("popular_list", false) )
|
||||
}
|
||||
live.postValue(false)
|
||||
_binding?.mangaRefresh?.isRefreshing = false
|
||||
withContext(Dispatchers.Main) {
|
||||
if (isAdded) {
|
||||
val sharedPrefs = requireContext().getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
||||
val isPopularList = sharedPrefs.getBoolean("popular_list", false)
|
||||
model.loadPopular("MANGA", sort = Anilist.sortBy[1], onList = isPopularList)
|
||||
}
|
||||
live.postValue(false)
|
||||
_binding?.mangaRefresh?.isRefreshing = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user