-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve error message display (#1037)
* Resolve error message display * Invalidate data source on update * Fix content padding on container * Remove trailing space --------- Co-authored-by: Ashley Davies <[email protected]>
- Loading branch information
Showing
5 changed files
with
75 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
after-party/src/commonMain/kotlin/io/ashdavies/activity/LoadStates.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.ashdavies.activity | ||
|
||
import androidx.paging.CombinedLoadStates | ||
import androidx.paging.LoadState | ||
import androidx.paging.LoadStates | ||
|
||
private val CombinedLoadStates.list: List<LoadStates> | ||
get() = listOfNotNull(source, mediator) | ||
|
||
private val LoadStates.list: List<LoadState> | ||
get() = listOf(refresh, prepend, append) | ||
|
||
internal val CombinedLoadStates.errorMessage: String? | ||
get() = firstNotNullOfOrNull { it as? LoadState.Error }?.error?.message | ||
|
||
internal val CombinedLoadStates.isRefreshing: Boolean | ||
get() = refresh is LoadState.Loading | ||
|
||
private fun <T> CombinedLoadStates.firstNotNullOfOrNull(predicate: (LoadState) -> T): T? { | ||
return list.firstNotNullOfOrNull { it.list.firstNotNullOfOrNull(predicate) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters