Compare commits

...

3 Commits

Author SHA1 Message Date
0b7f832573 Merge pull request 'fix-reload' (#195) from fix-reload into master
All checks were successful
Master / build (push) Successful in 11m29s
Realease / build (push) Successful in 5m52s
Realease / createTagAndChangelog (push) Successful in 45s
Realease / release (push) Successful in 7m23s
Reviewed-on: #195
2025-03-31 18:25:33 +00:00
22c966bf16 fix: Infinite scroll needs loading stats.
All checks were successful
PR / translations (pull_request) Successful in 31s
PR / PR (pull_request) Successful in 41s
PR / build (pull_request) Successful in 16m2s
PR test / integrationTests (pull_request) Successful in 43m44s
2025-03-30 21:57:36 +02:00
bdf2bb8b31 fix: do not reload items on resume. 2025-03-30 21:57:36 +02:00
4 changed files with 28 additions and 20 deletions

View File

@ -120,6 +120,7 @@ class HomeActivity :
binding.swipeRefreshLayout.setOnRefreshListener {
repository.offlineOverride = false
lastFetchDone = false
items.clear()
getElementsAccordingToTab()
binding.swipeRefreshLayout.isRefreshing = false
}
@ -458,6 +459,8 @@ class HomeActivity :
appendResults: Boolean,
itemType: ItemType,
) {
@Suppress("detekt:ComplexCondition")
if ((appendResults && items.size > 0) || (!appendResults && items.size == 0)) {
CountingIdlingResourceSingleton.increment()
binding.swipeRefreshLayout.isRefreshing = true
CoroutineScope(Dispatchers.IO).launch {
@ -476,6 +479,9 @@ class HomeActivity :
}
CountingIdlingResourceSingleton.decrement()
}
} else {
handleListResult()
}
}
private fun handleListResult(appendResults: Boolean = false) {
@ -534,7 +540,10 @@ class HomeActivity :
}
private fun reloadBadges() {
if (appSettingsService.isDisplayUnreadCountEnabled() || appSettingsService.isDisplayAllCountEnabled()) {
if (appSettingsService.isInfiniteLoadingEnabled() ||
appSettingsService.isDisplayUnreadCountEnabled() ||
appSettingsService.isDisplayAllCountEnabled()
) {
CountingIdlingResourceSingleton.increment()
CoroutineScope(Dispatchers.IO).launch {
repository.reloadBadges()

View File

@ -30,7 +30,7 @@ import org.kodein.di.instance
class ItemCardAdapter(
override val app: Activity,
override val items: ArrayList<SelfossModel.Item>,
override var items: ArrayList<SelfossModel.Item>,
override val updateHomeItems: (ArrayList<SelfossModel.Item>) -> Unit,
) : ItemsAdapter<ItemCardAdapter.ViewHolder>() {
override lateinit var binding: CardItemBinding

View File

@ -21,7 +21,7 @@ import org.kodein.di.instance
class ItemListAdapter(
override val app: Activity,
override val items: ArrayList<SelfossModel.Item>,
override var items: ArrayList<SelfossModel.Item>,
override val updateHomeItems: (ArrayList<SelfossModel.Item>) -> Unit,
) : ItemsAdapter<ItemListAdapter.ViewHolder>() {
override lateinit var binding: ListItemBinding

View File

@ -21,7 +21,7 @@ import org.kodein.di.DIAware
abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> :
RecyclerView.Adapter<VH>(),
DIAware {
abstract val items: ArrayList<SelfossModel.Item>
abstract var items: ArrayList<SelfossModel.Item>
abstract val repository: Repository
abstract val binding: ViewBinding
abstract val appSettingsService: AppSettingsService
@ -31,8 +31,7 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> :
protected val c: Context get() = app.baseContext
fun updateAllItems(items: ArrayList<SelfossModel.Item>) {
this.items.clear()
this.items.addAll(items)
this.items = items
updateHomeItems(items)
notifyDataSetChanged()
}