Compare commits

..

No commits in common. "bd6ebf1e1bacc10c03cb84786eec6cd3721332c5" and "ceba58e98f3942529dfdc681655d33a3cd01b99c" have entirely different histories.

4 changed files with 18 additions and 25 deletions

View File

@ -122,7 +122,6 @@ class HomeActivity :
lastFetchDone = false lastFetchDone = false
CountingIdlingResourceSingleton.increment() CountingIdlingResourceSingleton.increment()
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {
items.clear()
getElementsAccordingToTab() getElementsAccordingToTab()
binding.swipeRefreshLayout.isRefreshing = false binding.swipeRefreshLayout.isRefreshing = false
CountingIdlingResourceSingleton.decrement() CountingIdlingResourceSingleton.decrement()
@ -463,23 +462,19 @@ class HomeActivity :
appendResults: Boolean, appendResults: Boolean,
itemType: ItemType, itemType: ItemType,
) { ) {
if ((appendResults && items.size > 0) || (!appendResults && items.size == 0)) { CountingIdlingResourceSingleton.increment()
CountingIdlingResourceSingleton.increment() CoroutineScope(Dispatchers.Main).launch {
CoroutineScope(Dispatchers.Main).launch { binding.swipeRefreshLayout.isRefreshing = true
binding.swipeRefreshLayout.isRefreshing = true repository.displayedItems = itemType
repository.displayedItems = itemType items =
items = if (appendResults) {
if (appendResults) { repository.getOlderItems()
repository.getOlderItems() } else {
} else { repository.getNewerItems()
repository.getNewerItems() }
} binding.swipeRefreshLayout.isRefreshing = false
binding.swipeRefreshLayout.isRefreshing = false
handleListResult()
CountingIdlingResourceSingleton.decrement()
}
} else {
handleListResult() handleListResult()
CountingIdlingResourceSingleton.decrement()
} }
} }
@ -539,10 +534,7 @@ class HomeActivity :
} }
private fun reloadBadges() { private fun reloadBadges() {
if (appSettingsService.isInfiniteLoadingEnabled() || if (appSettingsService.isDisplayUnreadCountEnabled() || appSettingsService.isDisplayAllCountEnabled()) {
appSettingsService.isDisplayUnreadCountEnabled() ||
appSettingsService.isDisplayAllCountEnabled()
) {
CountingIdlingResourceSingleton.increment() CountingIdlingResourceSingleton.increment()
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
repository.reloadBadges() repository.reloadBadges()

View File

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

View File

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

View File

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